Skip to content

Commit

Permalink
Change deployment-alias type to *string. (#472)
Browse files Browse the repository at this point in the history
The deployment-alias field has the following behavior:
- Not added in request -> Don't update field
- Set to empty value -> Remove deployment alias
- Set to non-empty value -> Set alias to that value

So with the old spec, it wasn't possible to remove the alias after it was set, as due to omitempty an empty value is not added to the request. This is now possible.

The get-deployment has a slightly different behavior: If there is no deployment-alias, the field is not set, if there is a deployment-alias, the field is set. So for the get and responses, it is better to keep the type as it is.
  • Loading branch information
gigerdo committed May 24, 2024
1 parent 76b8bcd commit 3312360
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions cmd/generator/cloudspec/spec_modifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ func Modify(cloudSpec *spec.Swagger) {
cloudSpec.Definitions[k].Properties[kk] = prop
}

addExtension := func(model string, field string, key string, value interface{}) {
if k == model && kk == field {
prop.AddExtension(key, value)
cloudSpec.Definitions[k].Properties[kk] = prop
}
}
addExtension("DeploymentCreateRequest", "alias", nullableKey, true)
addExtension("DeploymentUpdateRequest", "alias", nullableKey, true)

if k == "ElasticsearchConfiguration" {
if kk == "enabled_built_in_plugins" ||
kk == "user_bundles" ||
Expand Down
2 changes: 1 addition & 1 deletion pkg/models/deployment_create_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/models/deployment_update_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3312360

Please sign in to comment.