Skip to content

Commit

Permalink
adding hasDifferentAPIVersion method directly for helm plugin, since …
Browse files Browse the repository at this point in the history
…this has been removed from kubebuilder and is probably still needed for helm

Signed-off-by: Adam D. Cornett <[email protected]>
  • Loading branch information
acornett21 committed Nov 5, 2024
1 parent 319b0d7 commit d87ab6f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/plugins/helm/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ func (p *createAPISubcommand) InjectResource(res *resource.Resource) error {
return fmt.Errorf("multiple groups are not allowed by default, to enable multi-group set 'multigroup: true' in your PROJECT file")
}

// Selected CRD version must match existing CRD versions.
// nolint:staticcheck
if hasDifferentAPIVersion(p.config.ListCRDVersions(), p.resource.API.CRDVersion) {
return fmt.Errorf("only one CRD version can be used for all resources, cannot add %q", p.resource.API.CRDVersion)
}

return nil
}

Expand All @@ -223,3 +229,8 @@ func (p *createAPISubcommand) Scaffold(fs machinery.Filesystem) error {

return nil
}

// hasDifferentCRDVersion returns true if any other CRD version is tracked in the project configuration.
func hasDifferentAPIVersion(versions []string, version string) bool {
return !(len(versions) == 0 || (len(versions) == 1 && versions[0] == version))
}

0 comments on commit d87ab6f

Please sign in to comment.