Skip to content

Commit

Permalink
added missing version field
Browse files Browse the repository at this point in the history
Signed-off-by: Jasmin Gacic <jasmin.gacic@gmail.com>
  • Loading branch information
jasmingacic committed Apr 11, 2022
1 parent 84419e4 commit 3785c99
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion server/go/api_apis_service_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/GIT_USER_ID/GIT_REPO_ID/util"
kuskv1 "github.com/kubeshop/kusk-gateway/api/v1alpha1"
"github.com/kubeshop/kusk-gateway/pkg/spec"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
)

// ApisApiService is a service that implements the logic for the ApisApiServicer
Expand Down Expand Up @@ -120,6 +120,8 @@ func (s *ApisApiService) convertAPICRDtoAPIModel(api *kuskv1.API) ApiItem {
return apiItem
}

apiItem.Version = getApiVersion(api.Spec.Spec)

apiItem.Service = ApiItemService{
Name: opts.Upstream.Service.Name,
Namespace: opts.Upstream.Service.Namespace,
Expand All @@ -131,3 +133,16 @@ func (s *ApisApiService) convertAPICRDtoAPIModel(api *kuskv1.API) ApiItem {

return apiItem
}

func getApiVersion(apiSpec string) string {
var yml map[string]interface{}
yaml.Unmarshal([]byte(apiSpec), &yml)

for k, v := range yml {
if k == "info" {
ss := v.(map[string]interface{})
return ss["version"].(string)
}
}
return ""
}

0 comments on commit 3785c99

Please sign in to comment.