diff --git a/cmd/switcher/switcher.go b/cmd/switcher/switcher.go index 099e1d33..386b287e 100644 --- a/cmd/switcher/switcher.go +++ b/cmd/switcher/switcher.go @@ -28,7 +28,7 @@ import ( "github.com/danielfoehrkn/kubeswitch/pkg/util" "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" switchconfig "github.com/danielfoehrkn/kubeswitch/pkg/config" "github.com/danielfoehrkn/kubeswitch/pkg/config/validation" @@ -340,11 +340,11 @@ func initialize() ([]store.KubeconfigStore, *types.Config, error) { // this is optional, so don't care about errors if !digitalOceanStoreAddedViaConfig { doStore, _ := store.NewDigitalOceanStore(types.KubeconfigStore{ - ID: pointer.String("doDefaultStore"), + ID: ptr.To("doDefaultStore"), Kind: types.StoreKindDigitalOcean, // for users with outdated `doctl` configs, don't show errors if they have no explicitly enabled the DO backing store - Required: pointer.Bool(false), - ShowPrefix: pointer.Bool(true), + Required: ptr.To(false), + ShowPrefix: ptr.To(true), }) if doStore != nil { // we found a valid `doctl` config, hence add Digital Ocean as a backing store with default configuration @@ -392,11 +392,11 @@ func getStoreFromFlagAndEnv(config *types.Config) *types.KubeconfigStore { } return &types.KubeconfigStore{ - ID: pointer.String("env-and-flag"), + ID: ptr.To("env-and-flag"), Kind: types.StoreKind(storageBackend), - KubeconfigName: pointer.String(kubeconfigName), + KubeconfigName: ptr.To(kubeconfigName), Paths: paths, - ShowPrefix: pointer.Bool(false), + ShowPrefix: ptr.To(false), } } diff --git a/pkg/config/migration/migrate.go b/pkg/config/migration/migrate.go index 4f2e44d9..ab6b15c9 100644 --- a/pkg/config/migration/migrate.go +++ b/pkg/config/migration/migrate.go @@ -15,7 +15,7 @@ package migration import ( - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "github.com/danielfoehrkn/kubeswitch/types" ) @@ -34,13 +34,13 @@ func ConvertConfiguration(old types.ConfigOld) types.Config { } filesystemStore := types.KubeconfigStore{ - ID: pointer.String("default"), + ID: ptr.To("default"), Kind: types.StoreKindFilesystem, Paths: []string{}, } vaultStore := types.KubeconfigStore{ - ID: pointer.String("default"), + ID: ptr.To("default"), Kind: types.StoreKindVault, Paths: []string{}, } diff --git a/pkg/config/migration/migration_test.go b/pkg/config/migration/migration_test.go index 44946a96..107120da 100644 --- a/pkg/config/migration/migration_test.go +++ b/pkg/config/migration/migration_test.go @@ -17,10 +17,9 @@ package migration_test import ( "time" - "k8s.io/utils/pointer" - "github.com/danielfoehrkn/kubeswitch/pkg/config/migration" "github.com/danielfoehrkn/kubeswitch/types" + "k8s.io/utils/ptr" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -50,24 +49,24 @@ var _ = Describe("ValidateConfig", func() { { Name: "name", Type: "type", - Path: pointer.String("my-path"), + Path: ptr.To("my-path"), }, } new := types.Config{ Kind: "SwitchConfig", Version: "v1alpha1", - KubeconfigName: pointer.String("name"), + KubeconfigName: ptr.To("name"), RefreshIndexAfter: &refreshIndexAfter, Hooks: hooks, KubeconfigStores: []types.KubeconfigStore{ { - ID: pointer.String("default"), + ID: ptr.To("default"), Kind: types.StoreKindFilesystem, Paths: []string{"path", "other-path"}, }, { - ID: pointer.String("default"), + ID: ptr.To("default"), Kind: types.StoreKindVault, Paths: []string{"path", "other-path"}, Config: types.StoreConfigVault{VaultAPIAddress: "vault-api"}, diff --git a/pkg/config/validation/validation_test.go b/pkg/config/validation/validation_test.go index 22120f3d..176f6570 100644 --- a/pkg/config/validation/validation_test.go +++ b/pkg/config/validation/validation_test.go @@ -21,7 +21,7 @@ import ( . "github.com/onsi/gomega" . "github.com/onsi/gomega/gstruct" "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "github.com/danielfoehrkn/kubeswitch/pkg/config/validation" "github.com/danielfoehrkn/kubeswitch/types" @@ -176,13 +176,13 @@ var _ = Describe("ValidateConfig", func() { Kind: types.StoreKindVault, RefreshIndexAfter: &minute, Paths: []string{"ab"}, - ID: pointer.String("id-one"), + ID: ptr.To("id-one"), }, { Kind: types.StoreKindVault, RefreshIndexAfter: &minute, Paths: []string{"ab"}, - ID: pointer.String("id-two"), + ID: ptr.To("id-two"), }, }, } @@ -220,14 +220,14 @@ var _ = Describe("ValidateConfig", func() { Kind: types.StoreKindGardener, Config: types.StoreConfigGardener{ GardenerAPIKubeconfigPath: "my-path-to-gardener-kubeconfig", - LandscapeName: pointer.String("dev"), + LandscapeName: ptr.To("dev"), }, }, { Kind: types.StoreKindGardener, Config: types.StoreConfigGardener{ GardenerAPIKubeconfigPath: "my-path-to-gardener-kubeconfig", - LandscapeName: pointer.String("canary"), + LandscapeName: ptr.To("canary"), }, }, }, @@ -355,7 +355,7 @@ var _ = Describe("ValidateConfig", func() { Kind: types.StoreKindGardener, Config: types.StoreConfigGardener{ GardenerAPIKubeconfigPath: "xy", - LandscapeName: pointer.String(""), + LandscapeName: ptr.To(""), }, }, }, @@ -380,7 +380,7 @@ var _ = Describe("ValidateConfig", func() { { Name: "my-hooks", Type: types.HookTypeExecutable, - Path: pointer.String("my-path"), + Path: ptr.To("my-path"), }, }, }