Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCM-7117 | add capability of list resource with a scalar items #203

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

mnecas
Copy link
Collaborator

@mnecas mnecas commented Apr 3, 2024

Issue: The LoadBalncerQuotaValues returns a list of scalar items. Because of this the metamodel started generating not valid sdk.

Sample of the model:

resource LoadBalancerQuotaValues {
	method List {
            in out Page Integer = 1
            in out Size Integer = 100
            out Total Integer
            out Items []Integer
	}
}

When generating the go sdk from teh model we get a error:

output/clustersmgmt/v1/load_balancer_quota_values_client.go:162:12: expected type, found '.'
output/clustersmgmt/v1/load_balancer_quota_values_client.go:191:59: expected type, found '.'
output/clustersmgmt/v1/load_balancer_quota_values_client.go:194:6: expected declaration, found '}'
E: Can't format generated sources: exit status 2

This is caused by the metamodel not handeling the list scalar items properly. Because the metamodel generates the reposnse struct and some other struct in following format:

type  LoadBalancerQuotaValuesListResponse struct {
	status int
	header http.Header
	err    *errors.Error
	items  *.IntegerList
	page   *int
	size   *int
	total  *int
}

I have added a fix so it would generate the sdk structs with the list scalars.

// LoadBalancerQuotaValuesListResponse is the response for the 'list' method.
type LoadBalancerQuotaValuesListResponse struct {
	status int
	header http.Header
	err    *errors.Error
	items  []int
	page   *int
	size   *int
	total  *int
}

@ahitacat
Copy link

ahitacat commented Apr 3, 2024

I have test this with this change in the model openshift-online/ocm-api-model#921 and it seems to work as expected.

@mnecas
Copy link
Collaborator Author

mnecas commented Apr 3, 2024

@jhernand could you ptal?

Issue: The LoadBalncerQuotaValues returns a list of scalar items. Because of
this the metamodel started generating not valid sdk.

Sample of the model:
```
resource LoadBalancerQuotaValues {
	method List {
            in out Page Integer = 1
            in out Size Integer = 100
            out Total Integer
            out Items []Integer
	}
}
```

When generating the go sdk from teh model we get a error:
```
output/clustersmgmt/v1/load_balancer_quota_values_client.go:162:12: expected type, found '.'
output/clustersmgmt/v1/load_balancer_quota_values_client.go:191:59: expected type, found '.'
output/clustersmgmt/v1/load_balancer_quota_values_client.go:194:6: expected declaration, found '}'
E: Can't format generated sources: exit status 2
```

This is caused by the metamodel not handeling the list scalar items
properly. Because the metamodel generates the reposnse struct and some
other struct in following format:
```
type  LoadBalancerQuotaValuesListResponse struct {
	status int
	header http.Header
	err    *errors.Error
	items  *.IntegerList
	page   *int
	size   *int
	total  *int
}
```

I have added a fix so it would generate the sdk structs with the list
scalars.
```
// LoadBalancerQuotaValuesListResponse is the response for the 'list' method.
type LoadBalancerQuotaValuesListResponse struct {
	status int
	header http.Header
	err    *errors.Error
	items  []int
	page   *int
	size   *int
	total  *int
}
```

Signed-off-by: Martin Necas <[email protected]>
@jhernand
Copy link
Collaborator

jhernand commented Apr 3, 2024

Looks good to me, thanks @mnecas. And yes, would be good to update the version of Go.

@mnecas
Copy link
Collaborator Author

mnecas commented Apr 3, 2024

Thank you for the quick review!
I'll create a task for the bump

@mnecas mnecas merged commit 510571e into openshift-online:main Apr 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants