@@ -30,11 +30,11 @@ import (
3030 "sigs.k8s.io/kubebuilder/v4/pkg/model/resource"
3131 "sigs.k8s.io/kubebuilder/v4/pkg/plugin"
3232 "sigs.k8s.io/kubebuilder/v4/pkg/plugin/util"
33- "sigs.k8s.io/kubebuilder/v4/pkg/plugins/golang/deploy-image/v1alpha1"
34- autoupdate "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/autoupdate/v1alpha"
35- "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/grafana/v1alpha"
36- hemlv1alpha "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v1alpha"
37- hemlv2alpha "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v2alpha"
33+ deployimagev1alpha1 "sigs.k8s.io/kubebuilder/v4/pkg/plugins/golang/deploy-image/v1alpha1"
34+ autoupdatev1alpha "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/autoupdate/v1alpha"
35+ grafanav1alpha "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/grafana/v1alpha"
36+ helmv1alpha "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v1alpha"
37+ helmv2alpha "sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v2alpha"
3838)
3939
4040// Generate store the required info for the command
@@ -240,7 +240,7 @@ func kubebuilderCreate(s store.Store) error {
240240// Migrates the Grafana plugin.
241241func migrateGrafanaPlugin (s store.Store , src , des string ) error {
242242 var grafanaPlugin struct {}
243- err := s .Config ().DecodePluginConfig (plugin .KeyFor (v1alpha .Plugin {}), grafanaPlugin )
243+ err := s .Config ().DecodePluginConfig (plugin .KeyFor (grafanav1alpha .Plugin {}), grafanaPlugin )
244244 if errors .As (err , & config.PluginKeyNotFoundError {}) {
245245 slog .Info ("Grafana plugin not found, skipping migration" )
246246 return nil
@@ -261,15 +261,15 @@ func migrateGrafanaPlugin(s store.Store, src, des string) error {
261261
262262func migrateAutoUpdatePlugin (s store.Store ) error {
263263 var autoUpdatePlugin struct {}
264- err := s .Config ().DecodePluginConfig (plugin .KeyFor (autoupdate .Plugin {}), autoUpdatePlugin )
264+ err := s .Config ().DecodePluginConfig (plugin .KeyFor (autoupdatev1alpha .Plugin {}), autoUpdatePlugin )
265265 if errors .As (err , & config.PluginKeyNotFoundError {}) {
266266 slog .Info ("Auto Update plugin not found, skipping migration" )
267267 return nil
268268 } else if err != nil {
269269 return fmt .Errorf ("failed to decode autoupdate plugin config: %w" , err )
270270 }
271271
272- args := []string {"edit" , "--plugins" , plugin .KeyFor (v1alpha .Plugin {})}
272+ args := []string {"edit" , "--plugins" , plugin .KeyFor (autoupdatev1alpha .Plugin {})}
273273 if err := util .RunCmd ("kubebuilder edit" , "kubebuilder" , args ... ); err != nil {
274274 return fmt .Errorf ("failed to run edit subcommand for Auto plugin: %w" , err )
275275 }
@@ -278,8 +278,8 @@ func migrateAutoUpdatePlugin(s store.Store) error {
278278
279279// Migrates the Deploy Image plugin.
280280func migrateDeployImagePlugin (s store.Store ) error {
281- var deployImagePlugin v1alpha1 .PluginConfig
282- err := s .Config ().DecodePluginConfig (plugin .KeyFor (v1alpha1 .Plugin {}), & deployImagePlugin )
281+ var deployImagePlugin deployimagev1alpha1 .PluginConfig
282+ err := s .Config ().DecodePluginConfig (plugin .KeyFor (deployimagev1alpha1 .Plugin {}), & deployImagePlugin )
283283 if errors .As (err , & config.PluginKeyNotFoundError {}) {
284284 slog .Info ("Deploy-image plugin not found, skipping migration" )
285285 return nil
@@ -297,7 +297,7 @@ func migrateDeployImagePlugin(s store.Store) error {
297297}
298298
299299// Creates an API with Deploy Image plugin.
300- func createAPIWithDeployImage (resourceData v1alpha1 .ResourceData ) error {
300+ func createAPIWithDeployImage (resourceData deployimagev1alpha1 .ResourceData ) error {
301301 args := append ([]string {"create" , "api" }, getGVKFlagsFromDeployImage (resourceData )... )
302302 args = append (args , getDeployImageOptions (resourceData )... )
303303 if err := util .RunCmd ("kubebuilder create api" , "kubebuilder" , args ... ); err != nil {
@@ -362,7 +362,7 @@ func getGVKFlags(res resource.Resource) []string {
362362}
363363
364364// Gets the GVK flags for a Deploy Image resource.
365- func getGVKFlagsFromDeployImage (resourceData v1alpha1 .ResourceData ) []string {
365+ func getGVKFlagsFromDeployImage (resourceData deployimagev1alpha1 .ResourceData ) []string {
366366 var args []string
367367 if resourceData .Group != "" {
368368 args = append (args , "--group" , resourceData .Group )
@@ -377,7 +377,7 @@ func getGVKFlagsFromDeployImage(resourceData v1alpha1.ResourceData) []string {
377377}
378378
379379// Gets the options for a Deploy Image resource.
380- func getDeployImageOptions (resourceData v1alpha1 .ResourceData ) []string {
380+ func getDeployImageOptions (resourceData deployimagev1alpha1 .ResourceData ) []string {
381381 var args []string
382382 if resourceData .Options .Image != "" {
383383 args = append (args , fmt .Sprintf ("--image=%s" , resourceData .Options .Image ))
@@ -391,7 +391,7 @@ func getDeployImageOptions(resourceData v1alpha1.ResourceData) []string {
391391 if resourceData .Options .RunAsUser != "" {
392392 args = append (args , fmt .Sprintf ("--run-as-user=%s" , resourceData .Options .RunAsUser ))
393393 }
394- args = append (args , fmt .Sprintf ("--plugins=%s" , plugin .KeyFor (v1alpha1 .Plugin {})))
394+ args = append (args , fmt .Sprintf ("--plugins=%s" , plugin .KeyFor (deployimagev1alpha1 .Plugin {})))
395395 return args
396396}
397397
@@ -499,7 +499,7 @@ func grafanaConfigMigrate(src, des string) error {
499499
500500// Edits the project to include the Grafana plugin.
501501func kubebuilderGrafanaEdit () error {
502- args := []string {"edit" , "--plugins" , plugin .KeyFor (v1alpha .Plugin {})}
502+ args := []string {"edit" , "--plugins" , plugin .KeyFor (grafanav1alpha .Plugin {})}
503503 if err := util .RunCmd ("kubebuilder edit" , "kubebuilder" , args ... ); err != nil {
504504 return fmt .Errorf ("failed to run edit subcommand for Grafana plugin: %w" , err )
505505 }
@@ -512,7 +512,7 @@ func kubebuilderHelmEditWithConfig(s store.Store) error {
512512 ManifestsFile string `json:"manifests,omitempty"`
513513 OutputDir string `json:"output,omitempty"`
514514 }
515- err := s .Config ().DecodePluginConfig (plugin .KeyFor (hemlv2alpha .Plugin {}), & cfg )
515+ err := s .Config ().DecodePluginConfig (plugin .KeyFor (helmv2alpha .Plugin {}), & cfg )
516516 if errors .As (err , & config.PluginKeyNotFoundError {}) {
517517 // No previous configuration, use defaults
518518 return kubebuilderHelmEdit (true )
@@ -521,7 +521,7 @@ func kubebuilderHelmEditWithConfig(s store.Store) error {
521521 }
522522
523523 // Use tracked configuration values
524- pluginKey := plugin .KeyFor (hemlv2alpha .Plugin {})
524+ pluginKey := plugin .KeyFor (helmv2alpha .Plugin {})
525525 args := []string {"edit" , "--plugins" , pluginKey }
526526 if cfg .ManifestsFile != "" {
527527 args = append (args , "--manifests" , cfg .ManifestsFile )
@@ -540,9 +540,9 @@ func kubebuilderHelmEditWithConfig(s store.Store) error {
540540func kubebuilderHelmEdit (isV2Alpha bool ) error {
541541 var pluginKey string
542542 if isV2Alpha {
543- pluginKey = plugin .KeyFor (hemlv2alpha .Plugin {})
543+ pluginKey = plugin .KeyFor (helmv2alpha .Plugin {})
544544 } else {
545- pluginKey = plugin .KeyFor (hemlv1alpha .Plugin {})
545+ pluginKey = plugin .KeyFor (helmv1alpha .Plugin {})
546546 }
547547
548548 args := []string {"edit" , "--plugins" , pluginKey }
@@ -558,13 +558,13 @@ func hasHelmPlugin(cfg store.Store) (bool, bool) {
558558 var pluginConfig map [string ]interface {}
559559
560560 // Check for v2alpha first (preferred)
561- err := cfg .Config ().DecodePluginConfig (plugin .KeyFor (hemlv2alpha .Plugin {}), & pluginConfig )
561+ err := cfg .Config ().DecodePluginConfig (plugin .KeyFor (helmv2alpha .Plugin {}), & pluginConfig )
562562 if err == nil {
563563 return true , true // has helm plugin, is v2alpha
564564 }
565565
566566 // Check for v1alpha
567- err = cfg .Config ().DecodePluginConfig (plugin .KeyFor (hemlv1alpha .Plugin {}), & pluginConfig )
567+ err = cfg .Config ().DecodePluginConfig (plugin .KeyFor (helmv1alpha .Plugin {}), & pluginConfig )
568568 if err != nil {
569569 // If neither Helm plugin is found, return false
570570 if errors .As (err , & config.PluginKeyNotFoundError {}) {
0 commit comments