@@ -30,11 +30,11 @@ import (
30
30
"sigs.k8s.io/kubebuilder/v4/pkg/model/resource"
31
31
"sigs.k8s.io/kubebuilder/v4/pkg/plugin"
32
32
"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"
38
38
)
39
39
40
40
// Generate store the required info for the command
@@ -240,7 +240,7 @@ func kubebuilderCreate(s store.Store) error {
240
240
// Migrates the Grafana plugin.
241
241
func migrateGrafanaPlugin (s store.Store , src , des string ) error {
242
242
var grafanaPlugin struct {}
243
- err := s .Config ().DecodePluginConfig (plugin .KeyFor (v1alpha .Plugin {}), grafanaPlugin )
243
+ err := s .Config ().DecodePluginConfig (plugin .KeyFor (grafanav1alpha .Plugin {}), grafanaPlugin )
244
244
if errors .As (err , & config.PluginKeyNotFoundError {}) {
245
245
slog .Info ("Grafana plugin not found, skipping migration" )
246
246
return nil
@@ -261,15 +261,15 @@ func migrateGrafanaPlugin(s store.Store, src, des string) error {
261
261
262
262
func migrateAutoUpdatePlugin (s store.Store ) error {
263
263
var autoUpdatePlugin struct {}
264
- err := s .Config ().DecodePluginConfig (plugin .KeyFor (autoupdate .Plugin {}), autoUpdatePlugin )
264
+ err := s .Config ().DecodePluginConfig (plugin .KeyFor (autoupdatev1alpha .Plugin {}), autoUpdatePlugin )
265
265
if errors .As (err , & config.PluginKeyNotFoundError {}) {
266
266
slog .Info ("Auto Update plugin not found, skipping migration" )
267
267
return nil
268
268
} else if err != nil {
269
269
return fmt .Errorf ("failed to decode autoupdate plugin config: %w" , err )
270
270
}
271
271
272
- args := []string {"edit" , "--plugins" , plugin .KeyFor (v1alpha .Plugin {})}
272
+ args := []string {"edit" , "--plugins" , plugin .KeyFor (autoupdatev1alpha .Plugin {})}
273
273
if err := util .RunCmd ("kubebuilder edit" , "kubebuilder" , args ... ); err != nil {
274
274
return fmt .Errorf ("failed to run edit subcommand for Auto plugin: %w" , err )
275
275
}
@@ -278,8 +278,8 @@ func migrateAutoUpdatePlugin(s store.Store) error {
278
278
279
279
// Migrates the Deploy Image plugin.
280
280
func 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 )
283
283
if errors .As (err , & config.PluginKeyNotFoundError {}) {
284
284
slog .Info ("Deploy-image plugin not found, skipping migration" )
285
285
return nil
@@ -297,7 +297,7 @@ func migrateDeployImagePlugin(s store.Store) error {
297
297
}
298
298
299
299
// Creates an API with Deploy Image plugin.
300
- func createAPIWithDeployImage (resourceData v1alpha1 .ResourceData ) error {
300
+ func createAPIWithDeployImage (resourceData deployimagev1alpha1 .ResourceData ) error {
301
301
args := append ([]string {"create" , "api" }, getGVKFlagsFromDeployImage (resourceData )... )
302
302
args = append (args , getDeployImageOptions (resourceData )... )
303
303
if err := util .RunCmd ("kubebuilder create api" , "kubebuilder" , args ... ); err != nil {
@@ -362,7 +362,7 @@ func getGVKFlags(res resource.Resource) []string {
362
362
}
363
363
364
364
// Gets the GVK flags for a Deploy Image resource.
365
- func getGVKFlagsFromDeployImage (resourceData v1alpha1 .ResourceData ) []string {
365
+ func getGVKFlagsFromDeployImage (resourceData deployimagev1alpha1 .ResourceData ) []string {
366
366
var args []string
367
367
if resourceData .Group != "" {
368
368
args = append (args , "--group" , resourceData .Group )
@@ -377,7 +377,7 @@ func getGVKFlagsFromDeployImage(resourceData v1alpha1.ResourceData) []string {
377
377
}
378
378
379
379
// Gets the options for a Deploy Image resource.
380
- func getDeployImageOptions (resourceData v1alpha1 .ResourceData ) []string {
380
+ func getDeployImageOptions (resourceData deployimagev1alpha1 .ResourceData ) []string {
381
381
var args []string
382
382
if resourceData .Options .Image != "" {
383
383
args = append (args , fmt .Sprintf ("--image=%s" , resourceData .Options .Image ))
@@ -391,7 +391,7 @@ func getDeployImageOptions(resourceData v1alpha1.ResourceData) []string {
391
391
if resourceData .Options .RunAsUser != "" {
392
392
args = append (args , fmt .Sprintf ("--run-as-user=%s" , resourceData .Options .RunAsUser ))
393
393
}
394
- args = append (args , fmt .Sprintf ("--plugins=%s" , plugin .KeyFor (v1alpha1 .Plugin {})))
394
+ args = append (args , fmt .Sprintf ("--plugins=%s" , plugin .KeyFor (deployimagev1alpha1 .Plugin {})))
395
395
return args
396
396
}
397
397
@@ -499,7 +499,7 @@ func grafanaConfigMigrate(src, des string) error {
499
499
500
500
// Edits the project to include the Grafana plugin.
501
501
func kubebuilderGrafanaEdit () error {
502
- args := []string {"edit" , "--plugins" , plugin .KeyFor (v1alpha .Plugin {})}
502
+ args := []string {"edit" , "--plugins" , plugin .KeyFor (grafanav1alpha .Plugin {})}
503
503
if err := util .RunCmd ("kubebuilder edit" , "kubebuilder" , args ... ); err != nil {
504
504
return fmt .Errorf ("failed to run edit subcommand for Grafana plugin: %w" , err )
505
505
}
@@ -512,7 +512,7 @@ func kubebuilderHelmEditWithConfig(s store.Store) error {
512
512
ManifestsFile string `json:"manifests,omitempty"`
513
513
OutputDir string `json:"output,omitempty"`
514
514
}
515
- err := s .Config ().DecodePluginConfig (plugin .KeyFor (hemlv2alpha .Plugin {}), & cfg )
515
+ err := s .Config ().DecodePluginConfig (plugin .KeyFor (helmv2alpha .Plugin {}), & cfg )
516
516
if errors .As (err , & config.PluginKeyNotFoundError {}) {
517
517
// No previous configuration, use defaults
518
518
return kubebuilderHelmEdit (true )
@@ -521,7 +521,7 @@ func kubebuilderHelmEditWithConfig(s store.Store) error {
521
521
}
522
522
523
523
// Use tracked configuration values
524
- pluginKey := plugin .KeyFor (hemlv2alpha .Plugin {})
524
+ pluginKey := plugin .KeyFor (helmv2alpha .Plugin {})
525
525
args := []string {"edit" , "--plugins" , pluginKey }
526
526
if cfg .ManifestsFile != "" {
527
527
args = append (args , "--manifests" , cfg .ManifestsFile )
@@ -540,9 +540,9 @@ func kubebuilderHelmEditWithConfig(s store.Store) error {
540
540
func kubebuilderHelmEdit (isV2Alpha bool ) error {
541
541
var pluginKey string
542
542
if isV2Alpha {
543
- pluginKey = plugin .KeyFor (hemlv2alpha .Plugin {})
543
+ pluginKey = plugin .KeyFor (helmv2alpha .Plugin {})
544
544
} else {
545
- pluginKey = plugin .KeyFor (hemlv1alpha .Plugin {})
545
+ pluginKey = plugin .KeyFor (helmv1alpha .Plugin {})
546
546
}
547
547
548
548
args := []string {"edit" , "--plugins" , pluginKey }
@@ -558,13 +558,13 @@ func hasHelmPlugin(cfg store.Store) (bool, bool) {
558
558
var pluginConfig map [string ]interface {}
559
559
560
560
// 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 )
562
562
if err == nil {
563
563
return true , true // has helm plugin, is v2alpha
564
564
}
565
565
566
566
// Check for v1alpha
567
- err = cfg .Config ().DecodePluginConfig (plugin .KeyFor (hemlv1alpha .Plugin {}), & pluginConfig )
567
+ err = cfg .Config ().DecodePluginConfig (plugin .KeyFor (helmv1alpha .Plugin {}), & pluginConfig )
568
568
if err != nil {
569
569
// If neither Helm plugin is found, return false
570
570
if errors .As (err , & config.PluginKeyNotFoundError {}) {
0 commit comments