Skip to content

Commit

Permalink
Fix incorrect comp sets check in admission
Browse files Browse the repository at this point in the history
* provider tpl capi contract should not
  support all of the declared capi contracts

Fixes #586
  • Loading branch information
zerospiel authored and Kshatrix committed Nov 1, 2024
1 parent 29bc4b4 commit 27d6593
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions internal/webhook/management_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ func (v *ManagementValidator) ValidateUpdate(ctx context.Context, _, newObj runt
return nil, fmt.Errorf("%s: not valid ProviderTemplate %s", invalidMgmtMsg, tplName)
}

for capi := range capiTpl.Status.CAPIContracts {
if _, ok := pTpl.Status.CAPIContracts[capi]; !ok {
wrongVersions = errors.Join(wrongVersions, fmt.Errorf("core CAPI contract version %s does not support ProviderTemplate %s", capi, pTpl.Name))
for capiVersion := range pTpl.Status.CAPIContracts {
if _, ok := capiTpl.Status.CAPIContracts[capiVersion]; !ok {
wrongVersions = errors.Join(wrongVersions, fmt.Errorf("core CAPI contract versions does not support %s version in the ProviderTemplate %s", capiVersion, pTpl.Name))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/webhook/management_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestManagementValidateUpdate(t *testing.T) {
),
},
warnings: admission.Warnings{"The Management object has incompatible CAPI contract versions in ProviderTemplates"},
err: fmt.Sprintf("the Management is invalid: core CAPI contract version %s does not support ProviderTemplate %s", capiVersion, template.DefaultName),
err: fmt.Sprintf("the Management is invalid: core CAPI contract versions does not support %s version in the ProviderTemplate %s", capiVersionOther, template.DefaultName),
},
{
name: "providertemplates match capi contracts, should succeed",
Expand Down

0 comments on commit 27d6593

Please sign in to comment.