Skip to content

Commit

Permalink
Remove CRD and Webwhook versions options since they are no longer useful
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 committed May 16, 2024
1 parent e227a13 commit e242df5
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 119 deletions.
38 changes: 0 additions & 38 deletions pkg/plugin/util/helpers.go

This file was deleted.

44 changes: 0 additions & 44 deletions pkg/plugin/util/helpers_test.go

This file was deleted.

26 changes: 0 additions & 26 deletions pkg/plugins/golang/deploy-image/v1alpha1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ const (
defaultCRDVersion = "v1"

Check failure on line 39 in pkg/plugins/golang/deploy-image/v1alpha1/api.go

View workflow job for this annotation

GitHub Actions / golangci-lint

const `defaultCRDVersion` is unused (unused)
)

const deprecateMsg = "The v1beta1 API version for CRDs and Webhooks are deprecated and are no longer supported since " +
"the Kubernetes release 1.22. This flag no longer required to exist in future releases. Also, we would like to " +
"recommend you no longer use these API versions." +
"More info: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-22"

var _ plugin.CreateAPISubcommand = &createAPISubcommand{}

type createAPISubcommand struct {
Expand Down Expand Up @@ -129,14 +124,7 @@ func (p *createAPISubcommand) BindFlags(fs *pflag.FlagSet) {

p.options = &goPlugin.Options{}

fs.StringVar(&p.options.CRDVersion, "crd-version", defaultCRDVersion,
"version of CustomResourceDefinition to scaffold. Options: [v1, v1beta1]")

fs.StringVar(&p.options.Plural, "plural", "", "resource irregular plural form")

// (not required raise an error in this case)
// nolint:errcheck,gosec
fs.MarkDeprecated("crd-version", deprecateMsg)
}

func (p *createAPISubcommand) InjectConfig(c config.Config) error {
Expand All @@ -163,20 +151,6 @@ func (p *createAPISubcommand) InjectResource(res *resource.Resource) error {
"to enable multi-group visit https://kubebuilder.io/migration/multi-group.html")
}

// Check CRDVersion against all other CRDVersions in p.config for compatibility.
// nolint:staticcheck
if util.HasDifferentCRDVersion(p.config, p.resource.API.CRDVersion) {
return fmt.Errorf("only one CRD version can be used for all resources, cannot add %q",
p.resource.API.CRDVersion)
}

// Check CRDVersion against all other CRDVersions in p.config for compatibility.
// nolint:staticcheck
if util.HasDifferentCRDVersion(p.config, 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 Down
9 changes: 2 additions & 7 deletions pkg/plugins/golang/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ type Options struct {
// Plural is the resource's kind plural form.
Plural string

// CRDVersion is the CustomResourceDefinition API version that will be used for the resource.
CRDVersion string
// WebhookVersion is the {Validating,Mutating}WebhookConfiguration API version that will be used for the resource.
WebhookVersion string

// Namespaced is true if the resource should be namespaced.
Namespaced bool

Expand All @@ -88,7 +83,7 @@ func (opts Options) UpdateResource(res *resource.Resource, c config.Config) {
}

res.API = &resource.API{
CRDVersion: opts.CRDVersion,
CRDVersion: "v1",
Namespaced: opts.Namespaced,
}

Expand All @@ -107,7 +102,7 @@ func (opts Options) UpdateResource(res *resource.Resource, c config.Config) {
} else {
res.Path = resource.APIPackagePath(c.GetRepository(), res.Group, res.Version, c.IsMultiGroup())
}
res.Webhooks.WebhookVersion = opts.WebhookVersion
res.Webhooks.WebhookVersion = "v1"
if opts.DoDefaulting {
res.Webhooks.Defaulting = true
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/plugins/golang/v4/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ func (p *createAPISubcommand) BindFlags(fs *pflag.FlagSet) {

func (p *createAPISubcommand) InjectConfig(c config.Config) error {
p.config = c
// go/v4 no longer supports v1beta1 option
p.options.CRDVersion = defaultCRDVersion
return nil
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/plugins/golang/v4/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ func (p *createWebhookSubcommand) BindFlags(fs *pflag.FlagSet) {

func (p *createWebhookSubcommand) InjectConfig(c config.Config) error {
p.config = c
// go/v4 no longer supports v1beta1 option
p.options.WebhookVersion = defaultWebhookVersion
return nil
}

Expand Down

0 comments on commit e242df5

Please sign in to comment.