Skip to content

Commit

Permalink
Remove default GitRepo Type from specification
Browse files Browse the repository at this point in the history
Our OpenAPI validation library added support for default values. This
includes a feature/bug that fails the validation if defaults are set for
`merge-patch+json` requests.

We currently define a GitRepo type default of `auto` . This is defined
across all requests and responses. However this is arguably wrong for
patches. When patching a resource we generally don't want to set default
as this will lead to unexpected results (i.e. reverting to the default
if we do not explicitly set it to the current value in the patch)

For this reason (and to fix the validation error) we remove the GitRepo
type default from the specification.
  • Loading branch information
glrf committed Aug 3, 2022
1 parent 5798ca4 commit 76555c8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 44 deletions.
1 change: 0 additions & 1 deletion openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ components:
type: string
description: Specifies if a repo should be managed by the git controller. A value of 'unmanaged' means it's not manged by the controller
example: auto
default: auto
deployKey:
type: string
description: SSH public key / deploy key for clusterconfiguration catalog Git repository. This property is managed by Steward.
Expand Down
86 changes: 43 additions & 43 deletions pkg/api/openapi.go

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

2 changes: 2 additions & 0 deletions pkg/service/tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func TestCreateTenant(t *testing.T) {
assert.Contains(t, tenant.Id, api.TenantIDPrefix)
assert.Equal(t, newTenant.DisplayName, tenant.DisplayName)
assert.Equal(t, newTenant.GitRepo.Url, tenant.GitRepo.Url)
assert.NotNil(t, tenant.GitRepo.Type)
assert.Equal(t, "auto", *tenant.GitRepo.Type)
assert.Contains(t, *tenant.Annotations, "new")
assert.Len(t, *tenant.Annotations, 1)

Expand Down

0 comments on commit 76555c8

Please sign in to comment.