diff --git a/channels/pkg/channels/addons_test.go b/channels/pkg/channels/addons_test.go index 8079dd308294f..01751154389d3 100644 --- a/channels/pkg/channels/addons_test.go +++ b/channels/pkg/channels/addons_test.go @@ -29,7 +29,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" fakekubernetes "k8s.io/client-go/kubernetes/fake" "k8s.io/kops/channels/pkg/api" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/utils" ) @@ -349,7 +348,7 @@ func Test_GetRequiredUpdates(t *testing.T) { addon := &Addon{ Name: "test", Spec: &api.AddonSpec{ - Name: fi.PtrTo("test"), + Name: new("test"), NeedsPKI: true, }, } @@ -377,7 +376,7 @@ func Test_NeedsRollingUpdate(t *testing.T) { newAddon: &Addon{ Name: "test", Spec: &api.AddonSpec{ - Name: fi.PtrTo("test"), + Name: new("test"), ManifestHash: "originalHash", NeedsRollingUpdate: api.NeedsRollingUpdateAll, }, @@ -387,7 +386,7 @@ func Test_NeedsRollingUpdate(t *testing.T) { newAddon: &Addon{ Name: "test", Spec: &api.AddonSpec{ - Name: fi.PtrTo("test"), + Name: new("test"), ManifestHash: "newHash", NeedsRollingUpdate: api.NeedsRollingUpdateAll, }, @@ -399,7 +398,7 @@ func Test_NeedsRollingUpdate(t *testing.T) { newAddon: &Addon{ Name: "test", Spec: &api.AddonSpec{ - Name: fi.PtrTo("test"), + Name: new("test"), ManifestHash: "newHash", NeedsRollingUpdate: api.NeedsRollingUpdateWorkers, }, @@ -411,7 +410,7 @@ func Test_NeedsRollingUpdate(t *testing.T) { newAddon: &Addon{ Name: "test", Spec: &api.AddonSpec{ - Name: fi.PtrTo("test"), + Name: new("test"), ManifestHash: "newHash", NeedsRollingUpdate: api.NeedsRollingUpdateControlPlane, }, @@ -423,7 +422,7 @@ func Test_NeedsRollingUpdate(t *testing.T) { newAddon: &Addon{ Name: "test", Spec: &api.AddonSpec{ - Name: fi.PtrTo("test"), + Name: new("test"), ManifestHash: "newHash", NeedsRollingUpdate: api.NeedsRollingUpdateAll, }, @@ -542,7 +541,7 @@ func Test_InstallPKI(t *testing.T) { addon := &Addon{ Name: "test", Spec: &api.AddonSpec{ - Name: fi.PtrTo("test"), + Name: new("test"), NeedsPKI: true, }, } diff --git a/channels/pkg/cmd/apply_channel_test.go b/channels/pkg/cmd/apply_channel_test.go index 71727dc42a76f..e9c0746847b58 100644 --- a/channels/pkg/cmd/apply_channel_test.go +++ b/channels/pkg/cmd/apply_channel_test.go @@ -26,7 +26,6 @@ import ( fakek8s "k8s.io/client-go/kubernetes/fake" "k8s.io/kops/channels/pkg/api" "k8s.io/kops/channels/pkg/channels" - "k8s.io/kops/upup/pkg/fi" ) func TestGetUpdates(t *testing.T) { @@ -59,7 +58,7 @@ func TestGetUpdates(t *testing.T) { "aws-ebs-csi-driver.addons.k8s.io": { Name: "aws-ebs-csi-driver.addons.k8s.io", Spec: &api.AddonSpec{ - Name: fi.PtrTo("aws-ebs-csi-driver.addons.k8s.io"), + Name: new("aws-ebs-csi-driver.addons.k8s.io"), Id: "k8s-1.17", ManifestHash: "abc", }, diff --git a/cloudmock/openstack/mockcompute/servers.go b/cloudmock/openstack/mockcompute/servers.go index a6a22c934f9f8..6addbe707fe7d 100644 --- a/cloudmock/openstack/mockcompute/servers.go +++ b/cloudmock/openstack/mockcompute/servers.go @@ -25,7 +25,6 @@ import ( "strings" "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" - "k8s.io/kops/upup/pkg/fi" "github.com/google/uuid" "github.com/gophercloud/gophercloud/v2" @@ -236,7 +235,7 @@ func (m *MockClient) createServer(w http.ResponseWriter, r *http.Request) { portID := create.Server.Networks[0].Port ports.Update(r.Context(), m.networkClient, portID, ports.UpdateOpts{ - DeviceID: fi.PtrTo(server.ID), + DeviceID: new(server.ID), }) // Assign an IP address diff --git a/clusterapi/pkg/builders/utils.go b/clusterapi/pkg/builders/utils.go index cfaf86970f2b5..99310331ed589 100644 --- a/clusterapi/pkg/builders/utils.go +++ b/clusterapi/pkg/builders/utils.go @@ -39,11 +39,7 @@ func makeRef(u *unstructured.Unstructured) map[string]any { // Kind: kind, // Name: owner.GetName(), // UID: owner.GetUID(), -// Controller: PtrTo(true), +// Controller: new(true), // }, // }) // } - -func PtrTo[T any](t T) *T { - return &t -} diff --git a/cmd/kops-controller/controllers/awsipam.go b/cmd/kops-controller/controllers/awsipam.go index 75bac41391cdb..66c283363bc64 100644 --- a/cmd/kops-controller/controllers/awsipam.go +++ b/cmd/kops-controller/controllers/awsipam.go @@ -35,7 +35,6 @@ import ( "k8s.io/apimachinery/pkg/types" corev1client "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/klog/v2" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/util/pkg/awslog" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -123,7 +122,7 @@ func (r *AWSIPAMReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct eni, err := r.ec2Client.DescribeNetworkInterfaces(ctx, &ec2.DescribeNetworkInterfacesInput{ Filters: []ec2types.Filter{ { - Name: fi.PtrTo("attachment.instance-id"), + Name: new("attachment.instance-id"), Values: []string{ instanceID, }, diff --git a/cmd/kops/create_cluster.go b/cmd/kops/create_cluster.go index 964e860b11170..a3b4d51e38cce 100644 --- a/cmd/kops/create_cluster.go +++ b/cmd/kops/create_cluster.go @@ -652,7 +652,7 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr if group.Spec.RootVolume == nil { group.Spec.RootVolume = &api.InstanceRootVolumeSpec{} } - group.Spec.RootVolume.Size = fi.PtrTo(c.ControlPlaneVolumeSize) + group.Spec.RootVolume.Size = new(c.ControlPlaneVolumeSize) } } @@ -661,7 +661,7 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr if group.Spec.RootVolume == nil { group.Spec.RootVolume = &api.InstanceRootVolumeSpec{} } - group.Spec.RootVolume.Type = fi.PtrTo(c.ControlPlaneVolumeType) + group.Spec.RootVolume.Type = new(c.ControlPlaneVolumeType) } } @@ -670,7 +670,7 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr if group.Spec.RootVolume == nil { group.Spec.RootVolume = &api.InstanceRootVolumeSpec{} } - group.Spec.RootVolume.Size = fi.PtrTo(c.NodeVolumeSize) + group.Spec.RootVolume.Size = new(c.NodeVolumeSize) } } @@ -679,7 +679,7 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr if group.Spec.RootVolume == nil { group.Spec.RootVolume = &api.InstanceRootVolumeSpec{} } - group.Spec.RootVolume.Type = fi.PtrTo(c.NodeVolumeType) + group.Spec.RootVolume.Type = new(c.NodeVolumeType) } } @@ -696,7 +696,7 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr } if c.DisableSubnetTags { - cluster.Spec.Networking.TagSubnets = fi.PtrTo(false) + cluster.Spec.Networking.TagSubnets = new(false) } if c.APIPublicName != "" { @@ -719,7 +719,7 @@ func RunCreateCluster(ctx context.Context, f *util.Factory, out io.Writer, c *Cr cluster.Spec.KubeProxy = &api.KubeProxyConfig{} } if cluster.Spec.KubeProxy.Enabled == nil { - cluster.Spec.KubeProxy.Enabled = fi.PtrTo(false) + cluster.Spec.KubeProxy.Enabled = new(false) } } diff --git a/cmd/kops/get_keypairs.go b/cmd/kops/get_keypairs.go index d243f898e257e..eabff309f2d76 100644 --- a/cmd/kops/get_keypairs.go +++ b/cmd/kops/get_keypairs.go @@ -153,7 +153,7 @@ func listKeypairs(keyStore fi.CAStore, names []string, includeDistrusted bool) ( keypair.AlternateNames = alternateNames } if rsaKey, ok := cert.PublicKey.(*rsa.PublicKey); ok { - keypair.KeyLength = fi.PtrTo(rsaKey.N.BitLen()) + keypair.KeyLength = new(rsaKey.N.BitLen()) } } items = append(items, &keypair) diff --git a/examples/kops-api-example/up.go b/examples/kops-api-example/up.go index b1642b61a9c38..f1aa498484ece 100644 --- a/examples/kops-api-example/up.go +++ b/examples/kops-api-example/up.go @@ -24,7 +24,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" api "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/client/simple/vfsclientset" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup" "k8s.io/kops/upup/pkg/fi/utils" "k8s.io/kops/util/pkg/vfs" @@ -60,7 +59,7 @@ func up(vfsContext *vfs.VFSContext, ctx context.Context) error { for _, masterZone := range masterZones { etcdMember := api.EtcdMemberSpec{ Name: masterZone, - InstanceGroup: fi.PtrTo(masterZone), + InstanceGroup: new(masterZone), } etcdCluster.Members = append(etcdCluster.Members, etcdMember) } diff --git a/nodeup/pkg/bootstrap/install.go b/nodeup/pkg/bootstrap/install.go index 7a976e0e7e3e9..400b616b2b34e 100644 --- a/nodeup/pkg/bootstrap/install.go +++ b/nodeup/pkg/bootstrap/install.go @@ -172,7 +172,7 @@ func (i *Installation) buildSystemdJob() *nodetasks.InstallService { service := &nodetasks.InstallService{Service: nodetasks.Service{ Name: serviceName, - Definition: fi.PtrTo(manifestString), + Definition: new(manifestString), }} service.InitDefaults() diff --git a/nodeup/pkg/model/channels.go b/nodeup/pkg/model/channels.go index 9ce203efc2a00..8e897f69765fd 100644 --- a/nodeup/pkg/model/channels.go +++ b/nodeup/pkg/model/channels.go @@ -66,8 +66,8 @@ func (b *ChannelsBuilder) Build(c *fi.NodeupModelBuilderContext) error { Path: channelsKubeconfigPath, Contents: kubeconfig, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0400"), - Owner: fi.PtrTo(wellknownusers.KopsChannelsName), + Mode: new("0400"), + Owner: new(wellknownusers.KopsChannelsName), }) manifest, err := b.readChannelsManifest(c) diff --git a/nodeup/pkg/model/containerd.go b/nodeup/pkg/model/containerd.go index 1d6042b5988d6..c76c3c05791d5 100644 --- a/nodeup/pkg/model/containerd.go +++ b/nodeup/pkg/model/containerd.go @@ -142,7 +142,7 @@ func (b *ContainerdBuilder) installContainerd(c *fi.NodeupModelBuilderContext) e Path: filepath.Join("/usr/bin", k), Contents: v, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0755"), + Mode: new("0755"), } c.AddTask(fileTask) } @@ -167,7 +167,7 @@ func (b *ContainerdBuilder) installContainerd(c *fi.NodeupModelBuilderContext) e Path: "/usr/sbin/runc", Contents: v, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0755"), + Mode: new("0755"), } c.AddTask(fileTask) } diff --git a/nodeup/pkg/model/containerd_test.go b/nodeup/pkg/model/containerd_test.go index e2e85d59e26ff..10164e8612ce9 100644 --- a/nodeup/pkg/model/containerd_test.go +++ b/nodeup/pkg/model/containerd_test.go @@ -64,56 +64,56 @@ func TestContainerdBuilder_BuildFlags(t *testing.T) { { kops.ContainerdConfig{ SkipInstall: false, - ConfigOverride: fi.PtrTo("test"), - Version: fi.PtrTo("test"), + ConfigOverride: new("test"), + Version: new("test"), }, "", }, { kops.ContainerdConfig{ - Address: fi.PtrTo("/run/containerd/containerd.sock"), + Address: new("/run/containerd/containerd.sock"), }, "--address=/run/containerd/containerd.sock", }, { kops.ContainerdConfig{ - LogLevel: fi.PtrTo("info"), + LogLevel: new("info"), }, "--log-level=info", }, { kops.ContainerdConfig{ - Root: fi.PtrTo("/var/lib/containerd"), + Root: new("/var/lib/containerd"), }, "--root=/var/lib/containerd", }, { kops.ContainerdConfig{ - State: fi.PtrTo("/run/containerd"), + State: new("/run/containerd"), }, "--state=/run/containerd", }, { kops.ContainerdConfig{ SkipInstall: false, - Address: fi.PtrTo("/run/containerd/containerd.sock"), - ConfigOverride: fi.PtrTo("test"), - LogLevel: fi.PtrTo("info"), - Root: fi.PtrTo("/var/lib/containerd"), - State: fi.PtrTo("/run/containerd"), - Version: fi.PtrTo("test"), + Address: new("/run/containerd/containerd.sock"), + ConfigOverride: new("test"), + LogLevel: new("info"), + Root: new("/var/lib/containerd"), + State: new("/run/containerd"), + Version: new("test"), }, "--address=/run/containerd/containerd.sock --log-level=info --root=/var/lib/containerd --state=/run/containerd", }, { kops.ContainerdConfig{ SkipInstall: true, - Address: fi.PtrTo("/run/containerd/containerd.sock"), - ConfigOverride: fi.PtrTo("test"), - LogLevel: fi.PtrTo("info"), - Root: fi.PtrTo("/var/lib/containerd"), - State: fi.PtrTo("/run/containerd"), - Version: fi.PtrTo("test"), + Address: new("/run/containerd/containerd.sock"), + ConfigOverride: new("test"), + LogLevel: new("info"), + Root: new("/var/lib/containerd"), + State: new("/run/containerd"), + Version: new("test"), }, "--address=/run/containerd/containerd.sock --log-level=info --root=/var/lib/containerd --state=/run/containerd", }, diff --git a/nodeup/pkg/model/context.go b/nodeup/pkg/model/context.go index 0c4a3be71bf36..65086ef327ade 100644 --- a/nodeup/pkg/model/context.go +++ b/nodeup/pkg/model/context.go @@ -539,7 +539,7 @@ func (b *NodeupModelContext) AddCNIBinAssets(c *fi.NodeupModelBuilderContext) er Path: filepath.Join(b.CNIBinDir(), name), Contents: res, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0755"), + Mode: new("0755"), }) } diff --git a/nodeup/pkg/model/convenience.go b/nodeup/pkg/model/convenience.go index e5a16ac489560..f330c71d8d058 100644 --- a/nodeup/pkg/model/convenience.go +++ b/nodeup/pkg/model/convenience.go @@ -19,18 +19,16 @@ package model import ( "fmt" "sort" - - "k8s.io/kops/upup/pkg/fi" ) // s is a helper that builds a *string from a string value func s(v string) *string { - return fi.PtrTo(v) + return new(v) } // b returns a pointer to a boolean func b(v bool) *bool { - return fi.PtrTo(v) + return new(v) } // buildContainerRuntimeEnvironmentVars just converts a series of keypairs to docker environment variables switches diff --git a/nodeup/pkg/model/etcd_manager_tls.go b/nodeup/pkg/model/etcd_manager_tls.go index ab00a00c41eda..ed94c252e8ed9 100644 --- a/nodeup/pkg/model/etcd_manager_tls.go +++ b/nodeup/pkg/model/etcd_manager_tls.go @@ -58,7 +58,7 @@ func (b *EtcdManagerTLSBuilder) Build(ctx *fi.NodeupModelBuilderContext) error { Path: filepath.Join(d, fileName+".crt"), Contents: fi.NewStringResource(b.NodeupConfig.CAs[keystoreName]), Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0644"), + Mode: new("0644"), }) } diff --git a/nodeup/pkg/model/gvisor_test.go b/nodeup/pkg/model/gvisor_test.go index 170ccf3344ac5..f54aa18e03950 100644 --- a/nodeup/pkg/model/gvisor_test.go +++ b/nodeup/pkg/model/gvisor_test.go @@ -37,26 +37,26 @@ func TestGVisorBuilderBuild(t *testing.T) { name: "disabled", distribution: distributions.DistributionDebian13, role: kops.InstanceGroupRoleNode, - gvisor: &kops.GVisorConfig{Enabled: fi.PtrTo(false)}, + gvisor: &kops.GVisorConfig{Enabled: new(false)}, }, { name: "enabled debian", distribution: distributions.DistributionDebian13, role: kops.InstanceGroupRoleNode, - gvisor: &kops.GVisorConfig{Enabled: fi.PtrTo(true)}, + gvisor: &kops.GVisorConfig{Enabled: new(true)}, wantTasks: []string{"AptSource/gvisor", "Package/runsc"}, }, { name: "enabled non debian", distribution: distributions.DistributionRhel9, role: kops.InstanceGroupRoleNode, - gvisor: &kops.GVisorConfig{Enabled: fi.PtrTo(true)}, + gvisor: &kops.GVisorConfig{Enabled: new(true)}, }, { name: "enabled control plane", distribution: distributions.DistributionDebian13, role: kops.InstanceGroupRoleControlPlane, - gvisor: &kops.GVisorConfig{Enabled: fi.PtrTo(true)}, + gvisor: &kops.GVisorConfig{Enabled: new(true)}, }, { name: "unset", diff --git a/nodeup/pkg/model/kube_apiserver.go b/nodeup/pkg/model/kube_apiserver.go index 82c55bdfe6cbd..20a4f70c7f72c 100644 --- a/nodeup/pkg/model/kube_apiserver.go +++ b/nodeup/pkg/model/kube_apiserver.go @@ -134,7 +134,7 @@ func (b *KubeAPIServerBuilder) Build(c *fi.NodeupModelBuilderContext) error { } if b.NodeupConfig.APIServerConfig.EncryptionConfigSecretHash != "" { - encryptionConfigPath := fi.PtrTo(filepath.Join(pathSrvKAPI, "encryptionconfig.yaml")) + encryptionConfigPath := new(filepath.Join(pathSrvKAPI, "encryptionconfig.yaml")) kubeAPIServer.EncryptionProviderConfig = encryptionConfigPath @@ -145,7 +145,7 @@ func (b *KubeAPIServerBuilder) Build(c *fi.NodeupModelBuilderContext) error { t := &nodetasks.File{ Path: *encryptionConfigPath, Contents: fi.NewStringResource(contents), - Mode: fi.PtrTo("600"), + Mode: new("600"), Type: nodetasks.FileType_File, } c.AddTask(t) @@ -176,7 +176,7 @@ func (b *KubeAPIServerBuilder) Build(c *fi.NodeupModelBuilderContext) error { Path: filepath.Join(pathSrvKAPI, "etcd-ca.crt"), Contents: fi.NewStringResource(b.NodeupConfig.CAs["etcd-clients-ca"]), Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0644"), + Mode: new("0644"), }) kubeAPIServer.EtcdCAFile = filepath.Join(pathSrvKAPI, "etcd-ca.crt") @@ -202,7 +202,7 @@ func (b *KubeAPIServerBuilder) Build(c *fi.NodeupModelBuilderContext) error { Path: filepath.Join(pathSrvKAPI, "apiserver-aggregator-ca.crt"), Contents: fi.NewStringResource(b.NodeupConfig.CAs["apiserver-aggregator-ca"]), Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0644"), + Mode: new("0644"), }) kubeAPIServer.RequestheaderClientCAFile = filepath.Join(pathSrvKAPI, "apiserver-aggregator-ca.crt") @@ -219,8 +219,8 @@ func (b *KubeAPIServerBuilder) Build(c *fi.NodeupModelBuilderContext) error { if err != nil { return err } - kubeAPIServer.ProxyClientCertFile = fi.PtrTo(filepath.Join(pathSrvKAPI, "apiserver-aggregator.crt")) - kubeAPIServer.ProxyClientKeyFile = fi.PtrTo(filepath.Join(pathSrvKAPI, "apiserver-aggregator.key")) + kubeAPIServer.ProxyClientCertFile = new(filepath.Join(pathSrvKAPI, "apiserver-aggregator.crt")) + kubeAPIServer.ProxyClientKeyFile = new(filepath.Join(pathSrvKAPI, "apiserver-aggregator.key")) } if err := b.writeServerCertificate(c, &kubeAPIServer); err != nil { @@ -345,7 +345,7 @@ func (b *KubeAPIServerBuilder) writeAuthenticationConfig(c *fi.NodeupModelBuilde if b.NodeupConfig.APIServerConfig.Authentication.AWS != nil { id := "aws-iam-authenticator" - kubeAPIServer.AuthenticationTokenWebhookConfigFile = fi.PtrTo(PathAuthnConfig) + kubeAPIServer.AuthenticationTokenWebhookConfigFile = new(PathAuthnConfig) { cluster := kubeconfig.KubectlCluster{ @@ -380,7 +380,7 @@ func (b *KubeAPIServerBuilder) writeAuthenticationConfig(c *fi.NodeupModelBuilde Path: PathAuthnConfig, Contents: fi.NewBytesResource(manifest), Type: nodetasks.FileType_File, - Mode: fi.PtrTo("600"), + Mode: new("600"), }) } @@ -415,18 +415,18 @@ func (b *KubeAPIServerBuilder) writeAuthenticationConfig(c *fi.NodeupModelBuilde Path: "/srv/kubernetes/aws-iam-authenticator/cert.pem", Contents: certificate, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("600"), - Owner: fi.PtrTo("aws-iam-authenticator"), - Group: fi.PtrTo("aws-iam-authenticator"), + Mode: new("600"), + Owner: new("aws-iam-authenticator"), + Group: new("aws-iam-authenticator"), }) c.AddTask(&nodetasks.File{ Path: "/srv/kubernetes/aws-iam-authenticator/key.pem", Contents: privateKey, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("600"), - Owner: fi.PtrTo("aws-iam-authenticator"), - Group: fi.PtrTo("aws-iam-authenticator"), + Mode: new("600"), + Owner: new("aws-iam-authenticator"), + Group: new("aws-iam-authenticator"), }) } diff --git a/nodeup/pkg/model/kube_apiserver_test.go b/nodeup/pkg/model/kube_apiserver_test.go index e0047be60fe90..105a33a8ab460 100644 --- a/nodeup/pkg/model/kube_apiserver_test.go +++ b/nodeup/pkg/model/kube_apiserver_test.go @@ -81,13 +81,13 @@ func Test_KubeAPIServer_BuildFlags(t *testing.T) { }, { kops.KubeAPIServerConfig{ - ExperimentalEncryptionProviderConfig: fi.PtrTo("/srv/kubernetes/encryptionconfig.yaml"), + ExperimentalEncryptionProviderConfig: new("/srv/kubernetes/encryptionconfig.yaml"), }, "--experimental-encryption-provider-config=/srv/kubernetes/encryptionconfig.yaml --secure-port=0", }, { kops.KubeAPIServerConfig{ - EncryptionProviderConfig: fi.PtrTo("/srv/kubernetes/encryptionconfig.yaml"), + EncryptionProviderConfig: new("/srv/kubernetes/encryptionconfig.yaml"), }, "--encryption-provider-config=/srv/kubernetes/encryptionconfig.yaml --secure-port=0", }, diff --git a/nodeup/pkg/model/kube_controller_manager.go b/nodeup/pkg/model/kube_controller_manager.go index 4d4801190f230..14b05cf029716 100644 --- a/nodeup/pkg/model/kube_controller_manager.go +++ b/nodeup/pkg/model/kube_controller_manager.go @@ -135,7 +135,7 @@ func (b *KubeControllerManagerBuilder) writeServerCertificate(c *fi.NodeupModelB return err } - kcm.TLSCertFile = fi.PtrTo(filepath.Join(pathSrvKCM, "server.crt")) + kcm.TLSCertFile = new(filepath.Join(pathSrvKCM, "server.crt")) kcm.TLSPrivateKeyFile = filepath.Join(pathSrvKCM, "server.key") } diff --git a/nodeup/pkg/model/kube_proxy.go b/nodeup/pkg/model/kube_proxy.go index 43806992d783f..79f87967e87af 100644 --- a/nodeup/pkg/model/kube_proxy.go +++ b/nodeup/pkg/model/kube_proxy.go @@ -170,7 +170,7 @@ func (b *KubeProxyBuilder) buildPod() (*v1.Pod, error) { Limits: resourceLimits, }, SecurityContext: &v1.SecurityContext{ - Privileged: fi.PtrTo(true), + Privileged: new(true), }, } diff --git a/nodeup/pkg/model/kube_scheduler.go b/nodeup/pkg/model/kube_scheduler.go index 317d82be29f91..9849f591a0336 100644 --- a/nodeup/pkg/model/kube_scheduler.go +++ b/nodeup/pkg/model/kube_scheduler.go @@ -170,7 +170,7 @@ func (b *KubeSchedulerBuilder) writeServerCertificate(c *fi.NodeupModelBuilderCo return err } - kubeScheduler.TLSCertFile = fi.PtrTo(filepath.Join(pathSrvScheduler, "server.crt")) + kubeScheduler.TLSCertFile = new(filepath.Join(pathSrvScheduler, "server.crt")) kubeScheduler.TLSPrivateKeyFile = filepath.Join(pathSrvScheduler, "server.key") } diff --git a/nodeup/pkg/model/kubelet.go b/nodeup/pkg/model/kubelet.go index 78e9685a80196..5c1711a26975e 100644 --- a/nodeup/pkg/model/kubelet.go +++ b/nodeup/pkg/model/kubelet.go @@ -598,8 +598,8 @@ func (b *KubeletBuilder) buildSystemdService() *nodetasks.Service { service.InitDefaults() if b.ConfigurationMode == "Warming" { - service.Running = fi.PtrTo(false) - service.Enabled = fi.PtrTo(false) + service.Running = new(false) + service.Enabled = new(false) } return service @@ -805,7 +805,7 @@ func (b *KubeletBuilder) buildKubeletConfigSpec(ctx context.Context) (*kops.Kube } // Write back values that could have changed - c.MaxPods = fi.PtrTo(int32(maxPods)) + c.MaxPods = new(int32(maxPods)) } if c.VolumePluginDirectory == "" { @@ -841,7 +841,7 @@ func (b *KubeletBuilder) buildKubeletConfigSpec(ctx context.Context) (*kops.Kube } if c.AuthenticationTokenWebhook == nil { - c.AuthenticationTokenWebhook = fi.PtrTo(true) + c.AuthenticationTokenWebhook = new(true) } return &c, nil @@ -892,7 +892,7 @@ func (b *KubeletBuilder) buildKubeletServingCertificate(c *fi.NodeupModelBuilder c.EnsureTask(&nodetasks.File{ Path: dir, Type: nodetasks.FileType_Directory, - Mode: fi.PtrTo("0755"), + Mode: new("0755"), }) } @@ -900,7 +900,7 @@ func (b *KubeletBuilder) buildKubeletServingCertificate(c *fi.NodeupModelBuilder Path: filepath.Join(dir, name+".crt"), Contents: cert, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0644"), + Mode: new("0644"), BeforeServices: []string{kubeletService}, }) @@ -908,7 +908,7 @@ func (b *KubeletBuilder) buildKubeletServingCertificate(c *fi.NodeupModelBuilder Path: filepath.Join(dir, name+".key"), Contents: key, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0400"), + Mode: new("0400"), BeforeServices: []string{kubeletService}, }) diff --git a/nodeup/pkg/model/kubelet_test.go b/nodeup/pkg/model/kubelet_test.go index 5615800435084..ce986ae609db5 100644 --- a/nodeup/pkg/model/kubelet_test.go +++ b/nodeup/pkg/model/kubelet_test.go @@ -404,7 +404,7 @@ func Test_BuildComponentConfigFile(t *testing.T) { ShutdownGracePeriodCriticalPods: &metav1.Duration{Duration: 10 * time.Second}, ImageMaximumGCAge: &metav1.Duration{Duration: 30 * time.Hour}, ImageMinimumGCAge: &metav1.Duration{Duration: 30 * time.Minute}, - MaxParallelImagePulls: fi.PtrTo(int32(5)), + MaxParallelImagePulls: new(int32(5)), } builder := &KubeletBuilder{NodeupModelContext: &NodeupModelContext{ diff --git a/nodeup/pkg/model/networking/cilium.go b/nodeup/pkg/model/networking/cilium.go index 864bb40fd47f7..66dcffb2fa7a2 100644 --- a/nodeup/pkg/model/networking/cilium.go +++ b/nodeup/pkg/model/networking/cilium.go @@ -102,7 +102,7 @@ WantedBy=multi-user.target service := &nodetasks.Service{ Name: "sys-fs-bpf.mount", - Definition: fi.PtrTo(unit), + Definition: new(unit), } service.InitDefaults() c.AddTask(service) @@ -145,8 +145,8 @@ WantedBy=multi-user.target service := &nodetasks.Service{ Name: "run-cilium-cgroupv2.mount", - Definition: fi.PtrTo(unit), - SmartRestart: fi.PtrTo(false), + Definition: new(unit), + SmartRestart: new(false), } service.InitDefaults() c.AddTask(service) @@ -163,7 +163,7 @@ func (b *CiliumBuilder) buildCiliumEtcdSecrets(c *fi.NodeupModelBuilderContext) Path: filepath.Join(dir, "etcd-ca.crt"), Contents: fi.NewStringResource(b.NodeupConfig.CAs[signer]), Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0600"), + Mode: new("0600"), }) if b.HasAPIServer { issueCert := &nodetasks.IssueCert{ @@ -187,7 +187,7 @@ func (b *CiliumBuilder) buildCiliumEtcdSecrets(c *fi.NodeupModelBuilderContext) Path: filepath.Join(dir, name+".crt"), Contents: cert, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0644"), + Mode: new("0644"), BeforeServices: []string{"kubelet.service"}, }) @@ -195,7 +195,7 @@ func (b *CiliumBuilder) buildCiliumEtcdSecrets(c *fi.NodeupModelBuilderContext) Path: filepath.Join(dir, name+".key"), Contents: key, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0400"), + Mode: new("0400"), BeforeServices: []string{"kubelet.service"}, }) diff --git a/nodeup/pkg/model/networking/kube_router.go b/nodeup/pkg/model/networking/kube_router.go index 46ae82c8fbe40..41fb8bc3f7996 100644 --- a/nodeup/pkg/model/networking/kube_router.go +++ b/nodeup/pkg/model/networking/kube_router.go @@ -53,7 +53,7 @@ func (b *KuberouterBuilder) Build(c *fi.NodeupModelBuilderContext) error { Path: "/var/lib/kube-router/kubeconfig", Contents: kubeconfig, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0400"), + Mode: new("0400"), BeforeServices: []string{"kubelet.service"}, }) @@ -68,10 +68,10 @@ func (b *KuberouterBuilder) Build(c *fi.NodeupModelBuilderContext) error { c.AddTask(&nodetasks.File{ Path: "/usr/share/iproute2", Type: nodetasks.FileType_Symlink, - Symlink: fi.PtrTo("/etc/iproute2"), - Owner: fi.PtrTo("root"), - Group: fi.PtrTo("root"), - Mode: fi.PtrTo("0755"), + Symlink: new("/etc/iproute2"), + Owner: new("root"), + Group: new("root"), + Mode: new("0755"), }) } diff --git a/nodeup/pkg/model/protokube.go b/nodeup/pkg/model/protokube.go index c9caba3baec9d..74b0548e4db0c 100644 --- a/nodeup/pkg/model/protokube.go +++ b/nodeup/pkg/model/protokube.go @@ -60,7 +60,7 @@ func (t *ProtokubeBuilder) Build(c *fi.NodeupModelBuilderContext) error { Path: filepath.Join("/opt/kops/bin", name), Contents: res, Type: nodetasks.FileType_File, - Mode: fi.PtrTo("0755"), + Mode: new("0755"), }) } @@ -133,14 +133,14 @@ type ProtokubeFlags struct { // ProtokubeFlags is responsible for building the command line flags for protokube func (t *ProtokubeBuilder) ProtokubeFlags() (*ProtokubeFlags, error) { f := &ProtokubeFlags{ - Cloud: fi.PtrTo(string(t.CloudProvider())), - Containerized: fi.PtrTo(false), - LogLevel: fi.PtrTo(int32(4)), + Cloud: new(string(t.CloudProvider())), + Containerized: new(false), + LogLevel: new(int32(4)), } if t.UsesLegacyGossip() { klog.Warningf("using (legacy) gossip DNS") - f.Gossip = fi.PtrTo(true) + f.Gossip = new(true) if t.NodeupConfig.GossipConfig != nil { f.GossipProtocol = t.NodeupConfig.GossipConfig.Protocol f.GossipListen = t.NodeupConfig.GossipConfig.Listen diff --git a/pkg/apis/kops/validation/aws_test.go b/pkg/apis/kops/validation/aws_test.go index 83a40f85e4e4a..101b1f2d52b68 100644 --- a/pkg/apis/kops/validation/aws_test.go +++ b/pkg/apis/kops/validation/aws_test.go @@ -25,7 +25,6 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/kops/cloudmock/aws/mockec2" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/awsup" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -43,7 +42,7 @@ func TestAWSValidateEBSCSIDriver(t *testing.T) { CloudProvider: kops.CloudProviderSpec{ AWS: &kops.AWSSpec{ EBSCSIDriver: &kops.EBSCSIDriverSpec{ - Enabled: fi.PtrTo(false), + Enabled: new(false), }, }, }, @@ -56,7 +55,7 @@ func TestAWSValidateEBSCSIDriver(t *testing.T) { CloudProvider: kops.CloudProviderSpec{ AWS: &kops.AWSSpec{ EBSCSIDriver: &kops.EBSCSIDriverSpec{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, }, @@ -159,7 +158,7 @@ func TestValidateInstanceGroupSpec(t *testing.T) { }, { Input: kops.InstanceGroupSpec{ - SpotDurationInMinutes: fi.PtrTo(int64(55)), + SpotDurationInMinutes: new(int64(55)), }, ExpectedErrors: []string{ "Unsupported value::test-nodes.spec.spotDurationInMinutes", @@ -167,7 +166,7 @@ func TestValidateInstanceGroupSpec(t *testing.T) { }, { Input: kops.InstanceGroupSpec{ - SpotDurationInMinutes: fi.PtrTo(int64(380)), + SpotDurationInMinutes: new(int64(380)), }, ExpectedErrors: []string{ "Unsupported value::test-nodes.spec.spotDurationInMinutes", @@ -175,7 +174,7 @@ func TestValidateInstanceGroupSpec(t *testing.T) { }, { Input: kops.InstanceGroupSpec{ - SpotDurationInMinutes: fi.PtrTo(int64(125)), + SpotDurationInMinutes: new(int64(125)), }, ExpectedErrors: []string{ "Unsupported value::test-nodes.spec.spotDurationInMinutes", @@ -183,13 +182,13 @@ func TestValidateInstanceGroupSpec(t *testing.T) { }, { Input: kops.InstanceGroupSpec{ - SpotDurationInMinutes: fi.PtrTo(int64(120)), + SpotDurationInMinutes: new(int64(120)), }, ExpectedErrors: []string{}, }, { Input: kops.InstanceGroupSpec{ - InstanceInterruptionBehavior: fi.PtrTo("invalidValue"), + InstanceInterruptionBehavior: new("invalidValue"), }, ExpectedErrors: []string{ "Unsupported value::test-nodes.spec.instanceInterruptionBehavior", @@ -197,19 +196,19 @@ func TestValidateInstanceGroupSpec(t *testing.T) { }, { Input: kops.InstanceGroupSpec{ - InstanceInterruptionBehavior: fi.PtrTo("terminate"), + InstanceInterruptionBehavior: new("terminate"), }, ExpectedErrors: []string{}, }, { Input: kops.InstanceGroupSpec{ - InstanceInterruptionBehavior: fi.PtrTo("hibernate"), + InstanceInterruptionBehavior: new("hibernate"), }, ExpectedErrors: []string{}, }, { Input: kops.InstanceGroupSpec{ - InstanceInterruptionBehavior: fi.PtrTo("stop"), + InstanceInterruptionBehavior: new("stop"), }, ExpectedErrors: []string{}, }, @@ -329,7 +328,7 @@ func TestMixedInstancePolicies(t *testing.T) { "c4.large", "c5.large", }, - OnDemandAboveBase: fi.PtrTo(int64(231)), + OnDemandAboveBase: new(int64(231)), }, }, ExpectedErrors: []string{"Invalid value::spec.mixedInstancesPolicy.onDemandAboveBase"}, @@ -388,8 +387,8 @@ func TestInstanceMetadataOptions(t *testing.T) { Spec: kops.InstanceGroupSpec{ Role: "Node", InstanceMetadata: &kops.InstanceMetadataOptions{ - HTTPPutResponseHopLimit: fi.PtrTo(int64(1)), - HTTPTokens: fi.PtrTo("abc"), + HTTPPutResponseHopLimit: new(int64(1)), + HTTPTokens: new("abc"), }, MachineType: "t3.medium", }, @@ -404,8 +403,8 @@ func TestInstanceMetadataOptions(t *testing.T) { Spec: kops.InstanceGroupSpec{ Role: "Node", InstanceMetadata: &kops.InstanceMetadataOptions{ - HTTPPutResponseHopLimit: fi.PtrTo(int64(-1)), - HTTPTokens: fi.PtrTo("required"), + HTTPPutResponseHopLimit: new(int64(-1)), + HTTPTokens: new("required"), }, MachineType: "t3.medium", }, @@ -449,7 +448,7 @@ func TestLoadBalancerSubnets(t *testing.T) { lbSubnets: []kops.LoadBalancerSubnetSpec{ { Name: "a", - PrivateIPv4Address: fi.PtrTo("10.0.0.10"), + PrivateIPv4Address: new("10.0.0.10"), AllocationID: nil, }, { @@ -486,7 +485,7 @@ func TestLoadBalancerSubnets(t *testing.T) { lbSubnets: []kops.LoadBalancerSubnetSpec{ { Name: "a", - PrivateIPv4Address: fi.PtrTo(""), + PrivateIPv4Address: new(""), AllocationID: nil, }, }, @@ -498,7 +497,7 @@ func TestLoadBalancerSubnets(t *testing.T) { { Name: "a", PrivateIPv4Address: nil, - AllocationID: fi.PtrTo(""), + AllocationID: new(""), }, }, expected: []string{"Required value::spec.api.loadBalancer.subnets[0].allocationID"}, @@ -508,7 +507,7 @@ func TestLoadBalancerSubnets(t *testing.T) { lbSubnets: []kops.LoadBalancerSubnetSpec{ { Name: "a", - PrivateIPv4Address: fi.PtrTo("invalidip"), + PrivateIPv4Address: new("invalidip"), AllocationID: nil, }, }, @@ -519,56 +518,56 @@ func TestLoadBalancerSubnets(t *testing.T) { lbSubnets: []kops.LoadBalancerSubnetSpec{ { Name: "a", - PrivateIPv4Address: fi.PtrTo("11.0.0.10"), + PrivateIPv4Address: new("11.0.0.10"), AllocationID: nil, }, }, expected: []string{"Invalid value::spec.api.loadBalancer.subnets[0].privateIPv4Address"}, }, { // invalid class - with privateIPv4Address, no allocationID - class: fi.PtrTo(string(kops.LoadBalancerClassClassic)), + class: new(string(kops.LoadBalancerClassClassic)), clusterSubnets: []string{"a", "b", "c"}, lbSubnets: []kops.LoadBalancerSubnetSpec{ { Name: "a", - PrivateIPv4Address: fi.PtrTo("10.0.0.10"), + PrivateIPv4Address: new("10.0.0.10"), AllocationID: nil, }, }, expected: []string{"Forbidden::spec.api.loadBalancer.subnets[0].privateIPv4Address"}, }, { // invalid class - no privateIPv4Address, with allocationID - class: fi.PtrTo(string(kops.LoadBalancerClassClassic)), + class: new(string(kops.LoadBalancerClassClassic)), clusterSubnets: []string{"a", "b", "c"}, lbSubnets: []kops.LoadBalancerSubnetSpec{ { Name: "a", PrivateIPv4Address: nil, - AllocationID: fi.PtrTo("eipalloc-222ghi789"), + AllocationID: new("eipalloc-222ghi789"), }, }, expected: []string{"Forbidden::spec.api.loadBalancer.subnets[0].allocationID"}, }, { // invalid type external for private IP - lbType: fi.PtrTo(string(kops.LoadBalancerTypePublic)), + lbType: new(string(kops.LoadBalancerTypePublic)), clusterSubnets: []string{"a", "b", "c"}, lbSubnets: []kops.LoadBalancerSubnetSpec{ { Name: "a", - PrivateIPv4Address: fi.PtrTo("10.0.0.10"), + PrivateIPv4Address: new("10.0.0.10"), AllocationID: nil, }, }, expected: []string{"Forbidden::spec.api.loadBalancer.subnets[0].privateIPv4Address"}, }, { // invalid type Internal for public IP - lbType: fi.PtrTo(string(kops.LoadBalancerTypeInternal)), + lbType: new(string(kops.LoadBalancerTypeInternal)), clusterSubnets: []string{"a", "b", "c"}, lbSubnets: []kops.LoadBalancerSubnetSpec{ { Name: "a", PrivateIPv4Address: nil, - AllocationID: fi.PtrTo("eipalloc-222ghi789"), + AllocationID: new("eipalloc-222ghi789"), }, }, expected: []string{"Forbidden::spec.api.loadBalancer.subnets[0].allocationID"}, @@ -896,7 +895,7 @@ func TestAWSValidateNLBSecurityGroupMode(t *testing.T) { Input: kops.ClusterSpec{ CloudProvider: kops.CloudProviderSpec{ AWS: &kops.AWSSpec{ - NLBSecurityGroupMode: fi.PtrTo("Managed"), + NLBSecurityGroupMode: new("Managed"), }, }, }, @@ -905,7 +904,7 @@ func TestAWSValidateNLBSecurityGroupMode(t *testing.T) { Input: kops.ClusterSpec{ CloudProvider: kops.CloudProviderSpec{ AWS: &kops.AWSSpec{ - NLBSecurityGroupMode: fi.PtrTo(""), + NLBSecurityGroupMode: new(""), }, }, }, @@ -922,7 +921,7 @@ func TestAWSValidateNLBSecurityGroupMode(t *testing.T) { Input: kops.ClusterSpec{ CloudProvider: kops.CloudProviderSpec{ AWS: &kops.AWSSpec{ - NLBSecurityGroupMode: fi.PtrTo("Invalid"), + NLBSecurityGroupMode: new("Invalid"), }, }, }, @@ -932,7 +931,7 @@ func TestAWSValidateNLBSecurityGroupMode(t *testing.T) { Input: kops.ClusterSpec{ CloudProvider: kops.CloudProviderSpec{ AWS: &kops.AWSSpec{ - NLBSecurityGroupMode: fi.PtrTo("managed"), + NLBSecurityGroupMode: new("managed"), }, }, }, diff --git a/pkg/apis/kops/validation/cluster_test.go b/pkg/apis/kops/validation/cluster_test.go index 9e8ab92ff3c34..6b63bee75d132 100644 --- a/pkg/apis/kops/validation/cluster_test.go +++ b/pkg/apis/kops/validation/cluster_test.go @@ -20,7 +20,6 @@ import ( "testing" "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/pkg/apis/kops" ) @@ -38,15 +37,15 @@ func TestValidEtcdChanges(t *testing.T) { Members: []kops.EtcdMemberSpec{ { Name: "a", - InstanceGroup: fi.PtrTo("eu-central-1a"), + InstanceGroup: new("eu-central-1a"), }, { Name: "b", - InstanceGroup: fi.PtrTo("eu-central-1b"), + InstanceGroup: new("eu-central-1b"), }, { Name: "c", - InstanceGroup: fi.PtrTo("eu-central-1c"), + InstanceGroup: new("eu-central-1c"), }, }, }, @@ -56,15 +55,15 @@ func TestValidEtcdChanges(t *testing.T) { Members: []kops.EtcdMemberSpec{ { Name: "a", - InstanceGroup: fi.PtrTo("eu-central-1a"), + InstanceGroup: new("eu-central-1a"), }, { Name: "b", - InstanceGroup: fi.PtrTo("eu-central-1b"), + InstanceGroup: new("eu-central-1b"), }, { Name: "d", - InstanceGroup: fi.PtrTo("eu-central-1d"), + InstanceGroup: new("eu-central-1d"), }, }, }, @@ -86,7 +85,7 @@ func TestValidEtcdChanges(t *testing.T) { Members: []kops.EtcdMemberSpec{ { Name: "a", - InstanceGroup: fi.PtrTo("eu-central-1a"), + InstanceGroup: new("eu-central-1a"), }, }, }, @@ -96,15 +95,15 @@ func TestValidEtcdChanges(t *testing.T) { Members: []kops.EtcdMemberSpec{ { Name: "a", - InstanceGroup: fi.PtrTo("eu-central-1a"), + InstanceGroup: new("eu-central-1a"), }, { Name: "b", - InstanceGroup: fi.PtrTo("eu-central-1b"), + InstanceGroup: new("eu-central-1b"), }, { Name: "c", - InstanceGroup: fi.PtrTo("eu-central-1c"), + InstanceGroup: new("eu-central-1c"), }, }, }, @@ -126,7 +125,7 @@ func TestValidEtcdChanges(t *testing.T) { Members: []kops.EtcdMemberSpec{ { Name: "a", - InstanceGroup: fi.PtrTo("eu-central-1a"), + InstanceGroup: new("eu-central-1a"), }, }, }, @@ -136,7 +135,7 @@ func TestValidEtcdChanges(t *testing.T) { Members: []kops.EtcdMemberSpec{ { Name: "a", - InstanceGroup: fi.PtrTo("eu-central-1a"), + InstanceGroup: new("eu-central-1a"), }, }, }, @@ -250,7 +249,7 @@ func TestEtcdVersionRequiredWithImage(t *testing.T) { Details: "image requires version", Spec: kops.EtcdClusterSpec{ Name: "main", - Members: []kops.EtcdMemberSpec{{Name: "a", InstanceGroup: fi.PtrTo("eu-central-1a")}}, + Members: []kops.EtcdMemberSpec{{Name: "a", InstanceGroup: new("eu-central-1a")}}, Image: "gcr.io/etcd-development/etcd:v3.6.99", }, ExpectedErrors: []string{ @@ -261,7 +260,7 @@ func TestEtcdVersionRequiredWithImage(t *testing.T) { Details: "image with version is valid", Spec: kops.EtcdClusterSpec{ Name: "main", - Members: []kops.EtcdMemberSpec{{Name: "a", InstanceGroup: fi.PtrTo("eu-central-1a")}}, + Members: []kops.EtcdMemberSpec{{Name: "a", InstanceGroup: new("eu-central-1a")}}, Version: "3.6.99", Image: "gcr.io/etcd-development/etcd:v3.6.99", }, @@ -270,7 +269,7 @@ func TestEtcdVersionRequiredWithImage(t *testing.T) { Details: "neither image nor version is valid", Spec: kops.EtcdClusterSpec{ Name: "main", - Members: []kops.EtcdMemberSpec{{Name: "a", InstanceGroup: fi.PtrTo("eu-central-1a")}}, + Members: []kops.EtcdMemberSpec{{Name: "a", InstanceGroup: new("eu-central-1a")}}, }, }, } diff --git a/pkg/apis/kops/validation/instancegroup_test.go b/pkg/apis/kops/validation/instancegroup_test.go index 51b96fa3c4470..9c8bd5e9a062b 100644 --- a/pkg/apis/kops/validation/instancegroup_test.go +++ b/pkg/apis/kops/validation/instancegroup_test.go @@ -24,11 +24,10 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" ) func s(v string) *string { - return fi.PtrTo(v) + return new(v) } func TestValidateInstanceProfile(t *testing.T) { @@ -111,15 +110,15 @@ func TestValidMasterInstanceGroup(t *testing.T) { Members: []kops.EtcdMemberSpec{ { Name: "a", - InstanceGroup: fi.PtrTo("eu-central-1a"), + InstanceGroup: new("eu-central-1a"), }, { Name: "b", - InstanceGroup: fi.PtrTo("eu-central-1b"), + InstanceGroup: new("eu-central-1b"), }, { Name: "c", - InstanceGroup: fi.PtrTo("eu-central-1c"), + InstanceGroup: new("eu-central-1c"), }, }, }, @@ -146,15 +145,15 @@ func TestValidMasterInstanceGroup(t *testing.T) { Members: []kops.EtcdMemberSpec{ { Name: "a", - InstanceGroup: fi.PtrTo("eu-central-1a"), + InstanceGroup: new("eu-central-1a"), }, { Name: "b", - InstanceGroup: fi.PtrTo("eu-central-1b"), + InstanceGroup: new("eu-central-1b"), }, { Name: "c", - InstanceGroup: fi.PtrTo("eu-central-1c"), + InstanceGroup: new("eu-central-1c"), }, }, }, @@ -222,7 +221,7 @@ func TestValidBootDevice(t *testing.T) { for _, g := range grid { ig := createMinimalInstanceGroup() ig.Spec.RootVolume = &kops.InstanceRootVolumeSpec{ - Type: fi.PtrTo(g.volumeType), + Type: new(g.volumeType), } errs := CrossValidateInstanceGroup(ig, cluster, nil, true) testErrors(t, g.volumeType, errs, g.expected) @@ -377,69 +376,69 @@ func TestValidateKarpenterStaticCapacity(t *testing.T) { }, { desc: "static with default feature gates", - minSize: fi.PtrTo(int32(4)), + minSize: new(int32(4)), }, { desc: "static with custom feature gates", - minSize: fi.PtrTo(int32(4)), + minSize: new(int32(4)), featureGates: "NodeRepair=false,StaticCapacity=true", }, { desc: "static with final feature gate enabled", - minSize: fi.PtrTo(int32(4)), + minSize: new(int32(4)), featureGates: "StaticCapacity=false,StaticCapacity=true", }, { desc: "zero minSize", - minSize: fi.PtrTo(int32(0)), + minSize: new(int32(0)), expected: []string{"Invalid value::spec.minSize"}, }, { desc: "negative minSize", - minSize: fi.PtrTo(int32(-1)), + minSize: new(int32(-1)), expected: []string{"Invalid value::spec.minSize"}, }, { desc: "custom feature gates omit static capacity", - minSize: fi.PtrTo(int32(4)), + minSize: new(int32(4)), featureGates: "NodeRepair=true", expected: []string{"Forbidden::spec.minSize"}, }, { desc: "whitespace feature gates", - minSize: fi.PtrTo(int32(4)), + minSize: new(int32(4)), featureGates: " ", expected: []string{"Forbidden::spec.minSize"}, }, { desc: "static capacity disabled", - minSize: fi.PtrTo(int32(4)), + minSize: new(int32(4)), featureGates: "StaticCapacity=false", expected: []string{"Forbidden::spec.minSize"}, }, { desc: "final feature gate disabled", - minSize: fi.PtrTo(int32(4)), + minSize: new(int32(4)), featureGates: "StaticCapacity=true,StaticCapacity=false", expected: []string{"Forbidden::spec.minSize"}, }, { desc: "maxSize for dynamic", - maxSize: fi.PtrTo(int32(4)), + maxSize: new(int32(4)), }, { desc: "maxSize for static", - minSize: fi.PtrTo(int32(4)), - maxSize: fi.PtrTo(int32(4)), + minSize: new(int32(4)), + maxSize: new(int32(4)), }, { desc: "zero maxSize", - maxSize: fi.PtrTo(int32(0)), + maxSize: new(int32(0)), expected: []string{"Invalid value::spec.maxSize"}, }, { desc: "negative maxSize", - maxSize: fi.PtrTo(int32(-1)), + maxSize: new(int32(-1)), expected: []string{"Invalid value::spec.maxSize"}, }, } @@ -574,20 +573,20 @@ func TestIGUpdatePolicy(t *testing.T) { }, { label: "automatic", - policy: fi.PtrTo(kops.UpdatePolicyAutomatic), + policy: new(kops.UpdatePolicyAutomatic), }, { label: "external", - policy: fi.PtrTo(kops.UpdatePolicyExternal), + policy: new(kops.UpdatePolicyExternal), }, { label: "empty", - policy: fi.PtrTo(""), + policy: new(""), expected: []string{unsupportedValueError}, }, { label: "unknown", - policy: fi.PtrTo("something-else"), + policy: new("something-else"), expected: []string{unsupportedValueError}, }, } { @@ -611,30 +610,30 @@ func TestValidateInstanceGroupGVisorWorkerOnly(t *testing.T) { { name: "enabled on worker", role: kops.InstanceGroupRoleNode, - enabled: fi.PtrTo(true), + enabled: new(true), }, { name: "enabled on control plane", role: kops.InstanceGroupRoleControlPlane, - enabled: fi.PtrTo(true), + enabled: new(true), expected: []string{"Forbidden::spec.containerd.gvisor"}, }, { name: "enabled on apiserver", role: kops.InstanceGroupRoleAPIServer, - enabled: fi.PtrTo(true), + enabled: new(true), expected: []string{"Forbidden::spec.containerd.gvisor"}, }, { name: "enabled on bastion", role: kops.InstanceGroupRoleBastion, - enabled: fi.PtrTo(true), + enabled: new(true), expected: []string{"Forbidden::spec.containerd.gvisor"}, }, { name: "disabled on apiserver", role: kops.InstanceGroupRoleAPIServer, - enabled: fi.PtrTo(false), + enabled: new(false), }, } { t.Run(test.name, func(t *testing.T) { @@ -667,8 +666,8 @@ func TestValidInstanceGroup(t *testing.T) { Spec: kops.InstanceGroupSpec{ Role: kops.InstanceGroupRoleControlPlane, Subnets: []string{"eu-central-1a"}, - MaxSize: fi.PtrTo(int32(1)), - MinSize: fi.PtrTo(int32(1)), + MaxSize: new(int32(1)), + MinSize: new(int32(1)), Image: "my-image", }, }, @@ -683,8 +682,8 @@ func TestValidInstanceGroup(t *testing.T) { Spec: kops.InstanceGroupSpec{ Role: kops.InstanceGroupRoleAPIServer, Subnets: []string{"eu-central-1a"}, - MaxSize: fi.PtrTo(int32(1)), - MinSize: fi.PtrTo(int32(1)), + MaxSize: new(int32(1)), + MinSize: new(int32(1)), Image: "my-image", }, }, @@ -699,8 +698,8 @@ func TestValidInstanceGroup(t *testing.T) { Spec: kops.InstanceGroupSpec{ Role: kops.InstanceGroupRoleNode, Subnets: []string{"eu-central-1a"}, - MaxSize: fi.PtrTo(int32(1)), - MinSize: fi.PtrTo(int32(1)), + MaxSize: new(int32(1)), + MinSize: new(int32(1)), Image: "my-image", }, }, @@ -715,8 +714,8 @@ func TestValidInstanceGroup(t *testing.T) { Spec: kops.InstanceGroupSpec{ Role: kops.InstanceGroupRoleBastion, Subnets: []string{"eu-central-1a"}, - MaxSize: fi.PtrTo(int32(1)), - MinSize: fi.PtrTo(int32(1)), + MaxSize: new(int32(1)), + MinSize: new(int32(1)), Image: "my-image", }, }, @@ -731,8 +730,8 @@ func TestValidInstanceGroup(t *testing.T) { Spec: kops.InstanceGroupSpec{ Role: kops.InstanceGroupRoleBastion, Subnets: []string{"eu-central-1a"}, - MaxSize: fi.PtrTo(int32(1)), - MinSize: fi.PtrTo(int32(1)), + MaxSize: new(int32(1)), + MinSize: new(int32(1)), }, }, ExpectedErrors: []string{"Forbidden::spec.image"}, @@ -746,8 +745,8 @@ func TestValidInstanceGroup(t *testing.T) { Spec: kops.InstanceGroupSpec{ Role: kops.InstanceGroupRoleControlPlane, Subnets: []string{"eu-central-1a"}, - MaxSize: fi.PtrTo(int32(2)), - MinSize: fi.PtrTo(int32(2)), + MaxSize: new(int32(2)), + MinSize: new(int32(2)), Image: "my-image", }, }, @@ -772,8 +771,8 @@ func createMinimalInstanceGroup() *kops.InstanceGroup { Spec: kops.InstanceGroupSpec{ CloudLabels: make(map[string]string), Role: "Node", - MaxSize: fi.PtrTo(int32(1)), - MinSize: fi.PtrTo(int32(1)), + MaxSize: new(int32(1)), + MinSize: new(int32(1)), Image: "my-image", }, } @@ -855,8 +854,8 @@ func TestCrossValidateAPIServerRole(t *testing.T) { Spec: kops.InstanceGroupSpec{ Role: kops.InstanceGroupRoleAPIServer, Subnets: []string{"eu-central-1a"}, - MaxSize: fi.PtrTo(int32(1)), - MinSize: fi.PtrTo(int32(1)), + MaxSize: new(int32(1)), + MinSize: new(int32(1)), Image: "my-image", }, } diff --git a/pkg/apis/kops/validation/validation_test.go b/pkg/apis/kops/validation/validation_test.go index 2de9b8abbe6bd..5605636661fbd 100644 --- a/pkg/apis/kops/validation/validation_test.go +++ b/pkg/apis/kops/validation/validation_test.go @@ -27,7 +27,6 @@ import ( "k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/utils/ptr" ) @@ -254,7 +253,7 @@ func TestValidateKubeAPIServer(t *testing.T) { }, { Input: kops.KubeAPIServerConfig{ - AuthorizationMode: fi.PtrTo("RBAC"), + AuthorizationMode: new("RBAC"), }, Cluster: &kops.Cluster{ Spec: kops.ClusterSpec{ @@ -273,7 +272,7 @@ func TestValidateKubeAPIServer(t *testing.T) { }, { Input: kops.KubeAPIServerConfig{ - AuthorizationMode: fi.PtrTo("RBAC,Node"), + AuthorizationMode: new("RBAC,Node"), }, Cluster: &kops.Cluster{ Spec: kops.ClusterSpec{ @@ -289,7 +288,7 @@ func TestValidateKubeAPIServer(t *testing.T) { }, { Input: kops.KubeAPIServerConfig{ - AuthorizationMode: fi.PtrTo("RBAC,Node,Bogus"), + AuthorizationMode: new("RBAC,Node,Bogus"), }, Cluster: &kops.Cluster{ Spec: kops.ClusterSpec{ @@ -320,7 +319,7 @@ func TestValidateKubeAPIServer(t *testing.T) { Spec: kops.ClusterSpec{ Authentication: &kops.AuthenticationSpec{ OIDC: &kops.OIDCAuthenticationSpec{ - ClientID: fi.PtrTo("foo"), + ClientID: new("foo"), }, }, }, @@ -698,7 +697,7 @@ func Test_Validate_AdditionalPolicies(t *testing.T) { Members: []kops.EtcdMemberSpec{ { Name: "us-test-1a", - InstanceGroup: fi.PtrTo("master-us-test-1a"), + InstanceGroup: new("master-us-test-1a"), }, }, }, @@ -743,7 +742,7 @@ func Test_Validate_Addons(t *testing.T) { { Name: "main", Members: []kops.EtcdMemberSpec{ - {Name: "us-test-1a", InstanceGroup: fi.PtrTo("master-us-test-1a")}, + {Name: "us-test-1a", InstanceGroup: new("master-us-test-1a")}, }, }, }, @@ -1129,7 +1128,7 @@ func Test_Validate_Calico(t *testing.T) { Description: "Calico BPF with kube-proxy explicitly disabled", Input: caliInput{ Cluster: &kops.ClusterSpec{ - KubeProxy: &kops.KubeProxyConfig{Enabled: fi.PtrTo(false)}, + KubeProxy: &kops.KubeProxyConfig{Enabled: new(false)}, }, Calico: &kops.CalicoNetworkingSpec{BPFEnabled: true}, }, @@ -1148,7 +1147,7 @@ func Test_Validate_Calico(t *testing.T) { Description: "Calico BPF with kube-proxy explicitly enabled", Input: caliInput{ Cluster: &kops.ClusterSpec{ - KubeProxy: &kops.KubeProxyConfig{Enabled: fi.PtrTo(true)}, + KubeProxy: &kops.KubeProxyConfig{Enabled: new(true)}, }, Calico: &kops.CalicoNetworkingSpec{BPFEnabled: true}, }, @@ -1195,7 +1194,7 @@ func Test_Validate_Cilium(t *testing.T) { }, { Cilium: kops.CiliumNetworkingSpec{ - Masquerade: fi.PtrTo(true), + Masquerade: new(true), IPAM: "eni", }, Spec: kops.ClusterSpec{ @@ -1212,7 +1211,7 @@ func Test_Validate_Cilium(t *testing.T) { }, { Cilium: kops.CiliumNetworkingSpec{ - Masquerade: fi.PtrTo(false), + Masquerade: new(false), IPAM: "eni", }, Spec: kops.ClusterSpec{ @@ -1223,8 +1222,8 @@ func Test_Validate_Cilium(t *testing.T) { }, { Cilium: kops.CiliumNetworkingSpec{ - EnableL7Proxy: fi.PtrTo(true), - InstallIptablesRules: fi.PtrTo(false), + EnableL7Proxy: new(true), + InstallIptablesRules: new(false), }, Spec: kops.ClusterSpec{ CloudProvider: kops.CloudProviderSpec{ @@ -1269,7 +1268,7 @@ func Test_Validate_Cilium(t *testing.T) { Cilium: kops.CiliumNetworkingSpec{ Version: "v1.8.0", Hubble: &kops.HubbleSpec{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, ExpectedErrors: []string{"Forbidden::cilium.hubble.enabled"}, @@ -1278,7 +1277,7 @@ func Test_Validate_Cilium(t *testing.T) { Cilium: kops.CiliumNetworkingSpec{ Version: "v1.18.0", Ingress: &kops.CiliumIngressSpec{ - Enabled: fi.PtrTo(true), + Enabled: new(true), DefaultLoadBalancerMode: "bad-value", }, }, @@ -1288,7 +1287,7 @@ func Test_Validate_Cilium(t *testing.T) { Cilium: kops.CiliumNetworkingSpec{ Version: "v1.18.0", Ingress: &kops.CiliumIngressSpec{ - Enabled: fi.PtrTo(true), + Enabled: new(true), DefaultLoadBalancerMode: "dedicated", }, }, @@ -1297,8 +1296,8 @@ func Test_Validate_Cilium(t *testing.T) { Cilium: kops.CiliumNetworkingSpec{ Version: "v1.18.0", GatewayAPI: &kops.CiliumGatewayAPISpec{ - Enabled: fi.PtrTo(true), - EnableSecretsSync: fi.PtrTo(true), + Enabled: new(true), + EnableSecretsSync: new(true), }, }, }, @@ -1306,12 +1305,12 @@ func Test_Validate_Cilium(t *testing.T) { Cilium: kops.CiliumNetworkingSpec{ Version: "v1.18.0", Hubble: &kops.HubbleSpec{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, Spec: kops.ClusterSpec{ CertManager: &kops.CertManagerConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, }, @@ -1495,7 +1494,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) { KubeDNS: &kops.KubeDNSConfig{ Provider: "CoreDNS", NodeLocalDNS: &kops.NodeLocalDNSConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, }, @@ -1512,7 +1511,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) { KubeDNS: &kops.KubeDNSConfig{ Provider: "CoreDNS", NodeLocalDNS: &kops.NodeLocalDNSConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, }, @@ -1529,7 +1528,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) { KubeDNS: &kops.KubeDNSConfig{ Provider: "CoreDNS", NodeLocalDNS: &kops.NodeLocalDNSConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, Networking: kops.NetworkingSpec{ @@ -1549,7 +1548,7 @@ func Test_Validate_NodeLocalDNS(t *testing.T) { KubeDNS: &kops.KubeDNSConfig{ Provider: "CoreDNS", NodeLocalDNS: &kops.NodeLocalDNSConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), LocalIP: "169.254.20.10", }, }, @@ -1581,13 +1580,13 @@ func Test_Validate_CloudConfiguration(t *testing.T) { { Description: "all false", Input: kops.CloudConfiguration{ - ManageStorageClasses: fi.PtrTo(false), + ManageStorageClasses: new(false), }, }, { Description: "all true", Input: kops.CloudConfiguration{ - ManageStorageClasses: fi.PtrTo(true), + ManageStorageClasses: new(true), }, }, { @@ -1596,7 +1595,7 @@ func Test_Validate_CloudConfiguration(t *testing.T) { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ BlockStorage: &kops.OpenstackBlockStorageConfig{ - CreateStorageClass: fi.PtrTo(false), + CreateStorageClass: new(false), }, }, }, @@ -1607,7 +1606,7 @@ func Test_Validate_CloudConfiguration(t *testing.T) { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ BlockStorage: &kops.OpenstackBlockStorageConfig{ - CreateStorageClass: fi.PtrTo(true), + CreateStorageClass: new(true), }, }, }, @@ -1615,12 +1614,12 @@ func Test_Validate_CloudConfiguration(t *testing.T) { { Description: "all false, os false", Input: kops.CloudConfiguration{ - ManageStorageClasses: fi.PtrTo(false), + ManageStorageClasses: new(false), }, CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ BlockStorage: &kops.OpenstackBlockStorageConfig{ - CreateStorageClass: fi.PtrTo(false), + CreateStorageClass: new(false), }, }, }, @@ -1628,12 +1627,12 @@ func Test_Validate_CloudConfiguration(t *testing.T) { { Description: "all false, os true", Input: kops.CloudConfiguration{ - ManageStorageClasses: fi.PtrTo(false), + ManageStorageClasses: new(false), }, CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ BlockStorage: &kops.OpenstackBlockStorageConfig{ - CreateStorageClass: fi.PtrTo(true), + CreateStorageClass: new(true), }, }, }, @@ -1642,12 +1641,12 @@ func Test_Validate_CloudConfiguration(t *testing.T) { { Description: "all true, os false", Input: kops.CloudConfiguration{ - ManageStorageClasses: fi.PtrTo(true), + ManageStorageClasses: new(true), }, CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ BlockStorage: &kops.OpenstackBlockStorageConfig{ - CreateStorageClass: fi.PtrTo(false), + CreateStorageClass: new(false), }, }, }, @@ -1656,12 +1655,12 @@ func Test_Validate_CloudConfiguration(t *testing.T) { { Description: "all true, os true", Input: kops.CloudConfiguration{ - ManageStorageClasses: fi.PtrTo(true), + ManageStorageClasses: new(true), }, CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ BlockStorage: &kops.OpenstackBlockStorageConfig{ - CreateStorageClass: fi.PtrTo(true), + CreateStorageClass: new(true), }, }, }, @@ -1776,7 +1775,7 @@ func Test_Validate_Nvidia_Cluster(t *testing.T) { Input: kops.ClusterSpec{ Containerd: &kops.ContainerdConfig{ NvidiaGPU: &kops.NvidiaGPUConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, CloudProvider: kops.CloudProviderSpec{ @@ -1788,7 +1787,7 @@ func Test_Validate_Nvidia_Cluster(t *testing.T) { Input: kops.ClusterSpec{ Containerd: &kops.ContainerdConfig{ NvidiaGPU: &kops.NvidiaGPUConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, CloudProvider: kops.CloudProviderSpec{ @@ -1801,7 +1800,7 @@ func Test_Validate_Nvidia_Cluster(t *testing.T) { Input: kops.ClusterSpec{ Containerd: &kops.ContainerdConfig{ NvidiaGPU: &kops.NvidiaGPUConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, CloudProvider: kops.CloudProviderSpec{ @@ -1828,7 +1827,7 @@ func Test_Validate_Nvidia_Ig(t *testing.T) { Input: kops.ClusterSpec{ Containerd: &kops.ContainerdConfig{ NvidiaGPU: &kops.NvidiaGPUConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, CloudProvider: kops.CloudProviderSpec{ @@ -1840,7 +1839,7 @@ func Test_Validate_Nvidia_Ig(t *testing.T) { Input: kops.ClusterSpec{ Containerd: &kops.ContainerdConfig{ NvidiaGPU: &kops.NvidiaGPUConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, CloudProvider: kops.CloudProviderSpec{ @@ -1852,7 +1851,7 @@ func Test_Validate_Nvidia_Ig(t *testing.T) { Input: kops.ClusterSpec{ Containerd: &kops.ContainerdConfig{ NvidiaGPU: &kops.NvidiaGPUConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, CloudProvider: kops.CloudProviderSpec{ @@ -1880,18 +1879,18 @@ func Test_Validate_GVisor(t *testing.T) { { name: "enabled in cluster config", inClusterConfig: true, - enabled: fi.PtrTo(true), + enabled: new(true), expectedErrors: []string{"Forbidden::containerd.gvisor"}, }, { name: "disabled in cluster config", inClusterConfig: true, - enabled: fi.PtrTo(false), + enabled: new(false), expectedErrors: []string{"Forbidden::containerd.gvisor"}, }, { name: "enabled in instance group config", - enabled: fi.PtrTo(true), + enabled: new(true), }, } for _, g := range grid { @@ -1918,7 +1917,7 @@ func Test_Validate_NriConfig(t *testing.T) { Input: kops.ClusterSpec{ Containerd: &kops.ContainerdConfig{ NRI: &kops.NRIConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, Version: &unsupportedContainerdVersion, }, @@ -1949,7 +1948,7 @@ func Test_Validate_NriConfig(t *testing.T) { Input: kops.ClusterSpec{ Containerd: &kops.ContainerdConfig{ NRI: &kops.NRIConfig{ - Enabled: fi.PtrTo(false), + Enabled: new(false), }, Version: &unsupportedContainerdVersion, }, @@ -1960,7 +1959,7 @@ func Test_Validate_NriConfig(t *testing.T) { Input: kops.ClusterSpec{ Containerd: &kops.ContainerdConfig{ NRI: &kops.NRIConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, Version: &supportedContainerdVersion, }, diff --git a/pkg/commands/set_cluster_test.go b/pkg/commands/set_cluster_test.go index 091350bf62cc5..8b97739a3bda2 100644 --- a/pkg/commands/set_cluster_test.go +++ b/pkg/commands/set_cluster_test.go @@ -21,7 +21,6 @@ import ( "testing" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" ) func TestSetClusterBadInput(t *testing.T) { @@ -57,7 +56,7 @@ func TestSetClusterFields(t *testing.T) { KubernetesVersion: "1.8.2", Kubelet: &kops.KubeletConfigSpec{ AuthorizationMode: "Webhook", - AuthenticationTokenWebhook: fi.PtrTo(true), + AuthenticationTokenWebhook: new(true), }, }, }, @@ -92,7 +91,7 @@ func TestSetClusterFields(t *testing.T) { Output: kops.Cluster{ Spec: kops.ClusterSpec{ Kubelet: &kops.KubeletConfigSpec{ - AuthenticationTokenWebhook: fi.PtrTo(false), + AuthenticationTokenWebhook: new(false), }, }, }, @@ -232,7 +231,7 @@ func TestSetClusterFields(t *testing.T) { Spec: kops.ClusterSpec{ Networking: kops.NetworkingSpec{ Cilium: &kops.CiliumNetworkingSpec{ - Masquerade: fi.PtrTo(false), + Masquerade: new(false), }, }, }, @@ -246,7 +245,7 @@ func TestSetClusterFields(t *testing.T) { Output: kops.Cluster{ Spec: kops.ClusterSpec{ KubeProxy: &kops.KubeProxyConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, }, @@ -304,13 +303,13 @@ func TestSetCiliumFields(t *testing.T) { Output: kops.Cluster{ Spec: kops.ClusterSpec{ KubeProxy: &kops.KubeProxyConfig{ - Enabled: fi.PtrTo(false), + Enabled: new(false), }, Networking: kops.NetworkingSpec{ Cilium: &kops.CiliumNetworkingSpec{ IPAM: "eni", EnableNodePort: true, - Masquerade: fi.PtrTo(false), + Masquerade: new(false), }, }, }, diff --git a/pkg/commands/set_instancegroups_test.go b/pkg/commands/set_instancegroups_test.go index eebc3fe3b7f1c..8a88d532ca5dc 100644 --- a/pkg/commands/set_instancegroups_test.go +++ b/pkg/commands/set_instancegroups_test.go @@ -21,7 +21,6 @@ import ( "testing" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" ) func TestSetInstanceGroupsBadInput(t *testing.T) { @@ -73,8 +72,8 @@ func TestSetInstanceGroupsFields(t *testing.T) { }, Output: kops.InstanceGroup{ Spec: kops.InstanceGroupSpec{ - MinSize: fi.PtrTo(int32(1)), - MaxSize: fi.PtrTo(int32(3)), + MinSize: new(int32(1)), + MaxSize: new(int32(3)), }, }, }, diff --git a/pkg/commands/toolbox_enroll.go b/pkg/commands/toolbox_enroll.go index ac62b9dec4ccb..e96576fa6d9f9 100644 --- a/pkg/commands/toolbox_enroll.go +++ b/pkg/commands/toolbox_enroll.go @@ -843,7 +843,7 @@ func (b *ConfigBuilder) GetBootstrapData(ctx context.Context) (*BootstrapData, e nodeupScript.CloudProvider = string(cluster.GetCloudProvider()) - bootConfig.ConfigBase = fi.PtrTo("file:///etc/kubernetes/kops/config") + bootConfig.ConfigBase = new("file:///etc/kubernetes/kops/config") nodeupScriptResource, err := nodeupScript.Build() if err != nil { diff --git a/pkg/commands/unset_cluster_test.go b/pkg/commands/unset_cluster_test.go index 1f2c5b6b11b22..b00d6dbe6ac67 100644 --- a/pkg/commands/unset_cluster_test.go +++ b/pkg/commands/unset_cluster_test.go @@ -21,7 +21,6 @@ import ( "testing" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" ) func TestUnsetClusterBadInput(t *testing.T) { @@ -52,7 +51,7 @@ func TestUnsetClusterFields(t *testing.T) { KubernetesVersion: "1.8.2", Kubelet: &kops.KubeletConfigSpec{ AuthorizationMode: "Webhook", - AuthenticationTokenWebhook: fi.PtrTo(true), + AuthenticationTokenWebhook: new(true), }, }, }, @@ -97,7 +96,7 @@ func TestUnsetClusterFields(t *testing.T) { Input: kops.Cluster{ Spec: kops.ClusterSpec{ Kubelet: &kops.KubeletConfigSpec{ - AuthenticationTokenWebhook: fi.PtrTo(false), + AuthenticationTokenWebhook: new(false), }, }, }, @@ -293,7 +292,7 @@ func TestUnsetClusterFields(t *testing.T) { Spec: kops.ClusterSpec{ Networking: kops.NetworkingSpec{ Cilium: &kops.CiliumNetworkingSpec{ - Masquerade: fi.PtrTo(false), + Masquerade: new(false), }, }, }, @@ -313,7 +312,7 @@ func TestUnsetClusterFields(t *testing.T) { Input: kops.Cluster{ Spec: kops.ClusterSpec{ KubeProxy: &kops.KubeProxyConfig{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, }, }, @@ -379,13 +378,13 @@ func TestUnsetCiliumFields(t *testing.T) { Input: kops.Cluster{ Spec: kops.ClusterSpec{ KubeProxy: &kops.KubeProxyConfig{ - Enabled: fi.PtrTo(false), + Enabled: new(false), }, Networking: kops.NetworkingSpec{ Cilium: &kops.CiliumNetworkingSpec{ IPAM: "eni", EnableNodePort: true, - Masquerade: fi.PtrTo(false), + Masquerade: new(false), }, }, }, diff --git a/pkg/commands/unset_instancegroups_test.go b/pkg/commands/unset_instancegroups_test.go index 7606344a7bfec..2894f70b26d28 100644 --- a/pkg/commands/unset_instancegroups_test.go +++ b/pkg/commands/unset_instancegroups_test.go @@ -21,7 +21,6 @@ import ( "testing" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" ) func TestUnsetInstanceGroupsBadInput(t *testing.T) { @@ -74,8 +73,8 @@ func TestUnsetInstanceGroupsFields(t *testing.T) { }, Input: kops.InstanceGroup{ Spec: kops.InstanceGroupSpec{ - MinSize: fi.PtrTo(int32(1)), - MaxSize: fi.PtrTo(int32(3)), + MinSize: new(int32(1)), + MaxSize: new(int32(3)), }, }, Output: kops.InstanceGroup{ diff --git a/pkg/controllers/clusterapi/utils.go b/pkg/controllers/clusterapi/utils.go index 56eef603e0d40..f040ef2746280 100644 --- a/pkg/controllers/clusterapi/utils.go +++ b/pkg/controllers/clusterapi/utils.go @@ -50,15 +50,11 @@ func setOwnerRef(u *unstructured.Unstructured, owner client.Object) { Kind: kind, Name: owner.GetName(), UID: owner.GetUID(), - Controller: PtrTo(true), + Controller: new(true), }, }) } -func PtrTo[T any](t T) *T { - return &t -} - func getCAPIClusterFromCAPIObject(ctx context.Context, kube client.Client, obj client.Object) (*unstructured.Unstructured, error) { id := types.NamespacedName{ Namespace: obj.GetNamespace(), diff --git a/pkg/flagbuilder/buildflags_test.go b/pkg/flagbuilder/buildflags_test.go index af5f208d4f866..7be756f4eb99a 100644 --- a/pkg/flagbuilder/buildflags_test.go +++ b/pkg/flagbuilder/buildflags_test.go @@ -25,7 +25,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" ) func resourceValue(s string) *resource.Quantity { @@ -46,7 +45,7 @@ func TestBuildKCMFlags(t *testing.T) { }, { Config: &kops.KubeControllerManagerConfig{ - TerminatedPodGCThreshold: fi.PtrTo(int32(1500)), + TerminatedPodGCThreshold: new(int32(1500)), }, Expected: "--terminated-pod-gc-threshold=1500", }, @@ -58,7 +57,7 @@ func TestBuildKCMFlags(t *testing.T) { }, { Config: &kops.KubeControllerManagerConfig{ - KubeAPIBurst: fi.PtrTo(int32(80)), + KubeAPIBurst: new(int32(80)), }, Expected: "--kube-api-burst=80", }, @@ -95,13 +94,13 @@ func TestKubeletConfigSpec(t *testing.T) { }, { Config: &kops.KubeletConfigSpec{ - LogLevel: fi.PtrTo(int32(0)), + LogLevel: new(int32(0)), }, Expected: "", }, { Config: &kops.KubeletConfigSpec{ - LogLevel: fi.PtrTo(int32(2)), + LogLevel: new(int32(2)), }, Expected: "--v=2", }, @@ -110,8 +109,8 @@ func TestKubeletConfigSpec(t *testing.T) { { Config: &kops.KubeletConfigSpec{ EvictionPressureTransitionPeriod: &metav1.Duration{Duration: 5 * time.Second}, - EvictionHard: fi.PtrTo("memory.available<100Mi"), - ResolverConfig: fi.PtrTo("test"), + EvictionHard: new("memory.available<100Mi"), + ResolverConfig: new("test"), }, Expected: "", }, @@ -152,13 +151,13 @@ func TestBuildAPIServerFlags(t *testing.T) { }, { Config: &kops.KubeAPIServerConfig{ - AuditWebhookBatchThrottleEnable: fi.PtrTo(true), + AuditWebhookBatchThrottleEnable: new(true), }, Expected: "--audit-webhook-batch-throttle-enable=true --secure-port=0", }, { Config: &kops.KubeAPIServerConfig{ - AuditWebhookBatchThrottleEnable: fi.PtrTo(false), + AuditWebhookBatchThrottleEnable: new(false), }, Expected: "--audit-webhook-batch-throttle-enable=false --secure-port=0", }, @@ -170,13 +169,13 @@ func TestBuildAPIServerFlags(t *testing.T) { }, { Config: &kops.KubeAPIServerConfig{ - AuditWebhookBatchMaxSize: fi.PtrTo(int32(1000)), + AuditWebhookBatchMaxSize: new(int32(1000)), }, Expected: "--audit-webhook-batch-max-size=1000 --secure-port=0", }, { Config: &kops.KubeAPIServerConfig{ - AuthorizationWebhookConfigFile: fi.PtrTo("/authorization.yaml"), + AuthorizationWebhookConfigFile: new("/authorization.yaml"), }, Expected: "--authorization-webhook-config-file=/authorization.yaml --secure-port=0", }, diff --git a/pkg/instancegroups/delete_test.go b/pkg/instancegroups/delete_test.go index 30404e9831fa8..def13232858c2 100644 --- a/pkg/instancegroups/delete_test.go +++ b/pkg/instancegroups/delete_test.go @@ -43,7 +43,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kops/cmd/kops/util" "k8s.io/kops/pkg/testutils" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/gce" ) @@ -101,7 +100,7 @@ func TestDeleteInstanceGroup_GCEWaitOnInstanceDeletion(t *testing.T) { Items: []*compute.MetadataItems{ { Key: "cluster-name", - Value: fi.PtrTo(clusterName), + Value: new(clusterName), }, }, }, @@ -189,7 +188,7 @@ func TestDeleteInstanceGroup_GCEMissingInstance(t *testing.T) { Items: []*compute.MetadataItems{ { Key: "cluster-name", - Value: fi.PtrTo(clusterName), + Value: new(clusterName), }, }, }, diff --git a/pkg/instancegroups/rollingupdate_test.go b/pkg/instancegroups/rollingupdate_test.go index ded85ce36c903..f51c7ec0ddfdf 100644 --- a/pkg/instancegroups/rollingupdate_test.go +++ b/pkg/instancegroups/rollingupdate_test.go @@ -40,7 +40,6 @@ import ( kopsapi "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/cloudinstances" "k8s.io/kops/pkg/validation" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/awsup" "k8s.io/kops/util/pkg/awsinterfaces" ) @@ -962,7 +961,7 @@ func TestRollingUpdateDisabled(t *testing.T) { c.CloudOnly = true c.Cluster.Spec.RollingUpdate = &kopsapi.RollingUpdate{ - DrainAndTerminate: fi.PtrTo(false), + DrainAndTerminate: new(false), } groups := getGroupsAllNeedUpdate(c.K8sClient, cloud) @@ -1006,7 +1005,7 @@ func TestRollingUpdateDisabledSurge(t *testing.T) { one := intstr.FromInt(1) c.Cluster.Spec.RollingUpdate = &kopsapi.RollingUpdate{ - DrainAndTerminate: fi.PtrTo(false), + DrainAndTerminate: new(false), MaxSurge: &one, } diff --git a/pkg/instancegroups/settings.go b/pkg/instancegroups/settings.go index 10de187570f6f..0c52a7ea66777 100644 --- a/pkg/instancegroups/settings.go +++ b/pkg/instancegroups/settings.go @@ -21,7 +21,6 @@ import ( "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/featureflag" - "k8s.io/kops/upup/pkg/fi" ) func resolveSettings(cluster *kops.Cluster, group *kops.InstanceGroup, numInstances int) kops.RollingUpdate { @@ -43,7 +42,7 @@ func resolveSettings(cluster *kops.Cluster, group *kops.InstanceGroup, numInstan } if rollingUpdate.DrainAndTerminate == nil { - rollingUpdate.DrainAndTerminate = fi.PtrTo(true) + rollingUpdate.DrainAndTerminate = new(true) } if rollingUpdate.MaxSurge == nil { diff --git a/pkg/model/awsmodel/api_loadbalancer.go b/pkg/model/awsmodel/api_loadbalancer.go index e88ff2d27b018..1935597509f31 100644 --- a/pkg/model/awsmodel/api_loadbalancer.go +++ b/pkg/model/awsmodel/api_loadbalancer.go @@ -137,7 +137,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { if lbSpec.SSLCertificate == "" { listener443 := &awstasks.NetworkLoadBalancerListener{ - Name: fi.PtrTo(b.NLBListenerName("api", 443)), + Name: new(b.NLBListenerName("api", 443)), Lifecycle: b.Lifecycle, NetworkLoadBalancer: b.LinkToNLB("api"), Port: 443, @@ -148,7 +148,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { // When using a custom certificate, we create a secondary listener on 8443, which does _not_ use the custom certificate. // This is because client certificates cannot be used in conjunction with custom certificates on NLBs. listener8443 := &awstasks.NetworkLoadBalancerListener{ - Name: fi.PtrTo(b.NLBListenerName("api", 8443)), + Name: new(b.NLBListenerName("api", 8443)), Lifecycle: b.Lifecycle, NetworkLoadBalancer: b.LinkToNLB("api"), Port: 8443, @@ -159,7 +159,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { // The primary listener _does_ use the custom certificate. listeners["443"].SSLCertificateID = lbSpec.SSLCertificate listener443 := &awstasks.NetworkLoadBalancerListener{ - Name: fi.PtrTo(b.NLBListenerName("api", 443)), + Name: new(b.NLBListenerName("api", 443)), Lifecycle: b.Lifecycle, NetworkLoadBalancer: b.LinkToNLB("api"), Port: 443, @@ -177,7 +177,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { if b.Cluster.UsesLoadBalancerForKopsController() { { nlbListener := &awstasks.NetworkLoadBalancerListener{ - Name: fi.PtrTo(b.NLBListenerName("api", wellknownports.KopsControllerPort)), + Name: new(b.NLBListenerName("api", wellknownports.KopsControllerPort)), Lifecycle: b.Lifecycle, NetworkLoadBalancer: b.LinkToNLB("api"), Port: wellknownports.KopsControllerPort, @@ -188,7 +188,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { if b.Cluster.Spec.Networking.Cilium != nil && b.Cluster.Spec.Networking.Cilium.EtcdManaged { nlbListener := &awstasks.NetworkLoadBalancerListener{ - Name: fi.PtrTo(b.NLBListenerName("etcd-cilium", wellknownports.EtcdCiliumClientPort)), + Name: new(b.NLBListenerName("etcd-cilium", wellknownports.EtcdCiliumClientPort)), Lifecycle: b.Lifecycle, NetworkLoadBalancer: b.LinkToNLB("api"), Port: wellknownports.EtcdCiliumClientPort, @@ -210,11 +210,11 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { tags["Name"] = "api." + b.ClusterName() nlb = &awstasks.NetworkLoadBalancer{ - Name: fi.PtrTo(b.NLBName("api")), + Name: new(b.NLBName("api")), Lifecycle: b.Lifecycle, - LoadBalancerBaseName: fi.PtrTo(b.LBName32("api")), - CLBName: fi.PtrTo("api." + b.ClusterName()), + LoadBalancerBaseName: new(b.LBName32("api")), + CLBName: new("api." + b.ClusterName()), SecurityGroups: []*awstasks.SecurityGroup{ b.LinkToELBSecurityGroup("api"), }, @@ -233,10 +233,10 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { } clb = &awstasks.ClassicLoadBalancer{ - Name: fi.PtrTo("api." + b.ClusterName()), + Name: new("api." + b.ClusterName()), Lifecycle: b.Lifecycle, - LoadBalancerName: fi.PtrTo(b.LBName32("api")), + LoadBalancerName: new(b.LBName32("api")), SecurityGroups: []*awstasks.SecurityGroup{ b.LinkToELBSecurityGroup("api"), }, @@ -245,20 +245,20 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Configure fast-recovery health-checks HealthCheck: &awstasks.ClassicLoadBalancerHealthCheck{ - Target: fi.PtrTo("SSL:443"), - Timeout: fi.PtrTo(int32(5)), - Interval: fi.PtrTo(int32(10)), - HealthyThreshold: fi.PtrTo(int32(2)), - UnhealthyThreshold: fi.PtrTo(int32(2)), + Target: new("SSL:443"), + Timeout: new(int32(5)), + Interval: new(int32(10)), + HealthyThreshold: new(int32(2)), + UnhealthyThreshold: new(int32(2)), }, ConnectionSettings: &awstasks.ClassicLoadBalancerConnectionSettings{ - IdleTimeout: fi.PtrTo(int32(idleTimeout.Seconds())), + IdleTimeout: new(int32(idleTimeout.Seconds())), }, ConnectionDraining: &awstasks.ClassicLoadBalancerConnectionDraining{ - Enabled: fi.PtrTo(true), - Timeout: fi.PtrTo(int32(300)), + Enabled: new(true), + Timeout: new(int32(300)), }, Tags: tags, @@ -266,9 +266,9 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { } if b.Cluster.UsesLoadBalancerForKopsController() { - lbSpec.CrossZoneLoadBalancing = fi.PtrTo(true) + lbSpec.CrossZoneLoadBalancing = new(true) } else if lbSpec.CrossZoneLoadBalancing == nil { - lbSpec.CrossZoneLoadBalancing = fi.PtrTo(false) + lbSpec.CrossZoneLoadBalancing = new(false) } clb.CrossZoneLoadBalancing = &awstasks.ClassicLoadBalancerCrossZoneLoadBalancing{ @@ -279,7 +279,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { switch lbSpec.Type { case kops.LoadBalancerTypeInternal: - clb.Scheme = fi.PtrTo("internal") + clb.Scheme = new("internal") nlb.Scheme = elbv2types.LoadBalancerSchemeEnumInternal case kops.LoadBalancerTypePublic: clb.Scheme = nil @@ -290,22 +290,22 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { if lbSpec.AccessLog != nil { clb.AccessLog = &awstasks.ClassicLoadBalancerAccessLog{ - EmitInterval: fi.PtrTo(int32(lbSpec.AccessLog.Interval)), - Enabled: fi.PtrTo(true), + EmitInterval: new(int32(lbSpec.AccessLog.Interval)), + Enabled: new(true), S3BucketName: lbSpec.AccessLog.Bucket, S3BucketPrefix: lbSpec.AccessLog.BucketPrefix, } nlb.AccessLog = &awstasks.NetworkLoadBalancerAccessLog{ - Enabled: fi.PtrTo(true), + Enabled: new(true), S3BucketName: lbSpec.AccessLog.Bucket, S3BucketPrefix: lbSpec.AccessLog.BucketPrefix, } } else { clb.AccessLog = &awstasks.ClassicLoadBalancerAccessLog{ - Enabled: fi.PtrTo(false), + Enabled: new(false), } nlb.AccessLog = &awstasks.NetworkLoadBalancerAccessLog{ - Enabled: fi.PtrTo(false), + Enabled: new(false), } } @@ -325,18 +325,18 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { groupTags["Name"] = groupName tg := &awstasks.TargetGroup{ - Name: fi.PtrTo(groupName), + Name: new(groupName), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), Tags: groupTags, Protocol: elbv2types.ProtocolEnumTcp, - Port: fi.PtrTo(int32(443)), + Port: new(int32(443)), Attributes: groupAttrs, - Interval: fi.PtrTo(int32(10)), - HealthyThreshold: fi.PtrTo(int32(2)), - UnhealthyThreshold: fi.PtrTo(int32(2)), + Interval: new(int32(10)), + HealthyThreshold: new(int32(2)), + UnhealthyThreshold: new(int32(2)), HealthCheckProtocol: elbv2types.ProtocolEnumTcp, - Shared: fi.PtrTo(false), + Shared: new(false), } tg.CreateNewRevisionsWith(nlb) c.AddTask(tg) @@ -351,19 +351,19 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { groupTags["Name"] = groupName tg := &awstasks.TargetGroup{ - Name: fi.PtrTo(groupName), + Name: new(groupName), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), Tags: groupTags, Protocol: elbv2types.ProtocolEnumTcp, - Port: fi.PtrTo(int32(wellknownports.KopsControllerPort)), + Port: new(int32(wellknownports.KopsControllerPort)), Attributes: groupAttrs, - Interval: fi.PtrTo(int32(10)), - HealthyThreshold: fi.PtrTo(int32(2)), - UnhealthyThreshold: fi.PtrTo(int32(2)), + Interval: new(int32(10)), + HealthyThreshold: new(int32(2)), + UnhealthyThreshold: new(int32(2)), HealthCheckProtocol: elbv2types.ProtocolEnumHttps, - HealthCheckPath: fi.PtrTo("/healthz"), - Shared: fi.PtrTo(false), + HealthCheckPath: new("/healthz"), + Shared: new(false), } tg.CreateNewRevisionsWith(nlb) @@ -378,18 +378,18 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { groupTags["Name"] = groupName tg := &awstasks.TargetGroup{ - Name: fi.PtrTo(groupName), + Name: new(groupName), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), Tags: groupTags, Protocol: elbv2types.ProtocolEnumTcp, - Port: fi.PtrTo(int32(wellknownports.EtcdCiliumClientPort)), + Port: new(int32(wellknownports.EtcdCiliumClientPort)), Attributes: groupAttrs, - Interval: fi.PtrTo(int32(10)), - HealthyThreshold: fi.PtrTo(int32(2)), - UnhealthyThreshold: fi.PtrTo(int32(2)), + Interval: new(int32(10)), + HealthyThreshold: new(int32(2)), + UnhealthyThreshold: new(int32(2)), HealthCheckProtocol: elbv2types.ProtocolEnumTcp, - Shared: fi.PtrTo(false), + Shared: new(false), } tg.CreateNewRevisionsWith(nlb) @@ -404,18 +404,18 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Override the returned name to be the expected NLB TG name tlsGroupTags["Name"] = tlsGroupName secondaryTG := &awstasks.TargetGroup{ - Name: fi.PtrTo(tlsGroupName), + Name: new(tlsGroupName), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), Tags: tlsGroupTags, Protocol: elbv2types.ProtocolEnumTls, - Port: fi.PtrTo(int32(443)), + Port: new(int32(443)), Attributes: groupAttrs, - Interval: fi.PtrTo(int32(10)), - HealthyThreshold: fi.PtrTo(int32(2)), - UnhealthyThreshold: fi.PtrTo(int32(2)), + Interval: new(int32(10)), + HealthyThreshold: new(int32(2)), + UnhealthyThreshold: new(int32(2)), HealthCheckProtocol: elbv2types.ProtocolEnumTcp, - Shared: fi.PtrTo(false), + Shared: new(false), } secondaryTG.CreateNewRevisionsWith(nlb) c.AddTask(secondaryTG) @@ -431,17 +431,17 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { var lbSG *awstasks.SecurityGroup { lbSG = &awstasks.SecurityGroup{ - Name: fi.PtrTo(b.ELBSecurityGroupName("api")), + Name: new(b.ELBSecurityGroupName("api")), Lifecycle: b.SecurityLifecycle, - Description: fi.PtrTo("Security group for api ELB"), + Description: new("Security group for api ELB"), RemoveExtraRules: []string{"port=443"}, VPC: b.LinkToVPC(), } lbSG.Tags = b.CloudTags(*lbSG.Name, false) if lbSpec.SecurityGroupOverride != nil { - lbSG.ID = fi.PtrTo(*lbSpec.SecurityGroupOverride) - lbSG.Shared = fi.PtrTo(true) + lbSG.ID = new(*lbSpec.SecurityGroupOverride) + lbSG.Shared = new(true) } c.AddTask(lbSG) @@ -451,20 +451,20 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { { { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("ipv4-api-elb-egress"), + Name: new("ipv4-api-elb-egress"), Lifecycle: b.SecurityLifecycle, - CIDR: fi.PtrTo("0.0.0.0/0"), - Egress: fi.PtrTo(true), + CIDR: new("0.0.0.0/0"), + Egress: new(true), SecurityGroup: lbSG, } AddDirectionalGroupRule(c, t) } { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("ipv6-api-elb-egress"), + Name: new("ipv6-api-elb-egress"), Lifecycle: b.SecurityLifecycle, - IPv6CIDR: fi.PtrTo("::/0"), - Egress: fi.PtrTo(true), + IPv6CIDR: new("::/0"), + Egress: new(true), SecurityGroup: lbSG, } AddDirectionalGroupRule(c, t) @@ -476,12 +476,12 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { for _, cidr := range b.Cluster.Spec.API.Access { { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("https-api-elb-" + cidr), + Name: new("https-api-elb-" + cidr), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(443)), - Protocol: fi.PtrTo("tcp"), + FromPort: new(int32(443)), + Protocol: new("tcp"), SecurityGroup: lbSG, - ToPort: fi.PtrTo(int32(443)), + ToPort: new(int32(443)), } t.SetCidrOrPrefix(cidr) AddDirectionalGroupRule(c, t) @@ -490,11 +490,11 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { // If we have opened a secondary listener on 8443, allow it also if b.APILoadBalancerClass() == kops.LoadBalancerClassNetwork && b.Cluster.Spec.API.LoadBalancer != nil && b.Cluster.Spec.API.LoadBalancer.SSLCertificate != "" { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("https-api-elb-8443-" + cidr), + Name: new("https-api-elb-8443-" + cidr), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(8443)), - ToPort: fi.PtrTo(int32(8443)), - Protocol: fi.PtrTo("tcp"), + FromPort: new(int32(8443)), + ToPort: new(int32(8443)), + Protocol: new("tcp"), SecurityGroup: lbSG, } lbSG.RemoveExtraRules = append(lbSG.RemoveExtraRules, "port=8443") @@ -506,12 +506,12 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Allow ICMP traffic required for PMTU discovery { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("icmpv6-pmtu-api-elb-" + cidr), + Name: new("icmpv6-pmtu-api-elb-" + cidr), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(-1)), - Protocol: fi.PtrTo("icmpv6"), + FromPort: new(int32(-1)), + Protocol: new("icmpv6"), SecurityGroup: lbSG, - ToPort: fi.PtrTo(int32(-1)), + ToPort: new(int32(-1)), } t.SetCidrOrPrefix(cidr) if t.CIDR == nil { @@ -520,12 +520,12 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { } { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("icmp-pmtu-api-elb-" + cidr), + Name: new("icmp-pmtu-api-elb-" + cidr), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(3)), - Protocol: fi.PtrTo("icmp"), + FromPort: new(int32(3)), + Protocol: new("icmp"), SecurityGroup: lbSG, - ToPort: fi.PtrTo(int32(4)), + ToPort: new(int32(4)), } t.SetCidrOrPrefix(cidr) if t.IPv6CIDR == nil { @@ -544,7 +544,7 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { for _, nodeGroup := range nodeGroups { suffix := nodeGroup.Suffix t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("node%s-to-elb", suffix)), + Name: new(fmt.Sprintf("node%s-to-elb", suffix)), Lifecycle: b.SecurityLifecycle, SecurityGroup: lbSG, SourceGroup: nodeGroup.Task, @@ -563,13 +563,13 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { suffix := masterGroup.Suffix // Allow access to control plane on secondary port through NLB t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("tcp-api-cp%s", suffix)), + Name: new(fmt.Sprintf("tcp-api-cp%s", suffix)), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(8443)), - Protocol: fi.PtrTo("tcp"), + FromPort: new(int32(8443)), + Protocol: new("tcp"), SecurityGroup: masterGroup.Task, SourceGroup: lbSG, - ToPort: fi.PtrTo(int32(8443)), + ToPort: new(int32(8443)), } c.AddTask(t) } @@ -579,10 +579,10 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { { for _, id := range b.Cluster.Spec.API.LoadBalancer.AdditionalSecurityGroups { t := &awstasks.SecurityGroup{ - Name: fi.PtrTo(id), + Name: new(id), Lifecycle: b.SecurityLifecycle, - ID: fi.PtrTo(id), - Shared: fi.PtrTo(true), + ID: new(id), + Shared: new(true), } c.EnsureTask(t) clb.SecurityGroups = append(clb.SecurityGroups, t) @@ -595,31 +595,31 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { for _, masterGroup := range masterGroups { suffix := masterGroup.Suffix c.AddTask(&awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("https-elb-to-master%s", suffix)), + Name: new(fmt.Sprintf("https-elb-to-master%s", suffix)), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(443)), - Protocol: fi.PtrTo("tcp"), + FromPort: new(int32(443)), + Protocol: new("tcp"), SecurityGroup: masterGroup.Task, SourceGroup: lbSG, - ToPort: fi.PtrTo(int32(443)), + ToPort: new(int32(443)), }) c.AddTask(&awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("icmp-pmtu-elb-to-cp%s", suffix)), + Name: new(fmt.Sprintf("icmp-pmtu-elb-to-cp%s", suffix)), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(3)), - Protocol: fi.PtrTo("icmp"), + FromPort: new(int32(3)), + Protocol: new("icmp"), SecurityGroup: masterGroup.Task, SourceGroup: lbSG, - ToPort: fi.PtrTo(int32(4)), + ToPort: new(int32(4)), }) c.AddTask(&awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("icmp-pmtu-cp%s-to-elb", suffix)), + Name: new(fmt.Sprintf("icmp-pmtu-cp%s-to-elb", suffix)), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(3)), - Protocol: fi.PtrTo("icmp"), + FromPort: new(int32(3)), + Protocol: new("icmp"), SecurityGroup: lbSG, SourceGroup: masterGroup.Task, - ToPort: fi.PtrTo(int32(4)), + ToPort: new(int32(4)), }) if b.Cluster.UsesLoadBalancerForKopsController() { { @@ -627,12 +627,12 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { clb.WellKnownServices = append(clb.WellKnownServices, wellknownservices.KopsController) c.AddTask(&awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("kops-controller-elb-to-cp%s", suffix)), + Name: new(fmt.Sprintf("kops-controller-elb-to-cp%s", suffix)), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(wellknownports.KopsControllerPort)), - Protocol: fi.PtrTo("tcp"), + FromPort: new(int32(wellknownports.KopsControllerPort)), + Protocol: new("tcp"), SecurityGroup: masterGroup.Task, - ToPort: fi.PtrTo(int32(wellknownports.KopsControllerPort)), + ToPort: new(int32(wellknownports.KopsControllerPort)), SourceGroup: lbSG, }) } @@ -641,12 +641,12 @@ func (b *APILoadBalancerBuilder) Build(c *fi.CloudupModelBuilderContext) error { nlb.WellKnownServices = append(nlb.WellKnownServices, wellknownservices.EtcdCilium) c.AddTask(&awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("etcd-cilium-elb-to-cp%s", suffix)), + Name: new(fmt.Sprintf("etcd-cilium-elb-to-cp%s", suffix)), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(wellknownports.EtcdCiliumClientPort)), - Protocol: fi.PtrTo("tcp"), + FromPort: new(int32(wellknownports.EtcdCiliumClientPort)), + Protocol: new("tcp"), SecurityGroup: masterGroup.Task, - ToPort: fi.PtrTo(int32(wellknownports.EtcdCiliumClientPort)), + ToPort: new(int32(wellknownports.EtcdCiliumClientPort)), SourceGroup: lbSG, }) } diff --git a/pkg/model/awsmodel/autoscalinggroup.go b/pkg/model/awsmodel/autoscalinggroup.go index 8bce6de989460..2088bd4f008a1 100644 --- a/pkg/model/awsmodel/autoscalinggroup.go +++ b/pkg/model/awsmodel/autoscalinggroup.go @@ -98,7 +98,7 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) e warmPool := b.Cluster.Spec.CloudProvider.AWS.WarmPool.ResolveDefaults(ig) - enabled := fi.PtrTo(warmPool.IsEnabled()) + enabled := new(warmPool.IsEnabled()) warmPoolTask := &awstasks.WarmPool{ Name: &name, Lifecycle: b.Lifecycle, @@ -108,7 +108,7 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) e if warmPool.IsEnabled() { warmPoolTask.MinSize = int32(warmPool.MinSize) if warmPool.MaxSize != nil { - warmPoolTask.MaxSize = fi.PtrTo(int32(aws.ToInt64(warmPool.MaxSize))) + warmPoolTask.MaxSize = new(int32(aws.ToInt64(warmPool.MaxSize))) } asg.Metrics = append(asg.Metrics, "WarmPoolMinSize", @@ -205,37 +205,37 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.CloudupMode } lt := &awstasks.LaunchTemplate{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, - CPUCredits: fi.PtrTo(fi.ValueOf(ig.Spec.CPUCredits)), - HTTPPutResponseHopLimit: fi.PtrTo(int32(1)), - HTTPTokens: fi.PtrTo(ec2types.LaunchTemplateHttpTokensStateRequired), - HTTPProtocolIPv6: fi.PtrTo(ec2types.LaunchTemplateInstanceMetadataProtocolIpv6Disabled), + CPUCredits: new(fi.ValueOf(ig.Spec.CPUCredits)), + HTTPPutResponseHopLimit: new(int32(1)), + HTTPTokens: new(ec2types.LaunchTemplateHttpTokensStateRequired), + HTTPProtocolIPv6: new(ec2types.LaunchTemplateInstanceMetadataProtocolIpv6Disabled), IAMInstanceProfile: link, - ImageID: fi.PtrTo(ig.Spec.Image), - InstanceMonitoring: fi.PtrTo(false), - IPv6AddressCount: fi.PtrTo(int32(0)), - RootVolumeIops: fi.PtrTo(int32(0)), - RootVolumeSize: fi.PtrTo(int32(rootVolumeSize)), + ImageID: new(ig.Spec.Image), + InstanceMonitoring: new(false), + IPv6AddressCount: new(int32(0)), + RootVolumeIops: new(int32(0)), + RootVolumeSize: new(int32(rootVolumeSize)), RootVolumeType: rootVolumeType, - RootVolumeEncryption: fi.PtrTo(rootVolumeEncryption), - RootVolumeKmsKey: fi.PtrTo(rootVolumeKmsKey), + RootVolumeEncryption: new(rootVolumeEncryption), + RootVolumeKmsKey: new(rootVolumeKmsKey), SecurityGroups: securityGroups, Tags: tags, UserData: userData, } if ig.Spec.InstanceInterruptionBehavior != nil { - lt.InstanceInterruptionBehavior = fi.PtrTo(ec2types.InstanceInterruptionBehavior(fi.ValueOf(ig.Spec.InstanceInterruptionBehavior))) + lt.InstanceInterruptionBehavior = new(ec2types.InstanceInterruptionBehavior(fi.ValueOf(ig.Spec.InstanceInterruptionBehavior))) } if ig.Spec.RootVolume != nil { if ig.Spec.RootVolume.IOPS != nil { - lt.RootVolumeIops = fi.PtrTo(int32(fi.ValueOf(ig.Spec.RootVolume.IOPS))) + lt.RootVolumeIops = new(int32(fi.ValueOf(ig.Spec.RootVolume.IOPS))) } lt.RootVolumeOptimization = ig.Spec.RootVolume.Optimization } if ig.Spec.Manager == kops.InstanceManagerCloudGroup { - lt.InstanceType = fi.PtrTo(ec2types.InstanceType(strings.Split(ig.Spec.MachineType, ",")[0])) + lt.InstanceType = new(ec2types.InstanceType(strings.Split(ig.Spec.MachineType, ",")[0])) } { @@ -248,12 +248,12 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.CloudupMode // @step: check if we can add a public ip to this subnet switch subnets[0].Type { case kops.SubnetTypePublic, kops.SubnetTypeUtility: - lt.AssociatePublicIP = fi.PtrTo(true) + lt.AssociatePublicIP = new(true) if ig.Spec.AssociatePublicIP != nil { lt.AssociatePublicIP = ig.Spec.AssociatePublicIP } case kops.SubnetTypeDualStack, kops.SubnetTypePrivate: - lt.AssociatePublicIP = fi.PtrTo(false) + lt.AssociatePublicIP = new(false) } // @step: add an IPv6 address @@ -263,8 +263,8 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.CloudupMode continue } if clusterSubnet.IPv6CIDR != "" { - lt.IPv6AddressCount = fi.PtrTo(int32(1)) - lt.HTTPProtocolIPv6 = fi.PtrTo(ec2types.LaunchTemplateInstanceMetadataProtocolIpv6Enabled) + lt.IPv6AddressCount = new(int32(1)) + lt.HTTPProtocolIPv6 = new(ec2types.LaunchTemplateInstanceMetadataProtocolIpv6Enabled) } } } @@ -279,14 +279,14 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.CloudupMode switch ec2types.VolumeType(x.Type) { case ec2types.VolumeTypeIo1, ec2types.VolumeTypeIo2: if x.IOPS == nil { - x.IOPS = fi.PtrTo(int64(DefaultVolumeIonIops)) + x.IOPS = new(int64(DefaultVolumeIonIops)) } case ec2types.VolumeTypeGp3: if x.IOPS == nil { - x.IOPS = fi.PtrTo(int64(DefaultVolumeGp3Iops)) + x.IOPS = new(int64(DefaultVolumeGp3Iops)) } if x.Throughput == nil { - x.Throughput = fi.PtrTo(int64(DefaultVolumeGp3Throughput)) + x.Throughput = new(int64(DefaultVolumeGp3Throughput)) } default: x.IOPS = nil @@ -300,18 +300,18 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.CloudupMode encryption = fi.ValueOf(x.Encrypted) } bdm := &awstasks.BlockDeviceMapping{ - DeviceName: fi.PtrTo(x.Device), - EbsDeleteOnTermination: fi.PtrTo(deleteOnTermination), - EbsEncrypted: fi.PtrTo(encryption), + DeviceName: new(x.Device), + EbsDeleteOnTermination: new(deleteOnTermination), + EbsEncrypted: new(encryption), EbsKmsKey: x.Key, - EbsVolumeSize: fi.PtrTo(int32(x.Size)), + EbsVolumeSize: new(int32(x.Size)), EbsVolumeType: ec2types.VolumeType(x.Type), } if x.IOPS != nil { - bdm.EbsVolumeIops = fi.PtrTo(int32(fi.ValueOf(x.IOPS))) + bdm.EbsVolumeIops = new(int32(fi.ValueOf(x.IOPS))) } if x.Throughput != nil { - bdm.EbsVolumeThroughput = fi.PtrTo(int32(fi.ValueOf(x.Throughput))) + bdm.EbsVolumeThroughput = new(int32(fi.ValueOf(x.Throughput))) } lt.BlockDeviceMappings = append(lt.BlockDeviceMappings, bdm) } @@ -321,26 +321,26 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.CloudupMode } if ig.Spec.InstanceMetadata != nil && ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit != nil { - lt.HTTPPutResponseHopLimit = fi.PtrTo(int32(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit))) + lt.HTTPPutResponseHopLimit = new(int32(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit))) } if ig.Spec.InstanceMetadata != nil && ig.Spec.InstanceMetadata.HTTPTokens != nil { - lt.HTTPTokens = fi.PtrTo(ec2types.LaunchTemplateHttpTokensState(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPTokens))) + lt.HTTPTokens = new(ec2types.LaunchTemplateHttpTokensState(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPTokens))) } switch rootVolumeType { case ec2types.VolumeTypeIo1, ec2types.VolumeTypeIo2: if ig.Spec.RootVolume == nil || fi.ValueOf(ig.Spec.RootVolume.IOPS) < 100 { - lt.RootVolumeIops = fi.PtrTo(int32(DefaultVolumeIonIops)) + lt.RootVolumeIops = new(int32(DefaultVolumeIonIops)) } case ec2types.VolumeTypeGp3: if ig.Spec.RootVolume == nil || fi.ValueOf(ig.Spec.RootVolume.IOPS) < 3000 { - lt.RootVolumeIops = fi.PtrTo(int32(DefaultVolumeGp3Iops)) + lt.RootVolumeIops = new(int32(DefaultVolumeGp3Iops)) } if ig.Spec.RootVolume == nil || fi.ValueOf(ig.Spec.RootVolume.Throughput) < 125 { - lt.RootVolumeThroughput = fi.PtrTo(int32(DefaultVolumeGp3Throughput)) + lt.RootVolumeThroughput = new(int32(DefaultVolumeGp3Throughput)) } else { - lt.RootVolumeThroughput = fi.PtrTo(int32(fi.ValueOf(ig.Spec.RootVolume.Throughput))) + lt.RootVolumeThroughput = new(int32(fi.ValueOf(ig.Spec.RootVolume.Throughput))) } default: lt.RootVolumeIops = nil @@ -359,14 +359,14 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.CloudupMode if ig.Spec.MixedInstancesPolicy == nil && ig.Spec.MaxPrice != nil { lt.SpotPrice = ig.Spec.MaxPrice } else { - lt.SpotPrice = fi.PtrTo("") + lt.SpotPrice = new("") } if ig.Spec.SpotDurationInMinutes != nil { - lt.SpotDurationInMinutes = fi.PtrTo(int32(fi.ValueOf(ig.Spec.SpotDurationInMinutes))) + lt.SpotDurationInMinutes = new(int32(fi.ValueOf(ig.Spec.SpotDurationInMinutes))) } if ig.Spec.Tenancy != "" { - lt.Tenancy = fi.PtrTo(ec2types.Tenancy(ig.Spec.Tenancy)) + lt.Tenancy = new(ec2types.Tenancy(ig.Spec.Tenancy)) } return lt, nil @@ -381,7 +381,7 @@ func (b *AutoscalingGroupModelBuilder) buildSecurityGroups(c *fi.CloudupModelBui sgLink = &awstasks.SecurityGroup{ ID: ig.Spec.SecurityGroupOverride, Name: &sgName, - Shared: fi.PtrTo(true), + Shared: new(true), } } @@ -391,10 +391,10 @@ func (b *AutoscalingGroupModelBuilder) buildSecurityGroups(c *fi.CloudupModelBui b.APILoadBalancerClass() == kops.LoadBalancerClassNetwork { for _, id := range b.Cluster.Spec.API.LoadBalancer.AdditionalSecurityGroups { sgTask := &awstasks.SecurityGroup{ - ID: fi.PtrTo(id), + ID: new(id), Lifecycle: b.SecurityLifecycle, - Name: fi.PtrTo("nlb-" + id), - Shared: fi.PtrTo(true), + Name: new("nlb-" + id), + Shared: new(true), } c.EnsureTask(sgTask) securityGroups = append(securityGroups, sgTask) @@ -404,10 +404,10 @@ func (b *AutoscalingGroupModelBuilder) buildSecurityGroups(c *fi.CloudupModelBui // @step: add any additional security groups to the instancegroup for _, id := range ig.Spec.AdditionalSecurityGroups { sgTask := &awstasks.SecurityGroup{ - ID: fi.PtrTo(id), + ID: new(id), Lifecycle: b.SecurityLifecycle, - Name: fi.PtrTo(id), - Shared: fi.PtrTo(true), + Name: new(id), + Shared: new(true), } c.EnsureTask(sgTask) securityGroups = append(securityGroups, sgTask) @@ -419,10 +419,10 @@ func (b *AutoscalingGroupModelBuilder) buildSecurityGroups(c *fi.CloudupModelBui // buildAutoScalingGroupTask is responsible for building the autoscaling task into the model func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupModelBuilderContext, name string, ig *kops.InstanceGroup) (*awstasks.AutoscalingGroup, error) { t := &awstasks.AutoscalingGroup{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, - Granularity: fi.PtrTo("1Minute"), + Granularity: new("1Minute"), Metrics: []string{ "GroupDesiredCapacity", "GroupInServiceInstances", @@ -434,20 +434,20 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo "GroupTotalInstances", }, - InstanceProtection: fi.PtrTo(false), + InstanceProtection: new(false), } - minSize := fi.PtrTo(int32(1)) - maxSize := fi.PtrTo(int32(1)) + minSize := new(int32(1)) + maxSize := new(int32(1)) if ig.Spec.MinSize != nil { - minSize = fi.PtrTo(int32(*ig.Spec.MinSize)) + minSize = new(int32(*ig.Spec.MinSize)) } else if ig.Spec.Role.HasNode() { - minSize = fi.PtrTo(int32(2)) + minSize = new(int32(2)) } if ig.Spec.MaxSize != nil { - maxSize = fi.PtrTo(int32(*ig.Spec.MaxSize)) + maxSize = new(int32(*ig.Spec.MaxSize)) } else if ig.Spec.Role.HasNode() { - maxSize = fi.PtrTo(int32(2)) + maxSize = new(int32(2)) } t.MinSize = minSize @@ -518,7 +518,7 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo Name: extLB.LoadBalancerName, Lifecycle: b.Lifecycle, LoadBalancerName: extLB.LoadBalancerName, - Shared: fi.PtrTo(true), + Shared: new(true), } t.LoadBalancers = append(t.LoadBalancers, lb) c.EnsureTask(lb) @@ -530,10 +530,10 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo return nil, err } tg := &awstasks.TargetGroup{ - Name: fi.PtrTo(targetGroupName), + Name: new(targetGroupName), Lifecycle: b.Lifecycle, ARN: extLB.TargetGroupARN, - Shared: fi.PtrTo(true), + Shared: new(true), } t.TargetGroups = append(t.TargetGroups, tg) c.EnsureTask(tg) @@ -554,28 +554,28 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo if cpu != nil { if cpu.Max != nil { cpuMax, _ := spec.InstanceRequirements.CPU.Max.AsInt64() - ir.CPUMax = fi.PtrTo(int32(cpuMax)) + ir.CPUMax = new(int32(cpuMax)) } if cpu.Min != nil { cpuMin, _ := spec.InstanceRequirements.CPU.Min.AsInt64() - ir.CPUMin = fi.PtrTo(int32(cpuMin)) + ir.CPUMin = new(int32(cpuMin)) } } else { - ir.CPUMin = fi.PtrTo(int32(0)) + ir.CPUMin = new(int32(0)) } memory := spec.InstanceRequirements.Memory if memory != nil { if memory.Max != nil { memoryMax := spec.InstanceRequirements.Memory.Max.ScaledValue(resource.Mega) - ir.MemoryMax = fi.PtrTo(int32(memoryMax)) + ir.MemoryMax = new(int32(memoryMax)) } if memory.Min != nil { memoryMin := spec.InstanceRequirements.Memory.Min.ScaledValue(resource.Mega) - ir.MemoryMin = fi.PtrTo(int32(memoryMin)) + ir.MemoryMin = new(int32(memoryMin)) } } else { - ir.MemoryMin = fi.PtrTo(int32(0)) + ir.MemoryMin = new(int32(0)) } if len(spec.InstanceRequirements.ExcludedInstanceTypes) > 0 { ir.ExcludedInstanceTypes = spec.InstanceRequirements.ExcludedInstanceTypes @@ -597,7 +597,7 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo } // In order to unset maxprice, the value needs to be "" if ig.Spec.MaxPrice == nil { - t.MixedSpotMaxPrice = fi.PtrTo("") + t.MixedSpotMaxPrice = new("") } else { t.MixedSpotMaxPrice = ig.Spec.MaxPrice } @@ -605,9 +605,9 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo if ig.Spec.MaxInstanceLifetime != nil { lifetimeSec := int32(ig.Spec.MaxInstanceLifetime.Seconds()) - t.MaxInstanceLifetime = fi.PtrTo(lifetimeSec) + t.MaxInstanceLifetime = new(lifetimeSec) } else { - t.MaxInstanceLifetime = fi.PtrTo(int32(0)) + t.MaxInstanceLifetime = new(int32(0)) } return t, nil } diff --git a/pkg/model/awsmodel/autoscalinggroup_test.go b/pkg/model/awsmodel/autoscalinggroup_test.go index f96a4811b6042..e229439ec0ce4 100644 --- a/pkg/model/awsmodel/autoscalinggroup_test.go +++ b/pkg/model/awsmodel/autoscalinggroup_test.go @@ -54,7 +54,7 @@ func TestRootVolumeOptimizationFlag(t *testing.T) { if ig.Spec.RootVolume == nil { ig.Spec.RootVolume = &kops.InstanceRootVolumeSpec{} } - ig.Spec.RootVolume.Optimization = fi.PtrTo(true) + ig.Spec.RootVolume.Optimization = new(true) k := [][]byte{} k = append(k, []byte(sshPublicKeyEntry)) @@ -96,7 +96,7 @@ func TestRootVolumeOptimizationFlag(t *testing.T) { // We need the CA for the bootstrap script caTask := &fitasks.Keypair{ - Name: fi.PtrTo(fi.CertificateIDCA), + Name: new(fi.CertificateIDCA), Subject: "cn=kubernetes", Type: "ca", } @@ -105,7 +105,7 @@ func TestRootVolumeOptimizationFlag(t *testing.T) { "etcd-clients-ca", } { task := &fitasks.Keypair{ - Name: fi.PtrTo(keypair), + Name: new(keypair), Subject: "cn=" + keypair, Type: "ca", } @@ -201,7 +201,7 @@ func TestAPIServerAdditionalSecurityGroupsWithNLB(t *testing.T) { // We need the CA for the bootstrap script caTask := &fitasks.Keypair{ - Name: fi.PtrTo(fi.CertificateIDCA), + Name: new(fi.CertificateIDCA), Subject: "cn=kubernetes", Type: "ca", } @@ -218,7 +218,7 @@ func TestAPIServerAdditionalSecurityGroupsWithNLB(t *testing.T) { "service-account", } { task := &fitasks.Keypair{ - Name: fi.PtrTo(keypair), + Name: new(keypair), Subject: "cn=" + keypair, Type: "ca", } @@ -229,7 +229,7 @@ func TestAPIServerAdditionalSecurityGroupsWithNLB(t *testing.T) { "kube-proxy", } { task := &fitasks.Keypair{ - Name: fi.PtrTo(keypair), + Name: new(keypair), Subject: "cn=" + keypair, Signer: caTask, Type: "client", diff --git a/pkg/model/awsmodel/bastion.go b/pkg/model/awsmodel/bastion.go index 04d9d3845893b..33a0e555bed71 100644 --- a/pkg/model/awsmodel/bastion.go +++ b/pkg/model/awsmodel/bastion.go @@ -78,21 +78,21 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Allow traffic from bastion instances to egress freely { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("ipv4-bastion-egress" + src.Suffix), + Name: new("ipv4-bastion-egress" + src.Suffix), Lifecycle: b.SecurityLifecycle, SecurityGroup: src.Task, - Egress: fi.PtrTo(true), - CIDR: fi.PtrTo("0.0.0.0/0"), + Egress: new(true), + CIDR: new("0.0.0.0/0"), } AddDirectionalGroupRule(c, t) } { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("ipv6-bastion-egress" + src.Suffix), + Name: new("ipv6-bastion-egress" + src.Suffix), Lifecycle: b.SecurityLifecycle, SecurityGroup: src.Task, - Egress: fi.PtrTo(true), - IPv6CIDR: fi.PtrTo("::/0"), + Egress: new(true), + IPv6CIDR: new("::/0"), } AddDirectionalGroupRule(c, t) } @@ -126,13 +126,13 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { for _, src := range bastionGroups { for _, dest := range masterGroups { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("bastion-to-master-ssh" + JoinSuffixes(src, dest)), + Name: new("bastion-to-master-ssh" + JoinSuffixes(src, dest)), Lifecycle: b.SecurityLifecycle, SecurityGroup: dest.Task, SourceGroup: src.Task, - Protocol: fi.PtrTo("tcp"), - FromPort: fi.PtrTo(int32(22)), - ToPort: fi.PtrTo(int32(22)), + Protocol: new("tcp"), + FromPort: new(int32(22)), + ToPort: new(int32(22)), } AddDirectionalGroupRule(c, t) } @@ -142,13 +142,13 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { for _, src := range bastionGroups { for _, dest := range nodeGroups { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("bastion-to-node-ssh" + JoinSuffixes(src, dest)), + Name: new("bastion-to-node-ssh" + JoinSuffixes(src, dest)), Lifecycle: b.SecurityLifecycle, SecurityGroup: dest.Task, SourceGroup: src.Task, - Protocol: fi.PtrTo("tcp"), - FromPort: fi.PtrTo(int32(22)), - ToPort: fi.PtrTo(int32(22)), + Protocol: new("tcp"), + FromPort: new(int32(22)), + ToPort: new(int32(22)), } AddDirectionalGroupRule(c, t) } @@ -157,9 +157,9 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { var lbSG *awstasks.SecurityGroup { lbSG = &awstasks.SecurityGroup{ - Name: fi.PtrTo(b.ELBSecurityGroupName("bastion")), + Name: new(b.ELBSecurityGroupName("bastion")), Lifecycle: b.SecurityLifecycle, - Description: fi.PtrTo("Security group for bastion ELB"), + Description: new("Security group for bastion ELB"), RemoveExtraRules: []string{"port=22"}, VPC: b.LinkToVPC(), } @@ -172,20 +172,20 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { { { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("ipv4-bastion-elb-egress"), + Name: new("ipv4-bastion-elb-egress"), Lifecycle: b.SecurityLifecycle, - CIDR: fi.PtrTo("0.0.0.0/0"), - Egress: fi.PtrTo(true), + CIDR: new("0.0.0.0/0"), + Egress: new(true), SecurityGroup: lbSG, } AddDirectionalGroupRule(c, t) } { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("ipv6-bastion-elb-egress"), + Name: new("ipv6-bastion-elb-egress"), Lifecycle: b.SecurityLifecycle, - IPv6CIDR: fi.PtrTo("::/0"), - Egress: fi.PtrTo(true), + IPv6CIDR: new("::/0"), + Egress: new(true), SecurityGroup: lbSG, } AddDirectionalGroupRule(c, t) @@ -233,12 +233,12 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // TODO: Could we get away without an NLB here? Tricky to fix if dns-controller breaks though... { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("ssh-nlb-%s", cidr)), + Name: new(fmt.Sprintf("ssh-nlb-%s", cidr)), Lifecycle: b.SecurityLifecycle, SecurityGroup: lbSG, - Protocol: fi.PtrTo("tcp"), - FromPort: fi.PtrTo(int32(22)), - ToPort: fi.PtrTo(int32(22)), + Protocol: new("tcp"), + FromPort: new(int32(22)), + ToPort: new(int32(22)), } t.SetCidrOrPrefix(cidr) AddDirectionalGroupRule(c, t) @@ -247,12 +247,12 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Allow ICMP traffic required for PMTU discovery { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("icmpv6-pmtu-ssh-nlb-" + cidr), + Name: new("icmpv6-pmtu-ssh-nlb-" + cidr), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(-1)), - Protocol: fi.PtrTo("icmpv6"), + FromPort: new(int32(-1)), + Protocol: new("icmpv6"), SecurityGroup: lbSG, - ToPort: fi.PtrTo(int32(-1)), + ToPort: new(int32(-1)), } t.SetCidrOrPrefix(cidr) if t.CIDR == nil { @@ -261,12 +261,12 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { } { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("icmp-pmtu-ssh-nlb-" + cidr), + Name: new("icmp-pmtu-ssh-nlb-" + cidr), Lifecycle: b.SecurityLifecycle, - FromPort: fi.PtrTo(int32(3)), - Protocol: fi.PtrTo("icmp"), + FromPort: new(int32(3)), + Protocol: new("icmp"), SecurityGroup: lbSG, - ToPort: fi.PtrTo(int32(4)), + ToPort: new(int32(4)), } t.SetCidrOrPrefix(cidr) if t.IPv6CIDR == nil { @@ -280,39 +280,39 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { { suffix := bastionGroup.Suffix t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("ssh-to-bastion%s", suffix)), + Name: new(fmt.Sprintf("ssh-to-bastion%s", suffix)), Lifecycle: b.SecurityLifecycle, SecurityGroup: bastionGroup.Task, SourceGroup: lbSG, - Protocol: fi.PtrTo("tcp"), - FromPort: fi.PtrTo(int32(22)), - ToPort: fi.PtrTo(int32(22)), + Protocol: new("tcp"), + FromPort: new(int32(22)), + ToPort: new(int32(22)), } AddDirectionalGroupRule(c, t) } { suffix := bastionGroup.Suffix t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("icmp-to-bastion%s", suffix)), + Name: new(fmt.Sprintf("icmp-to-bastion%s", suffix)), Lifecycle: b.SecurityLifecycle, SecurityGroup: bastionGroup.Task, SourceGroup: lbSG, - Protocol: fi.PtrTo("icmp"), - FromPort: fi.PtrTo(int32(3)), - ToPort: fi.PtrTo(int32(4)), + Protocol: new("icmp"), + FromPort: new(int32(3)), + ToPort: new(int32(4)), } AddDirectionalGroupRule(c, t) } { suffix := bastionGroup.Suffix t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("icmp-from-bastion%s", suffix)), + Name: new(fmt.Sprintf("icmp-from-bastion%s", suffix)), Lifecycle: b.SecurityLifecycle, SecurityGroup: lbSG, SourceGroup: bastionGroup.Task, - Protocol: fi.PtrTo("icmp"), - FromPort: fi.PtrTo(int32(3)), - ToPort: fi.PtrTo(int32(4)), + Protocol: new("icmp"), + FromPort: new(int32(3)), + ToPort: new(int32(4)), } AddDirectionalGroupRule(c, t) } @@ -329,7 +329,7 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { tags["Name"] = "bastion." + b.ClusterName() nlbListener := &awstasks.NetworkLoadBalancerListener{ - Name: fi.PtrTo(b.NLBListenerName("bastion", 22)), + Name: new(b.NLBListenerName("bastion", 22)), Lifecycle: b.Lifecycle, NetworkLoadBalancer: b.LinkToNLB("bastion"), Port: 22, @@ -338,11 +338,11 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { c.AddTask(nlbListener) nlb = &awstasks.NetworkLoadBalancer{ - Name: fi.PtrTo(b.NLBName("bastion")), + Name: new(b.NLBName("bastion")), Lifecycle: b.Lifecycle, - LoadBalancerBaseName: fi.PtrTo(b.LBName32("bastion")), - CLBName: fi.PtrTo("bastion." + b.ClusterName()), + LoadBalancerBaseName: new(b.LBName32("bastion")), + CLBName: new("bastion." + b.ClusterName()), SubnetMappings: nlbSubnetMappings, SecurityGroups: []*awstasks.SecurityGroup{ b.LinkToELBSecurityGroup("bastion"), @@ -377,18 +377,18 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { } tg := &awstasks.TargetGroup{ - Name: fi.PtrTo(sshGroupName), + Name: new(sshGroupName), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), Tags: sshGroupTags, Protocol: elbv2types.ProtocolEnumTcp, - Port: fi.PtrTo(int32(22)), + Port: new(int32(22)), Attributes: groupAttrs, - Interval: fi.PtrTo(int32(10)), - HealthyThreshold: fi.PtrTo(int32(2)), - UnhealthyThreshold: fi.PtrTo(int32(2)), + Interval: new(int32(10)), + HealthyThreshold: new(int32(2)), + UnhealthyThreshold: new(int32(2)), HealthCheckProtocol: elbv2types.ProtocolEnumTcp, - Shared: fi.PtrTo(false), + Shared: new(false), } tg.CreateNewRevisionsWith(nlb) @@ -398,10 +398,10 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { if b.Cluster.Spec.Networking.Topology != nil && b.Cluster.Spec.Networking.Topology.Bastion != nil && b.Cluster.Spec.Networking.Topology.Bastion.LoadBalancer != nil && b.Cluster.Spec.Networking.Topology.Bastion.LoadBalancer.AdditionalSecurityGroups != nil { for _, id := range b.Cluster.Spec.Networking.Topology.Bastion.LoadBalancer.AdditionalSecurityGroups { t := &awstasks.SecurityGroup{ - Name: fi.PtrTo(id), + Name: new(id), Lifecycle: b.SecurityLifecycle, - ID: fi.PtrTo(id), - Shared: fi.PtrTo(true), + ID: new(id), + Shared: new(true), } c.EnsureTask(t) nlb.SecurityGroups = append(nlb.SecurityGroups, t) @@ -419,22 +419,22 @@ func (b *BastionModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Here we implement the bastion CNAME logic // By default bastions will create a CNAME that follows the `bastion-$clustername` formula t := &awstasks.DNSName{ - Name: fi.PtrTo(publicName), + Name: new(publicName), Lifecycle: b.Lifecycle, Zone: b.LinkToDNSZone(), - ResourceName: fi.PtrTo(publicName), - ResourceType: fi.PtrTo("A"), + ResourceName: new(publicName), + ResourceType: new("A"), TargetLoadBalancer: b.LinkToNLB("bastion"), } c.AddTask(t) t = &awstasks.DNSName{ - Name: fi.PtrTo(publicName + "-AAAA"), + Name: new(publicName + "-AAAA"), Lifecycle: b.Lifecycle, Zone: b.LinkToDNSZone(), - ResourceName: fi.PtrTo(publicName), - ResourceType: fi.PtrTo("AAAA"), + ResourceName: new(publicName), + ResourceType: new("AAAA"), TargetLoadBalancer: b.LinkToNLB("bastion"), } c.AddTask(t) diff --git a/pkg/model/awsmodel/dns.go b/pkg/model/awsmodel/dns.go index b7a3eb8bb5633..00f49d9b771cc 100644 --- a/pkg/model/awsmodel/dns.go +++ b/pkg/model/awsmodel/dns.go @@ -40,7 +40,7 @@ func (b *DNSModelBuilder) ensureDNSZone(c *fi.CloudupModelBuilderContext) error // Configuration for a DNS zone dnsZone := &awstasks.DNSZone{ - Name: fi.PtrTo(b.NameForDNSZone()), + Name: new(b.NameForDNSZone()), Lifecycle: b.Lifecycle, } @@ -51,7 +51,7 @@ func (b *DNSModelBuilder) ensureDNSZone(c *fi.CloudupModelBuilderContext) error // Ignore case kops.DNSTypePrivate: - dnsZone.Private = fi.PtrTo(true) + dnsZone.Private = new(true) dnsZone.PrivateVPC = b.LinkToVPC() default: @@ -61,10 +61,10 @@ func (b *DNSModelBuilder) ensureDNSZone(c *fi.CloudupModelBuilderContext) error if !strings.Contains(b.Cluster.Spec.DNSZone, ".") { // Looks like a hosted zone ID - dnsZone.ZoneID = fi.PtrTo(b.Cluster.Spec.DNSZone) + dnsZone.ZoneID = new(b.Cluster.Spec.DNSZone) } else { // Looks like a normal DNS name - dnsZone.DNSName = fi.PtrTo(b.Cluster.Spec.DNSZone) + dnsZone.DNSName = new(b.Cluster.Spec.DNSZone) } c.EnsureTask(dnsZone) @@ -101,19 +101,19 @@ func (b *DNSModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { } c.AddTask(&awstasks.DNSName{ - Name: fi.PtrTo(b.Cluster.Spec.API.PublicName), - ResourceName: fi.PtrTo(b.Cluster.Spec.API.PublicName), + Name: new(b.Cluster.Spec.API.PublicName), + ResourceName: new(b.Cluster.Spec.API.PublicName), Lifecycle: b.Lifecycle, Zone: b.LinkToDNSZone(), - ResourceType: fi.PtrTo("A"), + ResourceType: new("A"), TargetLoadBalancer: targetLoadBalancer, }) c.AddTask(&awstasks.DNSName{ - Name: fi.PtrTo(b.Cluster.Spec.API.PublicName + "-AAAA"), - ResourceName: fi.PtrTo(b.Cluster.Spec.API.PublicName), + Name: new(b.Cluster.Spec.API.PublicName + "-AAAA"), + ResourceName: new(b.Cluster.Spec.API.PublicName), Lifecycle: b.Lifecycle, Zone: b.LinkToDNSZone(), - ResourceType: fi.PtrTo("AAAA"), + ResourceType: new("AAAA"), TargetLoadBalancer: targetLoadBalancer, }) } @@ -131,20 +131,20 @@ func (b *DNSModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Using EnsureTask as APIInternalName() and APIPublicName could be the same { c.EnsureTask(&awstasks.DNSName{ - Name: fi.PtrTo(b.Cluster.APIInternalName()), - ResourceName: fi.PtrTo(b.Cluster.APIInternalName()), + Name: new(b.Cluster.APIInternalName()), + ResourceName: new(b.Cluster.APIInternalName()), Lifecycle: b.Lifecycle, Zone: b.LinkToDNSZone(), - ResourceType: fi.PtrTo("A"), + ResourceType: new("A"), TargetLoadBalancer: targetLoadBalancer, }) } c.EnsureTask(&awstasks.DNSName{ - Name: fi.PtrTo(b.Cluster.APIInternalName() + "-AAAA"), - ResourceName: fi.PtrTo(b.Cluster.APIInternalName()), + Name: new(b.Cluster.APIInternalName() + "-AAAA"), + ResourceName: new(b.Cluster.APIInternalName()), Lifecycle: b.Lifecycle, Zone: b.LinkToDNSZone(), - ResourceType: fi.PtrTo("AAAA"), + ResourceType: new("AAAA"), TargetLoadBalancer: targetLoadBalancer, }) } diff --git a/pkg/model/awsmodel/external_access.go b/pkg/model/awsmodel/external_access.go index a62bdc9caa55a..e6ef5c7ebf6ae 100644 --- a/pkg/model/awsmodel/external_access.go +++ b/pkg/model/awsmodel/external_access.go @@ -63,12 +63,12 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.CloudupModelBuilderContext) err for _, masterGroup := range masterGroups { suffix := masterGroup.Suffix t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("ssh-external-to-master-%s%s", sshAccess, suffix)), + Name: new(fmt.Sprintf("ssh-external-to-master-%s%s", sshAccess, suffix)), Lifecycle: b.Lifecycle, SecurityGroup: masterGroup.Task, - Protocol: fi.PtrTo("tcp"), - FromPort: fi.PtrTo(int32(22)), - ToPort: fi.PtrTo(int32(22)), + Protocol: new("tcp"), + FromPort: new(int32(22)), + ToPort: new(int32(22)), } t.SetCidrOrPrefix(sshAccess) AddDirectionalGroupRule(c, t) @@ -77,12 +77,12 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.CloudupModelBuilderContext) err for _, nodeGroup := range nodeGroups { suffix := nodeGroup.Suffix t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("ssh-external-to-node-%s%s", sshAccess, suffix)), + Name: new(fmt.Sprintf("ssh-external-to-node-%s%s", sshAccess, suffix)), Lifecycle: b.Lifecycle, SecurityGroup: nodeGroup.Task, - Protocol: fi.PtrTo("tcp"), - FromPort: fi.PtrTo(int32(22)), - ToPort: fi.PtrTo(int32(22)), + Protocol: new("tcp"), + FromPort: new(int32(22)), + ToPort: new(int32(22)), } t.SetCidrOrPrefix(sshAccess) AddDirectionalGroupRule(c, t) @@ -100,24 +100,24 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.CloudupModelBuilderContext) err suffix := nodeGroup.Suffix { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("nodeport-tcp-external-to-node-%s%s", nodePortAccess, suffix)), + Name: new(fmt.Sprintf("nodeport-tcp-external-to-node-%s%s", nodePortAccess, suffix)), Lifecycle: b.Lifecycle, SecurityGroup: nodeGroup.Task, - Protocol: fi.PtrTo("tcp"), - FromPort: fi.PtrTo(int32(nodePortRange.Base)), - ToPort: fi.PtrTo(int32(nodePortRange.Base + nodePortRange.Size - 1)), + Protocol: new("tcp"), + FromPort: new(int32(nodePortRange.Base)), + ToPort: new(int32(nodePortRange.Base + nodePortRange.Size - 1)), } t.SetCidrOrPrefix(nodePortAccess) c.AddTask(t) } { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("nodeport-udp-external-to-node-%s%s", nodePortAccess, suffix)), + Name: new(fmt.Sprintf("nodeport-udp-external-to-node-%s%s", nodePortAccess, suffix)), Lifecycle: b.Lifecycle, SecurityGroup: nodeGroup.Task, - Protocol: fi.PtrTo("udp"), - FromPort: fi.PtrTo(int32(nodePortRange.Base)), - ToPort: fi.PtrTo(int32(nodePortRange.Base + nodePortRange.Size - 1)), + Protocol: new("udp"), + FromPort: new(int32(nodePortRange.Base)), + ToPort: new(int32(nodePortRange.Base + nodePortRange.Size - 1)), } t.SetCidrOrPrefix(nodePortAccess) c.AddTask(t) @@ -135,12 +135,12 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.CloudupModelBuilderContext) err for _, masterGroup := range masterGroups { suffix := masterGroup.Suffix t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("https-external-to-master-%s%s", apiAccess, suffix)), + Name: new(fmt.Sprintf("https-external-to-master-%s%s", apiAccess, suffix)), Lifecycle: b.Lifecycle, SecurityGroup: masterGroup.Task, - Protocol: fi.PtrTo("tcp"), - FromPort: fi.PtrTo(int32(443)), - ToPort: fi.PtrTo(int32(443)), + Protocol: new("tcp"), + FromPort: new(int32(443)), + ToPort: new(int32(443)), } t.SetCidrOrPrefix(apiAccess) AddDirectionalGroupRule(c, t) diff --git a/pkg/model/awsmodel/firewall.go b/pkg/model/awsmodel/firewall.go index 74b15b4f8c267..94c15ec876095 100644 --- a/pkg/model/awsmodel/firewall.go +++ b/pkg/model/awsmodel/firewall.go @@ -78,21 +78,21 @@ func (b *FirewallModelBuilder) buildNodeRules(c *fi.CloudupModelBuilderContext) // Allow full egress { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("ipv4-node-egress" + src.Suffix), + Name: new("ipv4-node-egress" + src.Suffix), Lifecycle: b.Lifecycle, SecurityGroup: src.Task, - Egress: fi.PtrTo(true), - CIDR: fi.PtrTo("0.0.0.0/0"), + Egress: new(true), + CIDR: new("0.0.0.0/0"), } AddDirectionalGroupRule(c, t) } { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("ipv6-node-egress" + src.Suffix), + Name: new("ipv6-node-egress" + src.Suffix), Lifecycle: b.Lifecycle, SecurityGroup: src.Task, - Egress: fi.PtrTo(true), - IPv6CIDR: fi.PtrTo("::/0"), + Egress: new(true), + IPv6CIDR: new("::/0"), } AddDirectionalGroupRule(c, t) } @@ -102,7 +102,7 @@ func (b *FirewallModelBuilder) buildNodeRules(c *fi.CloudupModelBuilderContext) suffix := JoinSuffixes(src, dest) t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("all-node-to-node" + suffix), + Name: new("all-node-to-node" + suffix), Lifecycle: b.Lifecycle, SecurityGroup: dest.Task, SourceGroup: src.Task, @@ -177,25 +177,25 @@ func (b *FirewallModelBuilder) applyNodeToMasterBlockSpecificPorts(c *fi.Cloudup for _, r := range udpRanges { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("node-to-master-udp-%d-%d%s", r.From, r.To, suffix)), + Name: new(fmt.Sprintf("node-to-master-udp-%d-%d%s", r.From, r.To, suffix)), Lifecycle: b.Lifecycle, SecurityGroup: masterGroup.Task, SourceGroup: nodeGroup.Task, - FromPort: fi.PtrTo(int32(r.From)), - ToPort: fi.PtrTo(int32(r.To)), - Protocol: fi.PtrTo("udp"), + FromPort: new(int32(r.From)), + ToPort: new(int32(r.To)), + Protocol: new("udp"), } AddDirectionalGroupRule(c, t) } for _, r := range tcpRanges { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("node-to-master-tcp-%d-%d%s", r.From, r.To, suffix)), + Name: new(fmt.Sprintf("node-to-master-tcp-%d-%d%s", r.From, r.To, suffix)), Lifecycle: b.Lifecycle, SecurityGroup: masterGroup.Task, SourceGroup: nodeGroup.Task, - FromPort: fi.PtrTo(int32(r.From)), - ToPort: fi.PtrTo(int32(r.To)), - Protocol: fi.PtrTo("tcp"), + FromPort: new(int32(r.From)), + ToPort: new(int32(r.To)), + Protocol: new("tcp"), } AddDirectionalGroupRule(c, t) } @@ -210,11 +210,11 @@ func (b *FirewallModelBuilder) applyNodeToMasterBlockSpecificPorts(c *fi.Cloudup } t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo(fmt.Sprintf("node-to-master-protocol-%s%s", name, suffix)), + Name: new(fmt.Sprintf("node-to-master-protocol-%s%s", name, suffix)), Lifecycle: b.Lifecycle, SecurityGroup: masterGroup.Task, SourceGroup: nodeGroup.Task, - Protocol: fi.PtrTo(awsName), + Protocol: new(awsName), } AddDirectionalGroupRule(c, t) } @@ -229,7 +229,7 @@ func (b *FirewallModelBuilder) applyNodeToMasterBlockSpecificPorts(c *fi.Cloudup suffix := JoinSuffixes(src, dest) t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("all-nodes-to-master" + suffix), + Name: new("all-nodes-to-master" + suffix), Lifecycle: b.Lifecycle, SecurityGroup: dest.Task, SourceGroup: src.Task, @@ -255,21 +255,21 @@ func (b *FirewallModelBuilder) buildMasterRules(c *fi.CloudupModelBuilderContext // Allow full egress { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("ipv4-master-egress" + src.Suffix), + Name: new("ipv4-master-egress" + src.Suffix), Lifecycle: b.Lifecycle, SecurityGroup: src.Task, - Egress: fi.PtrTo(true), - CIDR: fi.PtrTo("0.0.0.0/0"), + Egress: new(true), + CIDR: new("0.0.0.0/0"), } AddDirectionalGroupRule(c, t) } { t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("ipv6-master-egress" + src.Suffix), + Name: new("ipv6-master-egress" + src.Suffix), Lifecycle: b.Lifecycle, SecurityGroup: src.Task, - Egress: fi.PtrTo(true), - IPv6CIDR: fi.PtrTo("::/0"), + Egress: new(true), + IPv6CIDR: new("::/0"), } AddDirectionalGroupRule(c, t) } @@ -279,7 +279,7 @@ func (b *FirewallModelBuilder) buildMasterRules(c *fi.CloudupModelBuilderContext suffix := JoinSuffixes(src, dest) t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("all-master-to-master" + suffix), + Name: new("all-master-to-master" + suffix), Lifecycle: b.Lifecycle, SecurityGroup: dest.Task, SourceGroup: src.Task, @@ -292,7 +292,7 @@ func (b *FirewallModelBuilder) buildMasterRules(c *fi.CloudupModelBuilderContext suffix := JoinSuffixes(src, dest) t := &awstasks.SecurityGroupRule{ - Name: fi.PtrTo("all-master-to-node" + suffix), + Name: new("all-master-to-node" + suffix), Lifecycle: b.Lifecycle, SecurityGroup: dest.Task, SourceGroup: src.Task, @@ -344,27 +344,27 @@ func (b *AWSModelContext) GetSecurityGroups(role kops.InstanceGroupRole) ([]Secu } baseGroup = &awstasks.SecurityGroup{ - Name: fi.PtrTo(name), + Name: new(name), VPC: b.LinkToVPC(), - Description: fi.PtrTo("Security group for masters"), + Description: new("Security group for masters"), RemoveExtraRules: removeExtraRules, } baseGroup.Tags = b.CloudTags(name, false) case kops.InstanceGroupRoleNode: name := b.SecurityGroupName(role) baseGroup = &awstasks.SecurityGroup{ - Name: fi.PtrTo(name), + Name: new(name), VPC: b.LinkToVPC(), - Description: fi.PtrTo("Security group for nodes"), + Description: new("Security group for nodes"), RemoveExtraRules: []string{"port=22"}, } baseGroup.Tags = b.CloudTags(name, false) case kops.InstanceGroupRoleBastion: name := b.SecurityGroupName(role) baseGroup = &awstasks.SecurityGroup{ - Name: fi.PtrTo(name), + Name: new(name), VPC: b.LinkToVPC(), - Description: fi.PtrTo("Security group for bastion"), + Description: new("Security group for bastion"), RemoveExtraRules: []string{ "port=22", // SSH "port=3:4", // ICMP @@ -404,7 +404,7 @@ func (b *AWSModelContext) GetSecurityGroups(role kops.InstanceGroupRole) ([]Secu Name: &sgName, ID: ig.Spec.SecurityGroupOverride, VPC: b.LinkToVPC(), - Shared: fi.PtrTo(true), + Shared: new(true), Description: baseGroup.Description, } // Because the SecurityGroup is shared, we don't set RemoveExtraRules @@ -453,7 +453,7 @@ func JoinSuffixes(src SecurityGroupInfo, dest SecurityGroupInfo) string { func AddDirectionalGroupRule(c *fi.CloudupModelBuilderContext, t *awstasks.SecurityGroupRule) { name := generateName(t) - t.Name = fi.PtrTo(name) + t.Name = new(name) tags := make(map[string]string) for key, value := range t.SecurityGroup.Tags { tags[key] = value diff --git a/pkg/model/awsmodel/iam.go b/pkg/model/awsmodel/iam.go index d4e970dd62829..70655f67078c6 100644 --- a/pkg/model/awsmodel/iam.go +++ b/pkg/model/awsmodel/iam.go @@ -158,7 +158,7 @@ func (b *IAMModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { name := "external-" + fi.ValueOf(iamRole.Name) externalPolicies := aws.PolicyARNs c.AddTask(&awstasks.IAMRolePolicy{ - Name: fi.PtrTo(name), + Name: new(name), ExternalPolicies: &externalPolicies, Managed: true, Role: iamRole, @@ -199,7 +199,7 @@ func (b *IAMModelBuilder) buildIAMRole(role iam.Subject, iamName string, c *fi.C } iamRole := &awstasks.IAMRole{ - Name: fi.PtrTo(iamName), + Name: new(iamName), Lifecycle: b.Lifecycle, RolePolicyDocument: rolePolicy, @@ -207,14 +207,14 @@ func (b *IAMModelBuilder) buildIAMRole(role iam.Subject, iamName string, c *fi.C if isServiceAccount { // e.g. kube-system-dns-controller - iamRole.ExportWithID = fi.PtrTo(roleKey) + iamRole.ExportWithID = new(roleKey) sa, ok := role.ServiceAccount() if ok { iamRole.Tags = b.CloudTagsForServiceAccount(iamName, sa) } } else { // e.g. nodes - iamRole.ExportWithID = fi.PtrTo(roleKey + "s") + iamRole.ExportWithID = new(roleKey + "s") iamRole.Tags = b.CloudTags(iamName, false) } @@ -243,12 +243,12 @@ func (b *IAMModelBuilder) buildIAMRolePolicy(role iam.Subject, iamName string, i // but we might be creating the hosted zone dynamically. // We create a stub-reference which will be combined by the execution engine. iamPolicy.DNSZone = &awstasks.DNSZone{ - Name: fi.PtrTo(b.NameForDNSZone()), + Name: new(b.NameForDNSZone()), } } t := &awstasks.IAMRolePolicy{ - Name: fi.PtrTo(iamName), + Name: new(iamName), Lifecycle: b.Lifecycle, Role: iamRole, @@ -292,9 +292,9 @@ func (b *IAMModelBuilder) buildIAMTasks(role iam.Subject, iamName string, c *fi. var iamInstanceProfile *awstasks.IAMInstanceProfile { iamInstanceProfile = &awstasks.IAMInstanceProfile{ - Name: fi.PtrTo(iamName), + Name: new(iamName), Lifecycle: b.Lifecycle, - Shared: fi.PtrTo(shared), + Shared: new(shared), Tags: b.CloudTags(iamName, shared), } c.AddTask(iamInstanceProfile) @@ -314,7 +314,7 @@ func (b *IAMModelBuilder) buildIAMTasks(role iam.Subject, iamName string, c *fi. } { iamInstanceProfileRole := &awstasks.IAMInstanceProfileRole{ - Name: fi.PtrTo(iamName), + Name: new(iamName), Lifecycle: b.Lifecycle, InstanceProfile: iamInstanceProfile, @@ -336,7 +336,7 @@ func (b *IAMModelBuilder) buildIAMTasks(role iam.Subject, iamName string, c *fi. name := fmt.Sprintf("%s-policyoverride", roleKey) t := &awstasks.IAMRolePolicy{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, Role: iamRole, Managed: true, @@ -360,7 +360,7 @@ func (b *IAMModelBuilder) buildIAMTasks(role iam.Subject, iamName string, c *fi. additionalPolicyName := "additional." + iamName t := &awstasks.IAMRolePolicy{ - Name: fi.PtrTo(additionalPolicyName), + Name: new(additionalPolicyName), Lifecycle: b.Lifecycle, Role: iamRole, diff --git a/pkg/model/awsmodel/network.go b/pkg/model/awsmodel/network.go index d2e1aa938ee36..5c5b6ebbe8936 100644 --- a/pkg/model/awsmodel/network.go +++ b/pkg/model/awsmodel/network.go @@ -60,10 +60,10 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { vpcTags = nil } t := &awstasks.VPC{ - Name: fi.PtrTo(vpcName), + Name: new(vpcName), Lifecycle: b.Lifecycle, - Shared: fi.PtrTo(sharedVPC), - EnableDNSSupport: fi.PtrTo(true), + Shared: new(sharedVPC), + EnableDNSSupport: new(true), Tags: vpcTags, } @@ -74,20 +74,20 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { } else { // In theory we don't need to enable it for >= 1.5, // but seems safer to stick with existing behaviour - t.EnableDNSHostnames = fi.PtrTo(true) + t.EnableDNSHostnames = new(true) // Used only for Terraform rendering. // Direct rendering is handled via the VPCAmazonIPv6CIDRBlock task - t.AmazonIPv6 = fi.PtrTo(true) + t.AmazonIPv6 = new(true) t.AssociateExtraCIDRBlocks = b.Cluster.Spec.Networking.AdditionalNetworkCIDRs } if b.Cluster.Spec.Networking.NetworkID != "" { - t.ID = fi.PtrTo(b.Cluster.Spec.Networking.NetworkID) + t.ID = new(b.Cluster.Spec.Networking.NetworkID) } if b.Cluster.Spec.Networking.NetworkCIDR != "" { - t.CIDR = fi.PtrTo(b.Cluster.Spec.Networking.NetworkCIDR) + t.CIDR = new(b.Cluster.Spec.Networking.NetworkCIDR) } c.AddTask(t) @@ -96,20 +96,20 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { if !sharedVPC { // Associate an Amazon-provided IPv6 CIDR block with the VPC c.AddTask(&awstasks.VPCAmazonIPv6CIDRBlock{ - Name: fi.PtrTo("AmazonIPv6"), + Name: new("AmazonIPv6"), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), - Shared: fi.PtrTo(false), + Shared: new(false), }) // Associate additional CIDR blocks with the VPC for _, cidr := range b.Cluster.Spec.Networking.AdditionalNetworkCIDRs { c.AddTask(&awstasks.VPCCIDRBlock{ - Name: fi.PtrTo(cidr), + Name: new(cidr), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), - Shared: fi.PtrTo(false), - CIDRBlock: fi.PtrTo(cidr), + Shared: new(false), + CIDRBlock: new(cidr), }) } } @@ -117,22 +117,22 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // TODO: would be good to create these as shared, to verify them if !sharedVPC { dhcp := &awstasks.DHCPOptions{ - Name: fi.PtrTo(b.ClusterName()), + Name: new(b.ClusterName()), Lifecycle: b.Lifecycle, - DomainNameServers: fi.PtrTo("AmazonProvidedDNS"), + DomainNameServers: new("AmazonProvidedDNS"), Tags: tags, - Shared: fi.PtrTo(sharedVPC), + Shared: new(sharedVPC), } if b.Region == "us-east-1" { - dhcp.DomainName = fi.PtrTo("ec2.internal") + dhcp.DomainName = new("ec2.internal") } else { - dhcp.DomainName = fi.PtrTo(b.Region + ".compute.internal") + dhcp.DomainName = new(b.Region + ".compute.internal") } c.AddTask(dhcp) c.AddTask(&awstasks.VPCDHCPOptionsAssociation{ - Name: fi.PtrTo(b.ClusterName()), + Name: new(b.ClusterName()), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), DHCPOptions: dhcp, @@ -170,10 +170,10 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { if !allSubnetsUnmanaged { // The internet gateway is the main entry point to the cluster. igw = &awstasks.InternetGateway{ - Name: fi.PtrTo(b.ClusterName()), + Name: new(b.ClusterName()), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), - Shared: fi.PtrTo(sharedVPC), + Shared: new(sharedVPC), } igw.Tags = b.CloudTags(*igw.Name, *igw.Shared) c.AddTask(igw) @@ -186,28 +186,28 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { routeTableTags := b.CloudTags(vpcName, sharedRouteTable) routeTableTags[awsup.TagNameKopsRole] = "public" publicRouteTable = &awstasks.RouteTable{ - Name: fi.PtrTo(b.ClusterName()), + Name: new(b.ClusterName()), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), Tags: routeTableTags, - Shared: fi.PtrTo(sharedRouteTable), + Shared: new(sharedRouteTable), } c.AddTask(publicRouteTable) // TODO: Validate when allSubnetsShared c.AddTask(&awstasks.Route{ - Name: fi.PtrTo("0.0.0.0/0"), + Name: new("0.0.0.0/0"), Lifecycle: b.Lifecycle, - CIDR: fi.PtrTo("0.0.0.0/0"), + CIDR: new("0.0.0.0/0"), RouteTable: publicRouteTable, InternetGateway: igw, }) c.AddTask(&awstasks.Route{ - Name: fi.PtrTo("::/0"), + Name: new("::/0"), Lifecycle: b.Lifecycle, - IPv6CIDR: fi.PtrTo("::/0"), + IPv6CIDR: new("::/0"), RouteTable: publicRouteTable, InternetGateway: igw, }) @@ -279,21 +279,21 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { } subnet := &awstasks.Subnet{ - Name: fi.PtrTo(subnetName), - ShortName: fi.PtrTo(subnetSpec.Name), + Name: new(subnetName), + ShortName: new(subnetSpec.Name), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), - AvailabilityZone: fi.PtrTo(subnetSpec.Zone), - Shared: fi.PtrTo(sharedSubnet), + AvailabilityZone: new(subnetSpec.Zone), + Shared: new(sharedSubnet), Tags: tags, } if b.Cluster.Spec.ExternalCloudControllerManager != nil { - subnet.ResourceBasedNaming = fi.PtrTo(true) + subnet.ResourceBasedNaming = new(true) } if subnetSpec.CIDR != "" { - subnet.CIDR = fi.PtrTo(subnetSpec.CIDR) + subnet.CIDR = new(subnetSpec.CIDR) if !sharedVPC { for _, cidr := range b.Cluster.Spec.Networking.AdditionalNetworkCIDRs { _, additionalCIDR, err := net.ParseCIDR(cidr) @@ -305,7 +305,7 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { return err } if additionalCIDR.Contains(subnetIP) { - subnet.VPCCIDRBlock = &awstasks.VPCCIDRBlock{Name: fi.PtrTo(cidr)} + subnet.VPCCIDRBlock = &awstasks.VPCCIDRBlock{Name: new(cidr)} } } } @@ -315,10 +315,10 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { if !sharedVPC { subnet.AmazonIPv6CIDR = b.LinkToAmazonVPCIPv6CIDR() } - subnet.IPv6CIDR = fi.PtrTo(subnetSpec.IPv6CIDR) + subnet.IPv6CIDR = new(subnetSpec.IPv6CIDR) } if subnetSpec.ID != "" { - subnet.ID = fi.PtrTo(subnetSpec.ID) + subnet.ID = new(subnetSpec.ID) } c.AddTask(subnet) @@ -328,7 +328,7 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { if b.IsIPv6Only() && subnetSpec.Type == kops.SubnetTypePublic && subnetSpec.IPv6CIDR != "" { // Public IPv6-capable subnets route NAT64 to a NAT gateway c.AddTask(&awstasks.RouteTableAssociation{ - Name: fi.PtrTo("public-" + subnetSpec.Name + "." + b.ClusterName()), + Name: new("public-" + subnetSpec.Name + "." + b.ClusterName()), Lifecycle: b.Lifecycle, RouteTable: b.LinkToPublicRouteTableInZone(subnetSpec.Zone), Subnet: subnet, @@ -341,7 +341,7 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { infoByZone[subnetSpec.Zone].HaveIPv6PublicSubnet = true } else { c.AddTask(&awstasks.RouteTableAssociation{ - Name: fi.PtrTo(subnetSpec.Name + "." + b.ClusterName()), + Name: new(subnetSpec.Name + "." + b.ClusterName()), Lifecycle: b.Lifecycle, RouteTable: publicRouteTable, Subnet: subnet, @@ -357,7 +357,7 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // // Map the Private subnet to the Private route table c.AddTask(&awstasks.RouteTableAssociation{ - Name: fi.PtrTo("private-" + subnetSpec.Name + "." + b.ClusterName()), + Name: new("private-" + subnetSpec.Name + "." + b.ClusterName()), Lifecycle: b.Lifecycle, RouteTable: b.LinkToPrivateRouteTableInZone(subnetSpec.Zone), Subnet: subnet, @@ -382,10 +382,10 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { var eigw *awstasks.EgressOnlyInternetGateway if !allPrivateSubnetsUnmanaged && b.IsIPv6Only() { eigw = &awstasks.EgressOnlyInternetGateway{ - Name: fi.PtrTo(b.ClusterName()), + Name: new(b.ClusterName()), Lifecycle: b.Lifecycle, VPC: b.LinkToVPC(), - Shared: fi.PtrTo(sharedVPC), + Shared: new(sharedVPC), } eigw.Tags = b.CloudTags(*eigw.Name, *eigw.Shared) c.AddTask(eigw) @@ -441,13 +441,13 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { if strings.HasPrefix(egress, "nat-") { ngw = &awstasks.NatGateway{ - Name: fi.PtrTo(zone + "." + b.ClusterName()), + Name: new(zone + "." + b.ClusterName()), Lifecycle: b.Lifecycle, Subnet: egressSubnet, - ID: fi.PtrTo(egress), + ID: new(egress), AssociatedRouteTable: egressRouteTable, // If we're here, it means this NatGateway was specified, so we are Shared - Shared: fi.PtrTo(true), + Shared: new(true), Tags: b.CloudTags(zone+"."+b.ClusterName(), true), } @@ -456,17 +456,17 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { } else if strings.HasPrefix(egress, "eipalloc-") { eip := &awstasks.ElasticIP{ - Name: fi.PtrTo(zone + "." + b.ClusterName()), - ID: fi.PtrTo(egress), + Name: new(zone + "." + b.ClusterName()), + ID: new(egress), Lifecycle: b.Lifecycle, AssociatedNatGatewayRouteTable: egressRouteTable, - Shared: fi.PtrTo(true), + Shared: new(true), Tags: b.CloudTags(zone+"."+b.ClusterName(), true), } c.AddTask(eip) ngw = &awstasks.NatGateway{ - Name: fi.PtrTo(zone + "." + b.ClusterName()), + Name: new(zone + "." + b.ClusterName()), Lifecycle: b.Lifecycle, Subnet: egressSubnet, ElasticIP: eip, @@ -478,10 +478,10 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { } else if strings.HasPrefix(egress, "i-") { in = &awstasks.Instance{ - Name: fi.PtrTo(egress), + Name: new(egress), Lifecycle: b.Lifecycle, - ID: fi.PtrTo(egress), - Shared: fi.PtrTo(true), + ID: new(egress), + Shared: new(true), Tags: nil, // We don't need to add tags here } @@ -499,13 +499,13 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // subnet needs a NGW, lets create it. We tie it to a subnet // so we can track it in AWS eip := &awstasks.ElasticIP{ - Name: fi.PtrTo(zone + "." + b.ClusterName()), + Name: new(zone + "." + b.ClusterName()), Lifecycle: b.Lifecycle, AssociatedNatGatewayRouteTable: egressRouteTable, } if publicIP != "" { - eip.PublicIP = fi.PtrTo(publicIP) + eip.PublicIP = new(publicIP) eip.Tags = b.CloudTags(*eip.Name, true) } else { eip.Tags = b.CloudTags(*eip.Name, false) @@ -522,7 +522,7 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // var ngw = &awstasks.NatGateway{} ngw = &awstasks.NatGateway{ - Name: fi.PtrTo(zone + "." + b.ClusterName()), + Name: new(zone + "." + b.ClusterName()), Lifecycle: b.Lifecycle, Subnet: egressSubnet, ElasticIP: eip, @@ -541,11 +541,11 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { routeTableTags := b.CloudTags(b.NamePrivateRouteTableInZone(zone), routeTableShared) routeTableTags[awsup.TagNameKopsRole] = "private-" + zone rt := &awstasks.RouteTable{ - Name: fi.PtrTo(b.NamePrivateRouteTableInZone(zone)), + Name: new(b.NamePrivateRouteTableInZone(zone)), VPC: b.LinkToVPC(), Lifecycle: b.Lifecycle, - Shared: fi.PtrTo(routeTableShared), + Shared: new(routeTableShared), Tags: routeTableTags, } c.AddTask(rt) @@ -557,17 +557,17 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { var r *awstasks.Route if in != nil { r = &awstasks.Route{ - Name: fi.PtrTo("private-" + zone + "-0.0.0.0/0"), + Name: new("private-" + zone + "-0.0.0.0/0"), Lifecycle: b.Lifecycle, - CIDR: fi.PtrTo("0.0.0.0/0"), + CIDR: new("0.0.0.0/0"), RouteTable: rt, Instance: in, } } else { r = &awstasks.Route{ - Name: fi.PtrTo("private-" + zone + "-0.0.0.0/0"), + Name: new("private-" + zone + "-0.0.0.0/0"), Lifecycle: b.Lifecycle, - CIDR: fi.PtrTo("0.0.0.0/0"), + CIDR: new("0.0.0.0/0"), RouteTable: rt, // Only one of these will be not nil NatGateway: ngw, @@ -579,9 +579,9 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { if b.IsIPv6Only() { // Route NAT64 well-known prefix to the NAT gateway c.AddTask(&awstasks.Route{ - Name: fi.PtrTo("private-" + zone + "-64:ff9b::/96"), + Name: new("private-" + zone + "-64:ff9b::/96"), Lifecycle: b.Lifecycle, - IPv6CIDR: fi.PtrTo("64:ff9b::/96"), + IPv6CIDR: new("64:ff9b::/96"), RouteTable: rt, // Only one of these will be not nil NatGateway: ngw, @@ -590,9 +590,9 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Route IPv6 to the Egress-only Internet Gateway. c.AddTask(&awstasks.Route{ - Name: fi.PtrTo("private-" + zone + "-::/0"), + Name: new("private-" + zone + "-::/0"), Lifecycle: b.Lifecycle, - IPv6CIDR: fi.PtrTo("::/0"), + IPv6CIDR: new("::/0"), RouteTable: rt, EgressOnlyInternetGateway: eigw, }) @@ -624,36 +624,36 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { routeTableTags := b.CloudTags(b.NamePublicRouteTableInZone(zone), routeTableShared) routeTableTags[awsup.TagNameKopsRole] = "public-" + zone rt := &awstasks.RouteTable{ - Name: fi.PtrTo(b.NamePublicRouteTableInZone(zone)), + Name: new(b.NamePublicRouteTableInZone(zone)), VPC: b.LinkToVPC(), Lifecycle: b.Lifecycle, - Shared: fi.PtrTo(routeTableShared), + Shared: new(routeTableShared), Tags: routeTableTags, } c.AddTask(rt) // Routes for the public route table. c.AddTask(&awstasks.Route{ - Name: fi.PtrTo("public-" + zone + "-0.0.0.0/0"), + Name: new("public-" + zone + "-0.0.0.0/0"), Lifecycle: b.Lifecycle, - CIDR: fi.PtrTo("0.0.0.0/0"), + CIDR: new("0.0.0.0/0"), RouteTable: rt, InternetGateway: igw, }) c.AddTask(&awstasks.Route{ - Name: fi.PtrTo("public-" + zone + "-::/0"), + Name: new("public-" + zone + "-::/0"), Lifecycle: b.Lifecycle, - IPv6CIDR: fi.PtrTo("::/0"), + IPv6CIDR: new("::/0"), RouteTable: rt, InternetGateway: igw, }) // Route NAT64 well-known prefix to the NAT gateway c.AddTask(&awstasks.Route{ - Name: fi.PtrTo("public-" + zone + "-64:ff9b::/96"), + Name: new("public-" + zone + "-64:ff9b::/96"), Lifecycle: b.Lifecycle, - IPv6CIDR: fi.PtrTo("64:ff9b::/96"), + IPv6CIDR: new("64:ff9b::/96"), RouteTable: rt, // Only one of these will be not nil NatGateway: ngw, @@ -668,53 +668,53 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { func addAdditionalRoutes(routes []kops.RouteSpec, sbName string, rt *awstasks.RouteTable, lf fi.Lifecycle, c *fi.CloudupModelBuilderContext) error { for _, r := range routes { t := &awstasks.Route{ - Name: fi.PtrTo(sbName + "." + r.CIDR), + Name: new(sbName + "." + r.CIDR), Lifecycle: lf, - CIDR: fi.PtrTo(r.CIDR), + CIDR: new(r.CIDR), RouteTable: rt, } if strings.HasPrefix(r.Target, "pcx-") { - t.VPCPeeringConnectionID = fi.PtrTo(r.Target) + t.VPCPeeringConnectionID = new(r.Target) c.AddTask(t) } else if strings.HasPrefix(r.Target, "i-") { inst := &awstasks.Instance{ - Name: fi.PtrTo(r.Target), + Name: new(r.Target), Lifecycle: lf, - ID: fi.PtrTo(r.Target), - Shared: fi.PtrTo(true), + ID: new(r.Target), + Shared: new(true), } c.EnsureTask(inst) t.Instance = inst c.AddTask(t) } else if strings.HasPrefix(r.Target, "nat-") { nat := &awstasks.NatGateway{ - Name: fi.PtrTo(r.Target), + Name: new(r.Target), Lifecycle: lf, - ID: fi.PtrTo(r.Target), - Shared: fi.PtrTo(true), + ID: new(r.Target), + Shared: new(true), } c.EnsureTask(nat) t.NatGateway = nat c.AddTask(t) } else if strings.HasPrefix(r.Target, "tgw-") { - t.TransitGatewayID = fi.PtrTo(r.Target) + t.TransitGatewayID = new(r.Target) c.AddTask(t) } else if strings.HasPrefix(r.Target, "igw-") { internetGW := &awstasks.InternetGateway{ - Name: fi.PtrTo(r.Target), + Name: new(r.Target), Lifecycle: lf, - ID: fi.PtrTo(r.Target), - Shared: fi.PtrTo(true), + ID: new(r.Target), + Shared: new(true), } c.EnsureTask(internetGW) t.InternetGateway = internetGW c.AddTask(t) } else if strings.HasPrefix(r.Target, "eigw-") { eigw := &awstasks.EgressOnlyInternetGateway{ - Name: fi.PtrTo(r.Target), + Name: new(r.Target), Lifecycle: lf, - ID: fi.PtrTo(r.Target), - Shared: fi.PtrTo(true), + ID: new(r.Target), + Shared: new(true), } c.EnsureTask(eigw) t.EgressOnlyInternetGateway = eigw diff --git a/pkg/model/awsmodel/nodeterminationhandler.go b/pkg/model/awsmodel/nodeterminationhandler.go index 2218cc0accaa0..69f6f3933c727 100644 --- a/pkg/model/awsmodel/nodeterminationhandler.go +++ b/pkg/model/awsmodel/nodeterminationhandler.go @@ -127,7 +127,7 @@ func (b *NodeTerminationHandlerBuilder) build(c *fi.CloudupModelBuilderContext) policy.Statement = append(policy.Statement, &iam.Statement{ Effect: iam.StatementEffectAllow, Principal: iam.Principal{ - Service: fi.PtrTo(stringorset.Of("events.amazonaws.com", "sqs.amazonaws.com")), + Service: new(stringorset.Of("events.amazonaws.com", "sqs.amazonaws.com")), }, Action: stringorset.Of("sqs:SendMessage"), Resource: stringorset.String(arn.String()), diff --git a/pkg/model/awsmodel/oidc_provider.go b/pkg/model/awsmodel/oidc_provider.go index 372d257285067..4cf6a875c64ac 100644 --- a/pkg/model/awsmodel/oidc_provider.go +++ b/pkg/model/awsmodel/oidc_provider.go @@ -47,7 +47,7 @@ func (b *OIDCProviderBuilder) Build(c *fi.CloudupModelBuilderContext) error { } c.AddTask(&awstasks.IAMOIDCProvider{ - Name: fi.PtrTo(b.ClusterName()), + Name: new(b.ClusterName()), Lifecycle: b.Lifecycle, URL: b.Cluster.Spec.KubeAPIServer.ServiceAccountIssuer, ClientIDs: audiences, diff --git a/pkg/model/awsmodel/spotinst.go b/pkg/model/awsmodel/spotinst.go index 1c101edca8002..cf31f9dacda7e 100644 --- a/pkg/model/awsmodel/spotinst.go +++ b/pkg/model/awsmodel/spotinst.go @@ -211,10 +211,10 @@ func (b *SpotInstanceGroupModelBuilder) buildElastigroup(c *fi.CloudupModelBuild klog.V(4).Infof("Building instance group as Elastigroup: %q", b.AutoscalingGroupName(ig)) group := &spotinsttasks.Elastigroup{ Lifecycle: b.Lifecycle, - Name: fi.PtrTo(b.AutoscalingGroupName(ig)), - Region: fi.PtrTo(b.Region), - ImageID: fi.PtrTo(ig.Spec.Image), - OnDemandInstanceType: fi.PtrTo(strings.Split(ig.Spec.MachineType, ",")[0]), + Name: new(b.AutoscalingGroupName(ig)), + Region: new(b.Region), + ImageID: new(ig.Spec.Image), + OnDemandInstanceType: new(strings.Split(ig.Spec.MachineType, ",")[0]), SpotInstanceTypes: strings.Split(ig.Spec.MachineType, ","), } @@ -240,7 +240,7 @@ func (b *SpotInstanceGroupModelBuilder) buildElastigroup(c *fi.CloudupModelBuild } case SpotInstanceGroupLabelOrientation: - group.Orientation = fi.PtrTo(v) + group.Orientation = new(v) case SpotInstanceGroupLabelUtilizeReservedInstances: group.UtilizeReservedInstances, err = parseBool(v) @@ -267,7 +267,7 @@ func (b *SpotInstanceGroupModelBuilder) buildElastigroup(c *fi.CloudupModelBuild } case SpotInstanceGroupLabelHealthCheckType: - group.HealthCheckType = fi.PtrTo(strings.ToUpper(v)) + group.HealthCheckType = new(strings.ToUpper(v)) } } @@ -290,7 +290,7 @@ func (b *SpotInstanceGroupModelBuilder) buildElastigroup(c *fi.CloudupModelBuild // Tenancy. if ig.Spec.Tenancy != "" { - group.Tenancy = fi.PtrTo(ig.Spec.Tenancy) + group.Tenancy = new(ig.Spec.Tenancy) } // Security groups. @@ -363,11 +363,11 @@ func (b *SpotInstanceGroupModelBuilder) buildOcean(c *fi.CloudupModelBuilderCont klog.V(4).Infof("Building instance group as Ocean: %q", "nodes."+b.ClusterName()) ocean := &spotinsttasks.Ocean{ Lifecycle: b.Lifecycle, - Name: fi.PtrTo("nodes." + b.ClusterName()), + Name: new("nodes." + b.ClusterName()), } if featureflag.SpotinstOceanTemplate.Enabled() { - ocean.UseAsTemplateOnly = fi.PtrTo(true) + ocean.UseAsTemplateOnly = new(true) } if len(igs) == 0 { @@ -402,9 +402,9 @@ func (b *SpotInstanceGroupModelBuilder) buildOcean(c *fi.CloudupModelBuilderCont for k, v := range b.Cluster.Labels { switch k { case SpotClusterLabelSpreadNodesBy: - ocean.SpreadNodesBy = fi.PtrTo(v) + ocean.SpreadNodesBy = new(v) case SpotClusterLabelStrategyClusterOrientationAvailabilityVsCost: - ocean.AvailabilityVsCost = fi.PtrTo(string(spotinsttasks.NormalizeClusterOrientation(&v))) + ocean.AvailabilityVsCost = new(string(spotinsttasks.NormalizeClusterOrientation(&v))) case SpotClusterLabelResourceTagSpecificationVolumes: ocean.ResourceTagSpecificationVolumes, err = parseBool(v) if err != nil { @@ -419,7 +419,7 @@ func (b *SpotInstanceGroupModelBuilder) buildOcean(c *fi.CloudupModelBuilderCont } // Image. - ocean.ImageID = fi.PtrTo(ig.Spec.Image) + ocean.ImageID = new(ig.Spec.Image) // Strategy and instance types. for k, v := range ig.ObjectMeta.Labels { @@ -505,8 +505,8 @@ func (b *SpotInstanceGroupModelBuilder) buildOcean(c *fi.CloudupModelBuilderCont if !fi.ValueOf(ocean.UseAsTemplateOnly) { // Capacity. - ocean.MinSize = fi.PtrTo(int64(0)) - ocean.MaxSize = fi.PtrTo(int64(0)) + ocean.MinSize = new(int64(0)) + ocean.MaxSize = new(int64(0)) // User data. ocean.UserData, err = b.BootstrapScriptBuilder.ResourceNodeUp(c, ig) @@ -560,9 +560,9 @@ func (b *SpotInstanceGroupModelBuilder) buildLaunchSpec(c *fi.CloudupModelBuilde ig, igOcean *kops.InstanceGroup, ocean *spotinsttasks.Ocean) (err error) { klog.V(4).Infof("Building instance group as LaunchSpec: %q", b.AutoscalingGroupName(ig)) launchSpec := &spotinsttasks.LaunchSpec{ - Name: fi.PtrTo(b.AutoscalingGroupName(ig)), + Name: new(b.AutoscalingGroupName(ig)), Lifecycle: b.Lifecycle, - ImageID: fi.PtrTo(ig.Spec.Image), + ImageID: new(ig.Spec.Image), Ocean: ocean, // link to Ocean } @@ -603,8 +603,8 @@ func (b *SpotInstanceGroupModelBuilder) buildLaunchSpec(c *fi.CloudupModelBuilde // Capacity. minSize, maxSize := b.buildCapacity(ig) if !fi.ValueOf(ocean.UseAsTemplateOnly) { - ocean.MinSize = fi.PtrTo(fi.ValueOf(ocean.MinSize) + fi.ValueOf(minSize)) - ocean.MaxSize = fi.PtrTo(fi.ValueOf(ocean.MaxSize) + fi.ValueOf(maxSize)) + ocean.MinSize = new(fi.ValueOf(ocean.MinSize) + fi.ValueOf(minSize)) + ocean.MaxSize = new(fi.ValueOf(ocean.MaxSize) + fi.ValueOf(maxSize)) } launchSpec.MinSize = minSize @@ -696,9 +696,9 @@ func (b *SpotInstanceGroupModelBuilder) buildSecurityGroups(c *fi.CloudupModelBu for _, id := range ig.Spec.AdditionalSecurityGroups { sg := &awstasks.SecurityGroup{ Lifecycle: b.SecurityLifecycle, - ID: fi.PtrTo(id), - Name: fi.PtrTo(id), - Shared: fi.PtrTo(true), + ID: new(id), + Name: new(id), + Shared: new(true), } c.EnsureTask(sg) securityGroups = append(securityGroups, sg) @@ -761,7 +761,7 @@ func (b *SpotInstanceGroupModelBuilder) buildPublicIPOpts(ig *kops.InstanceGroup return nil, fmt.Errorf("unknown subnet type %q", subnetType) } - return fi.PtrTo(associatePublicIP), nil + return new(associatePublicIP), nil } func (b *SpotInstanceGroupModelBuilder) buildRootVolumeOpts(ig *kops.InstanceGroup) (*spotinsttasks.RootVolumeOpts, error) { @@ -799,19 +799,19 @@ func (b *SpotInstanceGroupModelBuilder) buildRootVolumeOpts(ig *kops.InstanceGro return nil, err } } - opts.Size = fi.PtrTo(int64(size)) + opts.Size = new(int64(size)) if typ == "" { typ = "gp2" } - opts.Type = fi.PtrTo(typ) + opts.Type = new(typ) if iops > 0 { - opts.IOPS = fi.PtrTo(int64(iops)) + opts.IOPS = new(int64(iops)) } if throughput > 0 { - opts.Throughput = fi.PtrTo(int64(throughput)) + opts.Throughput = new(int64(throughput)) } return opts, nil @@ -832,7 +832,7 @@ func (b *SpotInstanceGroupModelBuilder) buildCapacity(ig *kops.InstanceGroup) (* maxSize = 2 } - return fi.PtrTo(int64(minSize)), fi.PtrTo(int64(maxSize)) + return new(int64(minSize)), new(int64(maxSize)) } func (b *SpotInstanceGroupModelBuilder) buildLoadBalancers(c *fi.CloudupModelBuilderContext, @@ -860,7 +860,7 @@ func (b *SpotInstanceGroupModelBuilder) buildLoadBalancers(c *fi.CloudupModelBui lb := &awstasks.ClassicLoadBalancer{ Name: extLB.LoadBalancerName, LoadBalancerName: extLB.LoadBalancerName, - Shared: fi.PtrTo(true), + Shared: new(true), } loadBalancers = append(loadBalancers, lb) c.EnsureTask(lb) @@ -871,9 +871,9 @@ func (b *SpotInstanceGroupModelBuilder) buildLoadBalancers(c *fi.CloudupModelBui return nil, nil, err } tg := &awstasks.TargetGroup{ - Name: fi.PtrTo(ig.Name + "-" + targetGroupName), + Name: new(ig.Name + "-" + targetGroupName), ARN: extLB.TargetGroupARN, - Shared: fi.PtrTo(true), + Shared: new(true), } targetGroups = append(targetGroups, tg) c.AddTask(tg) @@ -893,7 +893,7 @@ func (b *SpotInstanceGroupModelBuilder) buildTags(ig *kops.InstanceGroup) (map[s func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig *kops.InstanceGroup) (*spotinsttasks.AutoScalerOpts, error) { opts := &spotinsttasks.AutoScalerOpts{ - ClusterID: fi.PtrTo(clusterID), + ClusterID: new(clusterID), } switch ig.Spec.Role { @@ -905,8 +905,8 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig } // Enable the auto scaler for Node instance groups. - opts.Enabled = fi.PtrTo(true) - opts.AutoConfig = fi.PtrTo(true) + opts.Enabled = new(true) + opts.AutoConfig = new(true) // Parse instance group labels. var defaultNodeLabels bool @@ -918,7 +918,7 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig if err != nil { return nil, err } - opts.Enabled = fi.PtrTo(!fi.ValueOf(v)) + opts.Enabled = new(!fi.ValueOf(v)) } case SpotInstanceGroupLabelAutoScalerDefaultNodeLabels: @@ -936,7 +936,7 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig if err != nil { return nil, err } - opts.Cooldown = fi.PtrTo(int(fi.ValueOf(v))) + opts.Cooldown = new(int(fi.ValueOf(v))) } case SpotInstanceGroupLabelAutoScalerAutoConfig: @@ -954,7 +954,7 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig if err != nil { return nil, err } - opts.AutoHeadroomPercentage = fi.PtrTo(int(fi.ValueOf(v))) + opts.AutoHeadroomPercentage = new(int(fi.ValueOf(v))) } case SpotInstanceGroupLabelAutoScalerHeadroomCPUPerUnit: @@ -966,7 +966,7 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig if opts.Headroom == nil { opts.Headroom = new(spotinsttasks.AutoScalerHeadroomOpts) } - opts.Headroom.CPUPerUnit = fi.PtrTo(int(fi.ValueOf(v))) + opts.Headroom.CPUPerUnit = new(int(fi.ValueOf(v))) } case SpotInstanceGroupLabelAutoScalerHeadroomGPUPerUnit: @@ -978,7 +978,7 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig if opts.Headroom == nil { opts.Headroom = new(spotinsttasks.AutoScalerHeadroomOpts) } - opts.Headroom.GPUPerUnit = fi.PtrTo(int(fi.ValueOf(v))) + opts.Headroom.GPUPerUnit = new(int(fi.ValueOf(v))) } case SpotInstanceGroupLabelAutoScalerHeadroomMemPerUnit: @@ -990,7 +990,7 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig if opts.Headroom == nil { opts.Headroom = new(spotinsttasks.AutoScalerHeadroomOpts) } - opts.Headroom.MemPerUnit = fi.PtrTo(int(fi.ValueOf(v))) + opts.Headroom.MemPerUnit = new(int(fi.ValueOf(v))) } case SpotInstanceGroupLabelAutoScalerHeadroomNumOfUnits: @@ -1002,7 +1002,7 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig if opts.Headroom == nil { opts.Headroom = new(spotinsttasks.AutoScalerHeadroomOpts) } - opts.Headroom.NumOfUnits = fi.PtrTo(int(fi.ValueOf(v))) + opts.Headroom.NumOfUnits = new(int(fi.ValueOf(v))) } case SpotInstanceGroupLabelAutoScalerScaleDownMaxPercentage: @@ -1026,7 +1026,7 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig if opts.Down == nil { opts.Down = new(spotinsttasks.AutoScalerDownOpts) } - opts.Down.EvaluationPeriods = fi.PtrTo(int(fi.ValueOf(v))) + opts.Down.EvaluationPeriods = new(int(fi.ValueOf(v))) } case SpotInstanceGroupLabelAutoScalerResourceLimitsMaxVCPU: @@ -1038,7 +1038,7 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig if opts.ResourceLimits == nil { opts.ResourceLimits = new(spotinsttasks.AutoScalerResourceLimitsOpts) } - opts.ResourceLimits.MaxVCPU = fi.PtrTo(int(fi.ValueOf(v))) + opts.ResourceLimits.MaxVCPU = new(int(fi.ValueOf(v))) } case SpotInstanceGroupLabelAutoScalerResourceLimitsMaxMemory: @@ -1050,7 +1050,7 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig if opts.ResourceLimits == nil { opts.ResourceLimits = new(spotinsttasks.AutoScalerResourceLimitsOpts) } - opts.ResourceLimits.MaxMemory = fi.PtrTo(int(fi.ValueOf(v))) + opts.ResourceLimits.MaxMemory = new(int(fi.ValueOf(v))) } } } @@ -1058,10 +1058,10 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig // Configure Elastigroup defaults to avoid state drifts. if !featureflag.SpotinstOcean.Enabled() { if opts.Cooldown == nil { - opts.Cooldown = fi.PtrTo(300) + opts.Cooldown = new(300) } if opts.Down != nil && opts.Down.EvaluationPeriods == nil { - opts.Down.EvaluationPeriods = fi.PtrTo(5) + opts.Down.EvaluationPeriods = new(5) } } @@ -1092,8 +1092,8 @@ func (b *SpotInstanceGroupModelBuilder) buildAutoScalerOpts(clusterID string, ig func (b *SpotInstanceGroupModelBuilder) buildInstanceMetadataOptions(ig *kops.InstanceGroup) *spotinsttasks.InstanceMetadataOptions { if ig.Spec.InstanceMetadata != nil { opt := new(spotinsttasks.InstanceMetadataOptions) - opt.HTTPPutResponseHopLimit = fi.PtrTo(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit)) - opt.HTTPTokens = fi.PtrTo(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPTokens)) + opt.HTTPPutResponseHopLimit = new(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPPutResponseHopLimit)) + opt.HTTPTokens = new(fi.ValueOf(ig.Spec.InstanceMetadata.HTTPTokens)) return opt } return nil diff --git a/pkg/model/awsmodel/sshkey.go b/pkg/model/awsmodel/sshkey.go index 944340a0c7595..53a95d3796a4b 100644 --- a/pkg/model/awsmodel/sshkey.go +++ b/pkg/model/awsmodel/sshkey.go @@ -39,7 +39,7 @@ func (b *SSHKeyModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { return err } t := &awstasks.SSHKey{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, Tags: b.CloudTags(b.ClusterName(), false), Shared: fi.ValueOf(b.Cluster.Spec.SSHKeyName) != "", diff --git a/pkg/model/azuremodel/api_loadbalancer.go b/pkg/model/azuremodel/api_loadbalancer.go index a2aef6ae092eb..9bda5b8aaed9e 100644 --- a/pkg/model/azuremodel/api_loadbalancer.go +++ b/pkg/model/azuremodel/api_loadbalancer.go @@ -52,7 +52,7 @@ func (b *APILoadBalancerModelBuilder) Build(c *fi.CloudupModelBuilderContext) er // Create LoadBalancer for API ELB lb := &azuretasks.LoadBalancer{ - Name: fi.PtrTo(b.NameForLoadBalancer()), + Name: new(b.NameForLoadBalancer()), Lifecycle: b.Lifecycle, ResourceGroup: b.LinkToResourceGroup(), Tags: map[string]*string{}, @@ -90,7 +90,7 @@ func (b *APILoadBalancerModelBuilder) Build(c *fi.CloudupModelBuilderContext) er // Create Public IP Address for Public Loadbalacer p := &azuretasks.PublicIPAddress{ - Name: fi.PtrTo(b.NameForLoadBalancer()), + Name: new(b.NameForLoadBalancer()), Lifecycle: b.Lifecycle, ResourceGroup: b.LinkToResourceGroup(), IPVersion: network.IPVersionIPv4, @@ -112,7 +112,7 @@ func (b *APILoadBalancerModelBuilder) Build(c *fi.CloudupModelBuilderContext) er Name: fmt.Sprintf("Health-HTTPS-%d", wellknownports.KopsControllerPort), Protocol: network.ProbeProtocolHTTPS, Port: wellknownports.KopsControllerPort, - RequestPath: fi.PtrTo("/healthz"), + RequestPath: new("/healthz"), IntervalInSeconds: 15, NumberOfProbes: 4, }) diff --git a/pkg/model/azuremodel/context.go b/pkg/model/azuremodel/context.go index dedbc27bf6438..d4476856d07d0 100644 --- a/pkg/model/azuremodel/context.go +++ b/pkg/model/azuremodel/context.go @@ -23,7 +23,6 @@ import ( "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/model" nodeidentityazure "k8s.io/kops/pkg/nodeidentity/azure" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/azure" "k8s.io/kops/upup/pkg/fi/cloudup/azuretasks" ) @@ -35,7 +34,7 @@ type AzureModelContext struct { // LinkToVirtualNetwork returns the Azure Virtual Network object the cluster is located in. func (c *AzureModelContext) LinkToVirtualNetwork() *azuretasks.VirtualNetwork { - return &azuretasks.VirtualNetwork{Name: fi.PtrTo(c.NameForVirtualNetwork())} + return &azuretasks.VirtualNetwork{Name: new(c.NameForVirtualNetwork())} } // NameForVirtualNetwork returns the name of the Azure Virtual Network object the cluster is located in. @@ -49,7 +48,7 @@ func (c *AzureModelContext) NameForVirtualNetwork() string { // LinkToResourceGroup returns the Resource Group object the cluster is located in. func (c *AzureModelContext) LinkToResourceGroup() *azuretasks.ResourceGroup { - return &azuretasks.ResourceGroup{Name: fi.PtrTo(c.NameForResourceGroup())} + return &azuretasks.ResourceGroup{Name: new(c.NameForResourceGroup())} } // NameForResourceGroup returns the name of the Resource Group object the cluster is located in. @@ -59,7 +58,7 @@ func (c *AzureModelContext) NameForResourceGroup() string { // LinkToAzureSubnet returns the Azure Subnet object the cluster is located in. func (c *AzureModelContext) LinkToAzureSubnet(spec *kops.ClusterSubnetSpec) *azuretasks.Subnet { - return &azuretasks.Subnet{Name: fi.PtrTo(spec.Name)} + return &azuretasks.Subnet{Name: new(spec.Name)} } // NameForRouteTable returns the name of the Route Table object for the cluster. @@ -69,7 +68,7 @@ func (c *AzureModelContext) NameForRouteTable() string { // LinkToLoadBalancer returns the Load Balancer object for the cluster. func (c *AzureModelContext) LinkToLoadBalancer() *azuretasks.LoadBalancer { - return &azuretasks.LoadBalancer{Name: fi.PtrTo(c.NameForLoadBalancer())} + return &azuretasks.LoadBalancer{Name: new(c.NameForLoadBalancer())} } // NameForLoadBalancer returns the name of the Load Balancer object for the cluster. @@ -89,12 +88,12 @@ func (c *AzureModelContext) NameForApplicationSecurityGroupNodes() string { // LinkToApplicationSecurityGroupControlPlane returns the Application Security Group object for the ControlPlane role. func (c *AzureModelContext) LinkToApplicationSecurityGroupControlPlane() *azuretasks.ApplicationSecurityGroup { - return &azuretasks.ApplicationSecurityGroup{Name: fi.PtrTo(c.NameForApplicationSecurityGroupControlPlane())} + return &azuretasks.ApplicationSecurityGroup{Name: new(c.NameForApplicationSecurityGroupControlPlane())} } // LinkToApplicationSecurityGroupNodes returns the Application Security Group object for the Node role. func (c *AzureModelContext) LinkToApplicationSecurityGroupNodes() *azuretasks.ApplicationSecurityGroup { - return &azuretasks.ApplicationSecurityGroup{Name: fi.PtrTo(c.NameForApplicationSecurityGroupNodes())} + return &azuretasks.ApplicationSecurityGroup{Name: new(c.NameForApplicationSecurityGroupNodes())} } // CloudTagsForInstanceGroup computes the tags to apply to instances in the specified InstanceGroup @@ -146,7 +145,7 @@ func (c *AzureModelContext) CloudTagsForInstanceGroup(ig *kops.InstanceGroup) ma // Replace all "/" with "_" as "/" is not an allowed key character in Azure. m := make(map[string]*string) for k, v := range labels { - m[strings.ReplaceAll(k, "/", "_")] = fi.PtrTo(v) + m[strings.ReplaceAll(k, "/", "_")] = new(v) } return m } diff --git a/pkg/model/azuremodel/context_test.go b/pkg/model/azuremodel/context_test.go index 57cddef24bb3d..7bde3ae6287ea 100644 --- a/pkg/model/azuremodel/context_test.go +++ b/pkg/model/azuremodel/context_test.go @@ -19,8 +19,6 @@ package azuremodel import ( "reflect" "testing" - - "k8s.io/kops/upup/pkg/fi" ) func TestCloudTagsForInstanceGroup(t *testing.T) { @@ -43,13 +41,13 @@ func TestCloudTagsForInstanceGroup(t *testing.T) { actual := c.CloudTagsForInstanceGroup(c.InstanceGroups[0]) expected := map[string]*string{ - "cluster_label_key": fi.PtrTo("cluster_label_value"), - "ig_label_key": fi.PtrTo("ig_label_value"), - "test_label": fi.PtrTo("from_ig"), - "k8s.io_cluster_node-template_label_0": fi.PtrTo("node_label/key=node_label_value"), - "k8s.io_cluster_node-template_taint_taint_key": fi.PtrTo("taint_value"), - "k8s.io_role_node": fi.PtrTo("1"), - "kops.k8s.io_instancegroup": fi.PtrTo("nodes"), + "cluster_label_key": new("cluster_label_value"), + "ig_label_key": new("ig_label_value"), + "test_label": new("from_ig"), + "k8s.io_cluster_node-template_label_0": new("node_label/key=node_label_value"), + "k8s.io_cluster_node-template_taint_taint_key": new("taint_value"), + "k8s.io_role_node": new("1"), + "kops.k8s.io_instancegroup": new("nodes"), } if !reflect.DeepEqual(actual, expected) { diff --git a/pkg/model/azuremodel/network.go b/pkg/model/azuremodel/network.go index 52ebc454225d0..05be933e4b53b 100644 --- a/pkg/model/azuremodel/network.go +++ b/pkg/model/azuremodel/network.go @@ -38,17 +38,17 @@ var _ fi.CloudupModelBuilder = &NetworkModelBuilder{} // Build builds tasks for creating a virtual network and subnets. func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { networkTask := &azuretasks.VirtualNetwork{ - Name: fi.PtrTo(b.NameForVirtualNetwork()), + Name: new(b.NameForVirtualNetwork()), Lifecycle: b.Lifecycle, ResourceGroup: b.LinkToResourceGroup(), - CIDR: fi.PtrTo(b.Cluster.Spec.Networking.NetworkCIDR), + CIDR: new(b.Cluster.Spec.Networking.NetworkCIDR), Tags: map[string]*string{}, - Shared: fi.PtrTo(b.Cluster.SharedVPC()), + Shared: new(b.Cluster.SharedVPC()), } c.AddTask(networkTask) ngwPipTask := &azuretasks.PublicIPAddress{ - Name: fi.PtrTo(b.NameForVirtualNetwork()), + Name: new(b.NameForVirtualNetwork()), Lifecycle: b.Lifecycle, ResourceGroup: b.LinkToResourceGroup(), IPVersion: network.IPVersionIPv4, @@ -59,7 +59,7 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { c.AddTask(ngwPipTask) nsgTask := &azuretasks.NetworkSecurityGroup{ - Name: fi.PtrTo(b.Cluster.AzureNetworkSecurityGroupName()), + Name: new(b.Cluster.AzureNetworkSecurityGroupName()), Lifecycle: b.Lifecycle, ResourceGroup: b.LinkToResourceGroup(), ApplicationSecurityGroups: []*azuretasks.ApplicationSecurityGroup{ @@ -71,140 +71,140 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { sshAccessIPv4 := ipv4CIDRs(b.Cluster.Spec.SSHAccess) if len(sshAccessIPv4) > 0 { nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowSSH"), - Priority: fi.PtrTo[int32](100), + Name: new("AllowSSH"), + Priority: new(int32(100)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolTCP, SourceAddressPrefixes: sshAccessIPv4, - SourcePortRange: fi.PtrTo("*"), + SourcePortRange: new("*"), DestinationApplicationSecurityGroupNames: []*string{ - fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane()), - fi.PtrTo(b.NameForApplicationSecurityGroupNodes()), + new(b.NameForApplicationSecurityGroupControlPlane()), + new(b.NameForApplicationSecurityGroupNodes()), }, - DestinationPortRange: fi.PtrTo("22"), + DestinationPortRange: new("22"), }) } sshAccessIPv6 := ipv6CIDRs(b.Cluster.Spec.SSHAccess) if len(sshAccessIPv6) > 0 { nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowSSH_v6"), - Priority: fi.PtrTo[int32](101), + Name: new("AllowSSH_v6"), + Priority: new(int32(101)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolTCP, SourceAddressPrefixes: sshAccessIPv6, - SourcePortRange: fi.PtrTo("*"), + SourcePortRange: new("*"), DestinationApplicationSecurityGroupNames: []*string{ - fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane()), - fi.PtrTo(b.NameForApplicationSecurityGroupNodes()), + new(b.NameForApplicationSecurityGroupControlPlane()), + new(b.NameForApplicationSecurityGroupNodes()), }, - DestinationPortRange: fi.PtrTo("22"), + DestinationPortRange: new("22"), }) } k8sAccessIPv4 := ipv4CIDRs(b.Cluster.Spec.API.Access) if len(k8sAccessIPv4) > 0 { nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowKubernetesAPI"), - Priority: fi.PtrTo[int32](200), + Name: new("AllowKubernetesAPI"), + Priority: new(int32(200)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolTCP, SourceAddressPrefixes: k8sAccessIPv4, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - DestinationPortRange: fi.PtrTo(strconv.Itoa(wellknownports.KubeAPIServer)), + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + DestinationPortRange: new(strconv.Itoa(wellknownports.KubeAPIServer)), }) } k8sAccessIPv6 := ipv6CIDRs(b.Cluster.Spec.API.Access) if len(k8sAccessIPv6) > 0 { nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowKubernetesAPI_v6"), - Priority: fi.PtrTo[int32](201), + Name: new("AllowKubernetesAPI_v6"), + Priority: new(int32(201)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolTCP, SourceAddressPrefixes: k8sAccessIPv6, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - DestinationPortRange: fi.PtrTo(strconv.Itoa(wellknownports.KubeAPIServer)), + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + DestinationPortRange: new(strconv.Itoa(wellknownports.KubeAPIServer)), }) } nodePortAccessIPv4 := ipv4CIDRs(b.Cluster.Spec.NodePortAccess) if len(nodePortAccessIPv4) > 0 { nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowNodePortTCP"), - Priority: fi.PtrTo[int32](300), + Name: new("AllowNodePortTCP"), + Priority: new(int32(300)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolAsterisk, SourceAddressPrefixes: nodePortAccessIPv4, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupNodes())}, - DestinationPortRange: fi.PtrTo("30000-32767"), + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupNodes())}, + DestinationPortRange: new("30000-32767"), }) } nodePortAccessIPv6 := ipv6CIDRs(b.Cluster.Spec.NodePortAccess) if len(nodePortAccessIPv6) > 0 { nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowNodePortTCP_v6"), - Priority: fi.PtrTo[int32](301), + Name: new("AllowNodePortTCP_v6"), + Priority: new(int32(301)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolAsterisk, SourceAddressPrefixes: nodePortAccessIPv6, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupNodes())}, - DestinationPortRange: fi.PtrTo("30000-32767"), + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupNodes())}, + DestinationPortRange: new("30000-32767"), }) } nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowControlPlaneToControlPlane"), - Priority: fi.PtrTo[int32](1000), + Name: new("AllowControlPlaneToControlPlane"), + Priority: new(int32(1000)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolAsterisk, - SourceApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - DestinationPortRange: fi.PtrTo("*"), + SourceApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + DestinationPortRange: new("*"), }) nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowControlPlaneToNodes"), - Priority: fi.PtrTo[int32](1001), + Name: new("AllowControlPlaneToNodes"), + Priority: new(int32(1001)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolAsterisk, - SourceApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupNodes())}, - DestinationPortRange: fi.PtrTo("*"), + SourceApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupNodes())}, + DestinationPortRange: new("*"), }) nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowNodesToNodes"), - Priority: fi.PtrTo[int32](1002), + Name: new("AllowNodesToNodes"), + Priority: new(int32(1002)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolAsterisk, - SourceApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupNodes())}, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupNodes())}, - DestinationPortRange: fi.PtrTo("*"), + SourceApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupNodes())}, + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupNodes())}, + DestinationPortRange: new("*"), }) // Kindnet preserves pod-CIDR source IPs to host services; Azure NSG ASG // matching needs an explicit allow since pod IPs aren't NIC-assigned. // Scoped to nodes to keep DenyAllToControlPlane and the etcd denies effective. if b.Cluster.Spec.Networking.Kindnet != nil && b.Cluster.Spec.Networking.PodCIDR != "" { nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowPodCIDRToNodes"), - Priority: fi.PtrTo[int32](1006), + Name: new("AllowPodCIDRToNodes"), + Priority: new(int32(1006)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolAsterisk, - SourceAddressPrefix: fi.PtrTo(b.Cluster.Spec.Networking.PodCIDR), - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupNodes())}, - DestinationPortRange: fi.PtrTo("*"), + SourceAddressPrefix: new(b.Cluster.Spec.Networking.PodCIDR), + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupNodes())}, + DestinationPortRange: new("*"), }) } etcdPeerMax := wellknownports.EtcdEventsPeerPort @@ -215,101 +215,101 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { } } nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("DenyNodesToEtcdManager"), - Priority: fi.PtrTo[int32](1003), + Name: new("DenyNodesToEtcdManager"), + Priority: new(int32(1003)), Access: network.SecurityRuleAccessDeny, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolTCP, - SourceApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupNodes())}, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - DestinationPortRange: fi.PtrTo(strconv.Itoa(wellknownports.EtcdMainPeerPort) + "-" + strconv.Itoa(etcdPeerMax)), + SourceApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupNodes())}, + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + DestinationPortRange: new(strconv.Itoa(wellknownports.EtcdMainPeerPort) + "-" + strconv.Itoa(etcdPeerMax)), }) nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("DenyNodesToEtcd"), - Priority: fi.PtrTo[int32](1004), + Name: new("DenyNodesToEtcd"), + Priority: new(int32(1004)), Access: network.SecurityRuleAccessDeny, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolTCP, - SourceApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupNodes())}, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - DestinationPortRange: fi.PtrTo(strconv.Itoa(wellknownports.ProtokubeGossipMemberlist) + "-" + strconv.Itoa(wellknownports.EtcdMainClientPort)), + SourceApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupNodes())}, + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + DestinationPortRange: new(strconv.Itoa(wellknownports.ProtokubeGossipMemberlist) + "-" + strconv.Itoa(wellknownports.EtcdMainClientPort)), }) nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowNodesToControlPlane"), - Priority: fi.PtrTo[int32](1005), + Name: new("AllowNodesToControlPlane"), + Priority: new(int32(1005)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolAsterisk, - SourceApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupNodes())}, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - DestinationPortRange: fi.PtrTo("*"), + SourceApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupNodes())}, + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + DestinationPortRange: new("*"), }) if b.Cluster.UsesLoadBalancerForKopsController() && b.Cluster.Spec.API.LoadBalancer != nil && b.Cluster.Spec.API.LoadBalancer.Type == kops.LoadBalancerTypePublic { // Node traffic to the public load balancer frontend egresses through the NAT gateway, so it // arrives with the NAT gateway public IP as its source and cannot be matched by the nodes ASG. nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowNodesToKubernetesAPI"), - Priority: fi.PtrTo[int32](2000), + Name: new("AllowNodesToKubernetesAPI"), + Priority: new(int32(2000)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolTCP, SourcePublicIPAddress: ngwPipTask, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - DestinationPortRange: fi.PtrTo(strconv.Itoa(wellknownports.KubeAPIServer)), + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + DestinationPortRange: new(strconv.Itoa(wellknownports.KubeAPIServer)), }) nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowNodesToKopsController"), - Priority: fi.PtrTo[int32](2001), + Name: new("AllowNodesToKopsController"), + Priority: new(int32(2001)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolTCP, SourcePublicIPAddress: ngwPipTask, - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - DestinationPortRange: fi.PtrTo(strconv.Itoa(wellknownports.KopsControllerPort)), + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + DestinationPortRange: new(strconv.Itoa(wellknownports.KopsControllerPort)), }) } nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("AllowAzureLoadBalancer"), - Priority: fi.PtrTo[int32](4000), + Name: new("AllowAzureLoadBalancer"), + Priority: new(int32(4000)), Access: network.SecurityRuleAccessAllow, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolAsterisk, - SourceAddressPrefix: fi.PtrTo("AzureLoadBalancer"), - SourcePortRange: fi.PtrTo("*"), - DestinationAddressPrefix: fi.PtrTo("VirtualNetwork"), - DestinationPortRange: fi.PtrTo("*"), + SourceAddressPrefix: new("AzureLoadBalancer"), + SourcePortRange: new("*"), + DestinationAddressPrefix: new("VirtualNetwork"), + DestinationPortRange: new("*"), }) nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("DenyAllToControlPlane"), - Priority: fi.PtrTo[int32](4001), + Name: new("DenyAllToControlPlane"), + Priority: new(int32(4001)), Access: network.SecurityRuleAccessDeny, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolAsterisk, - SourceAddressPrefix: fi.PtrTo("*"), - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane())}, - DestinationPortRange: fi.PtrTo("*"), + SourceAddressPrefix: new("*"), + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupControlPlane())}, + DestinationPortRange: new("*"), }) nsgTask.SecurityRules = append(nsgTask.SecurityRules, &azuretasks.NetworkSecurityRule{ - Name: fi.PtrTo("DenyAllToNodes"), - Priority: fi.PtrTo[int32](4002), + Name: new("DenyAllToNodes"), + Priority: new(int32(4002)), Access: network.SecurityRuleAccessDeny, Direction: network.SecurityRuleDirectionInbound, Protocol: network.SecurityRuleProtocolAsterisk, - SourceAddressPrefix: fi.PtrTo("*"), - SourcePortRange: fi.PtrTo("*"), - DestinationApplicationSecurityGroupNames: []*string{fi.PtrTo(b.NameForApplicationSecurityGroupNodes())}, - DestinationPortRange: fi.PtrTo("*"), + SourceAddressPrefix: new("*"), + SourcePortRange: new("*"), + DestinationApplicationSecurityGroupNames: []*string{new(b.NameForApplicationSecurityGroupNodes())}, + DestinationPortRange: new("*"), }) c.AddTask(nsgTask) ngwTask := &azuretasks.NatGateway{ - Name: fi.PtrTo(b.NameForVirtualNetwork()), + Name: new(b.NameForVirtualNetwork()), Lifecycle: b.Lifecycle, PublicIPAddresses: []*azuretasks.PublicIPAddress{ngwPipTask}, ResourceGroup: b.LinkToResourceGroup(), @@ -319,25 +319,25 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { c.AddTask(ngwTask) rtTask := &azuretasks.RouteTable{ - Name: fi.PtrTo(b.NameForRouteTable()), + Name: new(b.NameForRouteTable()), Lifecycle: b.Lifecycle, ResourceGroup: b.LinkToResourceGroup(), Tags: map[string]*string{}, - Shared: fi.PtrTo(b.Cluster.IsSharedAzureRouteTable()), + Shared: new(b.Cluster.IsSharedAzureRouteTable()), } c.AddTask(rtTask) for _, subnetSpec := range b.Cluster.Spec.Networking.Subnets { subnetTask := &azuretasks.Subnet{ - Name: fi.PtrTo(subnetSpec.Name), + Name: new(subnetSpec.Name), Lifecycle: b.Lifecycle, ResourceGroup: b.LinkToResourceGroup(), VirtualNetwork: b.LinkToVirtualNetwork(), NatGateway: ngwTask, NetworkSecurityGroup: nsgTask, RouteTable: rtTask, - CIDR: fi.PtrTo(subnetSpec.CIDR), - Shared: fi.PtrTo(b.Cluster.SharedVPC()), + CIDR: new(subnetSpec.CIDR), + Shared: new(b.Cluster.SharedVPC()), } c.AddTask(subnetTask) } diff --git a/pkg/model/azuremodel/resourcegroup.go b/pkg/model/azuremodel/resourcegroup.go index da0c34cd39f14..b3832dbf00e11 100644 --- a/pkg/model/azuremodel/resourcegroup.go +++ b/pkg/model/azuremodel/resourcegroup.go @@ -32,10 +32,10 @@ var _ fi.CloudupModelBuilder = &ResourceGroupModelBuilder{} // Build builds a task for creating a Resource Group. func (b *ResourceGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { t := &azuretasks.ResourceGroup{ - Name: fi.PtrTo(b.NameForResourceGroup()), + Name: new(b.NameForResourceGroup()), Lifecycle: b.Lifecycle, Tags: map[string]*string{}, - Shared: fi.PtrTo(b.Cluster.IsSharedAzureResourceGroup()), + Shared: new(b.Cluster.IsSharedAzureResourceGroup()), } c.AddTask(t) return nil diff --git a/pkg/model/azuremodel/testing.go b/pkg/model/azuremodel/testing.go index d91f3b2cc4ffc..34b51ea1a9e79 100644 --- a/pkg/model/azuremodel/testing.go +++ b/pkg/model/azuremodel/testing.go @@ -21,7 +21,6 @@ import ( "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/model" "k8s.io/kops/pkg/model/iam" - "k8s.io/kops/upup/pkg/fi" ) func newTestAzureModelContext() *AzureModelContext { @@ -80,7 +79,7 @@ func newTestInstanceGroup() *kops.InstanceGroup { Role: kops.InstanceGroupRoleNode, Image: "Canonical:UbuntuServer:18.04-LTS:latest", RootVolume: &kops.InstanceRootVolumeSpec{ - Size: fi.PtrTo(int32(32)), + Size: new(int32(32)), }, Subnets: []string{"test-subnet"}, }, diff --git a/pkg/model/azuremodel/vmscaleset.go b/pkg/model/azuremodel/vmscaleset.go index 50ea969cf7d5a..87d772bc0d1e1 100644 --- a/pkg/model/azuremodel/vmscaleset.go +++ b/pkg/model/azuremodel/vmscaleset.go @@ -42,13 +42,13 @@ var _ fi.CloudupModelBuilder = &VMScaleSetModelBuilder{} // Build is responsible for constructing the VM ScaleSet from the kops spec. func (b *VMScaleSetModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { c.AddTask(&azuretasks.ApplicationSecurityGroup{ - Name: fi.PtrTo(b.NameForApplicationSecurityGroupControlPlane()), + Name: new(b.NameForApplicationSecurityGroupControlPlane()), Lifecycle: b.Lifecycle, ResourceGroup: b.LinkToResourceGroup(), Tags: map[string]*string{}, }) c.AddTask(&azuretasks.ApplicationSecurityGroup{ - Name: fi.PtrTo(b.NameForApplicationSecurityGroupNodes()), + Name: new(b.NameForApplicationSecurityGroupNodes()), Lifecycle: b.Lifecycle, ResourceGroup: b.LinkToResourceGroup(), Tags: map[string]*string{}, @@ -105,13 +105,13 @@ func (b *VMScaleSetModelBuilder) buildVMScaleSetTask( azNumbers = append(azNumbers, &az) } t := &azuretasks.VMScaleSet{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, ResourceGroup: b.LinkToResourceGroup(), VirtualNetwork: b.LinkToVirtualNetwork(), - SKUName: fi.PtrTo(ig.Spec.MachineType), - ComputerNamePrefix: fi.PtrTo(ig.Name), - AdminUser: fi.PtrTo(b.Cluster.Spec.CloudProvider.Azure.AdminUser), + SKUName: new(ig.Spec.MachineType), + ComputerNamePrefix: new(ig.Name), + AdminUser: new(b.Cluster.Spec.CloudProvider.Azure.AdminUser), Zones: azNumbers, } @@ -141,7 +141,7 @@ func (b *VMScaleSetModelBuilder) buildVMScaleSetTask( if n > 1 { return nil, fmt.Errorf("expected at most one SSH public key; found %d keys", n) } - t.SSHPublicKey = fi.PtrTo(string(b.SSHPublicKeys[0])) + t.SSHPublicKey = new(string(b.SSHPublicKeys[0])) } if t.UserData, err = b.BootstrapScriptBuilder.ResourceNodeUp(c, ig); err != nil { @@ -160,12 +160,12 @@ func (b *VMScaleSetModelBuilder) buildVMScaleSetTask( switch subnet.Type { case kops.SubnetTypePublic, kops.SubnetTypeUtility: - t.RequirePublicIP = fi.PtrTo(true) + t.RequirePublicIP = new(true) if ig.Spec.AssociatePublicIP != nil { t.RequirePublicIP = ig.Spec.AssociatePublicIP } case kops.SubnetTypeDualStack, kops.SubnetTypePrivate: - t.RequirePublicIP = fi.PtrTo(false) + t.RequirePublicIP = new(false) default: return nil, fmt.Errorf("unexpected subnet type: for InstanceGroup %q; type was %s", ig.Name, subnet.Type) } @@ -198,7 +198,7 @@ func getCapacity(spec *kops.InstanceGroupSpec) (*int64, error) { if minSize != maxSize { return nil, fmt.Errorf("instance group must have the same min and max size in Azure, but got %d and %d", minSize, maxSize) } - return fi.PtrTo(int64(minSize)), nil + return new(int64(minSize)), nil } func getStorageProfile(spec *kops.InstanceGroupSpec) (*compute.VirtualMachineScaleSetStorageProfile, error) { diff --git a/pkg/model/azuremodel/vmscaleset_test.go b/pkg/model/azuremodel/vmscaleset_test.go index 3d8a08430c9f8..17da01089db27 100644 --- a/pkg/model/azuremodel/vmscaleset_test.go +++ b/pkg/model/azuremodel/vmscaleset_test.go @@ -52,13 +52,13 @@ func TestVMScaleSetModelBuilder_Build(t *testing.T) { } caTask := &fitasks.Keypair{ - Name: fi.PtrTo(fi.CertificateIDCA), + Name: new(fi.CertificateIDCA), Subject: "cn=kubernetes", Type: "ca", } c.AddTask(caTask) etcdCaTask := &fitasks.Keypair{ - Name: fi.PtrTo("etcd-clients-ca"), + Name: new("etcd-clients-ca"), Subject: "cn=etcd-clients-ca", Type: "ca", } @@ -68,7 +68,7 @@ func TestVMScaleSetModelBuilder_Build(t *testing.T) { "kube-proxy", } { c.AddTask(&fitasks.Keypair{ - Name: fi.PtrTo(cert), + Name: new(cert), Subject: "cn=" + cert, Signer: caTask, Type: "client", @@ -90,8 +90,8 @@ func TestGetCapacity(t *testing.T) { { spec: kops.InstanceGroupSpec{ Role: kops.InstanceGroupRoleControlPlane, - MinSize: fi.PtrTo(int32(3)), - MaxSize: fi.PtrTo(int32(3)), + MinSize: new(int32(3)), + MaxSize: new(int32(3)), }, success: true, capacity: 3, @@ -113,8 +113,8 @@ func TestGetCapacity(t *testing.T) { { spec: kops.InstanceGroupSpec{ Role: kops.InstanceGroupRoleControlPlane, - MinSize: fi.PtrTo(int32(1)), - MaxSize: fi.PtrTo(int32(2)), + MinSize: new(int32(1)), + MaxSize: new(int32(2)), }, success: false, }, @@ -149,8 +149,8 @@ func TestGetStorageProfile(t *testing.T) { spec: kops.InstanceGroupSpec{ Image: "Canonical:UbuntuServer:18.04-LTS:latest", RootVolume: &kops.InstanceRootVolumeSpec{ - Type: fi.PtrTo(string(compute.StorageAccountTypesUltraSSDLRS)), - Size: fi.PtrTo(int32(128)), + Type: new(string(compute.StorageAccountTypesUltraSSDLRS)), + Size: new(int32(128)), }, }, profile: &compute.VirtualMachineScaleSetStorageProfile{ diff --git a/pkg/model/bootstrapscript.go b/pkg/model/bootstrapscript.go index 55451c19b791f..a06bd3a81c249 100644 --- a/pkg/model/bootstrapscript.go +++ b/pkg/model/bootstrapscript.go @@ -245,16 +245,16 @@ func (b *BootstrapScriptBuilder) ResourceNodeUp(c *fi.CloudupModelBuilderContext c.AddTask(task) c.AddTask(&fitasks.ManagedFile{ - Name: fi.PtrTo("nodeupconfig-" + ig.Name), + Name: new("nodeupconfig-" + ig.Name), Lifecycle: b.Lifecycle, - Location: fi.PtrTo("igconfig/" + ig.Spec.Role.ToLowerString() + "/" + ig.Name + "/nodeupconfig.yaml"), + Location: new("igconfig/" + ig.Spec.Role.ToLowerString() + "/" + ig.Name + "/nodeupconfig.yaml"), Contents: &task.nodeupConfig, }) if ig.Spec.Manager == kops.InstanceManagerKarpenter { c.AddTask(&fitasks.ManagedFile{ - Name: fi.PtrTo("nodeupscript-" + ig.Name), + Name: new("nodeupscript-" + ig.Name), Lifecycle: b.Lifecycle, - Location: fi.PtrTo("igconfig/" + ig.Spec.Role.ToLowerString() + "/" + ig.Name + "/nodeupscript.sh"), + Location: new("igconfig/" + ig.Spec.Role.ToLowerString() + "/" + ig.Name + "/nodeupscript.sh"), Contents: &task.nodeupScript, }) } diff --git a/pkg/model/bootstrapscript_test.go b/pkg/model/bootstrapscript_test.go index 44a573ec9d947..e40362494cb48 100644 --- a/pkg/model/bootstrapscript_test.go +++ b/pkg/model/bootstrapscript_test.go @@ -146,7 +146,7 @@ func TestBootstrapUserData(t *testing.T) { } caTask := &fitasks.Keypair{ - Name: fi.PtrTo(fi.CertificateIDCA), + Name: new(fi.CertificateIDCA), Subject: "cn=kubernetes", Type: "ca", } @@ -165,7 +165,7 @@ func TestBootstrapUserData(t *testing.T) { "service-account", } { task := &fitasks.Keypair{ - Name: fi.PtrTo(keypair), + Name: new(keypair), Subject: "cn=" + keypair, Type: "ca", } @@ -233,7 +233,7 @@ func makeTestCluster(hookSpecRoles []kops.InstanceGroupRole, fileAssetSpecRoles Members: []kops.EtcdMemberSpec{ { Name: "test", - InstanceGroup: fi.PtrTo("ig-1"), + InstanceGroup: new("ig-1"), }, }, Version: "3.1.11", @@ -243,7 +243,7 @@ func makeTestCluster(hookSpecRoles []kops.InstanceGroupRole, fileAssetSpecRoles Members: []kops.EtcdMemberSpec{ { Name: "test", - InstanceGroup: fi.PtrTo("ig-1"), + InstanceGroup: new("ig-1"), }, }, Version: "3.1.11", @@ -251,7 +251,7 @@ func makeTestCluster(hookSpecRoles []kops.InstanceGroupRole, fileAssetSpecRoles }, }, Containerd: &kops.ContainerdConfig{ - LogLevel: fi.PtrTo("info"), + LogLevel: new("info"), }, KubeAPIServer: &kops.KubeAPIServerConfig{ Image: "CoreOS", diff --git a/pkg/model/components/apiserver.go b/pkg/model/components/apiserver.go index 30ea6a81af7f6..2963a91b6ffb3 100644 --- a/pkg/model/components/apiserver.go +++ b/pkg/model/components/apiserver.go @@ -51,7 +51,7 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(cluster *kops.Cluster) error if count == 0 { return fmt.Errorf("no instance groups found") } - c.APIServerCount = fi.PtrTo(int32(count)) + c.APIServerCount = new(int32(count)) } // @question: should the question every be able to set this? @@ -62,7 +62,7 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(cluster *kops.Cluster) error if err != nil { return err } - c.StorageBackend = fi.PtrTo(fmt.Sprintf("etcd%d", sem.Major)) + c.StorageBackend = new(fmt.Sprintf("etcd%d", sem.Major)) } if c.KubeletPreferredAddressTypes == nil { @@ -76,7 +76,7 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(cluster *kops.Cluster) error if clusterSpec.Authentication != nil { if clusterSpec.Authentication.Kopeio != nil { - c.AuthenticationTokenWebhookConfigFile = fi.PtrTo("/etc/kubernetes/authn.config") + c.AuthenticationTokenWebhookConfigFile = new("/etc/kubernetes/authn.config") } } @@ -84,9 +84,9 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(cluster *kops.Cluster) error // Do nothing - use the default as defined by the apiserver. // In practice unreachable: defaulting sets RBAC when authorization is omitted. } else if clusterSpec.Authorization.AlwaysAllow != nil { - clusterSpec.KubeAPIServer.AuthorizationMode = fi.PtrTo("AlwaysAllow") + clusterSpec.KubeAPIServer.AuthorizationMode = new("AlwaysAllow") } else if clusterSpec.Authorization.RBAC != nil { - clusterSpec.KubeAPIServer.AuthorizationMode = fi.PtrTo("Node,RBAC") + clusterSpec.KubeAPIServer.AuthorizationMode = new("Node,RBAC") } if err := b.configureAggregation(clusterSpec); err != nil { @@ -112,7 +112,7 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(cluster *kops.Cluster) error c.BindAddress = "0.0.0.0" } - c.AllowPrivileged = fi.PtrTo(true) + c.AllowPrivileged = new(true) c.ServiceClusterIPRange = clusterSpec.Networking.ServiceClusterIPRange c.EtcdServers = nil c.EtcdServersOverrides = nil @@ -157,7 +157,7 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(cluster *kops.Cluster) error } // We make sure to disable AnonymousAuth - c.AnonymousAuth = fi.PtrTo(false) + c.AnonymousAuth = new(false) // We query via the kube-apiserver-healthcheck proxy, which listens on port 3990 c.InsecureBindAddress = "" @@ -167,7 +167,7 @@ func (b *KubeAPIServerOptionsBuilder) BuildOptions(cluster *kops.Cluster) error metricsServer := clusterSpec.MetricsServer if metricsServer != nil && fi.ValueOf(metricsServer.Enabled) { if c.EnableAggregatorRouting == nil { - c.EnableAggregatorRouting = fi.PtrTo(true) + c.EnableAggregatorRouting = new(true) } } diff --git a/pkg/model/components/awscloudcontrollermanager.go b/pkg/model/components/awscloudcontrollermanager.go index 167fe9a05f1ec..6c33252935fe8 100644 --- a/pkg/model/components/awscloudcontrollermanager.go +++ b/pkg/model/components/awscloudcontrollermanager.go @@ -20,7 +20,6 @@ import ( "fmt" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -47,11 +46,11 @@ func (b *AWSCloudControllerManagerOptionsBuilder) BuildOptions(cluster *kops.Clu // No significant downside to always doing a leader election. // Also, having multiple control plane nodes requires leader election. - eccm.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: fi.PtrTo(true)} + eccm.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: new(true)} eccm.ClusterName = b.ClusterName - eccm.AllocateNodeCIDRs = fi.PtrTo(!clusterSpec.IsKopsControllerIPAM()) + eccm.AllocateNodeCIDRs = new(!clusterSpec.IsKopsControllerIPAM()) if eccm.ClusterCIDR == "" && !clusterSpec.IsKopsControllerIPAM() { eccm.ClusterCIDR = clusterSpec.Networking.PodCIDR @@ -60,14 +59,14 @@ func (b *AWSCloudControllerManagerOptionsBuilder) BuildOptions(cluster *kops.Clu // TODO: we want to consolidate this with the logic from KCM networking := &clusterSpec.Networking if networking.Kubenet != nil { - eccm.ConfigureCloudRoutes = fi.PtrTo(true) + eccm.ConfigureCloudRoutes = new(true) } else if networking.External != nil { - eccm.ConfigureCloudRoutes = fi.PtrTo(false) + eccm.ConfigureCloudRoutes = new(false) } else if UsesCNI(networking) { - eccm.ConfigureCloudRoutes = fi.PtrTo(false) + eccm.ConfigureCloudRoutes = new(false) } else if networking.Kopeio != nil { // Kopeio is based on kubenet / external - eccm.ConfigureCloudRoutes = fi.PtrTo(false) + eccm.ConfigureCloudRoutes = new(false) } else { return fmt.Errorf("no networking mode set") } diff --git a/pkg/model/components/awsebscsidriver.go b/pkg/model/components/awsebscsidriver.go index 96972dd3b300a..5ff704b7da8ac 100644 --- a/pkg/model/components/awsebscsidriver.go +++ b/pkg/model/components/awsebscsidriver.go @@ -18,7 +18,6 @@ package components import ( "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -37,13 +36,13 @@ func (b *AWSEBSCSIDriverOptionsBuilder) BuildOptions(o *kops.Cluster) error { if aws.EBSCSIDriver == nil { aws.EBSCSIDriver = &kops.EBSCSIDriverSpec{ - Enabled: fi.PtrTo(true), + Enabled: new(true), } } c := aws.EBSCSIDriver if c.Version == nil { - c.Version = fi.PtrTo("v1.58.0") + c.Version = new("v1.58.0") } return nil diff --git a/pkg/model/components/azurecloudcontrollermanager.go b/pkg/model/components/azurecloudcontrollermanager.go index 912910e48413f..161cbfcab6378 100644 --- a/pkg/model/components/azurecloudcontrollermanager.go +++ b/pkg/model/components/azurecloudcontrollermanager.go @@ -18,7 +18,6 @@ package components import ( "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -49,7 +48,7 @@ func (b *AzureCloudControllerManagerOptionsBuilder) BuildOptions(cluster *kops.C eccm.AzureNodeManagerImage = "mcr.microsoft.com/oss/v2/kubernetes/azure-cloud-node-manager:v1.36.2" } - eccm.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: fi.PtrTo(true)} + eccm.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: new(true)} if eccm.LogLevel == 0 { eccm.LogLevel = 2 @@ -61,9 +60,9 @@ func (b *AzureCloudControllerManagerOptionsBuilder) BuildOptions(cluster *kops.C // kOps associates with the node subnet. EnableIPForwarding is already set on every NIC. networking := cluster.Spec.Networking if networking.Kubenet != nil || networking.Kindnet != nil { - eccm.ConfigureCloudRoutes = fi.PtrTo(true) + eccm.ConfigureCloudRoutes = new(true) } else { - eccm.ConfigureCloudRoutes = fi.PtrTo(false) + eccm.ConfigureCloudRoutes = new(false) } return nil diff --git a/pkg/model/components/channels/model.go b/pkg/model/components/channels/model.go index edae0f945912b..9c53b61dfa226 100644 --- a/pkg/model/components/channels/model.go +++ b/pkg/model/components/channels/model.go @@ -76,8 +76,8 @@ func (b *ChannelsBuilder) Build(c *fi.CloudupModelBuilderContext) error { c.AddTask(&fitasks.ManagedFile{ Contents: fi.NewBytesResource(manifest), Lifecycle: b.Lifecycle, - Location: fi.PtrTo(channelsManifestPath), - Name: fi.PtrTo("manifests-channels-kops-channels"), + Location: new(channelsManifestPath), + Name: new("manifests-channels-kops-channels"), }) return nil } @@ -177,8 +177,8 @@ func (b *ChannelsBuilder) buildPod(channels []string) (*v1.Pod, error) { }, // ko-distroless's default nonroot uid can't read /var/lib/kops/kubeconfig. SecurityContext: &v1.SecurityContext{ - RunAsUser: fi.PtrTo(int64(wellknownusers.KopsChannelsID)), - RunAsNonRoot: fi.PtrTo(true), + RunAsUser: new(int64(wellknownusers.KopsChannelsID)), + RunAsNonRoot: new(true), }, } kubemanifest.AddHostPathMapping(pod, &container, "kubeconfig", channelsKubeconfigPath, diff --git a/pkg/model/components/cilium.go b/pkg/model/components/cilium.go index 140c108a163df..1ffbeaf13e17a 100644 --- a/pkg/model/components/cilium.go +++ b/pkg/model/components/cilium.go @@ -21,7 +21,6 @@ import ( "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/wellknownports" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -44,11 +43,11 @@ func (b *CiliumOptionsBuilder) BuildOptions(o *kops.Cluster) error { } if c.EnableEndpointHealthChecking == nil { - c.EnableEndpointHealthChecking = fi.PtrTo(true) + c.EnableEndpointHealthChecking = new(true) } if c.EnableHostFirewall == nil { - c.EnableHostFirewall = fi.PtrTo(false) + c.EnableHostFirewall = new(false) } if c.IdentityAllocationMode == "" { @@ -116,7 +115,7 @@ func (b *CiliumOptionsBuilder) BuildOptions(o *kops.Cluster) error { } if c.Masquerade == nil { - c.Masquerade = fi.PtrTo(!clusterSpec.IsIPv6Only()) + c.Masquerade = new(!clusterSpec.IsIPv6Only()) } if c.Tunnel == "" { @@ -128,27 +127,27 @@ func (b *CiliumOptionsBuilder) BuildOptions(o *kops.Cluster) error { } if c.EnableRemoteNodeIdentity == nil { - c.EnableRemoteNodeIdentity = fi.PtrTo(true) + c.EnableRemoteNodeIdentity = new(true) } if c.EnableUnreachableRoutes == nil { - c.EnableUnreachableRoutes = fi.PtrTo(false) + c.EnableUnreachableRoutes = new(false) } if c.EnableBPFMasquerade == nil { - c.EnableBPFMasquerade = fi.PtrTo(c.IPAM == "eni") + c.EnableBPFMasquerade = new(c.IPAM == "eni") } if c.EnableL7Proxy == nil { - c.EnableL7Proxy = fi.PtrTo(true) + c.EnableL7Proxy = new(true) } if c.EnableLocalRedirectPolicy == nil { - c.EnableLocalRedirectPolicy = fi.PtrTo(false) + c.EnableLocalRedirectPolicy = new(false) } if c.DisableCNPStatusUpdates == nil { - c.DisableCNPStatusUpdates = fi.PtrTo(true) + c.DisableCNPStatusUpdates = new(true) } if c.CPURequest == nil { @@ -166,39 +165,39 @@ func (b *CiliumOptionsBuilder) BuildOptions(o *kops.Cluster) error { } if c.CniExclusive == nil { - c.CniExclusive = fi.PtrTo(true) + c.CniExclusive = new(true) } hubble := c.Hubble if hubble != nil { if hubble.Enabled == nil { - hubble.Enabled = fi.PtrTo(true) + hubble.Enabled = new(true) } } else { c.Hubble = &kops.HubbleSpec{ - Enabled: fi.PtrTo(false), + Enabled: new(false), } } ingress := c.Ingress if ingress != nil { if ingress.Enabled == nil { - ingress.Enabled = fi.PtrTo(true) + ingress.Enabled = new(true) } } else { c.Ingress = &kops.CiliumIngressSpec{ - Enabled: fi.PtrTo(false), + Enabled: new(false), } } gatewayAPI := c.GatewayAPI if gatewayAPI != nil { if gatewayAPI.Enabled == nil { - gatewayAPI.Enabled = fi.PtrTo(true) + gatewayAPI.Enabled = new(true) } } else { c.GatewayAPI = &kops.CiliumGatewayAPISpec{ - Enabled: fi.PtrTo(false), + Enabled: new(false), } } diff --git a/pkg/model/components/cloudconfiguration.go b/pkg/model/components/cloudconfiguration.go index e18f4ab1cc808..1499d17521ac3 100644 --- a/pkg/model/components/cloudconfiguration.go +++ b/pkg/model/components/cloudconfiguration.go @@ -18,7 +18,6 @@ package components import ( "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -47,7 +46,7 @@ func (b *CloudConfigurationOptionsBuilder) BuildOptions(o *kops.Cluster) error { // adopting that more particular setting generally. manage = clusterSpec.CloudProvider.Openstack.BlockStorage.CreateStorageClass } else { - manage = fi.PtrTo(true) + manage = new(true) } c.ManageStorageClasses = manage } diff --git a/pkg/model/components/cloudconfiguration_test.go b/pkg/model/components/cloudconfiguration_test.go index b3dda7d59a8b5..bb5222037bc99 100644 --- a/pkg/model/components/cloudconfiguration_test.go +++ b/pkg/model/components/cloudconfiguration_test.go @@ -20,15 +20,14 @@ import ( "testing" kopsapi "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" ) func TestCloudConfigurationOptionsBuilder(t *testing.T) { ob := &CloudConfigurationOptionsBuilder{ Context: nil, } - disabled := fi.PtrTo(false) - enabled := fi.PtrTo(true) + disabled := new(false) + enabled := new(true) for _, test := range []struct { description string generalManageSCs *bool diff --git a/pkg/model/components/clusterautoscaler.go b/pkg/model/components/clusterautoscaler.go index de4c208049b69..17648c8a30ddf 100644 --- a/pkg/model/components/clusterautoscaler.go +++ b/pkg/model/components/clusterautoscaler.go @@ -57,53 +57,53 @@ func (b *ClusterAutoscalerOptionsBuilder) BuildOptions(o *kops.Cluster) error { image = "registry.k8s.io/autoscaling/cluster-autoscaler:v1.36.0" } } - cas.Image = fi.PtrTo(image) + cas.Image = new(image) } if cas.Expander == "" { cas.Expander = "random" } if cas.IgnoreDaemonSetsUtilization == nil { - cas.IgnoreDaemonSetsUtilization = fi.PtrTo(false) + cas.IgnoreDaemonSetsUtilization = new(false) } if cas.ScaleDownUtilizationThreshold == nil { - cas.ScaleDownUtilizationThreshold = fi.PtrTo("0.5") + cas.ScaleDownUtilizationThreshold = new("0.5") } if cas.SkipNodesWithCustomControllerPods == nil { - cas.SkipNodesWithCustomControllerPods = fi.PtrTo(true) + cas.SkipNodesWithCustomControllerPods = new(true) } if cas.SkipNodesWithLocalStorage == nil { - cas.SkipNodesWithLocalStorage = fi.PtrTo(true) + cas.SkipNodesWithLocalStorage = new(true) } if cas.SkipNodesWithSystemPods == nil { - cas.SkipNodesWithSystemPods = fi.PtrTo(true) + cas.SkipNodesWithSystemPods = new(true) } if cas.BalanceSimilarNodeGroups == nil { - cas.BalanceSimilarNodeGroups = fi.PtrTo(false) + cas.BalanceSimilarNodeGroups = new(false) } if cas.EmitPerNodegroupMetrics == nil { - cas.EmitPerNodegroupMetrics = fi.PtrTo(false) + cas.EmitPerNodegroupMetrics = new(false) } if cas.AWSUseStaticInstanceList == nil { - cas.AWSUseStaticInstanceList = fi.PtrTo(false) + cas.AWSUseStaticInstanceList = new(false) } if cas.NewPodScaleUpDelay == nil { - cas.NewPodScaleUpDelay = fi.PtrTo("0s") + cas.NewPodScaleUpDelay = new("0s") } if cas.ScaleDownDelayAfterAdd == nil { - cas.ScaleDownDelayAfterAdd = fi.PtrTo("10m0s") + cas.ScaleDownDelayAfterAdd = new("10m0s") } if cas.ScaleDownUnneededTime == nil { - cas.ScaleDownUnneededTime = fi.PtrTo("10m0s") + cas.ScaleDownUnneededTime = new("10m0s") } if cas.ScaleDownUnreadyTime == nil { - cas.ScaleDownUnreadyTime = fi.PtrTo("20m0s") + cas.ScaleDownUnreadyTime = new("20m0s") } if cas.MaxNodeProvisionTime == "" { cas.MaxNodeProvisionTime = "15m0s" } if cas.Expander == "priority" { - cas.CreatePriorityExpenderConfig = fi.PtrTo(true) + cas.CreatePriorityExpenderConfig = new(true) } return nil diff --git a/pkg/model/components/containerd.go b/pkg/model/components/containerd.go index d05fef38c4586..7b25b7db06a2b 100644 --- a/pkg/model/components/containerd.go +++ b/pkg/model/components/containerd.go @@ -47,25 +47,25 @@ func (b *ContainerdOptionsBuilder) BuildOptions(o *kops.Cluster) error { if fi.ValueOf(containerd.Version) == "" { switch { case b.IsKubernetesLT("1.32"): - containerd.Version = fi.PtrTo("1.7.32") + containerd.Version = new("1.7.32") containerd.Runc = &kops.Runc{ - Version: fi.PtrTo("1.3.5"), + Version: new("1.3.5"), } default: // Stay on containerd 2.2.x rather than 2.3.x to avoid a sandbox-image // regression in 2.3 (https://github.com/containerd/containerd/issues/13529). - containerd.Version = fi.PtrTo("2.2.4") + containerd.Version = new("2.2.4") containerd.Runc = &kops.Runc{ - Version: fi.PtrTo("1.3.5"), + Version: new("1.3.5"), } } } // Set the default log level to INFO - containerd.LogLevel = fi.PtrTo("info") + containerd.LogLevel = new("info") // Set the sandbox image used to scope pod shared resources used by the pod's containers. if fi.ValueOf(containerd.SandboxImage) == "" { - containerd.SandboxImage = fi.PtrTo(b.AssetBuilder.RemapImage(DefaultSandboxImage)) + containerd.SandboxImage = new(b.AssetBuilder.RemapImage(DefaultSandboxImage)) } if containerd.NvidiaGPU != nil && fi.ValueOf(containerd.NvidiaGPU.Enabled) { diff --git a/pkg/model/components/discovery.go b/pkg/model/components/discovery.go index 55d3c517423ae..a3e61cbb72bea 100644 --- a/pkg/model/components/discovery.go +++ b/pkg/model/components/discovery.go @@ -91,7 +91,7 @@ func (b *DiscoveryOptionsBuilder) BuildOptions(o *kops.Cluster) error { } kubeAPIServer.ServiceAccountIssuer = &serviceAccountIssuer } - kubeAPIServer.ServiceAccountJWKSURI = fi.PtrTo(*kubeAPIServer.ServiceAccountIssuer + "/openid/v1/jwks") + kubeAPIServer.ServiceAccountJWKSURI = new(*kubeAPIServer.ServiceAccountIssuer + "/openid/v1/jwks") // We set apiserver ServiceAccountKey and ServiceAccountSigningKeyFile in nodeup return nil diff --git a/pkg/model/components/etcdmanager/model.go b/pkg/model/components/etcdmanager/model.go index bcf04f9099b14..5db61e1ebae59 100644 --- a/pkg/model/components/etcdmanager/model.go +++ b/pkg/model/components/etcdmanager/model.go @@ -121,8 +121,8 @@ func (b *EtcdManagerBuilder) Build(c *fi.CloudupModelBuilderContext) error { c.AddTask(&fitasks.ManagedFile{ Contents: fi.NewBytesResource(manifestYAML), Lifecycle: b.Lifecycle, - Location: fi.PtrTo("manifests/etcd/" + name + ".yaml"), - Name: fi.PtrTo("manifests-etcdmanager-" + name), + Location: new("manifests/etcd/" + name + ".yaml"), + Name: new("manifests-etcdmanager-" + name), }) } @@ -146,15 +146,15 @@ func (b *EtcdManagerBuilder) Build(c *fi.CloudupModelBuilderContext) error { c.AddTask(&fitasks.ManagedFile{ Contents: fi.NewBytesResource(d), Lifecycle: b.Lifecycle, - Base: fi.PtrTo(backupStore), + Base: new(backupStore), // TODO: We need this to match the backup base (currently) - Location: fi.PtrTo(location + "/control/etcd-cluster-spec"), - Name: fi.PtrTo("etcd-cluster-spec-" + etcdCluster.Name), + Location: new(location + "/control/etcd-cluster-spec"), + Name: new("etcd-cluster-spec-" + etcdCluster.Name), }) // We create a CA keypair to enable secure communication c.AddTask(&fitasks.Keypair{ - Name: fi.PtrTo("etcd-manager-ca-" + etcdCluster.Name), + Name: new("etcd-manager-ca-" + etcdCluster.Name), Lifecycle: b.Lifecycle, Subject: "cn=etcd-manager-ca-" + etcdCluster.Name, Type: "ca", @@ -162,7 +162,7 @@ func (b *EtcdManagerBuilder) Build(c *fi.CloudupModelBuilderContext) error { // We create a CA for etcd peers and a separate one for clients c.AddTask(&fitasks.Keypair{ - Name: fi.PtrTo("etcd-peers-ca-" + etcdCluster.Name), + Name: new("etcd-peers-ca-" + etcdCluster.Name), Lifecycle: b.Lifecycle, Subject: "cn=etcd-peers-ca-" + etcdCluster.Name, Type: "ca", @@ -170,7 +170,7 @@ func (b *EtcdManagerBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Because API server can only have a single client-cert, we need to share a client CA c.EnsureTask(&fitasks.Keypair{ - Name: fi.PtrTo("etcd-clients-ca"), + Name: new("etcd-clients-ca"), Lifecycle: b.Lifecycle, Subject: "cn=etcd-clients-ca", Type: "ca", @@ -178,7 +178,7 @@ func (b *EtcdManagerBuilder) Build(c *fi.CloudupModelBuilderContext) error { if etcdCluster.Name == "cilium" { clientsCaCilium := &fitasks.Keypair{ - Name: fi.PtrTo("etcd-clients-ca-cilium"), + Name: new("etcd-clients-ca-cilium"), Lifecycle: b.Lifecycle, Subject: "cn=etcd-clients-ca-cilium", Type: "ca", @@ -502,11 +502,11 @@ func (b *EtcdManagerBuilder) buildPod(etcdCluster kops.EtcdClusterSpec, instance } if etcdCluster.Manager != nil && etcdCluster.Manager.BackupInterval != nil { - config.BackupInterval = fi.PtrTo(etcdCluster.Manager.BackupInterval.Duration.String()) + config.BackupInterval = new(etcdCluster.Manager.BackupInterval.Duration.String()) } if etcdCluster.Manager != nil && etcdCluster.Manager.DiscoveryPollInterval != nil { - config.DiscoveryPollInterval = fi.PtrTo(etcdCluster.Manager.DiscoveryPollInterval.Duration.String()) + config.DiscoveryPollInterval = new(etcdCluster.Manager.DiscoveryPollInterval.Duration.String()) } { @@ -515,7 +515,7 @@ func (b *EtcdManagerBuilder) buildPod(etcdCluster kops.EtcdClusterSpec, instance scheme := "https" if etcdCluster.Name == "events" && featureflag.EtcdEventsHTTP.Enabled() { scheme = "http" - config.EtcdInsecure = fi.PtrTo(true) + config.EtcdInsecure = new(true) klog.Warningf("etcd cluster %q is configured with TLS disabled (HTTP) via KOPS_FEATURE_FLAGS=EtcdEventsHTTP. This is for experiments only.", etcdCluster.Name) } @@ -600,7 +600,7 @@ func (b *EtcdManagerBuilder) buildPod(etcdCluster kops.EtcdClusterSpec, instance fmt.Sprintf("%s=%s", openstack.TagClusterName, b.Cluster.Name), } config.VolumeNameTag = openstack.TagNameEtcdClusterPrefix + etcdCluster.Name - config.NetworkCIDR = fi.PtrTo(b.Cluster.Spec.Networking.NetworkCIDR) + config.NetworkCIDR = new(b.Cluster.Spec.Networking.NetworkCIDR) case kops.CloudProviderScaleway: config.VolumeProvider = "scaleway" diff --git a/pkg/model/components/gcpcloudcontrollermanager.go b/pkg/model/components/gcpcloudcontrollermanager.go index fbc19698437e5..ee7367864af72 100644 --- a/pkg/model/components/gcpcloudcontrollermanager.go +++ b/pkg/model/components/gcpcloudcontrollermanager.go @@ -18,7 +18,6 @@ package components import ( "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/gce" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -44,19 +43,19 @@ func (b *GCPCloudControllerManagerOptionsBuilder) BuildOptions(cluster *kops.Clu // No significant downside to always doing a leader election. // Also, having multiple control plane nodes requires leader election. - ccmConfig.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: fi.PtrTo(true)} + ccmConfig.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: new(true)} // CCM interacts directly with the GCP API, use the name safe for GCP ccmConfig.ClusterName = gce.SafeClusterName(b.ClusterName) - ccmConfig.AllocateNodeCIDRs = fi.PtrTo(true) - ccmConfig.CIDRAllocatorType = fi.PtrTo("CloudAllocator") + ccmConfig.AllocateNodeCIDRs = new(true) + ccmConfig.CIDRAllocatorType = new("CloudAllocator") if ccmConfig.ClusterCIDR == "" { ccmConfig.ClusterCIDR = clusterSpec.Networking.PodCIDR } if gce.UsesIPAliases(cluster) { // We don't need to configure routes if we are using ipalias; these are "real" IPs - ccmConfig.ConfigureCloudRoutes = fi.PtrTo(false) + ccmConfig.ConfigureCloudRoutes = new(false) } if ccmConfig.Controllers == nil { diff --git a/pkg/model/components/gcppdcsidriver.go b/pkg/model/components/gcppdcsidriver.go index 66728eb3ddbee..18fc7e17e038b 100644 --- a/pkg/model/components/gcppdcsidriver.go +++ b/pkg/model/components/gcppdcsidriver.go @@ -18,7 +18,6 @@ package components import ( "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -39,13 +38,13 @@ func (b *GCPPDCSIDriverOptionsBuilder) BuildOptions(o *kops.Cluster) error { gce.PDCSIDriver = &kops.PDCSIDriver{} } if gce.PDCSIDriver.Enabled == nil { - gce.PDCSIDriver.Enabled = fi.PtrTo(true) + gce.PDCSIDriver.Enabled = new(true) } if gce.PDCSIDriver.DefaultStorageClassName == nil { - gce.PDCSIDriver.DefaultStorageClassName = fi.PtrTo("balanced-csi") + gce.PDCSIDriver.DefaultStorageClassName = new("balanced-csi") } if gce.PDCSIDriver.Version == nil { - gce.PDCSIDriver.Version = fi.PtrTo("v1.22.1") + gce.PDCSIDriver.Version = new("v1.22.1") } return nil diff --git a/pkg/model/components/hetznercloudcontrollermanager.go b/pkg/model/components/hetznercloudcontrollermanager.go index a25fbb7ac6e71..9a83f03f9be5f 100644 --- a/pkg/model/components/hetznercloudcontrollermanager.go +++ b/pkg/model/components/hetznercloudcontrollermanager.go @@ -18,7 +18,6 @@ package components import ( "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -43,16 +42,16 @@ func (b *HetznerCloudControllerManagerOptionsBuilder) BuildOptions(cluster *kops eccm := clusterSpec.ExternalCloudControllerManager eccm.CloudProvider = "hcloud" - eccm.AllowUntaggedCloud = fi.PtrTo(true) + eccm.AllowUntaggedCloud = new(true) eccm.LeaderElection = &kops.LeaderElectionConfiguration{ - LeaderElect: fi.PtrTo(false), + LeaderElect: new(false), } if eccm.ClusterCIDR == "" { eccm.ClusterCIDR = clusterSpec.Networking.PodCIDR } - eccm.AllocateNodeCIDRs = fi.PtrTo(true) - eccm.ConfigureCloudRoutes = fi.PtrTo(false) + eccm.AllocateNodeCIDRs = new(true) + eccm.ConfigureCloudRoutes = new(false) if eccm.Image == "" { eccm.Image = "hetznercloud/hcloud-cloud-controller-manager:v1.31.0" diff --git a/pkg/model/components/kindnet.go b/pkg/model/components/kindnet.go index 7d5324b2508b9..3a288ca9d774d 100644 --- a/pkg/model/components/kindnet.go +++ b/pkg/model/components/kindnet.go @@ -18,7 +18,6 @@ package components import ( "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -44,13 +43,13 @@ func (b *KindnetOptionsBuilder) BuildOptions(o *kops.Cluster) error { c.Masquerade = &kops.KindnetMasqueradeSpec{} if clusterSpec.IsIPv6Only() { // Kindnet should NOT masquerade when IPv6 is used - c.Masquerade.Enabled = fi.PtrTo(false) + c.Masquerade.Enabled = new(false) if o.GetCloudProvider() != kops.CloudProviderAWS { - c.NAT64 = fi.PtrTo(true) + c.NAT64 = new(true) } } else { // Kindnet should masquerade well known ranges if kops is not doing it - c.Masquerade.Enabled = fi.PtrTo(true) + c.Masquerade.Enabled = new(true) if clusterSpec.Networking.NetworkCIDR != "" { c.Masquerade.NonMasqueradeCIDRs = append(c.Masquerade.NonMasqueradeCIDRs, clusterSpec.Networking.NetworkCIDR) } @@ -64,11 +63,11 @@ func (b *KindnetOptionsBuilder) BuildOptions(o *kops.Cluster) error { } if c.FastPathThreshold == nil { - c.FastPathThreshold = fi.PtrTo(int32(0)) + c.FastPathThreshold = new(int32(0)) } if c.LogLevel == nil { - c.LogLevel = fi.PtrTo(int32(2)) + c.LogLevel = new(int32(2)) } return nil diff --git a/pkg/model/components/kubeapiserver/model.go b/pkg/model/components/kubeapiserver/model.go index 53c738b06d8c3..c8b8f20f9e8fa 100644 --- a/pkg/model/components/kubeapiserver/model.go +++ b/pkg/model/components/kubeapiserver/model.go @@ -58,8 +58,8 @@ func (b *KubeApiserverBuilder) Build(c *fi.CloudupModelBuilderContext) error { c.AddTask(&fitasks.ManagedFile{ Contents: fi.NewBytesResource(manifestYAML), Lifecycle: b.Lifecycle, - Location: fi.PtrTo(location), - Name: fi.PtrTo("manifests-static-" + key), + Location: new(location), + Name: new("manifests-static-" + key), }) b.AssetBuilder.AddStaticManifest(&assets.StaticManifest{ diff --git a/pkg/model/components/kubecontrollermanager.go b/pkg/model/components/kubecontrollermanager.go index edf7e76ada187..3efd90fdf4442 100644 --- a/pkg/model/components/kubecontrollermanager.go +++ b/pkg/model/components/kubecontrollermanager.go @@ -24,7 +24,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog/v2" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/gce" "k8s.io/kops/upup/pkg/fi/loader" "k8s.io/kops/upup/pkg/fi/utils" @@ -89,9 +88,9 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o *kops.Cluster) erro kcm.Image = image // Doesn't seem to be any real downside to always doing a leader election - kcm.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: fi.PtrTo(true)} + kcm.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: new(true)} - kcm.AllocateNodeCIDRs = fi.PtrTo(!clusterSpec.IsKopsControllerIPAM()) + kcm.AllocateNodeCIDRs = new(!clusterSpec.IsKopsControllerIPAM()) if kcm.ClusterCIDR == "" && !clusterSpec.IsKopsControllerIPAM() { kcm.ClusterCIDR = clusterSpec.Networking.PodCIDR @@ -105,41 +104,41 @@ func (b *KubeControllerManagerOptionsBuilder) BuildOptions(o *kops.Cluster) erro // Kubernetes limitation nodeSize = 16 } - kcm.NodeCIDRMaskSize = fi.PtrTo(int32(clusterSize + nodeSize)) + kcm.NodeCIDRMaskSize = new(int32(clusterSize + nodeSize)) } networking := &clusterSpec.Networking if networking.Kubenet != nil { - kcm.ConfigureCloudRoutes = fi.PtrTo(true) + kcm.ConfigureCloudRoutes = new(true) } else if networking.GCP != nil { - kcm.ConfigureCloudRoutes = fi.PtrTo(false) + kcm.ConfigureCloudRoutes = new(false) if kcm.CloudProvider == "external" { // kcm should not allocate node cidrs with the CloudAllocator if we're using the external CCM - kcm.AllocateNodeCIDRs = fi.PtrTo(false) + kcm.AllocateNodeCIDRs = new(false) } else { - kcm.CIDRAllocatorType = fi.PtrTo("CloudAllocator") + kcm.CIDRAllocatorType = new("CloudAllocator") } } else if networking.Kindnet != nil { // We don't expect KCM to configure routes; it should be done by the CCM (or by the infrastructure) - kcm.ConfigureCloudRoutes = fi.PtrTo(false) + kcm.ConfigureCloudRoutes = new(false) // If the cloud is allocating the node CIDRs, that should be done by CCM if o.GetCloudProvider() == kops.CloudProviderGCE && gce.UsesIPAliases(o) { - kcm.AllocateNodeCIDRs = fi.PtrTo(false) + kcm.AllocateNodeCIDRs = new(false) } } else if networking.External != nil { - kcm.ConfigureCloudRoutes = fi.PtrTo(false) + kcm.ConfigureCloudRoutes = new(false) } else if UsesCNI(networking) { - kcm.ConfigureCloudRoutes = fi.PtrTo(false) + kcm.ConfigureCloudRoutes = new(false) } else if networking.Kopeio != nil { // Kopeio is based on kubenet / external - kcm.ConfigureCloudRoutes = fi.PtrTo(false) + kcm.ConfigureCloudRoutes = new(false) } else { return fmt.Errorf("no networking mode set") } if kcm.UseServiceAccountCredentials == nil { - kcm.UseServiceAccountCredentials = fi.PtrTo(true) + kcm.UseServiceAccountCredentials = new(true) } if len(kcm.Controllers) == 0 { diff --git a/pkg/model/components/kubecontrollermanager_test.go b/pkg/model/components/kubecontrollermanager_test.go index c406d59e69b11..57ab0d3a29e75 100644 --- a/pkg/model/components/kubecontrollermanager_test.go +++ b/pkg/model/components/kubecontrollermanager_test.go @@ -25,7 +25,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" api "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/assets" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/util/pkg/vfs" ) @@ -104,40 +103,40 @@ func Test_Build_KCM_Builder_CIDR_Mask_Size(t *testing.T) { }, { PodCIDR: "2001:DB8::/32", - ExpectedMaskSize: fi.PtrTo(int32(48)), + ExpectedMaskSize: new(int32(48)), }, { PodCIDR: "2001:DB8::/65", - ExpectedMaskSize: fi.PtrTo(int32(81)), + ExpectedMaskSize: new(int32(81)), }, { PodCIDR: "2001:DB8::/32", ClusterCIDR: "2001:DB8::/65", - ExpectedMaskSize: fi.PtrTo(int32(81)), + ExpectedMaskSize: new(int32(81)), }, { PodCIDR: "2001:DB8::/95", - ExpectedMaskSize: fi.PtrTo(int32(111)), + ExpectedMaskSize: new(int32(111)), }, { PodCIDR: "2001:DB8::/96", - ExpectedMaskSize: fi.PtrTo(int32(112)), + ExpectedMaskSize: new(int32(112)), }, { PodCIDR: "2001:DB8::/97", - ExpectedMaskSize: fi.PtrTo(int32(112)), + ExpectedMaskSize: new(int32(112)), }, { PodCIDR: "2001:DB8::/98", - ExpectedMaskSize: fi.PtrTo(int32(113)), + ExpectedMaskSize: new(int32(113)), }, { PodCIDR: "2001:DB8::/99", - ExpectedMaskSize: fi.PtrTo(int32(113)), + ExpectedMaskSize: new(int32(113)), }, { PodCIDR: "2001:DB8::/100", - ExpectedMaskSize: fi.PtrTo(int32(114)), + ExpectedMaskSize: new(int32(114)), }, } for _, tc := range grid { diff --git a/pkg/model/components/kubedns.go b/pkg/model/components/kubedns.go index 5f45c768abb60..93fb5a3c37905 100644 --- a/pkg/model/components/kubedns.go +++ b/pkg/model/components/kubedns.go @@ -86,7 +86,7 @@ func (b *KubeDnsOptionsBuilder) BuildOptions(cluster *kops.Cluster) error { clusterSpec.KubeDNS.NodeLocalDNS = nodeLocalDNS } if nodeLocalDNS.Enabled == nil { - nodeLocalDNS.Enabled = fi.PtrTo(false) + nodeLocalDNS.Enabled = new(false) } if fi.ValueOf(nodeLocalDNS.Enabled) && nodeLocalDNS.LocalIP == "" { if clusterSpec.IsIPv6Only() { @@ -96,7 +96,7 @@ func (b *KubeDnsOptionsBuilder) BuildOptions(cluster *kops.Cluster) error { } } if fi.ValueOf(nodeLocalDNS.Enabled) && nodeLocalDNS.ForwardToKubeDNS == nil { - nodeLocalDNS.ForwardToKubeDNS = fi.PtrTo(false) + nodeLocalDNS.ForwardToKubeDNS = new(false) } if nodeLocalDNS.MemoryRequest == nil || nodeLocalDNS.MemoryRequest.IsZero() { @@ -110,7 +110,7 @@ func (b *KubeDnsOptionsBuilder) BuildOptions(cluster *kops.Cluster) error { } if nodeLocalDNS.Image == nil { - nodeLocalDNS.Image = fi.PtrTo("registry.k8s.io/dns/k8s-dns-node-cache:1.26.0") + nodeLocalDNS.Image = new("registry.k8s.io/dns/k8s-dns-node-cache:1.26.0") } return nil diff --git a/pkg/model/components/kubelet.go b/pkg/model/components/kubelet.go index 32f85c854add5..ee981b9629b47 100644 --- a/pkg/model/components/kubelet.go +++ b/pkg/model/components/kubelet.go @@ -55,12 +55,12 @@ func (b *KubeletOptionsBuilder) BuildOptions(cluster *kops.Cluster) error { // We _do_ allow debugging handlers, so we can do logs // This does allow more access than we would like though - cluster.Spec.ControlPlaneKubelet.EnableDebuggingHandlers = fi.PtrTo(true) + cluster.Spec.ControlPlaneKubelet.EnableDebuggingHandlers = new(true) // IsolateControlPlane enables the legacy behaviour, where master pods on a separate network // In newer versions of kubernetes, most of that functionality has been removed though if fi.ValueOf(cluster.Spec.Networking.IsolateControlPlane) { - cluster.Spec.ControlPlaneKubelet.EnableDebuggingHandlers = fi.PtrTo(false) + cluster.Spec.ControlPlaneKubelet.EnableDebuggingHandlers = new(false) cluster.Spec.ControlPlaneKubelet.HairpinMode = "none" } @@ -69,9 +69,9 @@ func (b *KubeletOptionsBuilder) BuildOptions(cluster *kops.Cluster) error { func (b *KubeletOptionsBuilder) configureKubelet(cluster *kops.Cluster, kubelet *kops.KubeletConfigSpec, kubernetesVersion model.KubernetesVersion) error { // Standard options - kubelet.EnableDebuggingHandlers = fi.PtrTo(true) + kubelet.EnableDebuggingHandlers = new(true) kubelet.PodManifestPath = "/etc/kubernetes/manifests" - kubelet.LogLevel = fi.PtrTo(int32(2)) + kubelet.LogLevel = new(int32(2)) kubelet.ClusterDomain = cluster.Spec.ClusterDNSDomain // AllowPrivileged is deprecated and removed in v1.14. @@ -112,7 +112,7 @@ func (b *KubeletOptionsBuilder) configureKubelet(cluster *kops.Cluster, kubelet "imagefs.available<10%", "imagefs.inodesFree<5%", } - kubelet.EvictionHard = fi.PtrTo(strings.Join(evictionHard, ",")) + kubelet.EvictionHard = new(strings.Join(evictionHard, ",")) } } @@ -139,8 +139,8 @@ func (b *KubeletOptionsBuilder) configureKubelet(cluster *kops.Cluster, kubelet if cluster.Spec.CloudConfig == nil { cluster.Spec.CloudConfig = &kops.CloudConfiguration{} } - cluster.Spec.CloudProvider.GCE.Multizone = fi.PtrTo(true) - cluster.Spec.CloudProvider.GCE.NodeTags = fi.PtrTo(gce.TagForRole(b.ClusterName, kops.InstanceGroupRoleNode)) + cluster.Spec.CloudProvider.GCE.Multizone = new(true) + cluster.Spec.CloudProvider.GCE.NodeTags = new(gce.TagForRole(b.ClusterName, kops.InstanceGroupRoleNode)) } // Set systemd as the default cgroup driver for kubelet @@ -150,7 +150,7 @@ func (b *KubeletOptionsBuilder) configureKubelet(cluster *kops.Cluster, kubelet kubelet.CgroupDriver = "systemd" if kubelet.ProtectKernelDefaults == nil { - kubelet.ProtectKernelDefaults = fi.PtrTo(true) + kubelet.ProtectKernelDefaults = new(true) } // We do not enable graceful shutdown when using amazonaws due to leaking ENIs. @@ -164,7 +164,7 @@ func (b *KubeletOptionsBuilder) configureKubelet(cluster *kops.Cluster, kubelet } if kubernetesVersion.IsLT("1.34") { - kubelet.RegisterSchedulable = fi.PtrTo(true) + kubelet.RegisterSchedulable = new(true) } return nil diff --git a/pkg/model/components/kubeproxy.go b/pkg/model/components/kubeproxy.go index 5fbc25ce788f9..0f47fb0db7742 100644 --- a/pkg/model/components/kubeproxy.go +++ b/pkg/model/components/kubeproxy.go @@ -20,7 +20,6 @@ import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -64,7 +63,7 @@ func (b *KubeProxyOptionsBuilder) BuildOptions(o *kops.Cluster) error { if config.ClusterCIDR == nil { if b.needsClusterCIDR(clusterSpec) { - config.ClusterCIDR = fi.PtrTo(clusterSpec.KubeControllerManager.ClusterCIDR) + config.ClusterCIDR = new(clusterSpec.KubeControllerManager.ClusterCIDR) } } diff --git a/pkg/model/components/kubescheduler.go b/pkg/model/components/kubescheduler.go index 8cedaccab5ddb..5c5eaafcf3e25 100644 --- a/pkg/model/components/kubescheduler.go +++ b/pkg/model/components/kubescheduler.go @@ -18,7 +18,6 @@ package components import ( "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -53,7 +52,7 @@ func (b *KubeSchedulerOptionsBuilder) BuildOptions(o *kops.Cluster) error { if config.LeaderElection == nil { // Doesn't seem to be any real downside to always doing a leader election config.LeaderElection = &kops.LeaderElectionConfiguration{ - LeaderElect: fi.PtrTo(true), + LeaderElect: new(true), } } diff --git a/pkg/model/components/linodecloudcontrollermanager.go b/pkg/model/components/linodecloudcontrollermanager.go index 7adf1ecf411df..eb40c953ff57d 100644 --- a/pkg/model/components/linodecloudcontrollermanager.go +++ b/pkg/model/components/linodecloudcontrollermanager.go @@ -18,7 +18,6 @@ package components import ( "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -44,14 +43,14 @@ func (b *LinodeCloudControllerManagerOptionsBuilder) BuildOptions(cluster *kops. eccm := clusterSpec.ExternalCloudControllerManager eccm.CloudProvider = "linode" eccm.LeaderElection = &kops.LeaderElectionConfiguration{ - LeaderElect: fi.PtrTo(true), + LeaderElect: new(true), } if eccm.ClusterCIDR == "" { eccm.ClusterCIDR = clusterSpec.Networking.PodCIDR } - eccm.AllocateNodeCIDRs = fi.PtrTo(true) - eccm.ConfigureCloudRoutes = fi.PtrTo(false) + eccm.AllocateNodeCIDRs = new(true) + eccm.ConfigureCloudRoutes = new(false) if eccm.Image == "" { // Using the official Linode (Akamai) CCM image diff --git a/pkg/model/components/nodeproblemdetector.go b/pkg/model/components/nodeproblemdetector.go index 4e96a3e1a5b47..87e7dcd07e1c6 100644 --- a/pkg/model/components/nodeproblemdetector.go +++ b/pkg/model/components/nodeproblemdetector.go @@ -19,7 +19,6 @@ package components import ( "k8s.io/apimachinery/pkg/api/resource" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -38,7 +37,7 @@ func (b *NodeProblemDetectorOptionsBuilder) BuildOptions(o *kops.Cluster) error npd := clusterSpec.NodeProblemDetector if npd.Enabled == nil { - npd.Enabled = fi.PtrTo(false) + npd.Enabled = new(false) } if npd.CPURequest == nil { @@ -57,7 +56,7 @@ func (b *NodeProblemDetectorOptionsBuilder) BuildOptions(o *kops.Cluster) error } if npd.Image == nil { - npd.Image = fi.PtrTo("registry.k8s.io/node-problem-detector/node-problem-detector:v0.8.18") + npd.Image = new("registry.k8s.io/node-problem-detector/node-problem-detector:v0.8.18") } return nil diff --git a/pkg/model/components/nodeterminationhandler.go b/pkg/model/components/nodeterminationhandler.go index aa59c78a4dd40..05602d100c13f 100644 --- a/pkg/model/components/nodeterminationhandler.go +++ b/pkg/model/components/nodeterminationhandler.go @@ -45,49 +45,49 @@ func (b *NodeTerminationHandlerOptionsBuilder) BuildOptions(o *kops.Cluster) err } nth := clusterSpec.CloudProvider.AWS.NodeTerminationHandler if nth.Enabled == nil { - nth.Enabled = fi.PtrTo(true) + nth.Enabled = new(true) } if !fi.ValueOf(nth.Enabled) { return nil } if nth.DeleteSQSMsgIfNodeNotFound == nil { - nth.DeleteSQSMsgIfNodeNotFound = fi.PtrTo(false) + nth.DeleteSQSMsgIfNodeNotFound = new(false) } if nth.EnableSpotInterruptionDraining == nil { - nth.EnableSpotInterruptionDraining = fi.PtrTo(true) + nth.EnableSpotInterruptionDraining = new(true) } if nth.EnableScheduledEventDraining == nil { - nth.EnableScheduledEventDraining = fi.PtrTo(true) + nth.EnableScheduledEventDraining = new(true) } if nth.EnableRebalanceMonitoring == nil { - nth.EnableRebalanceMonitoring = fi.PtrTo(false) + nth.EnableRebalanceMonitoring = new(false) } if nth.EnableRebalanceDraining == nil { - nth.EnableRebalanceDraining = fi.PtrTo(false) + nth.EnableRebalanceDraining = new(false) } if nth.EnableOutOfServiceTaint == nil { - nth.EnableOutOfServiceTaint = fi.PtrTo(false) + nth.EnableOutOfServiceTaint = new(false) } if nth.EnablePrometheusMetrics == nil { - nth.EnablePrometheusMetrics = fi.PtrTo(false) + nth.EnablePrometheusMetrics = new(false) } if nth.ExcludeFromLoadBalancers == nil { - nth.ExcludeFromLoadBalancers = fi.PtrTo(true) + nth.ExcludeFromLoadBalancers = new(true) } if nth.ManagedASGTag == nil { - nth.ManagedASGTag = fi.PtrTo("aws-node-termination-handler/managed") + nth.ManagedASGTag = new("aws-node-termination-handler/managed") } if nth.PodTerminationGracePeriod == nil { - nth.PodTerminationGracePeriod = fi.PtrTo(int32(-1)) + nth.PodTerminationGracePeriod = new(int32(-1)) } if nth.TaintNode == nil { - nth.TaintNode = fi.PtrTo(false) + nth.TaintNode = new(false) } if nth.CPURequest == nil { @@ -101,7 +101,7 @@ func (b *NodeTerminationHandlerOptionsBuilder) BuildOptions(o *kops.Cluster) err } if nth.Version == nil { - nth.Version = fi.PtrTo("v1.25.5") + nth.Version = new("v1.25.5") } return nil diff --git a/pkg/model/components/openstack.go b/pkg/model/components/openstack.go index 3d929a2bf1959..36d6e9083786e 100644 --- a/pkg/model/components/openstack.go +++ b/pkg/model/components/openstack.go @@ -21,7 +21,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/loader" ) @@ -49,14 +48,14 @@ func (b *OpenStackOptionsBuilder) BuildOptions(o *kops.Cluster) error { } if openstack.BlockStorage.CreateStorageClass == nil { - openstack.BlockStorage.CreateStorageClass = fi.PtrTo(true) + openstack.BlockStorage.CreateStorageClass = new(true) } if openstack.Metadata == nil { openstack.Metadata = &kops.OpenstackMetadata{} } if openstack.Metadata.ConfigDrive == nil { - openstack.Metadata.ConfigDrive = fi.PtrTo(false) + openstack.Metadata.ConfigDrive = new(false) } if clusterSpec.ExternalCloudControllerManager == nil { @@ -65,7 +64,7 @@ func (b *OpenStackOptionsBuilder) BuildOptions(o *kops.Cluster) error { // No significant downside to always doing a leader election. // Also, having a replicated (HA) control plane requires leader election. - clusterSpec.ExternalCloudControllerManager.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: fi.PtrTo(true)} + clusterSpec.ExternalCloudControllerManager.LeaderElection = &kops.LeaderElectionConfiguration{LeaderElect: new(true)} // Node status updates are happening unnecessarily often in kOps OpenStack. // Node status updates are useful if we are updating existing node flavor type or node addresses. diff --git a/pkg/model/config.go b/pkg/model/config.go index e68f71df9b36b..10987f34ef109 100644 --- a/pkg/model/config.go +++ b/pkg/model/config.go @@ -36,10 +36,10 @@ type ConfigBuilder struct { func (b *ConfigBuilder) Build(c *fi.CloudupModelBuilderContext) error { c.AddTask(&fitasks.ManagedFile{ - Name: fi.PtrTo(registry.PathKopsVersionUpdated), + Name: new(registry.PathKopsVersionUpdated), Lifecycle: b.Lifecycle, - Base: fi.PtrTo(b.Cluster.Spec.ConfigStore.Base), - Location: fi.PtrTo(registry.PathKopsVersionUpdated), + Base: new(b.Cluster.Spec.ConfigStore.Base), + Location: new(registry.PathKopsVersionUpdated), Contents: fi.NewStringResource(kopsbase.Version), }) @@ -48,10 +48,10 @@ func (b *ConfigBuilder) Build(c *fi.CloudupModelBuilderContext) error { return fmt.Errorf("serializing completed cluster spec: %w", err) } c.AddTask(&fitasks.ManagedFile{ - Name: fi.PtrTo(registry.PathClusterCompleted), + Name: new(registry.PathClusterCompleted), Lifecycle: b.Lifecycle, - Base: fi.PtrTo(b.Cluster.Spec.ConfigStore.Base), - Location: fi.PtrTo(registry.PathClusterCompleted), + Base: new(b.Cluster.Spec.ConfigStore.Base), + Location: new(registry.PathClusterCompleted), Contents: fi.NewBytesResource(versionedYaml), }) diff --git a/pkg/model/domodel/api_loadbalancer.go b/pkg/model/domodel/api_loadbalancer.go index 3fd2b24d6e30f..ed59dc3dee196 100644 --- a/pkg/model/domodel/api_loadbalancer.go +++ b/pkg/model/domodel/api_loadbalancer.go @@ -61,19 +61,19 @@ func (b *APILoadBalancerModelBuilder) Build(c *fi.CloudupModelBuilderContext) er // Create LoadBalancer for API LB loadbalancer := &dotasks.LoadBalancer{ - Name: fi.PtrTo(loadbalancerName), - Region: fi.PtrTo(b.Cluster.Spec.Networking.Subnets[0].Region), - DropletTag: fi.PtrTo(clusterMasterTag), + Name: new(loadbalancerName), + Region: new(b.Cluster.Spec.Networking.Subnets[0].Region), + DropletTag: new(clusterMasterTag), Lifecycle: b.Lifecycle, WellKnownServices: []wellknownservices.WellKnownService{wellknownservices.KopsController, wellknownservices.KubeAPIServer}, } if b.Cluster.Spec.Networking.NetworkID != "" { - loadbalancer.VPCUUID = fi.PtrTo(b.Cluster.Spec.Networking.NetworkID) + loadbalancer.VPCUUID = new(b.Cluster.Spec.Networking.NetworkID) } else if b.Cluster.Spec.Networking.NetworkCIDR != "" { vpcName := "vpc-" + clusterName - loadbalancer.VPCName = fi.PtrTo(vpcName) - loadbalancer.NetworkCIDR = fi.PtrTo(b.Cluster.Spec.Networking.NetworkCIDR) + loadbalancer.VPCName = new(vpcName) + loadbalancer.NetworkCIDR = new(b.Cluster.Spec.Networking.NetworkCIDR) } c.AddTask(loadbalancer) diff --git a/pkg/model/domodel/droplets.go b/pkg/model/domodel/droplets.go index 5babadc2dadb9..3871a4d2d29e2 100644 --- a/pkg/model/domodel/droplets.go +++ b/pkg/model/domodel/droplets.go @@ -72,13 +72,13 @@ func (d *DropletBuilder) Build(c *fi.CloudupModelBuilderContext) error { droplet := dotasks.Droplet{ Count: int(fi.ValueOf(ig.Spec.MinSize)), - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: d.Lifecycle, // kops do supports allow only 1 region - Region: fi.PtrTo(d.Cluster.Spec.Networking.Subnets[0].Region), - Size: fi.PtrTo(ig.Spec.MachineType), - Image: fi.PtrTo(ig.Spec.Image), + Region: new(d.Cluster.Spec.Networking.Subnets[0].Region), + Size: new(ig.Spec.MachineType), + Image: new(ig.Spec.Image), SSHKey: sshKey, Tags: []string{clusterTag}, } @@ -98,13 +98,13 @@ func (d *DropletBuilder) Build(c *fi.CloudupModelBuilderContext) error { droplet.Tags = append(droplet.Tags, do.TagKubernetesInstanceRole+":"+string(ig.Spec.Role)) if d.Cluster.Spec.Networking.NetworkID != "" { - droplet.VPCUUID = fi.PtrTo(d.Cluster.Spec.Networking.NetworkID) + droplet.VPCUUID = new(d.Cluster.Spec.Networking.NetworkID) } else if d.Cluster.Spec.Networking.NetworkCIDR != "" { // since networkCIDR specified as part of the request, it is made sure that vpc with this cidr exist before // creating the droplet, so you can associate with vpc uuid for this droplet. vpcName := "vpc-" + clusterName - droplet.VPCName = fi.PtrTo(vpcName) - droplet.NetworkCIDR = fi.PtrTo(d.Cluster.Spec.Networking.NetworkCIDR) + droplet.VPCName = new(vpcName) + droplet.NetworkCIDR = new(d.Cluster.Spec.Networking.NetworkCIDR) } userData, err := d.BootstrapScriptBuilder.ResourceNodeUp(c, ig) diff --git a/pkg/model/domodel/network.go b/pkg/model/domodel/network.go index 4b91c29eb8361..ee2befb92a2dd 100644 --- a/pkg/model/domodel/network.go +++ b/pkg/model/domodel/network.go @@ -44,10 +44,10 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Create a separate vpc for this cluster. vpc := &dotasks.VPC{ - Name: fi.PtrTo(vpcName), - Region: fi.PtrTo(b.Cluster.Spec.Networking.Subnets[0].Region), + Name: new(vpcName), + Region: new(b.Cluster.Spec.Networking.Subnets[0].Region), Lifecycle: b.Lifecycle, - IPRange: fi.PtrTo(ipRange), + IPRange: new(ipRange), } c.AddTask(vpc) diff --git a/pkg/model/gcemodel/autoscalinggroup.go b/pkg/model/gcemodel/autoscalinggroup.go index 03b5585fc52b1..7123adbc610a9 100644 --- a/pkg/model/gcemodel/autoscalinggroup.go +++ b/pkg/model/gcemodel/autoscalinggroup.go @@ -86,9 +86,9 @@ func (b *AutoscalingGroupModelBuilder) buildInstanceTemplate(c *fi.CloudupModelB return nil, err } - HasExternalIP := fi.PtrTo(false) + HasExternalIP := new(false) if subnet.Type == kops.SubnetTypePublic || subnet.Type == kops.SubnetTypeUtility || ig.IsBastion() { - HasExternalIP = fi.PtrTo(true) + HasExternalIP = new(true) } if ig.Spec.AssociatePublicIP != nil { HasExternalIP = ig.Spec.AssociatePublicIP @@ -104,7 +104,7 @@ func (b *AutoscalingGroupModelBuilder) buildInstanceTemplate(c *fi.CloudupModelB BootDiskSizeGB: i64(int64(volumeSize)), BootDiskImage: s(ig.Spec.Image), - Preemptible: fi.PtrTo(fi.ValueOf(ig.Spec.GCPProvisioningModel) == "SPOT"), + Preemptible: new(fi.ValueOf(ig.Spec.GCPProvisioningModel) == "SPOT"), GCPProvisioningModel: ig.Spec.GCPProvisioningModel, HasExternalIP: HasExternalIP, @@ -226,7 +226,7 @@ func (b *AutoscalingGroupModelBuilder) buildInstanceTemplate(c *fi.CloudupModelB } if gce.UsesIPAliases(b.Cluster) { - t.CanIPForward = fi.PtrTo(false) + t.CanIPForward = new(false) nodeCIDRMaskSize := int32(24) if b.Cluster.Spec.KubeControllerManager.NodeCIDRMaskSize != nil { @@ -236,7 +236,7 @@ func (b *AutoscalingGroupModelBuilder) buildInstanceTemplate(c *fi.CloudupModelB b.NameForIPAliasRange("pods"): fmt.Sprintf("/%d", nodeCIDRMaskSize), } } else { - t.CanIPForward = fi.PtrTo(true) + t.CanIPForward = new(true) } t.Subnet = b.LinkToSubnet(subnet) @@ -366,7 +366,7 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) e Name: s(name), Lifecycle: b.Lifecycle, Zone: s(zone), - TargetSize: fi.PtrTo(int64(targetSize)), + TargetSize: new(int64(targetSize)), UpdatePolicy: &gcetasks.UpdatePolicy{MinimalAction: "REPLACE", Type: "OPPORTUNISTIC"}, BaseInstanceName: s(ig.ObjectMeta.Name), InstanceTemplate: instanceTemplate, diff --git a/pkg/model/gcemodel/autoscalinggroup_test.go b/pkg/model/gcemodel/autoscalinggroup_test.go index 6ddb77eb23f9d..5ac32bbd4ce99 100644 --- a/pkg/model/gcemodel/autoscalinggroup_test.go +++ b/pkg/model/gcemodel/autoscalinggroup_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/assert" "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/model" - "k8s.io/kops/upup/pkg/fi" ) func TestSplitToZones(t *testing.T) { @@ -37,12 +36,12 @@ func TestSplitToZones(t *testing.T) { }{ { name: "no zones, minSize 2", - minSize: fi.PtrTo(int32(2)), + minSize: new(int32(2)), mustErr: true, }, { name: "1 zone, minSize 2", - minSize: fi.PtrTo(int32(2)), + minSize: new(int32(2)), zones: []string{"us-central1-a"}, expected: map[string]int{ "us-central1-a": 2, @@ -50,7 +49,7 @@ func TestSplitToZones(t *testing.T) { }, { name: "2 zones, minSize 2", - minSize: fi.PtrTo(int32(2)), + minSize: new(int32(2)), zones: []string{"us-central1-a", "us-central1-b"}, expected: map[string]int{ "us-central1-a": 1, @@ -59,7 +58,7 @@ func TestSplitToZones(t *testing.T) { }, { name: "2 zones, minSize 3", - minSize: fi.PtrTo(int32(3)), + minSize: new(int32(3)), zones: []string{"us-central1-a", "us-central1-b"}, expected: map[string]int{ "us-central1-a": 2, @@ -68,7 +67,7 @@ func TestSplitToZones(t *testing.T) { }, { name: "3 zones, minSize 2", - minSize: fi.PtrTo(int32(2)), + minSize: new(int32(2)), zones: []string{"us-central1-a", "us-central1-b", "us-central1-c"}, expected: map[string]int{ "us-central1-a": 1, diff --git a/pkg/model/gcemodel/context.go b/pkg/model/gcemodel/context.go index 92d9edb8d4aae..73617fb894d5e 100644 --- a/pkg/model/gcemodel/context.go +++ b/pkg/model/gcemodel/context.go @@ -20,7 +20,6 @@ import ( "k8s.io/klog/v2" "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/model" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/gce" "k8s.io/kops/upup/pkg/fi/cloudup/gcetasks" ) @@ -170,7 +169,7 @@ func (c *GCEModelContext) LinkToServiceAccount(ig *kops.InstanceGroup) *gcetasks return &gcetasks.ServiceAccount{ Name: s("shared"), Email: &c.Cluster.Spec.CloudProvider.GCE.ServiceAccount, - Shared: fi.PtrTo(true), + Shared: new(true), } } diff --git a/pkg/model/gcemodel/convenience.go b/pkg/model/gcemodel/convenience.go index f68d0e7058835..f61aefecfcebf 100644 --- a/pkg/model/gcemodel/convenience.go +++ b/pkg/model/gcemodel/convenience.go @@ -16,14 +16,12 @@ limitations under the License. package gcemodel -import "k8s.io/kops/upup/pkg/fi" - // s is a helper that builds a *string from a string value func s(v string) *string { - return fi.PtrTo(v) + return new(v) } // i64 is a helper that builds a *int64 from an int64 value func i64(v int64) *int64 { - return fi.PtrTo(v) + return new(v) } diff --git a/pkg/model/gcemodel/network.go b/pkg/model/gcemodel/network.go index 452219b62f026..2a944626c4d88 100644 --- a/pkg/model/gcemodel/network.go +++ b/pkg/model/gcemodel/network.go @@ -41,7 +41,7 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { return nil } network.Lifecycle = b.Lifecycle - network.Shared = fi.PtrTo(sharedNetwork) + network.Shared = new(sharedNetwork) if !sharedNetwork { // As we're creating the network, we're also creating the subnets. // We therefore use custom mode, for a few reasons: @@ -65,7 +65,7 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { Network: network, Lifecycle: b.Lifecycle, Region: s(b.Region), - Shared: fi.PtrTo(sharedSubnet), + Shared: new(sharedSubnet), SecondaryIpRanges: make(map[string]string), } diff --git a/pkg/model/gcemodel/service_accounts.go b/pkg/model/gcemodel/service_accounts.go index c03e65f846225..209a4e9e586a2 100644 --- a/pkg/model/gcemodel/service_accounts.go +++ b/pkg/model/gcemodel/service_accounts.go @@ -37,7 +37,7 @@ func (b *ServiceAccountsBuilder) Build(c *fi.CloudupModelBuilderContext) error { serviceAccount := &gcetasks.ServiceAccount{ Name: s("shared"), Email: &b.Cluster.Spec.CloudProvider.GCE.ServiceAccount, - Shared: fi.PtrTo(true), + Shared: new(true), Lifecycle: b.Lifecycle, } c.AddTask(serviceAccount) @@ -66,11 +66,11 @@ func (b *ServiceAccountsBuilder) Build(c *fi.CloudupModelBuilderContext) error { } switch ig.Spec.Role { case kops.InstanceGroupRoleAPIServer, kops.InstanceGroupRoleControlPlane: - serviceAccount.Description = fi.PtrTo("kubernetes control-plane instances") + serviceAccount.Description = new("kubernetes control-plane instances") case kops.InstanceGroupRoleNode: - serviceAccount.Description = fi.PtrTo("kubernetes worker nodes") + serviceAccount.Description = new("kubernetes worker nodes") case kops.InstanceGroupRoleBastion: - serviceAccount.Description = fi.PtrTo("bastion nodes") + serviceAccount.Description = new("bastion nodes") default: klog.Warningf("unknown instance role %q", ig.Spec.Role) } diff --git a/pkg/model/hetznermodel/firewall.go b/pkg/model/hetznermodel/firewall.go index d55dd7fd52a03..62273e86d8ed5 100644 --- a/pkg/model/hetznermodel/firewall.go +++ b/pkg/model/hetznermodel/firewall.go @@ -50,7 +50,7 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.CloudupModelBuilderContext) err fmt.Sprintf("%s=%s", hetzner.TagKubernetesInstanceRole, string(kops.InstanceGroupRoleControlPlane)), } controlPlaneFirewall := &hetznertasks.Firewall{ - Name: fi.PtrTo("control-plane." + b.ClusterName()), + Name: new("control-plane." + b.ClusterName()), Lifecycle: b.Lifecycle, Selector: strings.Join(controlPlaneLabelSelector, ","), Rules: []*hetznertasks.FirewallRule{ @@ -58,7 +58,7 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.CloudupModelBuilderContext) err Direction: string(hcloud.FirewallRuleDirectionIn), SourceIPs: sshAccess, Protocol: string(hcloud.FirewallRuleProtocolTCP), - Port: fi.PtrTo("22"), + Port: new("22"), }, }, Labels: map[string]string{ @@ -71,7 +71,7 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.CloudupModelBuilderContext) err fmt.Sprintf("%s=%s", hetzner.TagKubernetesInstanceRole, string(kops.InstanceGroupRoleNode)), } nodesFirewall := &hetznertasks.Firewall{ - Name: fi.PtrTo("nodes." + b.ClusterName()), + Name: new("nodes." + b.ClusterName()), Lifecycle: b.Lifecycle, Selector: strings.Join(nodesLabelSelector, ","), Rules: []*hetznertasks.FirewallRule{ @@ -79,7 +79,7 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.CloudupModelBuilderContext) err Direction: string(hcloud.FirewallRuleDirectionIn), SourceIPs: sshAccess, Protocol: string(hcloud.FirewallRuleProtocolTCP), - Port: fi.PtrTo("22"), + Port: new("22"), }, }, Labels: map[string]string{ @@ -101,7 +101,7 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.CloudupModelBuilderContext) err Direction: string(hcloud.FirewallRuleDirectionIn), SourceIPs: apiAccess, Protocol: string(hcloud.FirewallRuleProtocolTCP), - Port: fi.PtrTo("443"), + Port: new("443"), }) } @@ -122,13 +122,13 @@ func (b *ExternalAccessModelBuilder) Build(c *fi.CloudupModelBuilderContext) err Direction: string(hcloud.FirewallRuleDirectionIn), SourceIPs: nodePortAccess, Protocol: string(hcloud.FirewallRuleProtocolTCP), - Port: fi.PtrTo(fmt.Sprintf("%d-%d", nodePortRange.Base, nodePortRange.Base+nodePortRange.Size-1)), + Port: new(fmt.Sprintf("%d-%d", nodePortRange.Base, nodePortRange.Base+nodePortRange.Size-1)), }) nodesFirewall.Rules = append(nodesFirewall.Rules, &hetznertasks.FirewallRule{ Direction: string(hcloud.FirewallRuleDirectionIn), SourceIPs: nodePortAccess, Protocol: string(hcloud.FirewallRuleProtocolUDP), - Port: fi.PtrTo(fmt.Sprintf("%d-%d", nodePortRange.Base, nodePortRange.Base+nodePortRange.Size-1)), + Port: new(fmt.Sprintf("%d-%d", nodePortRange.Base, nodePortRange.Base+nodePortRange.Size-1)), }) } diff --git a/pkg/model/hetznermodel/loadbalancer.go b/pkg/model/hetznermodel/loadbalancer.go index 46796db5b8f08..b889cbb1ae601 100644 --- a/pkg/model/hetznermodel/loadbalancer.go +++ b/pkg/model/hetznermodel/loadbalancer.go @@ -43,7 +43,7 @@ func (b *LoadBalancerModelBuilder) Build(c *fi.CloudupModelBuilderContext) error fmt.Sprintf("%s=%s", hetzner.TagKubernetesInstanceRole, string(kops.InstanceGroupRoleControlPlane)), } loadbalancer := hetznertasks.LoadBalancer{ - Name: fi.PtrTo("api." + b.ClusterName()), + Name: new("api." + b.ClusterName()), Lifecycle: b.Lifecycle, Network: b.LinkToNetwork(), Location: b.InstanceGroups[0].Spec.Subnets[0], @@ -51,13 +51,13 @@ func (b *LoadBalancerModelBuilder) Build(c *fi.CloudupModelBuilderContext) error Services: []*hetznertasks.LoadBalancerService{ { Protocol: string(hcloud.LoadBalancerServiceProtocolTCP), - ListenerPort: fi.PtrTo(wellknownports.KubeAPIServer), - DestinationPort: fi.PtrTo(wellknownports.KubeAPIServer), + ListenerPort: new(wellknownports.KubeAPIServer), + DestinationPort: new(wellknownports.KubeAPIServer), }, { Protocol: string(hcloud.LoadBalancerServiceProtocolTCP), - ListenerPort: fi.PtrTo(wellknownports.KopsControllerPort), - DestinationPort: fi.PtrTo(wellknownports.KopsControllerPort), + ListenerPort: new(wellknownports.KopsControllerPort), + DestinationPort: new(wellknownports.KopsControllerPort), }, }, Target: strings.Join(controlPlaneLabelSelector, ","), diff --git a/pkg/model/hetznermodel/network.go b/pkg/model/hetznermodel/network.go index 719a64c0d1c40..2a84b79e43d96 100644 --- a/pkg/model/hetznermodel/network.go +++ b/pkg/model/hetznermodel/network.go @@ -32,7 +32,7 @@ var _ fi.CloudupModelBuilder = &NetworkModelBuilder{} func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { network := &hetznertasks.Network{ - Name: fi.PtrTo(b.ClusterName()), + Name: new(b.ClusterName()), Lifecycle: b.Lifecycle, } @@ -46,7 +46,7 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { hetzner.TagKubernetesClusterName: b.ClusterName(), } } else { - network.ID = fi.PtrTo(b.Cluster.Spec.Networking.NetworkID) + network.ID = new(b.Cluster.Spec.Networking.NetworkID) } c.AddTask(network) diff --git a/pkg/model/hetznermodel/servers.go b/pkg/model/hetznermodel/servers.go index 356e588fcc55b..2d51bd462e522 100644 --- a/pkg/model/hetznermodel/servers.go +++ b/pkg/model/hetznermodel/servers.go @@ -41,7 +41,7 @@ func (b *ServerGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) error return err } t := &hetznertasks.SSHKey{ - Name: fi.PtrTo(b.ClusterName() + "-" + fingerprint), + Name: new(b.ClusterName() + "-" + fingerprint), Lifecycle: b.Lifecycle, PublicKey: string(sshkey), Labels: map[string]string{ @@ -65,7 +65,7 @@ func (b *ServerGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) error } serverGroup := hetznertasks.ServerGroup{ - Name: fi.PtrTo(ig.Name), + Name: new(ig.Name), Lifecycle: b.Lifecycle, SSHKeys: sshkeyTasks, Network: b.LinkToNetwork(), diff --git a/pkg/model/iam/iam_builder_test.go b/pkg/model/iam/iam_builder_test.go index fe91d2acd6e9b..0ad0593182d4a 100644 --- a/pkg/model/iam/iam_builder_test.go +++ b/pkg/model/iam/iam_builder_test.go @@ -65,7 +65,7 @@ func TestRoundTrip(t *testing.T) { { IAM: &Statement{ Effect: StatementEffectDeny, - Principal: Principal{Service: fi.PtrTo(stringorset.Of("service"))}, + Principal: Principal{Service: new(stringorset.Of("service"))}, Condition: map[string]interface{}{ "bar": "baz", }, @@ -129,7 +129,7 @@ func TestPolicyGeneration(t *testing.T) { { Role: &NodeRoleMaster{}, AllowContainerRegistry: false, - NLBSecurityGroupMode: fi.PtrTo("Managed"), + NLBSecurityGroupMode: new("Managed"), Policy: "tests/iam_builder_master_nlb_sg_managed.json", }, { @@ -213,7 +213,7 @@ func TestPolicyGeneration(t *testing.T) { CloudProvider: kops.CloudProviderSpec{ AWS: &kops.AWSSpec{ EBSCSIDriver: &kops.EBSCSIDriverSpec{ - Enabled: fi.PtrTo(true), + Enabled: new(true), }, NLBSecurityGroupMode: x.NLBSecurityGroupMode, }, diff --git a/pkg/model/issuerdiscovery.go b/pkg/model/issuerdiscovery.go index a7c71deaeb597..6cf4763fcbb7c 100644 --- a/pkg/model/issuerdiscovery.go +++ b/pkg/model/issuerdiscovery.go @@ -99,7 +99,7 @@ func (b *IssuerDiscoveryModelBuilder) Build(c *fi.CloudupModelBuilderContext) er } if !isPublic { klog.Infof("serviceAccountIssuers bucket %q is not public; will use object ACL", discoveryStore.Bucket()) - publicFileACL = fi.PtrTo(true) + publicFileACL = new(true) } } else { klog.Infof("using user managed serviceAccountIssuers") @@ -117,7 +117,7 @@ func (b *IssuerDiscoveryModelBuilder) Build(c *fi.CloudupModelBuilderContext) er } if !isPublic { klog.Infof("serviceAccountIssuers bucket %q is not public; will use object ACL", discoveryStore.Bucket()) - publicFileACL = fi.PtrTo(true) + publicFileACL = new(true) } } else { klog.Infof("using user managed serviceAccountIssuers") @@ -133,9 +133,9 @@ func (b *IssuerDiscoveryModelBuilder) Build(c *fi.CloudupModelBuilderContext) er keysFile := &fitasks.ManagedFile{ Contents: keys, Lifecycle: b.Lifecycle, - Location: fi.PtrTo("openid/v1/jwks"), - Name: fi.PtrTo("keys.json"), - Base: fi.PtrTo(discoveryStorePath), + Location: new("openid/v1/jwks"), + Name: new("keys.json"), + Base: new(discoveryStorePath), PublicACL: publicFileACL, } c.AddTask(keysFile) @@ -143,9 +143,9 @@ func (b *IssuerDiscoveryModelBuilder) Build(c *fi.CloudupModelBuilderContext) er discoveryFile := &fitasks.ManagedFile{ Contents: fi.NewBytesResource(discovery), Lifecycle: b.Lifecycle, - Location: fi.PtrTo(".well-known/openid-configuration"), - Name: fi.PtrTo("discovery.json"), - Base: fi.PtrTo(discoveryStorePath), + Location: new(".well-known/openid-configuration"), + Name: new("discovery.json"), + Base: new(discoveryStorePath), PublicACL: publicFileACL, } c.AddTask(discoveryFile) diff --git a/pkg/model/linodemodel/sshkey.go b/pkg/model/linodemodel/sshkey.go index 258959bc1d0d7..e3f1a6d9461b5 100644 --- a/pkg/model/linodemodel/sshkey.go +++ b/pkg/model/linodemodel/sshkey.go @@ -52,7 +52,7 @@ func (b *SSHKeyModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { } t := &linodetasks.SSHKey{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, } if len(b.SSHPublicKeys) > 0 { diff --git a/pkg/model/linodemodel/sshkey_test.go b/pkg/model/linodemodel/sshkey_test.go index f52cfb9fd81b5..940cf1bdfcc1c 100644 --- a/pkg/model/linodemodel/sshkey_test.go +++ b/pkg/model/linodemodel/sshkey_test.go @@ -35,7 +35,7 @@ func TestSSHKeyModelBuilderBuildWithPublicKey(t *testing.T) { sshKeyName := "custom.ssh:key" cluster := &kops.Cluster{ ObjectMeta: metav1.ObjectMeta{Name: "example.k8s.local"}, - Spec: kops.ClusterSpec{SSHKeyName: fi.PtrTo(sshKeyName)}, + Spec: kops.ClusterSpec{SSHKeyName: new(sshKeyName)}, } b := &SSHKeyModelBuilder{ LinodeModelContext: &LinodeModelContext{KopsModelContext: &model.KopsModelContext{ @@ -82,7 +82,7 @@ func TestSSHKeyModelBuilderBuildWithExistingKeyName(t *testing.T) { sshKeyName := "existing.ssh:key" cluster := &kops.Cluster{ ObjectMeta: metav1.ObjectMeta{Name: "example.k8s.local"}, - Spec: kops.ClusterSpec{SSHKeyName: fi.PtrTo(sshKeyName)}, + Spec: kops.ClusterSpec{SSHKeyName: new(sshKeyName)}, } b := &SSHKeyModelBuilder{ LinodeModelContext: &LinodeModelContext{KopsModelContext: &model.KopsModelContext{ diff --git a/pkg/model/linodemodel/vpc.go b/pkg/model/linodemodel/vpc.go index 23957cb72b5da..03d13cfbee463 100644 --- a/pkg/model/linodemodel/vpc.go +++ b/pkg/model/linodemodel/vpc.go @@ -47,10 +47,10 @@ func (b *VPCModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { name := linode.NormalizeLinodeLabel(b.ClusterName()) description := fmt.Sprintf("kOps VPC for %s", b.ClusterName()) c.AddTask(&linodetasks.VPC{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, - Description: fi.PtrTo(description), - Region: fi.PtrTo(region), + Description: new(description), + Region: new(region), }) return nil diff --git a/pkg/model/master_volumes.go b/pkg/model/master_volumes.go index 9f14e77abcb1c..ee1d84d0f9edc 100644 --- a/pkg/model/master_volumes.go +++ b/pkg/model/master_volumes.go @@ -183,22 +183,22 @@ func (b *MasterVolumeBuilder) addAWSVolume(c *fi.CloudupModelBuilderContext, nam encrypted := fi.ValueOf(m.EncryptedVolume) t := &awstasks.EBSVolume{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, - AvailabilityZone: fi.PtrTo(zone), - SizeGB: fi.PtrTo(int32(volumeSize)), + AvailabilityZone: new(zone), + SizeGB: new(int32(volumeSize)), VolumeType: ec2types.VolumeType(volumeType), KmsKeyId: m.KmsKeyID, - Encrypted: fi.PtrTo(encrypted), + Encrypted: new(encrypted), Tags: tags, } switch ec2types.VolumeType(volumeType) { case ec2types.VolumeTypeGp3: - t.VolumeThroughput = fi.PtrTo(int32(volumeThroughput)) + t.VolumeThroughput = new(int32(volumeThroughput)) fallthrough case ec2types.VolumeTypeIo1, ec2types.VolumeTypeIo2: - t.VolumeIops = fi.PtrTo(int32(volumeIops)) + t.VolumeIops = new(int32(volumeIops)) } c.AddTask(t) @@ -246,10 +246,10 @@ func (b *MasterVolumeBuilder) addDOVolume(c *fi.CloudupModelBuilderContext, name tags[do.TagKubernetesClusterNamePrefix] = do.SafeClusterName(b.Cluster.ObjectMeta.Name) t := &dotasks.Volume{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, - SizeGB: fi.PtrTo(int64(volumeSize)), - Region: fi.PtrTo(zone), + SizeGB: new(int64(volumeSize)), + Region: new(zone), Tags: tags, } @@ -289,20 +289,20 @@ func (b *MasterVolumeBuilder) addGCEVolume(c *fi.CloudupModelBuilderContext, pre volumeThroughput := fi.ValueOf(m.VolumeThroughput) t := &gcetasks.Disk{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, - Zone: fi.PtrTo(zone), - SizeGB: fi.PtrTo(int64(volumeSize)), - VolumeType: fi.PtrTo(volumeType), + Zone: new(zone), + SizeGB: new(int64(volumeSize)), + VolumeType: new(volumeType), Labels: tags, } if volumeIops > 0 { - t.VolumeIops = fi.PtrTo(int64(volumeIops)) + t.VolumeIops = new(int64(volumeIops)) } if volumeThroughput > 0 { - t.VolumeThroughput = fi.PtrTo(int64(volumeThroughput)) + t.VolumeThroughput = new(int64(volumeThroughput)) } c.AddTask(t) @@ -315,7 +315,7 @@ func (b *MasterVolumeBuilder) addHetznerVolume(c *fi.CloudupModelBuilderContext, tags[hetzner.TagKubernetesVolumeRole] = etcd.Name t := &hetznertasks.Volume{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, Size: int(volumeSize), Location: zone, @@ -344,10 +344,10 @@ func (b *MasterVolumeBuilder) addOpenstackVolume(c *fi.CloudupModelBuilderContex zone = fi.ValueOf(b.Cluster.Spec.CloudProvider.Openstack.BlockStorage.OverrideAZ) } t := &openstacktasks.Volume{ - Name: fi.PtrTo(name), - AvailabilityZone: fi.PtrTo(zone), - VolumeType: fi.PtrTo(volumeType), - SizeGB: fi.PtrTo(int64(volumeSize)), + Name: new(name), + AvailabilityZone: new(zone), + VolumeType: new(volumeType), + SizeGB: new(int64(volumeSize)), Tags: tags, Lifecycle: b.Lifecycle, } @@ -372,19 +372,19 @@ func (b *MasterVolumeBuilder) addAzureVolume( // The tags are use by Protokube to mount the volume and use it for etcd. tags := map[string]*string{ // This is the configuration of the etcd cluster. - azure.TagNameEtcdClusterPrefix + etcd.Name: fi.PtrTo(m.Name + "/" + strings.Join(allMembers, ",")), + azure.TagNameEtcdClusterPrefix + etcd.Name: new(m.Name + "/" + strings.Join(allMembers, ",")), // This says "only mount on a control plane node". - azure.TagNameRolePrefix + azure.TagRoleControlPlane: fi.PtrTo("1"), - azure.TagNameRolePrefix + azure.TagRoleMaster: fi.PtrTo("1"), + azure.TagNameRolePrefix + azure.TagRoleControlPlane: new("1"), + azure.TagNameRolePrefix + azure.TagRoleMaster: new("1"), // We always add an owned tags (these can't be shared). // Use dash (_) as a splitter. Other CSPs use slash (/), but slash is not // allowed as a tag key in Azure. - "kubernetes.io_cluster_" + b.Cluster.ObjectMeta.Name: fi.PtrTo("owned"), + "kubernetes.io_cluster_" + b.Cluster.ObjectMeta.Name: new("owned"), } // Apply all user defined labels on the volumes. for k, v := range b.Cluster.Spec.CloudLabels { - tags[k] = fi.PtrTo(v) + tags[k] = new(v) } zoneNumber, err := azure.ZoneToAvailabilityZoneNumber(zone) @@ -394,15 +394,15 @@ func (b *MasterVolumeBuilder) addAzureVolume( // TODO(kenji): Respect m.EncryptedVolume. t := &azuretasks.Disk{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, // We cannot use AzureModelContext.LinkToResourceGroup() here because of cyclic dependency. ResourceGroup: &azuretasks.ResourceGroup{ - Name: fi.PtrTo(b.Cluster.AzureResourceGroupName()), + Name: new(b.Cluster.AzureResourceGroupName()), }, - SizeGB: fi.PtrTo(volumeSize), + SizeGB: new(volumeSize), Tags: tags, - VolumeType: fi.PtrTo(armcompute.DiskStorageAccountTypes(volumeType)), + VolumeType: new(armcompute.DiskStorageAccountTypes(volumeType)), Zones: []*string{&zoneNumber}, } c.AddTask(t) @@ -422,12 +422,12 @@ func (b *MasterVolumeBuilder) addScalewayVolume(c *fi.CloudupModelBuilderContext } t := &scalewaytasks.Volume{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, - Size: fi.PtrTo(int64(volumeSize) * 1e9), + Size: new(int64(volumeSize) * 1e9), Zone: &zone, Tags: volumeTags, - Type: fi.PtrTo(string(instance.VolumeVolumeTypeBSSD)), + Type: new(string(instance.VolumeVolumeTypeBSSD)), } c.AddTask(t) } diff --git a/pkg/model/names.go b/pkg/model/names.go index 7bc4e381c6f44..297e035e56669 100644 --- a/pkg/model/names.go +++ b/pkg/model/names.go @@ -132,7 +132,7 @@ func (b *KopsModelContext) LinkToVPC() *awstasks.VPC { } func (b *KopsModelContext) LinkToAmazonVPCIPv6CIDR() *awstasks.VPCAmazonIPv6CIDRBlock { - return &awstasks.VPCAmazonIPv6CIDRBlock{Name: fi.PtrTo("AmazonIPv6")} + return &awstasks.VPCAmazonIPv6CIDRBlock{Name: new("AmazonIPv6")} } func (b *KopsModelContext) LinkToDNSZone() *awstasks.DNSZone { @@ -220,7 +220,7 @@ func (b *KopsModelContext) NamePublicRouteTableInZone(zoneName string) string { } func (b *KopsModelContext) LinkToPublicRouteTableInZone(zoneName string) *awstasks.RouteTable { - return &awstasks.RouteTable{Name: fi.PtrTo(b.NamePublicRouteTableInZone(zoneName))} + return &awstasks.RouteTable{Name: new(b.NamePublicRouteTableInZone(zoneName))} } func (b *KopsModelContext) NamePrivateRouteTableInZone(zoneName string) string { @@ -228,7 +228,7 @@ func (b *KopsModelContext) NamePrivateRouteTableInZone(zoneName string) string { } func (b *KopsModelContext) LinkToPrivateRouteTableInZone(zoneName string) *awstasks.RouteTable { - return &awstasks.RouteTable{Name: fi.PtrTo(b.NamePrivateRouteTableInZone(zoneName))} + return &awstasks.RouteTable{Name: new(b.NamePrivateRouteTableInZone(zoneName))} } func (b *KopsModelContext) InstanceName(ig *kops.InstanceGroup, suffix string) string { diff --git a/pkg/model/openstackmodel/context.go b/pkg/model/openstackmodel/context.go index 767aedeb984aa..c288f9ec01563 100644 --- a/pkg/model/openstackmodel/context.go +++ b/pkg/model/openstackmodel/context.go @@ -22,7 +22,6 @@ import ( "k8s.io/klog/v2" "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/model" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" "k8s.io/kops/upup/pkg/fi/cloudup/openstacktasks" ) @@ -131,5 +130,5 @@ func (c *OpenstackModelContext) LinkToPort(name *string) *openstacktasks.Port { } func (c *OpenstackModelContext) LinkToSecurityGroup(name string) *openstacktasks.SecurityGroup { - return &openstacktasks.SecurityGroup{Name: fi.PtrTo(name)} + return &openstacktasks.SecurityGroup{Name: new(name)} } diff --git a/pkg/model/openstackmodel/convenience.go b/pkg/model/openstackmodel/convenience.go index 7d5de09a1e43c..857fe593fbe8c 100644 --- a/pkg/model/openstackmodel/convenience.go +++ b/pkg/model/openstackmodel/convenience.go @@ -16,19 +16,17 @@ limitations under the License. package openstackmodel -import "k8s.io/kops/upup/pkg/fi" - // s is a helper that builds a *string from a string value func s(v string) *string { - return fi.PtrTo(v) + return new(v) } // i32 is a helper that builds a *int32 from an int32 value func i32(v int32) *int32 { - return fi.PtrTo(v) + return new(v) } // i is a helper that builds a *int from an int value func i(v int) *int { - return fi.PtrTo(v) + return new(v) } diff --git a/pkg/model/openstackmodel/firewall.go b/pkg/model/openstackmodel/firewall.go index 6f86e19e2d4d6..2d5fb5fb58470 100644 --- a/pkg/model/openstackmodel/firewall.go +++ b/pkg/model/openstackmodel/firewall.go @@ -78,7 +78,7 @@ func (b *FirewallModelBuilder) addDirectionalGroupRule(c *fi.CloudupModelBuilder RemoteGroup: dest, RemoteIPPrefix: sgr.RemoteIPPrefix, SecGroup: source, - Delete: fi.PtrTo(false), + Delete: new(false), } klog.V(8).Infof("Adding rule %v", fi.ValueOf(t.GetName())) @@ -648,7 +648,7 @@ func (b *FirewallModelBuilder) getExistingRules(sgMap map[string]*openstacktasks return fmt.Errorf("Found multiple security groups with the same name: %v", sgName) } sg := sgs[0] - sgt.Name = fi.PtrTo(sg.Name) + sgt.Name = new(sg.Name) sgIdMap[sg.ID] = sgt } @@ -663,17 +663,17 @@ func (b *FirewallModelBuilder) getExistingRules(sgMap map[string]*openstacktasks for _, rule := range sgRules { t := &openstacktasks.SecurityGroupRule{ - ID: fi.PtrTo(rule.ID), - Direction: fi.PtrTo(rule.Direction), - EtherType: fi.PtrTo(rule.EtherType), - PortRangeMax: fi.PtrTo(rule.PortRangeMax), - PortRangeMin: fi.PtrTo(rule.PortRangeMin), - Protocol: fi.PtrTo(rule.Protocol), - RemoteIPPrefix: fi.PtrTo(rule.RemoteIPPrefix), + ID: new(rule.ID), + Direction: new(rule.Direction), + EtherType: new(rule.EtherType), + PortRangeMax: new(rule.PortRangeMax), + PortRangeMin: new(rule.PortRangeMin), + Protocol: new(rule.Protocol), + RemoteIPPrefix: new(rule.RemoteIPPrefix), RemoteGroup: sgIdMap[rule.RemoteGroupID], Lifecycle: b.Lifecycle, SecGroup: sgIdMap[rule.SecGroupID], - Delete: fi.PtrTo(true), + Delete: new(true), } klog.V(8).Infof("Adding existing rule %v", t) b.Rules[fi.ValueOf(t.GetName())] = t diff --git a/pkg/model/openstackmodel/network.go b/pkg/model/openstackmodel/network.go index 6d397a9321d6c..54459e40e52b1 100644 --- a/pkg/model/openstackmodel/network.go +++ b/pkg/model/openstackmodel/network.go @@ -77,7 +77,7 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { dnsSplitted := strings.Split(fi.ValueOf(osSpec.Router.DNSServers), ",") dnsNameSrv := make([]*string, len(dnsSplitted)) for i, ns := range dnsSplitted { - dnsNameSrv[i] = fi.PtrTo(ns) + dnsNameSrv[i] = new(ns) } t.DNSServers = dnsNameSrv } diff --git a/pkg/model/openstackmodel/servergroup.go b/pkg/model/openstackmodel/servergroup.go index 715ff10e03bfd..8adb34d69358f 100644 --- a/pkg/model/openstackmodel/servergroup.go +++ b/pkg/model/openstackmodel/servergroup.go @@ -146,7 +146,7 @@ func (b *ServerGroupModelBuilder) buildInstances(c *fi.CloudupModelBuilderContex // FIXME: Must ensure 63 or less characters // replace all dots and _ with -, this is needed to get external cloudprovider working iName := strings.ReplaceAll(strings.ToLower(fmt.Sprintf("%s-%d.%s", ig.Name, i+1, b.ClusterName())), "_", "-") - instanceName := fi.PtrTo(strings.ReplaceAll(iName, ".", "-")) + instanceName := new(strings.ReplaceAll(iName, ".", "-")) var az *string var subnets []*openstacktasks.Subnet @@ -155,9 +155,9 @@ func (b *ServerGroupModelBuilder) buildInstances(c *fi.CloudupModelBuilderContex subnet := ig.Spec.Subnets[int(i)%len(ig.Spec.Subnets)] // bastion subnet name might contain a "utility-" prefix if ig.Spec.Role.HasBastion() { - az = fi.PtrTo(strings.Replace(subnet, "utility-", "", 1)) + az = new(strings.Replace(subnet, "utility-", "", 1)) } else { - az = fi.PtrTo(subnet) + az = new(subnet) } subnetName, subnetType, err := b.findSubnetClusterSpec(subnet) @@ -171,7 +171,7 @@ func (b *ServerGroupModelBuilder) buildInstances(c *fi.CloudupModelBuilderContex } if len(ig.Spec.Zones) > 0 { zone := ig.Spec.Zones[int(i)%len(ig.Spec.Zones)] - az = fi.PtrTo(zone) + az = new(zone) } // Create instance port task portName := fmt.Sprintf("%s-%s", "port", *instanceName) @@ -184,7 +184,7 @@ func (b *ServerGroupModelBuilder) buildInstances(c *fi.CloudupModelBuilderContex ), ".", "-", ) portTask := &openstacktasks.Port{ - Name: fi.PtrTo(portName), + Name: new(portName), InstanceGroupName: &groupName, Network: b.LinkToNetwork(), Tags: []string{ @@ -213,12 +213,12 @@ func (b *ServerGroupModelBuilder) buildInstances(c *fi.CloudupModelBuilderContex Name: instanceName, Lifecycle: b.Lifecycle, GroupName: s(groupName), - Region: fi.PtrTo(b.Cluster.Spec.Networking.Subnets[0].Region), - Flavor: fi.PtrTo(ig.Spec.MachineType), - Image: fi.PtrTo(ig.Spec.Image), - SSHKey: fi.PtrTo(sshKeyName), + Region: new(b.Cluster.Spec.Networking.Subnets[0].Region), + Flavor: new(ig.Spec.MachineType), + Image: new(ig.Spec.Image), + SSHKey: new(sshKeyName), ServerGroup: sg, - Role: fi.PtrTo(string(ig.Spec.Role)), + Role: new(string(ig.Spec.Role)), Port: portTask, UserData: startupScript, Metadata: metaWithName, @@ -236,7 +236,7 @@ func (b *ServerGroupModelBuilder) buildInstances(c *fi.CloudupModelBuilderContex } if havePublicSubnet || ig.Spec.Role.HasBastion() { t := &openstacktasks.FloatingIP{ - Name: fi.PtrTo(fmt.Sprintf("%s-%s", "fip", *instanceTask.Name)), + Name: new(fmt.Sprintf("%s-%s", "fip", *instanceTask.Name)), Lifecycle: b.Lifecycle, } c.AddTask(t) @@ -314,8 +314,8 @@ func (b *ServerGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) error } lbTask := &openstacktasks.LB{ - Name: fi.PtrTo(b.APIResourceName()), - Subnet: fi.PtrTo(lbSubnetName), + Name: new(b.APIResourceName()), + Subnet: new(lbSubnetName), Lifecycle: b.Lifecycle, } @@ -331,7 +331,7 @@ func (b *ServerGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) error c.AddTask(lbTask) lbfipTask := &openstacktasks.FloatingIP{ - Name: fi.PtrTo(fmt.Sprintf("%s-%s", "fip", *lbTask.Name)), + Name: new(fmt.Sprintf("%s-%s", "fip", *lbTask.Name)), LB: lbTask, Lifecycle: b.Lifecycle, } @@ -340,7 +340,7 @@ func (b *ServerGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) error lbfipTask.WellKnownServices = append(lbfipTask.WellKnownServices, wellknownservices.KubeAPIServer) poolTask := &openstacktasks.LBPool{ - Name: fi.PtrTo(fmt.Sprintf("%s-https", fi.ValueOf(lbTask.Name))), + Name: new(fmt.Sprintf("%s-https", fi.ValueOf(lbTask.Name))), Loadbalancer: lbTask, Lifecycle: b.Lifecycle, } @@ -348,8 +348,8 @@ func (b *ServerGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) error nameForResource := fi.ValueOf(lbTask.Name) listenerTask := &openstacktasks.LBListener{ - Name: fi.PtrTo(nameForResource), - Port: fi.PtrTo(wellknownports.KubeAPIServer), + Name: new(nameForResource), + Port: new(wellknownports.KubeAPIServer), Lifecycle: b.Lifecycle, Pool: poolTask, } @@ -367,7 +367,7 @@ func (b *ServerGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) error c.AddTask(listenerTask) monitorTask := &openstacktasks.PoolMonitor{ - Name: fi.PtrTo(nameForResource), + Name: new(nameForResource), Pool: poolTask, Lifecycle: b.Lifecycle, } @@ -381,14 +381,14 @@ func (b *ServerGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) error for _, ig := range b.InstanceGroups { if ig.Spec.Role.HasControlPlane() { associateTask := &openstacktasks.PoolAssociation{ - Name: fi.PtrTo(fmt.Sprintf("%s-%s", clusterName, ig.Name)), - ServerPrefix: fi.PtrTo(ig.Name), + Name: new(fmt.Sprintf("%s-%s", clusterName, ig.Name)), + ServerPrefix: new(ig.Name), ClusterName: s(clusterName), Pool: poolTask, - InterfaceName: fi.PtrTo(ifName), - ProtocolPort: fi.PtrTo(wellknownports.KubeAPIServer), + InterfaceName: new(ifName), + ProtocolPort: new(wellknownports.KubeAPIServer), Lifecycle: b.Lifecycle, - Weight: fi.PtrTo(1), + Weight: new(1), } c.AddTask(associateTask) } diff --git a/pkg/model/openstackmodel/servergroup_test.go b/pkg/model/openstackmodel/servergroup_test.go index 4ccc5e412c9c6..8bcb6f7868350 100644 --- a/pkg/model/openstackmodel/servergroup_test.go +++ b/pkg/model/openstackmodel/servergroup_test.go @@ -55,10 +55,10 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Router: &kops.OpenstackRouter{ - ExternalNetwork: fi.PtrTo("test"), + ExternalNetwork: new("test"), }, Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -118,10 +118,10 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Router: &kops.OpenstackRouter{ - ExternalNetwork: fi.PtrTo("test"), + ExternalNetwork: new("test"), }, Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -208,10 +208,10 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Router: &kops.OpenstackRouter{ - ExternalNetwork: fi.PtrTo("test"), + ExternalNetwork: new("test"), }, Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -337,10 +337,10 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Router: &kops.OpenstackRouter{ - ExternalNetwork: fi.PtrTo("test"), + ExternalNetwork: new("test"), }, Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -402,10 +402,10 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { Openstack: &kops.OpenstackSpec{ Loadbalancer: &kops.OpenstackLoadbalancerConfig{}, Router: &kops.OpenstackRouter{ - ExternalNetwork: fi.PtrTo("test"), + ExternalNetwork: new("test"), }, Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -534,34 +534,34 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ BlockStorage: &kops.OpenstackBlockStorageConfig{ - Version: fi.PtrTo("v3"), - IgnoreAZ: fi.PtrTo(false), - CreateStorageClass: fi.PtrTo(false), - CSITopologySupport: fi.PtrTo(true), + Version: new("v3"), + IgnoreAZ: new(false), + CreateStorageClass: new(false), + CSITopologySupport: new(true), }, Loadbalancer: &kops.OpenstackLoadbalancerConfig{ - FloatingNetwork: fi.PtrTo("test"), - FloatingSubnet: fi.PtrTo("test-lb-subnet"), - Method: fi.PtrTo("ROUND_ROBIN"), - Provider: fi.PtrTo("amphora"), - UseOctavia: fi.PtrTo(true), + FloatingNetwork: new("test"), + FloatingSubnet: new("test-lb-subnet"), + Method: new("ROUND_ROBIN"), + Provider: new("amphora"), + UseOctavia: new(true), }, Monitor: &kops.OpenstackMonitor{ - Delay: fi.PtrTo("1m"), - MaxRetries: fi.PtrTo(3), - Timeout: fi.PtrTo("30s"), + Delay: new("1m"), + MaxRetries: new(3), + Timeout: new("30s"), }, Network: &kops.OpenstackNetwork{ - AvailabilityZoneHints: []*string{fi.PtrTo("zone-1"), fi.PtrTo("zone-2"), fi.PtrTo("zone-3")}, + AvailabilityZoneHints: []*string{new("zone-1"), new("zone-2"), new("zone-3")}, }, Router: &kops.OpenstackRouter{ - DNSServers: fi.PtrTo("8.8.8.8,8.8.4.4"), - ExternalSubnet: fi.PtrTo("test-router-subnet"), - ExternalNetwork: fi.PtrTo("test"), - AvailabilityZoneHints: []*string{fi.PtrTo("ha-zone")}, + DNSServers: new("8.8.8.8,8.8.4.4"), + ExternalSubnet: new("test-router-subnet"), + ExternalNetwork: new("test"), + AvailabilityZoneHints: []*string{new("ha-zone")}, }, Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -692,34 +692,34 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ BlockStorage: &kops.OpenstackBlockStorageConfig{ - Version: fi.PtrTo("v3"), - IgnoreAZ: fi.PtrTo(false), - CreateStorageClass: fi.PtrTo(false), - CSITopologySupport: fi.PtrTo(true), + Version: new("v3"), + IgnoreAZ: new(false), + CreateStorageClass: new(false), + CSITopologySupport: new(true), }, Loadbalancer: &kops.OpenstackLoadbalancerConfig{ - FloatingNetwork: fi.PtrTo("test"), - FloatingSubnet: fi.PtrTo("test-lb-subnet"), - Method: fi.PtrTo("ROUND_ROBIN"), - Provider: fi.PtrTo("amphora"), - UseOctavia: fi.PtrTo(true), + FloatingNetwork: new("test"), + FloatingSubnet: new("test-lb-subnet"), + Method: new("ROUND_ROBIN"), + Provider: new("amphora"), + UseOctavia: new(true), }, Monitor: &kops.OpenstackMonitor{ - Delay: fi.PtrTo("1m"), - MaxRetries: fi.PtrTo(3), - Timeout: fi.PtrTo("30s"), + Delay: new("1m"), + MaxRetries: new(3), + Timeout: new("30s"), }, Network: &kops.OpenstackNetwork{ - AvailabilityZoneHints: []*string{fi.PtrTo("zone-1")}, + AvailabilityZoneHints: []*string{new("zone-1")}, }, Router: &kops.OpenstackRouter{ - DNSServers: fi.PtrTo("8.8.8.8,8.8.4.4"), - ExternalSubnet: fi.PtrTo("test-router-subnet"), - ExternalNetwork: fi.PtrTo("test"), - AvailabilityZoneHints: []*string{fi.PtrTo("zone-1")}, + DNSServers: new("8.8.8.8,8.8.4.4"), + ExternalSubnet: new("test-router-subnet"), + ExternalNetwork: new("test"), + AvailabilityZoneHints: []*string{new("zone-1")}, }, Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -819,7 +819,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -945,10 +945,10 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Router: &kops.OpenstackRouter{ - ExternalNetwork: fi.PtrTo("test"), + ExternalNetwork: new("test"), }, Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -1034,10 +1034,10 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Router: &kops.OpenstackRouter{ - ExternalNetwork: fi.PtrTo("test"), + ExternalNetwork: new("test"), }, Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -1066,7 +1066,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { MachineType: "blc.1-2", Subnets: []string{"subnet"}, Zones: []string{"zone-1"}, - AssociatePublicIP: fi.PtrTo(false), + AssociatePublicIP: new(false), }, }, { @@ -1081,7 +1081,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { MachineType: "blc.2-4", Subnets: []string{"subnet"}, Zones: []string{"zone-1"}, - AssociatePublicIP: fi.PtrTo(false), + AssociatePublicIP: new(false), }, }, }, @@ -1099,10 +1099,10 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Router: &kops.OpenstackRouter{ - ExternalNetwork: fi.PtrTo("test"), + ExternalNetwork: new("test"), }, Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -1136,7 +1136,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { MachineType: "blc.1-2", Subnets: []string{"subnet"}, Zones: []string{"zone-1"}, - AssociatePublicIP: fi.PtrTo(false), + AssociatePublicIP: new(false), }, }, { @@ -1151,7 +1151,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { MachineType: "blc.1-2", Subnets: []string{"subnet"}, Zones: []string{"zone-1"}, - AssociatePublicIP: fi.PtrTo(false), + AssociatePublicIP: new(false), }, }, { @@ -1173,7 +1173,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { MachineType: "blc.1-2", Subnets: []string{"utility-subnet"}, Zones: []string{"zone-1"}, - AssociatePublicIP: fi.PtrTo(false), + AssociatePublicIP: new(false), }, }, }, @@ -1191,7 +1191,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -1240,7 +1240,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -1291,7 +1291,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -1340,7 +1340,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -1389,7 +1389,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -1438,7 +1438,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -1487,7 +1487,7 @@ func getServerGroupModelBuilderTestInput() []serverGroupModelBuilderTestInput { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ Metadata: &kops.OpenstackMetadata{ - ConfigDrive: fi.PtrTo(false), + ConfigDrive: new(false), }, }, }, @@ -1596,7 +1596,7 @@ func RunGoldenTest(t *testing.T, basedir string, testCase serverGroupModelBuilde // We need the CA and service-account for the bootstrap script caTask := &fitasks.Keypair{ - Name: fi.PtrTo(fi.CertificateIDCA), + Name: new(fi.CertificateIDCA), Subject: "cn=kubernetes", Type: "ca", } @@ -1613,7 +1613,7 @@ func RunGoldenTest(t *testing.T, basedir string, testCase serverGroupModelBuilde "service-account", } { task := &fitasks.Keypair{ - Name: fi.PtrTo(keypair), + Name: new(keypair), Subject: "cn=" + keypair, Type: "ca", } @@ -1624,7 +1624,7 @@ func RunGoldenTest(t *testing.T, basedir string, testCase serverGroupModelBuilde "kube-proxy", } { task := &fitasks.Keypair{ - Name: fi.PtrTo(keypair), + Name: new(keypair), Subject: "cn=" + keypair, Signer: caTask, Type: "client", diff --git a/pkg/model/pki.go b/pkg/model/pki.go index 538e0717f4e44..14e86180b6507 100644 --- a/pkg/model/pki.go +++ b/pkg/model/pki.go @@ -35,7 +35,7 @@ var _ fi.CloudupModelBuilder = &PKIModelBuilder{} func (b *PKIModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // TODO: Only create the CA via this task defaultCA := &fitasks.Keypair{ - Name: fi.PtrTo(fi.CertificateIDCA), + Name: new(fi.CertificateIDCA), Lifecycle: b.Lifecycle, Subject: "cn=kubernetes-ca", Type: "ca", @@ -47,7 +47,7 @@ func (b *PKIModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { b.Cluster.Spec.ServiceAccountIssuerDiscovery.DiscoveryService.URL != "" { // TODO: Only create the discovery CA via this task (but it's tricky because we need the ID so early) discoveryCA := &fitasks.Keypair{ - Name: fi.PtrTo(string(fi.DiscoveryCAID)), + Name: new(string(fi.DiscoveryCAID)), Lifecycle: b.Lifecycle, Subject: "cn=" + fi.DiscoveryCAID, Type: "ca", @@ -57,7 +57,7 @@ func (b *PKIModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { { aggregatorCA := &fitasks.Keypair{ - Name: fi.PtrTo("apiserver-aggregator-ca"), + Name: new("apiserver-aggregator-ca"), Lifecycle: b.Lifecycle, Subject: "cn=apiserver-aggregator-ca", Type: "ca", @@ -68,7 +68,7 @@ func (b *PKIModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { { serviceAccount := &fitasks.Keypair{ // We only need the private key, but it's easier to create a certificate as well. - Name: fi.PtrTo("service-account"), + Name: new("service-account"), Lifecycle: b.Lifecycle, Subject: "cn=service-account", Type: "ca", @@ -78,7 +78,7 @@ func (b *PKIModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Create auth tokens (though this is deprecated) for _, x := range tokens.GetKubernetesAuthTokens_Deprecated() { - c.AddTask(&fitasks.Secret{Name: fi.PtrTo(x), Lifecycle: b.Lifecycle}) + c.AddTask(&fitasks.Secret{Name: new(x), Lifecycle: b.Lifecycle}) } { @@ -88,7 +88,7 @@ func (b *PKIModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { } t := &fitasks.MirrorSecrets{ - Name: fi.PtrTo("mirror-secrets"), + Name: new("mirror-secrets"), Lifecycle: b.Lifecycle, MirrorPath: mirrorPath, } @@ -103,7 +103,7 @@ func (b *PKIModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { // Keypair used by the kubelet t := &fitasks.MirrorKeystore{ - Name: fi.PtrTo("mirror-keystore"), + Name: new("mirror-keystore"), Lifecycle: b.Lifecycle, MirrorPath: mirrorPath, } diff --git a/pkg/model/scalewaymodel/api_loadbalancer.go b/pkg/model/scalewaymodel/api_loadbalancer.go index e50ddb7fdd035..b0a1bce0c13c8 100644 --- a/pkg/model/scalewaymodel/api_loadbalancer.go +++ b/pkg/model/scalewaymodel/api_loadbalancer.go @@ -71,8 +71,8 @@ func (b *APILoadBalancerModelBuilder) Build(c *fi.CloudupModelBuilderContext) er loadBalancerName := "api." + b.ClusterName() loadBalancer := &scalewaytasks.LoadBalancer{ - Name: fi.PtrTo(loadBalancerName), - Zone: fi.PtrTo(string(zone)), + Name: new(loadBalancerName), + Zone: new(string(zone)), Type: scalewaytasks.LbDefaultType, Lifecycle: b.Lifecycle, Tags: lbTags, @@ -103,20 +103,20 @@ func (b *APILoadBalancerModelBuilder) Build(c *fi.CloudupModelBuilderContext) er func createLbBackendAndFrontend(name string, port int, zone scw.Zone, loadBalancer *scalewaytasks.LoadBalancer) (*scalewaytasks.LBBackend, *scalewaytasks.LBFrontend) { lbBackendKopsController := &scalewaytasks.LBBackend{ - Name: fi.PtrTo("lb-backend-" + name), - Zone: fi.PtrTo(string(zone)), - ForwardProtocol: fi.PtrTo(string(lb.ProtocolTCP)), - ForwardPort: fi.PtrTo(int32(port)), - ForwardPortAlgorithm: fi.PtrTo(string(lb.ForwardPortAlgorithmRoundrobin)), - StickySessions: fi.PtrTo(string(lb.StickySessionsTypeNone)), - ProxyProtocol: fi.PtrTo(string(lb.ProxyProtocolProxyProtocolNone)), + Name: new("lb-backend-" + name), + Zone: new(string(zone)), + ForwardProtocol: new(string(lb.ProtocolTCP)), + ForwardPort: new(int32(port)), + ForwardPortAlgorithm: new(string(lb.ForwardPortAlgorithmRoundrobin)), + StickySessions: new(string(lb.StickySessionsTypeNone)), + ProxyProtocol: new(string(lb.ProxyProtocolProxyProtocolNone)), LoadBalancer: loadBalancer, } lbFrontendKopsController := &scalewaytasks.LBFrontend{ - Name: fi.PtrTo("lb-frontend-" + name), - Zone: fi.PtrTo(string(zone)), - InboundPort: fi.PtrTo(int32(port)), + Name: new("lb-frontend-" + name), + Zone: new(string(zone)), + InboundPort: new(int32(port)), LoadBalancer: loadBalancer, LBBackend: lbBackendKopsController, } diff --git a/pkg/model/scalewaymodel/dns.go b/pkg/model/scalewaymodel/dns.go index 5ca1b75082f8f..31e4f51c96f89 100644 --- a/pkg/model/scalewaymodel/dns.go +++ b/pkg/model/scalewaymodel/dns.go @@ -45,11 +45,11 @@ func (b *DNSModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { if !b.UseLoadBalancerForAPI() { recordShortName := strings.TrimSuffix(b.Cluster.Spec.API.PublicName, "."+b.Cluster.Spec.DNSZone) dnsAPIExternal := &scalewaytasks.DNSRecord{ - Name: fi.PtrTo(recordShortName), - Data: fi.PtrTo(placeholderIP), - DNSZone: fi.PtrTo(b.Cluster.Spec.DNSZone), - Type: fi.PtrTo(domain.RecordTypeA.String()), - TTL: fi.PtrTo(defaultTTL), + Name: new(recordShortName), + Data: new(placeholderIP), + DNSZone: new(b.Cluster.Spec.DNSZone), + Type: new(domain.RecordTypeA.String()), + TTL: new(defaultTTL), Lifecycle: b.Lifecycle, } c.AddTask(dnsAPIExternal) @@ -58,11 +58,11 @@ func (b *DNSModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { if !b.UseLoadBalancerForInternalAPI() { recordShortName := strings.TrimSuffix(b.Cluster.APIInternalName(), "."+b.Cluster.Spec.DNSZone) dnsAPIInternal := &scalewaytasks.DNSRecord{ - Name: fi.PtrTo(recordShortName), - Data: fi.PtrTo(placeholderIP), - DNSZone: fi.PtrTo(b.Cluster.Spec.DNSZone), - Type: fi.PtrTo(domain.RecordTypeA.String()), - TTL: fi.PtrTo(defaultTTL), + Name: new(recordShortName), + Data: new(placeholderIP), + DNSZone: new(b.Cluster.Spec.DNSZone), + Type: new(domain.RecordTypeA.String()), + TTL: new(defaultTTL), Lifecycle: b.Lifecycle, } c.AddTask(dnsAPIInternal) @@ -71,11 +71,11 @@ func (b *DNSModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { recordSuffix := strings.TrimSuffix(b.Cluster.ObjectMeta.Name, "."+b.Cluster.Spec.DNSZone) recordShortName := kopsControllerInternalRecordPrefix + recordSuffix kopsControllerInternal := &scalewaytasks.DNSRecord{ - Name: fi.PtrTo(recordShortName), - Data: fi.PtrTo(placeholderIP), - DNSZone: fi.PtrTo(b.Cluster.Spec.DNSZone), - Type: fi.PtrTo(domain.RecordTypeA.String()), - TTL: fi.PtrTo(defaultTTL), + Name: new(recordShortName), + Data: new(placeholderIP), + DNSZone: new(b.Cluster.Spec.DNSZone), + Type: new(domain.RecordTypeA.String()), + TTL: new(defaultTTL), Lifecycle: b.Lifecycle, } c.AddTask(kopsControllerInternal) diff --git a/pkg/model/scalewaymodel/instances.go b/pkg/model/scalewaymodel/instances.go index 3c53663634143..043c881e82515 100644 --- a/pkg/model/scalewaymodel/instances.go +++ b/pkg/model/scalewaymodel/instances.go @@ -65,20 +65,20 @@ func (b *InstanceModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { instance := scalewaytasks.Instance{ Count: int(fi.ValueOf(ig.Spec.MinSize)), - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, - Zone: fi.PtrTo(string(zone)), - CommercialType: fi.PtrTo(ig.Spec.MachineType), - Image: fi.PtrTo(ig.Spec.Image), + Zone: new(string(zone)), + CommercialType: new(ig.Spec.MachineType), + Image: new(ig.Spec.Image), UserData: &userData, Tags: instanceTags, } if ig.IsControlPlane() { instance.Tags = append(instance.Tags, scaleway.TagNameRolePrefix+"="+scaleway.TagRoleControlPlane) - instance.Role = fi.PtrTo(scaleway.TagRoleControlPlane) + instance.Role = new(scaleway.TagRoleControlPlane) } else { - instance.Role = fi.PtrTo(scaleway.TagRoleWorker) + instance.Role = new(scaleway.TagRoleWorker) } // If the instance's commercial type is one that has no local storage, we have to specify for the @@ -86,9 +86,9 @@ func (b *InstanceModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { for _, commercialType := range commercialTypesWithBlockStorageOnly { if strings.HasPrefix(ig.Spec.MachineType, commercialType) { if ig.IsControlPlane() { - instance.VolumeSize = fi.PtrTo(defaultControlPlaneRootVolumeSizeGB) + instance.VolumeSize = new(defaultControlPlaneRootVolumeSizeGB) } else { - instance.VolumeSize = fi.PtrTo(defaultNodeRootVolumeSizeGB) + instance.VolumeSize = new(defaultNodeRootVolumeSizeGB) } break } diff --git a/pkg/model/scalewaymodel/sshkey.go b/pkg/model/scalewaymodel/sshkey.go index 2029d7447e0ef..66c4e6078b394 100644 --- a/pkg/model/scalewaymodel/sshkey.go +++ b/pkg/model/scalewaymodel/sshkey.go @@ -39,7 +39,7 @@ func (b *SSHKeyModelBuilder) Build(c *fi.CloudupModelBuilderContext) error { sshKeyResource := fi.Resource(fi.NewStringResource(string(b.SSHPublicKeys[0]))) t := &scalewaytasks.SSHKey{ - Name: fi.PtrTo(name), + Name: new(name), Lifecycle: b.Lifecycle, PublicKey: &sshKeyResource, } diff --git a/pkg/nodemodel/fileassets.go b/pkg/nodemodel/fileassets.go index 738a2839757cc..31e47b096b80f 100644 --- a/pkg/nodemodel/fileassets.go +++ b/pkg/nodemodel/fileassets.go @@ -26,7 +26,6 @@ import ( "k8s.io/kops/pkg/apis/kops/model" "k8s.io/kops/pkg/assets" "k8s.io/kops/pkg/nodemodel/wellknownassets" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/util/pkg/architectures" ) @@ -75,7 +74,7 @@ func BuildKubernetesFileAssets(ig model.InstanceGroup, assetBuilder *assets.Asse case kops.CloudProviderGCE: binaryLocation := ig.RawClusterSpec().CloudProvider.GCE.BinariesLocation if binaryLocation == nil { - binaryLocation = fi.PtrTo("https://artifacts.k8s.io/binaries/cloud-provider-gcp/v35.0.0") + binaryLocation = new("https://artifacts.k8s.io/binaries/cloud-provider-gcp/v35.0.0") } u, err := url.Parse(fmt.Sprintf("%s/auth-provider-gcp/linux/%s/auth-provider-gcp", *binaryLocation, arch)) @@ -91,7 +90,7 @@ func BuildKubernetesFileAssets(ig model.InstanceGroup, assetBuilder *assets.Asse case kops.CloudProviderAWS: binaryLocation := ig.RawClusterSpec().CloudProvider.AWS.BinariesLocation if binaryLocation == nil { - binaryLocation = fi.PtrTo("https://artifacts.k8s.io/binaries/cloud-provider-aws/v1.31.7") + binaryLocation = new("https://artifacts.k8s.io/binaries/cloud-provider-aws/v1.31.7") } u, err := url.Parse(fmt.Sprintf("%s/linux/%s/ecr-credential-provider-linux-%s", *binaryLocation, arch, arch)) diff --git a/pkg/nodemodel/nodeupconfigbuilder.go b/pkg/nodemodel/nodeupconfigbuilder.go index 8a409f94fff49..c75ee3f8175ec 100644 --- a/pkg/nodemodel/nodeupconfigbuilder.go +++ b/pkg/nodemodel/nodeupconfigbuilder.go @@ -388,7 +388,7 @@ func (n *nodeUpConfigBuilder) BuildConfig(ig *kops.InstanceGroup, wellKnownAddre bootConfig.ConfigServer = buildConfigServerOptions(cluster.ObjectMeta.Name, config.CAs[fi.CertificateIDCA], bootConfig.APIServerIPs) delete(config.CAs, fi.CertificateIDCA) } else { - bootConfig.ConfigBase = fi.PtrTo(n.configBase.Path()) + bootConfig.ConfigBase = new(n.configBase.Path()) } for _, manifest := range n.assetBuilder.StaticManifests() { diff --git a/pkg/resources/aws/aws.go b/pkg/resources/aws/aws.go index 4d563ad49a941..b9788d72ea541 100644 --- a/pkg/resources/aws/aws.go +++ b/pkg/resources/aws/aws.go @@ -1440,7 +1440,7 @@ func DeleteAutoScalingGroupLaunchTemplate(cloud fi.Cloud, r *resources.Resource) klog.V(2).Infof("Deleting EC2 LaunchTemplate %q", r.ID) if _, err := c.EC2().DeleteLaunchTemplate(ctx, &ec2.DeleteLaunchTemplateInput{ - LaunchTemplateId: fi.PtrTo(r.ID), + LaunchTemplateId: new(r.ID), }); err != nil { return fmt.Errorf("error deleting ec2 LaunchTemplate %q: %v", r.ID, err) } @@ -2176,7 +2176,7 @@ func ListIAMOIDCProviders(cloud fi.Cloud, vpcID, clusterName string) ([]*resourc func DeleteIAMOIDCProvider(cloud fi.Cloud, r *resources.Resource) error { ctx := context.TODO() c := cloud.(awsup.AWSCloud) - arn := fi.PtrTo(r.ID) + arn := new(r.ID) { klog.V(2).Infof("Deleting IAM OIDC Provider %v", arn) request := &iam.DeleteOpenIDConnectProviderInput{ diff --git a/pkg/resources/aws/aws_test.go b/pkg/resources/aws/aws_test.go index c28cf43e01454..a9a04c32395f3 100644 --- a/pkg/resources/aws/aws_test.go +++ b/pkg/resources/aws/aws_test.go @@ -30,7 +30,6 @@ import ( "k8s.io/kops/cloudmock/aws/mockec2" "k8s.io/kops/cloudmock/aws/mockiam" "k8s.io/kops/pkg/resources" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/awsup" ) @@ -110,7 +109,7 @@ func TestListIAMInstanceProfiles(t *testing.T) { tags := []iamtypes.Tag{ { Key: &ownershipTagKey, - Value: fi.PtrTo("owned"), + Value: new("owned"), }, } @@ -139,7 +138,7 @@ func TestListIAMInstanceProfiles(t *testing.T) { Tags: []iamtypes.Tag{ { Key: &owner, - Value: fi.PtrTo("owned"), + Value: new("owned"), }, }, } @@ -184,7 +183,7 @@ func TestListIAMRoles(t *testing.T) { tags := []iamtypes.Tag{ { Key: &ownershipTagKey, - Value: fi.PtrTo("owned"), + Value: new("owned"), }, } @@ -213,7 +212,7 @@ func TestListIAMRoles(t *testing.T) { Tags: []iamtypes.Tag{ { Key: &owner, - Value: fi.PtrTo("owned"), + Value: new("owned"), }, }, } @@ -355,12 +354,12 @@ func TestMatchesElbTags(t *testing.T) { tags: map[string]string{"tagkey1": "tagvalue1"}, actual: []elbtypes.Tag{ { - Key: fi.PtrTo("tagkey1"), - Value: fi.PtrTo("tagvalue1"), + Key: new("tagkey1"), + Value: new("tagvalue1"), }, { - Key: fi.PtrTo("tagkey2"), - Value: fi.PtrTo("tagvalue2"), + Key: new("tagkey2"), + Value: new("tagvalue2"), }, }, expected: true, @@ -369,12 +368,12 @@ func TestMatchesElbTags(t *testing.T) { tags: map[string]string{"tagkey2": "tagvalue2"}, actual: []elbtypes.Tag{ { - Key: fi.PtrTo("tagkey1"), - Value: fi.PtrTo("tagvalue1"), + Key: new("tagkey1"), + Value: new("tagvalue1"), }, { - Key: fi.PtrTo("tagkey2"), - Value: fi.PtrTo("tagvalue2"), + Key: new("tagkey2"), + Value: new("tagvalue2"), }, }, expected: true, @@ -383,12 +382,12 @@ func TestMatchesElbTags(t *testing.T) { tags: map[string]string{"tagkey3": "tagvalue3"}, actual: []elbtypes.Tag{ { - Key: fi.PtrTo("tagkey1"), - Value: fi.PtrTo("tagvalue1"), + Key: new("tagkey1"), + Value: new("tagvalue1"), }, { - Key: fi.PtrTo("tagkey2"), - Value: fi.PtrTo("tagvalue2"), + Key: new("tagkey2"), + Value: new("tagvalue2"), }, }, expected: false, diff --git a/pkg/resources/spotinst/aws.go b/pkg/resources/spotinst/aws.go index 9c0fd03d1a08e..e2f0d05809d11 100644 --- a/pkg/resources/spotinst/aws.go +++ b/pkg/resources/spotinst/aws.go @@ -72,7 +72,7 @@ func (x *awsElastigroupService) Create(ctx context.Context, group InstanceGroup) // Read returns an existing InstanceGroup by ID. func (x *awsElastigroupService) Read(ctx context.Context, groupID string) (InstanceGroup, error) { input := &awseg.ReadGroupInput{ - GroupID: fi.PtrTo(groupID), + GroupID: new(groupID), } output, err := x.svc.Read(ctx, input) @@ -96,7 +96,7 @@ func (x *awsElastigroupService) Update(ctx context.Context, group InstanceGroup) // Delete deletes an existing InstanceGroup by ID. func (x *awsElastigroupService) Delete(ctx context.Context, groupID string) error { input := &awseg.DeleteGroupInput{ - GroupID: fi.PtrTo(groupID), + GroupID: new(groupID), } _, err := x.svc.Delete(ctx, input) @@ -106,10 +106,10 @@ func (x *awsElastigroupService) Delete(ctx context.Context, groupID string) erro // Detach removes one or more instances from the specified InstanceGroup. func (x *awsElastigroupService) Detach(ctx context.Context, groupID string, instanceIDs []string) error { input := &awseg.DetachGroupInput{ - GroupID: fi.PtrTo(groupID), + GroupID: new(groupID), InstanceIDs: instanceIDs, - ShouldDecrementTargetCapacity: fi.PtrTo(false), - ShouldTerminateInstances: fi.PtrTo(true), + ShouldDecrementTargetCapacity: new(false), + ShouldTerminateInstances: new(true), } _, err := x.svc.Detach(ctx, input) @@ -119,7 +119,7 @@ func (x *awsElastigroupService) Detach(ctx context.Context, groupID string, inst // Instances returns a list of all instances that belong to specified InstanceGroup. func (x *awsElastigroupService) Instances(ctx context.Context, groupID string) ([]Instance, error) { input := &awseg.StatusGroupInput{ - GroupID: fi.PtrTo(groupID), + GroupID: new(groupID), } output, err := x.svc.Status(ctx, input) @@ -171,7 +171,7 @@ func (x *awsOceanService) Create(ctx context.Context, group InstanceGroup) (stri // Read returns an existing InstanceGroup by ID. func (x *awsOceanService) Read(ctx context.Context, clusterID string) (InstanceGroup, error) { input := &awsoc.ReadClusterInput{ - ClusterID: fi.PtrTo(clusterID), + ClusterID: new(clusterID), } output, err := x.svc.ReadCluster(ctx, input) @@ -195,7 +195,7 @@ func (x *awsOceanService) Update(ctx context.Context, group InstanceGroup) error // Delete deletes an existing InstanceGroup by ID. func (x *awsOceanService) Delete(ctx context.Context, clusterID string) error { input := &awsoc.DeleteClusterInput{ - ClusterID: fi.PtrTo(clusterID), + ClusterID: new(clusterID), } _, err := x.svc.DeleteCluster(ctx, input) @@ -205,10 +205,10 @@ func (x *awsOceanService) Delete(ctx context.Context, clusterID string) error { // Detach removes one or more instances from the specified InstanceGroup. func (x *awsOceanService) Detach(ctx context.Context, clusterID string, instanceIDs []string) error { input := &awsoc.DetachClusterInstancesInput{ - ClusterID: fi.PtrTo(clusterID), + ClusterID: new(clusterID), InstanceIDs: instanceIDs, - ShouldDecrementTargetCapacity: fi.PtrTo(false), - ShouldTerminateInstances: fi.PtrTo(true), + ShouldDecrementTargetCapacity: new(false), + ShouldTerminateInstances: new(true), } _, err := x.svc.DetachClusterInstances(ctx, input) @@ -218,7 +218,7 @@ func (x *awsOceanService) Detach(ctx context.Context, clusterID string, instance // Instances returns a list of all instances that belong to specified InstanceGroup. func (x *awsOceanService) Instances(ctx context.Context, clusterID string) ([]Instance, error) { input := &awsoc.ListClusterInstancesInput{ - ClusterID: fi.PtrTo(clusterID), + ClusterID: new(clusterID), } output, err := x.svc.ListClusterInstances(ctx, input) @@ -241,7 +241,7 @@ type awsOceanLaunchSpecService struct { // List returns a list of LaunchSpecs. func (x *awsOceanLaunchSpecService) List(ctx context.Context, oceanID string) ([]LaunchSpec, error) { input := &awsoc.ListLaunchSpecsInput{ - OceanID: fi.PtrTo(oceanID), + OceanID: new(oceanID), } output, err := x.svc.ListLaunchSpecs(ctx, input) @@ -274,7 +274,7 @@ func (x *awsOceanLaunchSpecService) Create(ctx context.Context, spec LaunchSpec) // Read returns an existing LaunchSpec by ID. func (x *awsOceanLaunchSpecService) Read(ctx context.Context, specID string) (LaunchSpec, error) { input := &awsoc.ReadLaunchSpecInput{ - LaunchSpecID: fi.PtrTo(specID), + LaunchSpecID: new(specID), } output, err := x.svc.ReadLaunchSpec(ctx, input) @@ -298,7 +298,7 @@ func (x *awsOceanLaunchSpecService) Update(ctx context.Context, spec LaunchSpec) // Delete deletes an existing LaunchSpec by ID. func (x *awsOceanLaunchSpecService) Delete(ctx context.Context, specID string) error { input := &awsoc.DeleteLaunchSpecInput{ - LaunchSpecID: fi.PtrTo(specID), + LaunchSpecID: new(specID), } _, err := x.svc.DeleteLaunchSpec(ctx, input) diff --git a/pkg/testutils/cluster.go b/pkg/testutils/cluster.go index dcca8d3c9f9b2..b607d637c1888 100644 --- a/pkg/testutils/cluster.go +++ b/pkg/testutils/cluster.go @@ -21,7 +21,6 @@ import ( "k8s.io/apimachinery/pkg/util/sets" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" ) // BuildMinimalClusterAWS a generic minimal AWS cluster @@ -58,7 +57,7 @@ func addEtcdClusters(c *kops.Cluster) { for _, zone := range etcdZones { m := kops.EtcdMemberSpec{} m.Name = zone - m.InstanceGroup = fi.PtrTo("master-" + zone) + m.InstanceGroup = new("master-" + zone) etcd.Members = append(etcd.Members, m) } c.Spec.EtcdClusters = append(c.Spec.EtcdClusters, etcd) @@ -125,7 +124,7 @@ func buildMinimalCluster(clusterName string) *kops.Cluster { c.Spec.DNSZone = "test.com" - c.Spec.SSHKeyName = fi.PtrTo("test") + c.Spec.SSHKeyName = new("test") addEtcdClusters(c) diff --git a/pkg/testutils/integrationtestharness.go b/pkg/testutils/integrationtestharness.go index f4bf307c56d27..4d988a58c70ab 100644 --- a/pkg/testutils/integrationtestharness.go +++ b/pkg/testutils/integrationtestharness.go @@ -57,7 +57,6 @@ import ( "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/featureflag" "k8s.io/kops/pkg/pki" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/awsup" "k8s.io/kops/upup/pkg/fi/cloudup/azuretasks" "k8s.io/kops/upup/pkg/fi/cloudup/openstack" @@ -325,11 +324,11 @@ func SetupMockOpenstack() *openstack.MockCloud { extNetworkName := "external" networkCreateOpts := networks.CreateOpts{ Name: extNetworkName, - AdminStateUp: fi.PtrTo(true), + AdminStateUp: new(true), } extNetwork := external.CreateOptsExt{ CreateOptsBuilder: networkCreateOpts, - External: fi.PtrTo(true), + External: new(true), } c.CreateNetwork(extNetwork) c.SetExternalNetwork(&extNetworkName) @@ -338,12 +337,12 @@ func SetupMockOpenstack() *openstack.MockCloud { extSubnet := subnets.CreateOpts{ Name: extSubnetName, NetworkID: extNetworkName, - EnableDHCP: fi.PtrTo(true), + EnableDHCP: new(true), CIDR: "172.20.0.0/22", } c.CreateSubnet(extSubnet) - c.SetExternalSubnet(fi.PtrTo(extSubnetName)) - c.SetLBFloatingSubnet(fi.PtrTo(extSubnetName)) + c.SetExternalSubnet(new(extSubnetName)) + c.SetLBFloatingSubnet(new(extSubnetName)) images.Create(context.TODO(), c.MockImageClient.ServiceClient(), images.CreateOpts{ Name: "Ubuntu-26.04", MinDisk: 12, @@ -352,13 +351,13 @@ func SetupMockOpenstack() *openstack.MockCloud { Name: "n1-standard-2", RAM: 8192, VCPUs: 8, - Disk: fi.PtrTo(16), + Disk: new(16), }) flavors.Create(context.TODO(), c.MockNovaClient.ServiceClient(), flavors.CreateOpts{ Name: "n1-standard-1", RAM: 8192, VCPUs: 4, - Disk: fi.PtrTo(16), + Disk: new(16), }) zones.Create(context.TODO(), c.MockDNSClient.ServiceClient(), zones.CreateOpts{ Name: "minimal-openstack.k8s.local", diff --git a/pkg/wellknownoperators/operators.go b/pkg/wellknownoperators/operators.go index 6dbed0294f4eb..1b3bbfbb94511 100644 --- a/pkg/wellknownoperators/operators.go +++ b/pkg/wellknownoperators/operators.go @@ -27,7 +27,6 @@ import ( "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/featureflag" "k8s.io/kops/pkg/kubemanifest" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/util/pkg/vfs" ) @@ -103,10 +102,10 @@ func (b *Builder) loadClusterPackage(u *unstructured.Unstructured) (*Package, er addon := &Package{ Manifest: manifestBytes, Spec: channelsapi.AddonSpec{ - Name: fi.PtrTo(operatorKey), + Name: new(operatorKey), Id: id, Selector: map[string]string{"k8s-addon": operatorKey}, - Manifest: fi.PtrTo(location), + Manifest: new(location), }, } return addon, nil diff --git a/protokube/pkg/protokube/scaleway_volumes.go b/protokube/pkg/protokube/scaleway_volumes.go index 32febd2e23e7e..c6135b26eb603 100644 --- a/protokube/pkg/protokube/scaleway_volumes.go +++ b/protokube/pkg/protokube/scaleway_volumes.go @@ -26,7 +26,6 @@ import ( kopsv "k8s.io/kops" "k8s.io/kops/protokube/pkg/gossip" gossipscw "k8s.io/kops/protokube/pkg/gossip/scaleway" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/scaleway" ) @@ -88,9 +87,9 @@ func NewScwCloudProvider() (*ScwCloudProvider, error) { ips, err := ipam.NewAPI(scwClient).ListIPs(&ipam.ListIPsRequest{ Region: region, - ResourceID: fi.PtrTo(serverID), - IsIPv6: fi.PtrTo(false), - Zonal: fi.PtrTo(zone.String()), + ResourceID: new(serverID), + IsIPv6: new(false), + Zonal: new(zone.String()), }, scw.WithAllPages()) if err != nil { return nil, fmt.Errorf("listing server's IPs: %w", err) diff --git a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go index c8f5172ff6ac8..f128ba8672357 100644 --- a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go +++ b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go @@ -165,7 +165,7 @@ func (e *AutoscalingGroup) Find(c *fi.CloudupContext) (*AutoscalingGroup, error) // Use 0 as default value when api returns nil (same as model) if g.MaxInstanceLifetime == nil { - actual.MaxInstanceLifetime = fi.PtrTo(int32(0)) + actual.MaxInstanceLifetime = new(int32(0)) } else { actual.MaxInstanceLifetime = g.MaxInstanceLifetime } @@ -279,7 +279,7 @@ func (e *AutoscalingGroup) Find(c *fi.CloudupContext) (*AutoscalingGroup, error) actual.MixedSpotMaxPrice = mpd.SpotMaxPrice // MixedSpotMaxPrice must be set to "" in order to unset. if mpd.SpotMaxPrice == nil { - actual.MixedSpotMaxPrice = fi.PtrTo("") + actual.MixedSpotMaxPrice = new("") } } @@ -397,7 +397,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos MaxSize: e.MaxSize, NewInstancesProtectedFromScaleIn: e.InstanceProtection, Tags: v.AutoscalingGroupTags(), - VPCZoneIdentifier: fi.PtrTo(strings.Join(e.AutoscalingGroupSubnets(), ",")), + VPCZoneIdentifier: new(strings.Join(e.AutoscalingGroupSubnets(), ",")), CapacityRebalance: e.CapacityRebalance, } @@ -448,7 +448,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos p := request.MixedInstancesPolicy.LaunchTemplate for _, x := range e.MixedInstanceOverrides { p.Overrides = append(p.Overrides, autoscalingtypes.LaunchTemplateOverrides{ - InstanceType: fi.PtrTo(x), + InstanceType: new(x), }, ) } @@ -561,7 +561,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos if changes.MixedInstanceOverrides != nil { p := request.MixedInstancesPolicy.LaunchTemplate for _, x := range changes.MixedInstanceOverrides { - p.Overrides = append(p.Overrides, autoscalingtypes.LaunchTemplateOverrides{InstanceType: fi.PtrTo(x)}) + p.Overrides = append(p.Overrides, autoscalingtypes.LaunchTemplateOverrides{InstanceType: new(x)}) } changes.MixedInstanceOverrides = nil } @@ -591,7 +591,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos request.MaxInstanceLifetime = e.MaxInstanceLifetime changes.MaxInstanceLifetime = nil } else { - request.MaxInstanceLifetime = fi.PtrTo(int32(0)) + request.MaxInstanceLifetime = new(int32(0)) } var updateTagsRequest *autoscaling.CreateOrUpdateTagsInput @@ -988,9 +988,9 @@ func (_ *AutoscalingGroup) RenderTerraform(t *terraform.TerraformTarget, a, e, c for _, k := range maps.SortedKeys(e.Tags) { v := e.Tags[k] tf.Tags = append(tf.Tags, &terraformASGTag{ - Key: fi.PtrTo(k), - Value: fi.PtrTo(v), - PropagateAtLaunch: fi.PtrTo(true), + Key: new(k), + Value: new(v), + PropagateAtLaunch: new(true), }) } @@ -1006,7 +1006,7 @@ func (_ *AutoscalingGroup) RenderTerraform(t *terraform.TerraformTarget, a, e, c if e.UseMixedInstancesPolicy() { // Temporary warning until https://github.com/terraform-providers/terraform-provider-aws/issues/9750 is resolved - if e.MixedSpotAllocationStrategy == fi.PtrTo("capacity-optimized") { + if e.MixedSpotAllocationStrategy == new("capacity-optimized") { fmt.Print("Terraform does not currently support a capacity optimized strategy - please see https://github.com/terraform-providers/terraform-provider-aws/issues/9750") } @@ -1036,7 +1036,7 @@ func (_ *AutoscalingGroup) RenderTerraform(t *terraform.TerraformTarget, a, e, c } for _, x := range e.MixedInstanceOverrides { - tf.MixedInstancesPolicy[0].LaunchTemplate[0].Override = append(tf.MixedInstancesPolicy[0].LaunchTemplate[0].Override, &terraformAutoscalingMixedInstancesPolicyLaunchTemplateOverride{InstanceType: fi.PtrTo(x)}) + tf.MixedInstancesPolicy[0].LaunchTemplate[0].Override = append(tf.MixedInstancesPolicy[0].LaunchTemplate[0].Override, &terraformAutoscalingMixedInstancesPolicyLaunchTemplateOverride{InstanceType: new(x)}) } } else if e.LaunchTemplate != nil { tf.LaunchTemplate = &terraformAutoscalingLaunchTemplateSpecification{ @@ -1084,7 +1084,7 @@ func (_ *AutoscalingGroup) RenderTerraform(t *terraform.TerraformTarget, a, e, c var processes []*string if e.SuspendProcesses != nil { for _, p := range *e.SuspendProcesses { - processes = append(processes, fi.PtrTo(p)) + processes = append(processes, new(p)) } } tf.SuspendedProcesses = processes diff --git a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_test.go b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_test.go index 5838b86f61007..b68ab5e853c29 100644 --- a/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_test.go +++ b/upup/pkg/fi/cloudup/awstasks/autoscalinggroup_test.go @@ -22,7 +22,6 @@ import ( "testing" "k8s.io/kops/pkg/diff" - "k8s.io/kops/upup/pkg/fi" "github.com/aws/aws-sdk-go-v2/aws" autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types" @@ -202,16 +201,16 @@ func TestAutoscalingGroupTerraformRender(t *testing.T) { cases := []*renderTest{ { Resource: &AutoscalingGroup{ - Name: fi.PtrTo("test"), - Granularity: fi.PtrTo("5min"), - LaunchTemplate: &LaunchTemplate{Name: fi.PtrTo("test_lc")}, - MaxSize: fi.PtrTo(int32(10)), + Name: new("test"), + Granularity: new("5min"), + LaunchTemplate: &LaunchTemplate{Name: new("test_lc")}, + MaxSize: new(int32(10)), Metrics: []string{"test"}, - MinSize: fi.PtrTo(int32(1)), + MinSize: new(int32(1)), Subnets: []*Subnet{ { - Name: fi.PtrTo("test-sg"), - ID: fi.PtrTo("sg-1111"), + Name: new("test-sg"), + ID: new("sg-1111"), }, }, Tags: map[string]string{ @@ -259,19 +258,19 @@ terraform { }, { Resource: &AutoscalingGroup{ - Name: fi.PtrTo("test1"), - LaunchTemplate: &LaunchTemplate{Name: fi.PtrTo("test_lt")}, - MaxSize: fi.PtrTo(int32(10)), + Name: new("test1"), + LaunchTemplate: &LaunchTemplate{Name: new("test_lt")}, + MaxSize: new(int32(10)), Metrics: []string{"test"}, - MinSize: fi.PtrTo(int32(5)), + MinSize: new(int32(5)), MixedInstanceOverrides: []string{"t2.medium", "t2.large"}, - MixedOnDemandBase: fi.PtrTo(int32(4)), - MixedOnDemandAboveBase: fi.PtrTo(int32(30)), - MixedSpotAllocationStrategy: fi.PtrTo("capacity-optimized"), + MixedOnDemandBase: new(int32(4)), + MixedOnDemandAboveBase: new(int32(30)), + MixedSpotAllocationStrategy: new("capacity-optimized"), Subnets: []*Subnet{ { - Name: fi.PtrTo("test-sg"), - ID: fi.PtrTo("sg-1111"), + Name: new("test-sg"), + ID: new("sg-1111"), }, }, Tags: map[string]string{ @@ -333,24 +332,24 @@ terraform { }, { Resource: &AutoscalingGroup{ - Name: fi.PtrTo("test1"), - LaunchTemplate: &LaunchTemplate{Name: fi.PtrTo("test_lt")}, - MaxSize: fi.PtrTo(int32(10)), + Name: new("test1"), + LaunchTemplate: &LaunchTemplate{Name: new("test_lt")}, + MaxSize: new(int32(10)), Metrics: []string{"test"}, - MinSize: fi.PtrTo(int32(5)), + MinSize: new(int32(5)), MixedInstanceOverrides: []string{"t2.medium", "t2.large"}, - MixedOnDemandBase: fi.PtrTo(int32(4)), - MixedOnDemandAboveBase: fi.PtrTo(int32(30)), - MixedSpotAllocationStrategy: fi.PtrTo("capacity-optimized"), + MixedOnDemandBase: new(int32(4)), + MixedOnDemandAboveBase: new(int32(30)), + MixedSpotAllocationStrategy: new("capacity-optimized"), WarmPool: &WarmPool{ - Enabled: fi.PtrTo(true), + Enabled: new(true), MinSize: 3, - MaxSize: fi.PtrTo(int32(5)), + MaxSize: new(int32(5)), }, Subnets: []*Subnet{ { - Name: fi.PtrTo("test-sg"), - ID: fi.PtrTo("sg-1111"), + Name: new("test-sg"), + ID: new("sg-1111"), }, }, Tags: map[string]string{ diff --git a/upup/pkg/fi/cloudup/awstasks/autoscalinglifecyclehook.go b/upup/pkg/fi/cloudup/awstasks/autoscalinglifecyclehook.go index b6181b879bf35..e5e0f8682dcfd 100644 --- a/upup/pkg/fi/cloudup/awstasks/autoscalinglifecyclehook.go +++ b/upup/pkg/fi/cloudup/awstasks/autoscalinglifecyclehook.go @@ -88,7 +88,7 @@ func (h *AutoscalingLifecycleHook) Find(c *fi.CloudupContext) (*AutoscalingLifec DefaultResult: hook.DefaultResult, HeartbeatTimeout: hook.HeartbeatTimeout, LifecycleTransition: hook.LifecycleTransition, - Enabled: fi.PtrTo(true), + Enabled: new(true), } return actual, nil diff --git a/upup/pkg/fi/cloudup/awstasks/block_device_mappings.go b/upup/pkg/fi/cloudup/awstasks/block_device_mappings.go index d50b197eee516..3099a8dbc7d37 100644 --- a/upup/pkg/fi/cloudup/awstasks/block_device_mappings.go +++ b/upup/pkg/fi/cloudup/awstasks/block_device_mappings.go @@ -124,7 +124,7 @@ func (i *BlockDeviceMapping) ToAutoscaling(deviceName string) *autoscalingtypes. DeleteOnTermination: i.EbsDeleteOnTermination, Encrypted: i.EbsEncrypted, VolumeSize: i.EbsVolumeSize, - VolumeType: fi.PtrTo(string(i.EbsVolumeType)), + VolumeType: new(string(i.EbsVolumeType)), } if ec2types.VolumeType(fi.ValueOf(o.Ebs.VolumeType)) == ec2types.VolumeTypeIo1 || ec2types.VolumeType(fi.ValueOf(o.Ebs.VolumeType)) == ec2types.VolumeTypeIo2 { o.Ebs.Iops = i.EbsVolumeIops diff --git a/upup/pkg/fi/cloudup/awstasks/classic_load_balancer.go b/upup/pkg/fi/cloudup/awstasks/classic_load_balancer.go index b4d44caa21bd5..37195e77c12e4 100644 --- a/upup/pkg/fi/cloudup/awstasks/classic_load_balancer.go +++ b/upup/pkg/fi/cloudup/awstasks/classic_load_balancer.go @@ -668,7 +668,7 @@ func (_ *ClassicLoadBalancer) RenderTerraform(t *terraform.TerraformTarget, a, e LoadBalancerName: e.LoadBalancerName, } if fi.ValueOf(e.Scheme) == "internal" { - tf.Internal = fi.PtrTo(true) + tf.Internal = new(true) } for _, subnet := range e.Subnets { diff --git a/upup/pkg/fi/cloudup/awstasks/dnsname.go b/upup/pkg/fi/cloudup/awstasks/dnsname.go index 9d9890b8addf5..23b095e9026bb 100644 --- a/upup/pkg/fi/cloudup/awstasks/dnsname.go +++ b/upup/pkg/fi/cloudup/awstasks/dnsname.go @@ -162,7 +162,7 @@ func findDNSTargetNLB(cloud awsup.AWSCloud, aliasTarget *route53types.AliasTarge if nameTag == "" { return nil, fmt.Errorf("Found NLB %q linked to DNS name %q, but it did not have a Name tag", loadBalancerName, fi.ValueOf(targetDNSName)) } - return &NetworkLoadBalancer{Name: fi.PtrTo(nameTag)}, nil + return &NetworkLoadBalancer{Name: new(nameTag)}, nil } return nil, nil } @@ -183,7 +183,7 @@ func findDNSTargetELB(cloud awsup.AWSCloud, aliasTarget *route53types.AliasTarge if nameTag == "" { return nil, fmt.Errorf("Found ELB %q linked to DNS name %q, but it did not have a Name tag", loadBalancerName, fi.ValueOf(targetDNSName)) } - return &ClassicLoadBalancer{Name: fi.PtrTo(nameTag)}, nil + return &ClassicLoadBalancer{Name: new(nameTag)}, nil } return nil, nil } diff --git a/upup/pkg/fi/cloudup/awstasks/dnszone.go b/upup/pkg/fi/cloudup/awstasks/dnszone.go index 8bac77bd1a006..42cf17f8d76a7 100644 --- a/upup/pkg/fi/cloudup/awstasks/dnszone.go +++ b/upup/pkg/fi/cloudup/awstasks/dnszone.go @@ -68,10 +68,10 @@ func (e *DNSZone) Find(c *fi.CloudupContext) (*DNSZone, error) { actual := &DNSZone{} actual.Name = e.Name if z.HostedZone.Name != nil { - actual.DNSName = fi.PtrTo(strings.TrimSuffix(*z.HostedZone.Name, ".")) + actual.DNSName = new(strings.TrimSuffix(*z.HostedZone.Name, ".")) } if z.HostedZone.Id != nil { - actual.ZoneID = fi.PtrTo(strings.TrimPrefix(*z.HostedZone.Id, "/hostedzone/")) + actual.ZoneID = new(strings.TrimPrefix(*z.HostedZone.Id, "/hostedzone/")) } actual.Private = aws.Bool(z.HostedZone.Config.PrivateZone) diff --git a/upup/pkg/fi/cloudup/awstasks/egressonlyinternetgateway_test.go b/upup/pkg/fi/cloudup/awstasks/egressonlyinternetgateway_test.go index bc294aaeb185f..907f5a148a1ca 100644 --- a/upup/pkg/fi/cloudup/awstasks/egressonlyinternetgateway_test.go +++ b/upup/pkg/fi/cloudup/awstasks/egressonlyinternetgateway_test.go @@ -73,14 +73,14 @@ func TestSharedEgressOnlyInternetGatewayDoesNotRename(t *testing.T) { Lifecycle: fi.LifecycleSync, CIDR: s("172.20.0.0/16"), Tags: map[string]string{"kubernetes.io/cluster/cluster.example.com": "shared"}, - Shared: fi.PtrTo(true), + Shared: new(true), ID: vpc.Vpc.VpcId, } eigw1 := &EgressOnlyInternetGateway{ Name: s("eigw1"), Lifecycle: fi.LifecycleSync, VPC: vpc1, - Shared: fi.PtrTo(true), + Shared: new(true), ID: internetGateway.EgressOnlyInternetGateway.EgressOnlyInternetGatewayId, Tags: make(map[string]string), } diff --git a/upup/pkg/fi/cloudup/awstasks/helper.go b/upup/pkg/fi/cloudup/awstasks/helper.go index 308b96d59312d..76ac2f70bdcdd 100644 --- a/upup/pkg/fi/cloudup/awstasks/helper.go +++ b/upup/pkg/fi/cloudup/awstasks/helper.go @@ -21,7 +21,6 @@ import ( "fmt" ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/upup/pkg/fi/cloudup/awsup" ) @@ -38,7 +37,7 @@ func buildEphemeralDevices(cloud awsup.AWSCloud, machineType ec2types.InstanceTy blockDeviceMappings := make(map[string]*BlockDeviceMapping) for _, ed := range mt.EphemeralDevices() { - blockDeviceMappings[ed.DeviceName] = &BlockDeviceMapping{VirtualName: fi.PtrTo(ed.VirtualName)} + blockDeviceMappings[ed.DeviceName] = &BlockDeviceMapping{VirtualName: new(ed.VirtualName)} } return blockDeviceMappings, nil diff --git a/upup/pkg/fi/cloudup/awstasks/internetgateway_test.go b/upup/pkg/fi/cloudup/awstasks/internetgateway_test.go index 8042aa514e299..04e6f26a87f9a 100644 --- a/upup/pkg/fi/cloudup/awstasks/internetgateway_test.go +++ b/upup/pkg/fi/cloudup/awstasks/internetgateway_test.go @@ -89,14 +89,14 @@ func TestSharedInternetGatewayDoesNotRename(t *testing.T) { Lifecycle: fi.LifecycleSync, CIDR: s("172.20.0.0/16"), Tags: map[string]string{"kubernetes.io/cluster/cluster.example.com": "shared"}, - Shared: fi.PtrTo(true), + Shared: new(true), ID: vpc.Vpc.VpcId, } igw1 := &InternetGateway{ Name: s("igw1"), Lifecycle: fi.LifecycleSync, VPC: vpc1, - Shared: fi.PtrTo(true), + Shared: new(true), ID: internetGateway.InternetGateway.InternetGatewayId, Tags: make(map[string]string), } diff --git a/upup/pkg/fi/cloudup/awstasks/launchtemplate.go b/upup/pkg/fi/cloudup/awstasks/launchtemplate.go index 6e751c0bb3a13..522c5c48f3dd1 100644 --- a/upup/pkg/fi/cloudup/awstasks/launchtemplate.go +++ b/upup/pkg/fi/cloudup/awstasks/launchtemplate.go @@ -172,7 +172,7 @@ func (t *LaunchTemplate) FindDeletions(c *fi.CloudupContext) ([]fi.CloudupDeleti for _, lt := range list { if aws.ToString(lt.LaunchTemplateName) != aws.ToString(t.Name) { - removals = append(removals, &deleteLaunchTemplate{lc: fi.PtrTo(lt)}) + removals = append(removals, &deleteLaunchTemplate{lc: new(lt)}) } } diff --git a/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go b/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go index 0d8673bec8755..33d9202c9110f 100644 --- a/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go +++ b/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go @@ -43,7 +43,7 @@ func (t *LaunchTemplate) RenderAWS(c *awsup.AWSAPITarget, a, e, changes *LaunchT // @step: lets build the launch template data data := &ec2types.RequestLaunchTemplateData{ - DisableApiTermination: fi.PtrTo(false), + DisableApiTermination: new(false), EbsOptimized: t.RootVolumeOptimization, ImageId: image.ImageId, InstanceType: fi.ValueOf(t.InstanceType), @@ -56,7 +56,7 @@ func (t *LaunchTemplate) RenderAWS(c *awsup.AWSAPITarget, a, e, changes *LaunchT { AssociatePublicIpAddress: t.AssociatePublicIP, DeleteOnTermination: aws.Bool(true), - DeviceIndex: fi.PtrTo(int32(0)), + DeviceIndex: new(int32(0)), Ipv6AddressCount: t.IPv6AddressCount, }, }, @@ -94,7 +94,7 @@ func (t *LaunchTemplate) RenderAWS(c *awsup.AWSAPITarget, a, e, changes *LaunchT data.Placement = &ec2types.LaunchTemplatePlacementRequest{Tenancy: fi.ValueOf(t.Tenancy)} } // @step: set the instance monitoring - data.Monitoring = &ec2types.LaunchTemplatesMonitoringRequest{Enabled: fi.PtrTo(false)} + data.Monitoring = &ec2types.LaunchTemplatesMonitoringRequest{Enabled: new(false)} if t.InstanceMonitoring != nil { data.Monitoring = &ec2types.LaunchTemplatesMonitoringRequest{Enabled: t.InstanceMonitoring} } @@ -216,31 +216,31 @@ func (t *LaunchTemplate) Find(c *fi.CloudupContext) (*LaunchTemplate, error) { klog.V(3).Infof("found existing LaunchTemplate: %s", fi.ValueOf(lt.LaunchTemplateName)) actual := &LaunchTemplate{ - AssociatePublicIP: fi.PtrTo(false), + AssociatePublicIP: new(false), ID: lt.LaunchTemplateId, ImageID: lt.LaunchTemplateData.ImageId, - InstanceMonitoring: fi.PtrTo(false), + InstanceMonitoring: new(false), Lifecycle: t.Lifecycle, Name: t.Name, RootVolumeOptimization: lt.LaunchTemplateData.EbsOptimized, } if len(lt.LaunchTemplateData.InstanceType) > 0 { - actual.InstanceType = fi.PtrTo(lt.LaunchTemplateData.InstanceType) + actual.InstanceType = new(lt.LaunchTemplateData.InstanceType) } // @step: check if any of the interfaces are public facing for _, x := range lt.LaunchTemplateData.NetworkInterfaces { if aws.ToBool(x.AssociatePublicIpAddress) { - actual.AssociatePublicIP = fi.PtrTo(true) + actual.AssociatePublicIP = new(true) } for _, id := range x.Groups { - actual.SecurityGroups = append(actual.SecurityGroups, &SecurityGroup{ID: fi.PtrTo(id)}) + actual.SecurityGroups = append(actual.SecurityGroups, &SecurityGroup{ID: new(id)}) } actual.IPv6AddressCount = x.Ipv6AddressCount } // In older Kops versions, security groups were added to LaunchTemplateData.SecurityGroupIds for _, id := range lt.LaunchTemplateData.SecurityGroupIds { - actual.SecurityGroups = append(actual.SecurityGroups, &SecurityGroup{ID: fi.PtrTo("legacy-" + id)}) + actual.SecurityGroups = append(actual.SecurityGroups, &SecurityGroup{ID: new("legacy-" + id)}) } sort.Sort(OrderSecurityGroupsById(actual.SecurityGroups)) @@ -255,7 +255,7 @@ func (t *LaunchTemplate) Find(c *fi.CloudupContext) (*LaunchTemplate, error) { } // @step: add the tenancy if lt.LaunchTemplateData.Placement != nil && len(lt.LaunchTemplateData.Placement.Tenancy) > 0 { - actual.Tenancy = fi.PtrTo(lt.LaunchTemplateData.Placement.Tenancy) + actual.Tenancy = new(lt.LaunchTemplateData.Placement.Tenancy) } // @step: add the ssh if there is one if lt.LaunchTemplateData.KeyName != nil { @@ -271,7 +271,7 @@ func (t *LaunchTemplate) Find(c *fi.CloudupContext) (*LaunchTemplate, error) { actual.SpotPrice = imo.SpotOptions.MaxPrice actual.SpotDurationInMinutes = imo.SpotOptions.BlockDurationMinutes if len(imo.SpotOptions.InstanceInterruptionBehavior) > 0 { - actual.InstanceInterruptionBehavior = fi.PtrTo(imo.SpotOptions.InstanceInterruptionBehavior) + actual.InstanceInterruptionBehavior = new(imo.SpotOptions.InstanceInterruptionBehavior) } } else { actual.SpotPrice = aws.String("") @@ -298,7 +298,7 @@ func (t *LaunchTemplate) Find(c *fi.CloudupContext) (*LaunchTemplate, error) { if b.Ebs.KmsKeyId != nil { actual.RootVolumeKmsKey = b.Ebs.KmsKeyId } else { - actual.RootVolumeKmsKey = fi.PtrTo("") + actual.RootVolumeKmsKey = new("") } } else { _, d := BlockDeviceMappingFromLaunchTemplateBootDeviceRequest(b) @@ -327,10 +327,10 @@ func (t *LaunchTemplate) Find(c *fi.CloudupContext) (*LaunchTemplate, error) { if options := lt.LaunchTemplateData.MetadataOptions; options != nil { actual.HTTPPutResponseHopLimit = options.HttpPutResponseHopLimit if len(options.HttpTokens) > 0 { - actual.HTTPTokens = fi.PtrTo(options.HttpTokens) + actual.HTTPTokens = new(options.HttpTokens) } if len(options.HttpProtocolIpv6) > 0 { - actual.HTTPProtocolIPv6 = fi.PtrTo(options.HttpProtocolIpv6) + actual.HTTPProtocolIPv6 = new(options.HttpProtocolIpv6) } } diff --git a/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_terraform.go b/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_terraform.go index 4ef26cf5d9663..30ddecc15db03 100644 --- a/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_terraform.go +++ b/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_terraform.go @@ -197,10 +197,10 @@ func (t *LaunchTemplate) RenderTerraform(target *terraform.TerraformTarget, a, e EBSOptimized: e.RootVolumeOptimization, ImageID: image, InstanceType: e.InstanceType, - Lifecycle: &terraform.Lifecycle{CreateBeforeDestroy: fi.PtrTo(true)}, + Lifecycle: &terraform.Lifecycle{CreateBeforeDestroy: new(true)}, MetadataOptions: &terraformLaunchTemplateInstanceMetadata{ // See issue https://github.com/hashicorp/terraform-provider-aws/issues/12564. - HTTPEndpoint: fi.PtrTo("enabled"), + HTTPEndpoint: new("enabled"), HTTPTokens: e.HTTPTokens, HTTPPutResponseHopLimit: e.HTTPPutResponseHopLimit, HTTPProtocolIPv6: e.HTTPProtocolIPv6, @@ -208,7 +208,7 @@ func (t *LaunchTemplate) RenderTerraform(target *terraform.TerraformTarget, a, e NetworkInterfaces: []*terraformLaunchTemplateNetworkInterface{ { AssociatePublicIPAddress: e.AssociatePublicIP, - DeleteOnTermination: fi.PtrTo(true), + DeleteOnTermination: new(true), Ipv6AddressCount: e.IPv6AddressCount, }, }, @@ -222,7 +222,7 @@ func (t *LaunchTemplate) RenderTerraform(target *terraform.TerraformTarget, a, e } tf.MarketOptions = []*terraformLaunchTemplateMarketOptions{ { - MarketType: fi.PtrTo("spot"), + MarketType: new("spot"), SpotOptions: []*terraformLaunchTemplateMarketOptionsSpotOptions{&marketSpotOptions}, }, } @@ -295,21 +295,21 @@ func (t *LaunchTemplate) RenderTerraform(target *terraform.TerraformTarget, a, e for _, key := range devicesKeys { tf.BlockDeviceMappings = append(tf.BlockDeviceMappings, &terraformLaunchTemplateBlockDevice{ VirtualName: devices[key].VirtualName, - DeviceName: fi.PtrTo(key), + DeviceName: new(key), }) } if e.Tags != nil { tf.TagSpecifications = append(tf.TagSpecifications, &terraformLaunchTemplateTagSpecification{ - ResourceType: fi.PtrTo("instance"), + ResourceType: new("instance"), Tags: e.Tags, }) tf.TagSpecifications = append(tf.TagSpecifications, &terraformLaunchTemplateTagSpecification{ - ResourceType: fi.PtrTo("volume"), + ResourceType: new("volume"), Tags: e.Tags, }) tf.TagSpecifications = append(tf.TagSpecifications, &terraformLaunchTemplateTagSpecification{ - ResourceType: fi.PtrTo("network-interface"), + ResourceType: new("network-interface"), Tags: e.Tags, }) tf.Tags = e.Tags @@ -320,16 +320,16 @@ func (t *LaunchTemplate) RenderTerraform(target *terraform.TerraformTarget, a, e func createTerraformLaunchTemplateBlockDevice(deviceName string, v *BlockDeviceMapping) *terraformLaunchTemplateBlockDevice { return &terraformLaunchTemplateBlockDevice{ - DeviceName: fi.PtrTo(deviceName), + DeviceName: new(deviceName), EBS: []*terraformLaunchTemplateBlockDeviceEBS{ { - DeleteOnTermination: fi.PtrTo(true), + DeleteOnTermination: new(true), Encrypted: v.EbsEncrypted, KmsKeyID: v.EbsKmsKey, IOPS: v.EbsVolumeIops, Throughput: v.EbsVolumeThroughput, VolumeSize: v.EbsVolumeSize, - VolumeType: fi.PtrTo(string(v.EbsVolumeType)), + VolumeType: new(string(v.EbsVolumeType)), }, }, } diff --git a/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_terraform_test.go b/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_terraform_test.go index 8a3033df79d0c..dc1a04e621eb8 100644 --- a/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_terraform_test.go +++ b/upup/pkg/fi/cloudup/awstasks/launchtemplate_target_terraform_test.go @@ -28,31 +28,31 @@ func TestLaunchTemplateTerraformRender(t *testing.T) { cases := []*renderTest{ { Resource: &LaunchTemplate{ - Name: fi.PtrTo("test"), - AssociatePublicIP: fi.PtrTo(true), + Name: new("test"), + AssociatePublicIP: new(true), IAMInstanceProfile: &IAMInstanceProfile{ - Name: fi.PtrTo("nodes"), + Name: new("nodes"), }, - ID: fi.PtrTo("test-11"), - InstanceMonitoring: fi.PtrTo(true), - InstanceType: fi.PtrTo(ec2types.InstanceTypeT2Medium), - SpotPrice: fi.PtrTo("0.1"), - SpotDurationInMinutes: fi.PtrTo(int32(60)), - InstanceInterruptionBehavior: fi.PtrTo(ec2types.InstanceInterruptionBehaviorHibernate), - RootVolumeOptimization: fi.PtrTo(true), - RootVolumeIops: fi.PtrTo(int32(100)), - RootVolumeSize: fi.PtrTo(int32(64)), + ID: new("test-11"), + InstanceMonitoring: new(true), + InstanceType: new(ec2types.InstanceTypeT2Medium), + SpotPrice: new("0.1"), + SpotDurationInMinutes: new(int32(60)), + InstanceInterruptionBehavior: new(ec2types.InstanceInterruptionBehaviorHibernate), + RootVolumeOptimization: new(true), + RootVolumeIops: new(int32(100)), + RootVolumeSize: new(int32(64)), SSHKey: &SSHKey{ - Name: fi.PtrTo("newkey"), + Name: new("newkey"), PublicKey: fi.NewStringResource("newkey"), }, SecurityGroups: []*SecurityGroup{ - {Name: fi.PtrTo("nodes-1"), ID: fi.PtrTo("1111")}, - {Name: fi.PtrTo("nodes-2"), ID: fi.PtrTo("2222")}, + {Name: new("nodes-1"), ID: new("1111")}, + {Name: new("nodes-2"), ID: new("2222")}, }, - Tenancy: fi.PtrTo(ec2types.TenancyDedicated), - HTTPTokens: fi.PtrTo(ec2types.LaunchTemplateHttpTokensStateOptional), - HTTPPutResponseHopLimit: fi.PtrTo(int32(1)), + Tenancy: new(ec2types.TenancyDedicated), + HTTPTokens: new(ec2types.LaunchTemplateHttpTokensStateOptional), + HTTPPutResponseHopLimit: new(int32(1)), }, Expected: `provider "aws" { region = "eu-west-2" @@ -108,36 +108,36 @@ terraform { }, { Resource: &LaunchTemplate{ - Name: fi.PtrTo("test"), - AssociatePublicIP: fi.PtrTo(true), + Name: new("test"), + AssociatePublicIP: new(true), IAMInstanceProfile: &IAMInstanceProfile{ - Name: fi.PtrTo("nodes"), + Name: new("nodes"), }, BlockDeviceMappings: []*BlockDeviceMapping{ { - DeviceName: fi.PtrTo("/dev/xvdd"), + DeviceName: new("/dev/xvdd"), EbsVolumeType: ec2types.VolumeTypeGp2, - EbsVolumeSize: fi.PtrTo(int32(100)), - EbsDeleteOnTermination: fi.PtrTo(true), - EbsEncrypted: fi.PtrTo(true), + EbsVolumeSize: new(int32(100)), + EbsDeleteOnTermination: new(true), + EbsEncrypted: new(true), }, }, - ID: fi.PtrTo("test-11"), - InstanceMonitoring: fi.PtrTo(true), - InstanceType: fi.PtrTo(ec2types.InstanceTypeT2Medium), - RootVolumeOptimization: fi.PtrTo(true), - RootVolumeIops: fi.PtrTo(int32(100)), - RootVolumeSize: fi.PtrTo(int32(64)), + ID: new("test-11"), + InstanceMonitoring: new(true), + InstanceType: new(ec2types.InstanceTypeT2Medium), + RootVolumeOptimization: new(true), + RootVolumeIops: new(int32(100)), + RootVolumeSize: new(int32(64)), SSHKey: &SSHKey{ - Name: fi.PtrTo("mykey"), + Name: new("mykey"), }, SecurityGroups: []*SecurityGroup{ - {Name: fi.PtrTo("nodes-1"), ID: fi.PtrTo("1111")}, - {Name: fi.PtrTo("nodes-2"), ID: fi.PtrTo("2222")}, + {Name: new("nodes-1"), ID: new("1111")}, + {Name: new("nodes-2"), ID: new("2222")}, }, - Tenancy: fi.PtrTo(ec2types.TenancyDedicated), - HTTPTokens: fi.PtrTo(ec2types.LaunchTemplateHttpTokensStateRequired), - HTTPPutResponseHopLimit: fi.PtrTo(int32(5)), + Tenancy: new(ec2types.TenancyDedicated), + HTTPTokens: new(ec2types.LaunchTemplateHttpTokensStateRequired), + HTTPPutResponseHopLimit: new(int32(5)), }, Expected: `provider "aws" { region = "eu-west-2" diff --git a/upup/pkg/fi/cloudup/awstasks/network_load_balancer.go b/upup/pkg/fi/cloudup/awstasks/network_load_balancer.go index 817d8c8fedbb4..e502c653a1d68 100644 --- a/upup/pkg/fi/cloudup/awstasks/network_load_balancer.go +++ b/upup/pkg/fi/cloudup/awstasks/network_load_balancer.go @@ -270,7 +270,7 @@ func (e *NetworkLoadBalancer) Find(c *fi.CloudupContext) (*NetworkLoadBalancer, if err != nil { return nil, err } - actual.CrossZoneLoadBalancing = fi.PtrTo(b) + actual.CrossZoneLoadBalancing = new(b) case "access_logs.s3.enabled": b, err := strconv.ParseBool(*value) if err != nil { @@ -279,7 +279,7 @@ func (e *NetworkLoadBalancer) Find(c *fi.CloudupContext) (*NetworkLoadBalancer, if actual.AccessLog == nil { actual.AccessLog = &NetworkLoadBalancerAccessLog{} } - actual.AccessLog.Enabled = fi.PtrTo(b) + actual.AccessLog.Enabled = new(b) case "access_logs.s3.bucket": if actual.AccessLog == nil { actual.AccessLog = &NetworkLoadBalancerAccessLog{} diff --git a/upup/pkg/fi/cloudup/awstasks/securitygrouprule.go b/upup/pkg/fi/cloudup/awstasks/securitygrouprule.go index 4f567fcb0cb9b..892dfac9a1fb9 100644 --- a/upup/pkg/fi/cloudup/awstasks/securitygrouprule.go +++ b/upup/pkg/fi/cloudup/awstasks/securitygrouprule.go @@ -359,29 +359,29 @@ type terraformSecurityGroupIngress struct { func (_ *SecurityGroupRule) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *SecurityGroupRule) error { tf := &terraformSecurityGroupIngress{ - Type: fi.PtrTo("ingress"), + Type: new("ingress"), SecurityGroup: e.SecurityGroup.TerraformLink(), FromPort: e.FromPort, ToPort: e.ToPort, Protocol: e.Protocol, } if fi.ValueOf(e.Egress) { - tf.Type = fi.PtrTo("egress") + tf.Type = new("egress") } if e.Protocol == nil { - tf.Protocol = fi.PtrTo("-1") - tf.FromPort = fi.PtrTo(int32(0)) - tf.ToPort = fi.PtrTo(int32(0)) + tf.Protocol = new("-1") + tf.FromPort = new(int32(0)) + tf.ToPort = new(int32(0)) } if tf.FromPort == nil { // FromPort is required by tf - tf.FromPort = fi.PtrTo(int32(0)) + tf.FromPort = new(int32(0)) } if tf.ToPort == nil { // ToPort is required by tf - tf.ToPort = fi.PtrTo(int32(65535)) + tf.ToPort = new(int32(65535)) } if e.SourceGroup != nil { diff --git a/upup/pkg/fi/cloudup/awstasks/sshkey.go b/upup/pkg/fi/cloudup/awstasks/sshkey.go index b716d8ed87fc7..61cb6dfaf5a2f 100644 --- a/upup/pkg/fi/cloudup/awstasks/sshkey.go +++ b/upup/pkg/fi/cloudup/awstasks/sshkey.go @@ -95,7 +95,7 @@ func (e *SSHKey) find(ctx context.Context, cloud awsup.AWSCloud) (*SSHKey, error fingerprint := fi.ValueOf(k.KeyFingerprint) fingerprint = strings.TrimRight(fingerprint, "=") fingerprint = fmt.Sprintf("SHA256:%s", fingerprint) - actual.KeyFingerprint = fi.PtrTo(fingerprint) + actual.KeyFingerprint = new(fingerprint) } if fi.ValueOf(actual.KeyFingerprint) == fi.ValueOf(e.KeyFingerprint) { klog.V(2).Infof("SSH key fingerprints match; assuming public keys match") diff --git a/upup/pkg/fi/cloudup/awstasks/subnet.go b/upup/pkg/fi/cloudup/awstasks/subnet.go index 89b164ab30112..d7fdcc3bbdc0d 100644 --- a/upup/pkg/fi/cloudup/awstasks/subnet.go +++ b/upup/pkg/fi/cloudup/awstasks/subnet.go @@ -74,7 +74,7 @@ func (a OrderSubnetsById) Less(i, j int) bool { } func (e *Subnet) Find(c *fi.CloudupContext) (*Subnet, error) { - e.AssignIPv6AddressOnCreation = fi.PtrTo(e.IPv6CIDR != nil) + e.AssignIPv6AddressOnCreation = new(e.IPv6CIDR != nil) subnet, err := e.findEc2Subnet(c) if err != nil { @@ -111,7 +111,7 @@ func (e *Subnet) Find(c *fi.CloudupContext) (*Subnet, error) { actual.AssignIPv6AddressOnCreation = subnet.AssignIpv6AddressOnCreation - actual.ResourceBasedNaming = fi.PtrTo(subnet.PrivateDnsNameOptionsOnLaunch.HostnameType == ec2types.HostnameTypeResourceName) + actual.ResourceBasedNaming = new(subnet.PrivateDnsNameOptionsOnLaunch.HostnameType == ec2types.HostnameTypeResourceName) if *actual.ResourceBasedNaming { if fi.ValueOf(actual.CIDR) != "" && !aws.ToBool(subnet.PrivateDnsNameOptionsOnLaunch.EnableResourceNameDnsARecord) { actual.ResourceBasedNaming = nil @@ -436,18 +436,18 @@ func (_ *Subnet) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *Su Tags: e.Tags, } if fi.ValueOf(e.CIDR) == "" { - tf.EnableDNS64 = fi.PtrTo(true) - tf.IPv6Native = fi.PtrTo(true) + tf.EnableDNS64 = new(true) + tf.IPv6Native = new(true) } if fi.ValueOf(e.IPv6CIDR) != "" { - tf.AssignIPv6AddressOnCreation = fi.PtrTo(true) + tf.AssignIPv6AddressOnCreation = new(true) } if e.ResourceBasedNaming != nil { hostnameType := ec2types.HostnameTypeIpName if *e.ResourceBasedNaming { hostnameType = ec2types.HostnameTypeResourceName } - tf.PrivateDNSHostnameTypeOnLaunch = fi.PtrTo(string(hostnameType)) + tf.PrivateDNSHostnameTypeOnLaunch = new(string(hostnameType)) if fi.ValueOf(e.CIDR) != "" { tf.EnableResourceNameDNSARecordOnLaunch = e.ResourceBasedNaming } diff --git a/upup/pkg/fi/cloudup/awstasks/subnet_test.go b/upup/pkg/fi/cloudup/awstasks/subnet_test.go index ae71c2da6c34c..651767c0e5b5d 100644 --- a/upup/pkg/fi/cloudup/awstasks/subnet_test.go +++ b/upup/pkg/fi/cloudup/awstasks/subnet_test.go @@ -85,7 +85,7 @@ func TestSubnetCreate(t *testing.T) { Lifecycle: fi.LifecycleSync, VPC: vpc1, CIDR: s("172.20.1.0/24"), - ResourceBasedNaming: fi.PtrTo(true), + ResourceBasedNaming: new(true), Tags: map[string]string{"Name": "subnet1"}, } @@ -165,7 +165,7 @@ func TestSubnetCreateIPv6(t *testing.T) { VPC: vpc1, CIDR: s("172.20.1.0/24"), IPv6CIDR: s("2001:db8:0:1::/64"), - ResourceBasedNaming: fi.PtrTo(true), + ResourceBasedNaming: new(true), Tags: map[string]string{"Name": "subnet1"}, } @@ -369,7 +369,7 @@ func TestSharedSubnetCreateDoesNotCreateNew(t *testing.T) { Lifecycle: fi.LifecycleSync, CIDR: s("172.20.0.0/16"), Tags: map[string]string{"kubernetes.io/cluster/cluster.example.com": "shared"}, - Shared: fi.PtrTo(true), + Shared: new(true), ID: vpc.Vpc.VpcId, } subnet1 := &Subnet{ @@ -378,7 +378,7 @@ func TestSharedSubnetCreateDoesNotCreateNew(t *testing.T) { VPC: vpc1, CIDR: s("172.20.1.0/24"), Tags: map[string]string{"kubernetes.io/cluster/cluster.example.com": "shared"}, - Shared: fi.PtrTo(true), + Shared: new(true), ID: subnet.Subnet.SubnetId, } diff --git a/upup/pkg/fi/cloudup/awstasks/targetgroup.go b/upup/pkg/fi/cloudup/awstasks/targetgroup.go index 2349eb2a2c291..341d42886518a 100644 --- a/upup/pkg/fi/cloudup/awstasks/targetgroup.go +++ b/upup/pkg/fi/cloudup/awstasks/targetgroup.go @@ -406,7 +406,7 @@ func (_ *TargetGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *TargetGrou // HTTP/HTTPS health checks need a path and matcher, 200-399 matches the NLB create default. if proto == elbv2types.ProtocolEnumHttp || proto == elbv2types.ProtocolEnumHttps { request.HealthCheckPath = e.HealthCheckPath - request.Matcher = &elbv2types.Matcher{HttpCode: fi.PtrTo("200-399")} + request.Matcher = &elbv2types.Matcher{HttpCode: new("200-399")} } if _, err := t.Cloud.ELBV2().ModifyTargetGroup(ctx, request); err != nil { return fmt.Errorf("modifying NLB target group health check: %w", err) @@ -425,8 +425,8 @@ func ModifyTargetGroupAttributes(ctx context.Context, cloud awsup.AWSCloud, arn } for k, v := range attributes { attrReq.Attributes = append(attrReq.Attributes, elbv2types.TargetGroupAttribute{ - Key: fi.PtrTo(k), - Value: fi.PtrTo(v), + Key: new(k), + Value: new(v), }) } if _, err := cloud.ELBV2().ModifyTargetGroupAttributes(ctx, attrReq); err != nil { diff --git a/upup/pkg/fi/cloudup/awstasks/targetgroup_test.go b/upup/pkg/fi/cloudup/awstasks/targetgroup_test.go index 0006ab1b66b99..f89662bb18cfd 100644 --- a/upup/pkg/fi/cloudup/awstasks/targetgroup_test.go +++ b/upup/pkg/fi/cloudup/awstasks/targetgroup_test.go @@ -67,7 +67,7 @@ func TestTargetGroupHealthCheckChange(t *testing.T) { Lifecycle: fi.LifecycleSync, CIDR: s("172.20.0.0/16"), Tags: map[string]string{"kubernetes.io/cluster/cluster.example.com": "shared"}, - Shared: fi.PtrTo(true), + Shared: new(true), ID: vpc.Vpc.VpcId, } tg1 := &TargetGroup{ @@ -76,13 +76,13 @@ func TestTargetGroupHealthCheckChange(t *testing.T) { VPC: vpc1, Tags: map[string]string{"Name": "tg1"}, Protocol: elbv2types.ProtocolEnumTcp, - Port: fi.PtrTo(int32(3988)), - Interval: fi.PtrTo(int32(10)), - HealthyThreshold: fi.PtrTo(int32(2)), - UnhealthyThreshold: fi.PtrTo(int32(2)), + Port: new(int32(3988)), + Interval: new(int32(10)), + HealthyThreshold: new(int32(2)), + UnhealthyThreshold: new(int32(2)), HealthCheckProtocol: healthCheckProtocol, HealthCheckPath: healthCheckPath, - Shared: fi.PtrTo(false), + Shared: new(false), } return map[string]fi.CloudupTask{ diff --git a/upup/pkg/fi/cloudup/awstasks/vpc_test.go b/upup/pkg/fi/cloudup/awstasks/vpc_test.go index 0c32c2fb59d79..b4f94931ac2fd 100644 --- a/upup/pkg/fi/cloudup/awstasks/vpc_test.go +++ b/upup/pkg/fi/cloudup/awstasks/vpc_test.go @@ -65,7 +65,7 @@ func TestVPCCreate(t *testing.T) { expected := &ec2types.Vpc{ CidrBlock: s("172.21.0.0/16"), - IsDefault: fi.PtrTo(false), + IsDefault: new(false), VpcId: vpc1.ID, Tags: buildTags(map[string]string{ "Name": "vpc1", @@ -155,7 +155,7 @@ func TestSharedVPCAdditionalCIDR(t *testing.T) { Lifecycle: fi.LifecycleSync, CIDR: s("172.21.0.0/16"), Tags: map[string]string{"Name": "vpc-1"}, - Shared: fi.PtrTo(true), + Shared: new(true), } return map[string]fi.CloudupTask{ "vpc-1": vpc1, @@ -178,7 +178,7 @@ func TestSharedVPCAdditionalCIDR(t *testing.T) { expected := &ec2types.Vpc{ CidrBlock: s("172.21.0.0/16"), - IsDefault: fi.PtrTo(false), + IsDefault: new(false), VpcId: vpc1.ID, Tags: buildTags(map[string]string{ "Name": "vpc-1", diff --git a/upup/pkg/fi/cloudup/awstasks/warmpool.go b/upup/pkg/fi/cloudup/awstasks/warmpool.go index 5e15c26e3451b..6c265a5cc6287 100644 --- a/upup/pkg/fi/cloudup/awstasks/warmpool.go +++ b/upup/pkg/fi/cloudup/awstasks/warmpool.go @@ -92,7 +92,7 @@ func (e *WarmPool) Find(c *fi.CloudupContext) (*WarmPool, error) { return &WarmPool{ Name: e.Name, Lifecycle: e.Lifecycle, - Enabled: fi.PtrTo(false), + Enabled: new(false), AutoscalingGroup: &AutoscalingGroup{Name: e.AutoscalingGroup.Name}, }, nil } @@ -100,7 +100,7 @@ func (e *WarmPool) Find(c *fi.CloudupContext) (*WarmPool, error) { actual := &WarmPool{ Name: e.Name, Lifecycle: e.Lifecycle, - Enabled: fi.PtrTo(true), + Enabled: new(true), AutoscalingGroup: &AutoscalingGroup{Name: e.AutoscalingGroup.Name}, MaxSize: warmPool.WarmPoolConfiguration.MaxGroupPreparedCapacity, MinSize: fi.ValueOf(warmPool.WarmPoolConfiguration.MinSize), @@ -124,12 +124,12 @@ func (*WarmPool) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *WarmPool) error minSize := e.MinSize maxSize := e.MaxSize if maxSize == nil { - maxSize = fi.PtrTo(int32(-1)) + maxSize = new(int32(-1)) } request := &autoscaling.PutWarmPoolInput{ AutoScalingGroupName: e.AutoscalingGroup.Name, MaxGroupPreparedCapacity: maxSize, - MinSize: fi.PtrTo(minSize), + MinSize: new(minSize), } _, err := svc.PutWarmPool(ctx, request) @@ -143,7 +143,7 @@ func (*WarmPool) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *WarmPool) error _, err := svc.DeleteWarmPool(ctx, &autoscaling.DeleteWarmPoolInput{ AutoScalingGroupName: e.AutoscalingGroup.Name, // We don't need to do any cleanup so, the faster the better - ForceDelete: fi.PtrTo(true), + ForceDelete: new(true), }) if err != nil { return fmt.Errorf("error deleting warm pool: %w", err) diff --git a/upup/pkg/fi/cloudup/azuretasks/applicationsecuritygroup_terraform.go b/upup/pkg/fi/cloudup/azuretasks/applicationsecuritygroup_terraform.go index d1d9d67010eeb..2ad37a3933e4f 100644 --- a/upup/pkg/fi/cloudup/azuretasks/applicationsecuritygroup_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/applicationsecuritygroup_terraform.go @@ -32,7 +32,7 @@ type terraformAzureApplicationSecurityGroup struct { func (*ApplicationSecurityGroup) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *ApplicationSecurityGroup) error { tf := &terraformAzureApplicationSecurityGroup{ Name: e.Name, - Location: fi.PtrTo(t.Cloud.Region()), + Location: new(t.Cloud.Region()), ResourceGroupName: e.ResourceGroup.terraformName(), Tags: stringMap(e.Tags), } diff --git a/upup/pkg/fi/cloudup/azuretasks/disk_terraform.go b/upup/pkg/fi/cloudup/azuretasks/disk_terraform.go index 5b2e1e4311d2d..670bd6d9fd8fc 100644 --- a/upup/pkg/fi/cloudup/azuretasks/disk_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/disk_terraform.go @@ -44,7 +44,7 @@ func (*Disk) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *Disk) createOption := string(compute.DiskCreateOptionEmpty) tf := &terraformAzureManagedDisk{ Name: e.Name, - Location: fi.PtrTo(t.Cloud.Region()), + Location: new(t.Cloud.Region()), ResourceGroupName: e.ResourceGroup.terraformName(), StorageAccountType: stringPtr(e.VolumeType), CreateOption: &createOption, diff --git a/upup/pkg/fi/cloudup/azuretasks/loadbalancer_terraform.go b/upup/pkg/fi/cloudup/azuretasks/loadbalancer_terraform.go index df00d3729685e..8f35e9cf3ba97 100644 --- a/upup/pkg/fi/cloudup/azuretasks/loadbalancer_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/loadbalancer_terraform.go @@ -79,14 +79,14 @@ func (*LoadBalancer) RenderTerraform(t *terraform.TerraformTarget, a, e, changes sku := string(e.SKU) tf := &terraformAzureLoadBalancer{ Name: e.Name, - Location: fi.PtrTo(t.Cloud.Region()), + Location: new(t.Cloud.Region()), ResourceGroupName: e.ResourceGroup.terraformName(), SKU: &sku, Tags: stringMap(e.Tags), } frontend := &terraformAzureLoadBalancerFrontendIPConfiguration{ - Name: fi.PtrTo(terraformAzureLoadBalancerFrontendName), + Name: new(terraformAzureLoadBalancerFrontendName), } if fi.ValueOf(e.External) { frontend.PublicIPAddressID = e.PublicIPAddress.terraformID() @@ -116,13 +116,13 @@ func (*LoadBalancer) RenderTerraform(t *terraform.TerraformTarget, a, e, changes for _, probe := range e.Probes { probeResourceName := fmt.Sprintf("%s-%s", fi.ValueOf(e.Name), probe.Name) if err := t.RenderResource("azurerm_lb_probe", probeResourceName, &terraformAzureLoadBalancerProbe{ - Name: fi.PtrTo(probe.Name), + Name: new(probe.Name), LoadBalancerID: e.terraformID(), - Protocol: fi.PtrTo(string(probe.Protocol)), - Port: fi.PtrTo(probe.Port), + Protocol: new(string(probe.Protocol)), + Port: new(probe.Port), RequestPath: probe.RequestPath, - IntervalInSeconds: fi.PtrTo(probe.IntervalInSeconds), - NumberOfProbes: fi.PtrTo(probe.NumberOfProbes), + IntervalInSeconds: new(probe.IntervalInSeconds), + NumberOfProbes: new(probe.NumberOfProbes), }); err != nil { return err } @@ -134,16 +134,16 @@ func (*LoadBalancer) RenderTerraform(t *terraform.TerraformTarget, a, e, changes ruleProtocol := string(rule.Protocol) loadDistribution := string(rule.LoadDistribution) if err := t.RenderResource("azurerm_lb_rule", ruleResourceName, &terraformAzureLoadBalancerRule{ - Name: fi.PtrTo(rule.Name), + Name: new(rule.Name), LoadBalancerID: e.terraformID(), Protocol: &ruleProtocol, - FrontendPort: fi.PtrTo(rule.Port), - BackendPort: fi.PtrTo(rule.Port), - FrontendIPConfigurationName: fi.PtrTo(terraformAzureLoadBalancerFrontendName), + FrontendPort: new(rule.Port), + BackendPort: new(rule.Port), + FrontendIPConfigurationName: new(terraformAzureLoadBalancerFrontendName), BackendAddressPoolIDs: []*terraformWriter.Literal{e.terraformBackendAddressPoolID()}, ProbeID: terraformWriter.LiteralProperty("azurerm_lb_probe", probeResourceName, "id"), - IdleTimeoutInMinutes: fi.PtrTo(rule.IdleTimeoutInMinutes), - FloatingIPEnabled: fi.PtrTo(rule.EnableFloatingIP), + IdleTimeoutInMinutes: new(rule.IdleTimeoutInMinutes), + FloatingIPEnabled: new(rule.EnableFloatingIP), LoadDistribution: &loadDistribution, }); err != nil { return err diff --git a/upup/pkg/fi/cloudup/azuretasks/natgateway_terraform.go b/upup/pkg/fi/cloudup/azuretasks/natgateway_terraform.go index 004164d5b0651..a86ae13fd5155 100644 --- a/upup/pkg/fi/cloudup/azuretasks/natgateway_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/natgateway_terraform.go @@ -41,7 +41,7 @@ func (*NatGateway) RenderTerraform(t *terraform.TerraformTarget, a, e, changes * skuName := string(e.SKU) tf := &terraformAzureNatGateway{ Name: e.Name, - Location: fi.PtrTo(t.Cloud.Region()), + Location: new(t.Cloud.Region()), ResourceGroupName: e.ResourceGroup.terraformName(), SKUName: &skuName, Tags: stringMap(e.Tags), diff --git a/upup/pkg/fi/cloudup/azuretasks/networksecuritygroup_terraform.go b/upup/pkg/fi/cloudup/azuretasks/networksecuritygroup_terraform.go index abd8ab17d0665..52ab384f2bac0 100644 --- a/upup/pkg/fi/cloudup/azuretasks/networksecuritygroup_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/networksecuritygroup_terraform.go @@ -49,7 +49,7 @@ type terraformAzureNetworkSecurityGroup struct { func (*NetworkSecurityGroup) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *NetworkSecurityGroup) error { tf := &terraformAzureNetworkSecurityGroup{ Name: e.Name, - Location: fi.PtrTo(t.Cloud.Region()), + Location: new(t.Cloud.Region()), ResourceGroupName: e.ResourceGroup.terraformName(), Tags: stringMap(e.Tags), } diff --git a/upup/pkg/fi/cloudup/azuretasks/publicipaddress_terraform.go b/upup/pkg/fi/cloudup/azuretasks/publicipaddress_terraform.go index 26f9630cb59b2..5e1f52f04d098 100644 --- a/upup/pkg/fi/cloudup/azuretasks/publicipaddress_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/publicipaddress_terraform.go @@ -38,7 +38,7 @@ func (*PublicIPAddress) RenderTerraform(t *terraform.TerraformTarget, a, e, chan ipVersion := string(e.IPVersion) tf := &terraformAzurePublicIPAddress{ Name: e.Name, - Location: fi.PtrTo(t.Cloud.Region()), + Location: new(t.Cloud.Region()), ResourceGroupName: e.ResourceGroup.terraformName(), AllocationMethod: &allocationMethod, SKU: &sku, diff --git a/upup/pkg/fi/cloudup/azuretasks/resourcegroup_terraform.go b/upup/pkg/fi/cloudup/azuretasks/resourcegroup_terraform.go index a3da50ccbe9d9..a8ba7036ea2fe 100644 --- a/upup/pkg/fi/cloudup/azuretasks/resourcegroup_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/resourcegroup_terraform.go @@ -35,7 +35,7 @@ func (*ResourceGroup) RenderTerraform(t *terraform.TerraformTarget, a, e, change tf := &terraformAzureResourceGroup{ Name: e.Name, - Location: fi.PtrTo(t.Cloud.Region()), + Location: new(t.Cloud.Region()), Tags: stringMap(e.Tags), } return t.RenderResource("azurerm_resource_group", fi.ValueOf(e.Name), tf) diff --git a/upup/pkg/fi/cloudup/azuretasks/roleassignment_terraform.go b/upup/pkg/fi/cloudup/azuretasks/roleassignment_terraform.go index 639d64e6399f6..397366dad3cc5 100644 --- a/upup/pkg/fi/cloudup/azuretasks/roleassignment_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/roleassignment_terraform.go @@ -37,7 +37,7 @@ func (*RoleAssignment) RenderTerraform(t *terraform.TerraformTarget, a, e, chang Scope: e.Scope, RoleDefinitionID: &roleDefinitionID, PrincipalID: e.VMScaleSet.terraformPrincipalID(), - SkipServicePrincipalAADCheck: fi.PtrTo(true), + SkipServicePrincipalAADCheck: new(true), } return t.RenderResource("azurerm_role_assignment", fi.ValueOf(e.Name), tf) } diff --git a/upup/pkg/fi/cloudup/azuretasks/routetable_terraform.go b/upup/pkg/fi/cloudup/azuretasks/routetable_terraform.go index 5929885a5b808..83bd13faf53b4 100644 --- a/upup/pkg/fi/cloudup/azuretasks/routetable_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/routetable_terraform.go @@ -36,7 +36,7 @@ func (*RouteTable) RenderTerraform(t *terraform.TerraformTarget, a, e, changes * tf := &terraformAzureRouteTable{ Name: e.Name, - Location: fi.PtrTo(t.Cloud.Region()), + Location: new(t.Cloud.Region()), ResourceGroupName: e.ResourceGroup.terraformName(), Tags: stringMap(e.Tags), } diff --git a/upup/pkg/fi/cloudup/azuretasks/subnet.go b/upup/pkg/fi/cloudup/azuretasks/subnet.go index 29833ded02183..39f9092cc5d0c 100644 --- a/upup/pkg/fi/cloudup/azuretasks/subnet.go +++ b/upup/pkg/fi/cloudup/azuretasks/subnet.go @@ -123,7 +123,7 @@ func (s *Subnet) Find(c *fi.CloudupContext) (*Subnet, error) { } if found.Properties.RouteTable != nil { fs.RouteTable = &RouteTable{ - Name: fi.PtrTo(path.Base(fi.ValueOf(found.Properties.RouteTable.ID))), + Name: new(path.Base(fi.ValueOf(found.Properties.RouteTable.ID))), ID: found.Properties.RouteTable.ID, } } diff --git a/upup/pkg/fi/cloudup/azuretasks/virtualnetwork_terraform.go b/upup/pkg/fi/cloudup/azuretasks/virtualnetwork_terraform.go index 3fce260699031..aa270bdeea8c4 100644 --- a/upup/pkg/fi/cloudup/azuretasks/virtualnetwork_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/virtualnetwork_terraform.go @@ -37,7 +37,7 @@ func (*VirtualNetwork) RenderTerraform(t *terraform.TerraformTarget, a, e, chang tf := &terraformAzureVirtualNetwork{ Name: e.Name, - Location: fi.PtrTo(t.Cloud.Region()), + Location: new(t.Cloud.Region()), ResourceGroupName: e.ResourceGroup.terraformName(), AddressSpace: []string{fi.ValueOf(e.CIDR)}, Tags: stringMap(e.Tags), diff --git a/upup/pkg/fi/cloudup/azuretasks/vmscaleset_terraform.go b/upup/pkg/fi/cloudup/azuretasks/vmscaleset_terraform.go index c7f9eb6c903ba..97e287fe1d7d9 100644 --- a/upup/pkg/fi/cloudup/azuretasks/vmscaleset_terraform.go +++ b/upup/pkg/fi/cloudup/azuretasks/vmscaleset_terraform.go @@ -105,7 +105,7 @@ func (*VMScaleSet) RenderTerraform(t *terraform.TerraformTarget, a, e, changes * tf := &terraformAzureVMScaleSet{ Name: e.Name, ResourceGroupName: e.ResourceGroup.terraformName(), - Location: fi.PtrTo(t.Cloud.Region()), + Location: new(t.Cloud.Region()), SKU: e.SKUName, Instances: e.Capacity, Zones: stringSlice(e.Zones), @@ -125,7 +125,7 @@ func (*VMScaleSet) RenderTerraform(t *terraform.TerraformTarget, a, e, changes * DiskSizeGB: storageProfile.OSDisk.DiskSizeGB, }, Identity: &terraformAzureVMScaleSetIdentity{ - Type: fi.PtrTo("SystemAssigned"), + Type: new("SystemAssigned"), }, Tags: stringMap(e.Tags), } @@ -145,8 +145,8 @@ func (*VMScaleSet) RenderTerraform(t *terraform.TerraformTarget, a, e, changes * tf.NetworkInterface = []*terraformAzureVMScaleSetNetworkInterface{ { Name: e.Name, - Primary: fi.PtrTo(true), - EnableIPForwarding: fi.PtrTo(true), + Primary: new(true), + EnableIPForwarding: new(true), IPConfiguration: []*terraformAzureVMScaleSetIPConfiguration{ ipConfig, }, @@ -176,7 +176,7 @@ func (vmss *VMScaleSet) terraformIPConfiguration(t *terraform.TerraformTarget) ( } cfg := &terraformAzureVMScaleSetIPConfiguration{ Name: vmss.Name, - Primary: fi.PtrTo(true), + Primary: new(true), SubnetID: subnetID, ApplicationSecurityGroupIDs: applicationSecurityGroupIDs(vmss.ApplicationSecurityGroups), } diff --git a/upup/pkg/fi/cloudup/azuretasks/vmscaleset_test.go b/upup/pkg/fi/cloudup/azuretasks/vmscaleset_test.go index 71ff198a7a127..d0f56d4e77e6e 100644 --- a/upup/pkg/fi/cloudup/azuretasks/vmscaleset_test.go +++ b/upup/pkg/fi/cloudup/azuretasks/vmscaleset_test.go @@ -320,7 +320,7 @@ func TestVMScaleSetRun(t *testing.T) { t.Fatalf("unexpected error: %s", err) } expectedTags := map[string]*string{ - azure.TagClusterName: fi.PtrTo(testClusterName), + azure.TagClusterName: new(testClusterName), } if a, e := vmss.Tags, expectedTags; !reflect.DeepEqual(a, e) { t.Errorf("unexpected tags: expected %+v, but got %+v", e, a) diff --git a/upup/pkg/fi/cloudup/bootstrapchannelbuilder/addonmanifest_test.go b/upup/pkg/fi/cloudup/bootstrapchannelbuilder/addonmanifest_test.go index 0637c28c9dbe7..69cc12f22366a 100644 --- a/upup/pkg/fi/cloudup/bootstrapchannelbuilder/addonmanifest_test.go +++ b/upup/pkg/fi/cloudup/bootstrapchannelbuilder/addonmanifest_test.go @@ -54,8 +54,8 @@ func TestAddonManifestNormalizeSkipsRenderForRawSources(t *testing.T) { rendered: []byte("apiVersion: v1\nkind: ConfigMap\ndata:\n literal: rendered\n"), } addon := &AddonManifest{ - Name: fi.PtrTo("raw-addon"), - Location: fi.PtrTo("addons/raw-addon.yaml"), + Name: new("raw-addon"), + Location: new("addons/raw-addon.yaml"), source: fi.NewBytesResource(rawManifest), skipRender: true, addonRenderer: renderer, @@ -89,8 +89,8 @@ func TestAddonManifestNormalizeRendersTemplateSources(t *testing.T) { rendered: []byte("apiVersion: v1\nkind: ConfigMap\ndata:\n literal: rendered\n"), } addon := &AddonManifest{ - Name: fi.PtrTo("template-addon"), - Location: fi.PtrTo("addons/template-addon.yaml"), + Name: new("template-addon"), + Location: new("addons/template-addon.yaml"), source: fi.NewBytesResource([]byte("apiVersion: v1\nkind: ConfigMap\ndata:\n literal: {{ .Value }}\n")), addonRenderer: renderer, addonSpec: testAddonSpec("template-addon"), @@ -153,8 +153,8 @@ func TestAddonCollectImagesRendersTemplateSources(t *testing.T) { func testAddonSpec(name string) *channelsapi.AddonSpec { return &channelsapi.AddonSpec{ - Name: fi.PtrTo(name), + Name: new(name), Selector: map[string]string{"k8s-addon": name}, - Manifest: fi.PtrTo(name + ".yaml"), + Manifest: new(name + ".yaml"), } } diff --git a/upup/pkg/fi/cloudup/bootstrapchannelbuilder/bootstrapchannelbuilder.go b/upup/pkg/fi/cloudup/bootstrapchannelbuilder/bootstrapchannelbuilder.go index 9649dbce284cf..453c3d93d14b7 100644 --- a/upup/pkg/fi/cloudup/bootstrapchannelbuilder/bootstrapchannelbuilder.go +++ b/upup/pkg/fi/cloudup/bootstrapchannelbuilder/bootstrapchannelbuilder.go @@ -169,9 +169,9 @@ func (b *BootstrapChannelBuilder) Build(c *fi.CloudupModelBuilderContext) error location := key + "/default.yaml" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), }) addon.SkipRemap = true @@ -194,9 +194,9 @@ func (b *BootstrapChannelBuilder) Build(c *fi.CloudupModelBuilderContext) error } task := &AddonManifest{ - Name: fi.PtrTo(b.Cluster.ObjectMeta.Name + "-addons-" + addonKey(addon.Spec)), + Name: new(b.Cluster.ObjectMeta.Name + "-addons-" + addonKey(addon.Spec)), Lifecycle: b.Lifecycle, - Location: fi.PtrTo("addons/" + *addon.Spec.Manifest), + Location: new("addons/" + *addon.Spec.Manifest), addonRenderer: b.addonRenderer, source: addon.Source, @@ -213,9 +213,9 @@ func (b *BootstrapChannelBuilder) Build(c *fi.CloudupModelBuilderContext) error } c.AddTask(&BootstrapChannel{ - Name: fi.PtrTo(b.Cluster.ObjectMeta.Name + "-addons-bootstrap"), + Name: new(b.Cluster.ObjectMeta.Name + "-addons-bootstrap"), Lifecycle: b.Lifecycle, - Location: fi.PtrTo("addons/bootstrap-channel.yaml"), + Location: new("addons/bootstrap-channel.yaml"), addonManifests: addonTasks, }) @@ -319,9 +319,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.16" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), NeedsRollingUpdate: channelsapi.NeedsRollingUpdateControlPlane, Id: id, }) @@ -343,9 +343,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.12" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -361,9 +361,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.12" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -381,9 +381,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.9" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -395,9 +395,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/v" + version + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), }) } @@ -407,9 +407,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.12" spec := &channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, } @@ -436,9 +436,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.19" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) @@ -458,9 +458,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.12" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), NeedsRollingUpdate: channelsapi.NeedsRollingUpdateAll, Id: id, }) @@ -477,9 +477,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.15" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -500,9 +500,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.11" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-app": "metrics-server"}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, NeedsPKI: !fi.ValueOf(b.Cluster.Spec.MetricsServer.Insecure), }) @@ -519,8 +519,8 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.16" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), - Manifest: fi.PtrTo(location), + Name: new(key), + Manifest: new(location), Id: id, }) addon.BuildPrune = true @@ -544,9 +544,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.11" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) addon.BuildPrune = true @@ -569,9 +569,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.17" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) addon.BuildPrune = true @@ -596,9 +596,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.16" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -620,9 +620,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.20" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -645,9 +645,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, NeedsPKI: true, }) @@ -668,11 +668,11 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{ "k8s-addon": key, }, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, NeedsPKI: true, }) @@ -689,9 +689,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -705,9 +705,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) addon.BuildPrune = true @@ -723,9 +723,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -737,9 +737,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -752,9 +752,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -764,9 +764,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -776,9 +776,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -791,9 +791,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -803,9 +803,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -815,9 +815,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) addon.BuildPrune = true @@ -833,9 +833,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -846,8 +846,8 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.23" location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), - Manifest: fi.PtrTo(location), + Name: new(key), + Manifest: new(location), Selector: map[string]string{"k8s-addon": key}, Id: id, }) @@ -862,9 +862,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -874,9 +874,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -890,9 +890,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: map[string]string{"k8s-addon": key}, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) addon.BuildPrune = true @@ -938,8 +938,8 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.23" location := key + "/" + id + ".yaml" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), - Manifest: fi.PtrTo(location), + Name: new(key), + Manifest: new(location), Selector: map[string]string{"k8s-addon": key}, Id: id, }) @@ -961,9 +961,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.12" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: networkingSelector(), - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) @@ -979,9 +979,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: networkingSelector(), - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) addon.BuildPrune = true @@ -996,9 +996,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: networkingSelector(), - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) addon.BuildPrune = true @@ -1013,9 +1013,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.12" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: networkingSelector(), - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -1034,9 +1034,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: networkingSelector(), - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, NeedsRollingUpdate: channelsapi.NeedsRollingUpdateAll, }) @@ -1051,9 +1051,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: networkingSelector(), - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, NeedsRollingUpdate: channelsapi.NeedsRollingUpdateAll, }) @@ -1076,9 +1076,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.12" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: authenticationSelector, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -1091,9 +1091,9 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.12" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: authenticationSelector, - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, }) } @@ -1108,8 +1108,8 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) location := key + "/" + id + ".yaml" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), - Manifest: fi.PtrTo(location), + Name: new(key), + Manifest: new(location), Selector: map[string]string{"k8s-addon": key}, Id: id, }) @@ -1124,8 +1124,8 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.13-ccm" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), - Manifest: fi.PtrTo(location), + Name: new(key), + Manifest: new(location), Selector: map[string]string{"k8s-addon": key}, Id: id, }) @@ -1141,8 +1141,8 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.18" location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), - Manifest: fi.PtrTo(location), + Name: new(key), + Manifest: new(location), Selector: map[string]string{"k8s-addon": key}, Id: id, }) @@ -1159,8 +1159,8 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.17" location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), - Manifest: fi.PtrTo(location), + Name: new(key), + Manifest: new(location), Selector: map[string]string{"k8s-addon": key}, Id: id, }) @@ -1178,8 +1178,8 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.20" location := key + "/" + id + ".yaml" addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), - Manifest: fi.PtrTo(location), + Name: new(key), + Manifest: new(location), Selector: map[string]string{"k8s-addon": key}, NeedsPKI: true, Id: id, @@ -1193,8 +1193,8 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.CloudupModelBuilderContext) id := "k8s-1.19" location := key + "/" + id + ".yaml" addon := addons.Add(&channelsapi.AddonSpec{ - Name: fi.PtrTo(key), - Manifest: fi.PtrTo(location), + Name: new(key), + Manifest: new(location), Selector: map[string]string{"k8s-addon": key}, Id: id, }) diff --git a/upup/pkg/fi/cloudup/bootstrapchannelbuilder/cilium.go b/upup/pkg/fi/cloudup/bootstrapchannelbuilder/cilium.go index da9bdca91e5af..08e8d7c0813b6 100644 --- a/upup/pkg/fi/cloudup/bootstrapchannelbuilder/cilium.go +++ b/upup/pkg/fi/cloudup/bootstrapchannelbuilder/cilium.go @@ -38,9 +38,9 @@ func addCiliumAddon(b *BootstrapChannelBuilder, addons *AddonList) error { location := key + "/" + id + "-v1.15.yaml" addon := &api.AddonSpec{ - Name: fi.PtrTo(key), + Name: new(key), Selector: networkingSelector(), - Manifest: fi.PtrTo(location), + Manifest: new(location), Id: id, NeedsRollingUpdate: api.NeedsRollingUpdateAll, } diff --git a/upup/pkg/fi/cloudup/deepvalidate_test.go b/upup/pkg/fi/cloudup/deepvalidate_test.go index 8119117ac249c..2a7e3c13f83d7 100644 --- a/upup/pkg/fi/cloudup/deepvalidate_test.go +++ b/upup/pkg/fi/cloudup/deepvalidate_test.go @@ -23,7 +23,6 @@ import ( kopsapi "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/apis/kops/validation" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/util/pkg/vfs" ) @@ -135,8 +134,8 @@ func TestDeepValidate_EvenEtcdClusterSize(t *testing.T) { { Name: "main", Members: []kopsapi.EtcdMemberSpec{ - {Name: "us-test-1a", InstanceGroup: fi.PtrTo("us-test-1a")}, - {Name: "us-test-1b", InstanceGroup: fi.PtrTo("us-test-1b")}, + {Name: "us-test-1a", InstanceGroup: new("us-test-1a")}, + {Name: "us-test-1b", InstanceGroup: new("us-test-1b")}, }, }, } @@ -157,9 +156,9 @@ func TestDeepValidate_MissingEtcdMember(t *testing.T) { { Name: "main", Members: []kopsapi.EtcdMemberSpec{ - {Name: "us-test-1a", InstanceGroup: fi.PtrTo("us-test-1a")}, - {Name: "us-test-1b", InstanceGroup: fi.PtrTo("us-test-1b")}, - {Name: "us-test-1c", InstanceGroup: fi.PtrTo("us-test-1c")}, + {Name: "us-test-1a", InstanceGroup: new("us-test-1a")}, + {Name: "us-test-1b", InstanceGroup: new("us-test-1b")}, + {Name: "us-test-1c", InstanceGroup: new("us-test-1c")}, }, }, } diff --git a/upup/pkg/fi/cloudup/defaults.go b/upup/pkg/fi/cloudup/defaults.go index 832ff5afe71cd..3f10bc9142706 100644 --- a/upup/pkg/fi/cloudup/defaults.go +++ b/upup/pkg/fi/cloudup/defaults.go @@ -55,7 +55,7 @@ func PerformAssignments(c *kops.Cluster, vfsContext *vfs.VFSContext, cloud fi.Cl etcdCluster.Manager = &kops.EtcdManagerSpec{} } if etcdCluster.Manager.BackupRetentionDays == nil { - etcdCluster.Manager.BackupRetentionDays = fi.PtrTo[uint32](90) + etcdCluster.Manager.BackupRetentionDays = new(uint32(90)) } } diff --git a/upup/pkg/fi/cloudup/dotasks/droplet.go b/upup/pkg/fi/cloudup/dotasks/droplet.go index e57955ad03300..66bf2170e0f8e 100644 --- a/upup/pkg/fi/cloudup/dotasks/droplet.go +++ b/upup/pkg/fi/cloudup/dotasks/droplet.go @@ -81,15 +81,15 @@ func (d *Droplet) Find(c *fi.CloudupContext) (*Droplet, error) { } return &Droplet{ - Name: fi.PtrTo(foundDroplet.Name), + Name: new(foundDroplet.Name), Count: count, - Region: fi.PtrTo(foundDroplet.Region.Slug), - Size: fi.PtrTo(foundDroplet.Size.Slug), + Region: new(foundDroplet.Region.Slug), + Size: new(foundDroplet.Size.Slug), Image: d.Image, //Image should not change so we keep it as-is Tags: foundDroplet.Tags, SSHKey: d.SSHKey, // TODO: get from droplet or ignore change UserData: d.UserData, // TODO: get from droplet or ignore change - VPCUUID: fi.PtrTo(foundDroplet.VPCUUID), + VPCUUID: new(foundDroplet.VPCUUID), Lifecycle: d.Lifecycle, }, nil } diff --git a/upup/pkg/fi/cloudup/dotasks/loadbalancer.go b/upup/pkg/fi/cloudup/dotasks/loadbalancer.go index 45f22e8ef5066..40f061708a022 100644 --- a/upup/pkg/fi/cloudup/dotasks/loadbalancer.go +++ b/upup/pkg/fi/cloudup/dotasks/loadbalancer.go @@ -83,10 +83,10 @@ func (lb *LoadBalancer) Find(c *fi.CloudupContext) (*LoadBalancer, error) { } return &LoadBalancer{ - Name: fi.PtrTo(loadbalancer.Name), - ID: fi.PtrTo(loadbalancer.ID), - Region: fi.PtrTo(loadbalancer.Region.Slug), - VPCUUID: fi.PtrTo(loadbalancer.VPCUUID), + Name: new(loadbalancer.Name), + ID: new(loadbalancer.ID), + Region: new(loadbalancer.Region.Slug), + VPCUUID: new(loadbalancer.VPCUUID), // Ignore system fields Lifecycle: lb.Lifecycle, @@ -164,8 +164,8 @@ func (_ *LoadBalancer) RenderDO(t *do.DOAPITarget, a, e, changes *LoadBalancer) klog.V(10).Infof("load balancer retrieved=%s, e.Name=%s", loadbalancer.Name, fi.ValueOf(e.Name)) if strings.Contains(loadbalancer.Name, fi.ValueOf(e.Name)) { // load balancer already exists. - e.ID = fi.PtrTo(loadbalancer.ID) - e.IPAddress = fi.PtrTo(loadbalancer.IP) // This will be empty on create, but will be filled later on FindAddresses invokation. + e.ID = new(loadbalancer.ID) + e.IPAddress = new(loadbalancer.IP) // This will be empty on create, but will be filled later on FindAddresses invokation. return nil } } @@ -194,8 +194,8 @@ func (_ *LoadBalancer) RenderDO(t *do.DOAPITarget, a, e, changes *LoadBalancer) return fmt.Errorf("Error creating load balancer with Name=%s, Error=%v", fi.ValueOf(e.Name), err) } - e.ID = fi.PtrTo(loadbalancer.ID) - e.IPAddress = fi.PtrTo(loadbalancer.IP) // This will be empty on create, but will be filled later on FindAddresses invokation. + e.ID = new(loadbalancer.ID) + e.IPAddress = new(loadbalancer.IP) // This will be empty on create, but will be filled later on FindAddresses invokation. klog.V(2).Infof("load balancer for DO created with id: %s", loadbalancer.ID) return nil diff --git a/upup/pkg/fi/cloudup/dotasks/volume.go b/upup/pkg/fi/cloudup/dotasks/volume.go index b82f6ba4d8e97..9e6ead2d68c11 100644 --- a/upup/pkg/fi/cloudup/dotasks/volume.go +++ b/upup/pkg/fi/cloudup/dotasks/volume.go @@ -60,11 +60,11 @@ func (v *Volume) Find(c *fi.CloudupContext) (*Volume, error) { for _, volume := range volumes { if volume.Name == fi.ValueOf(v.Name) { return &Volume{ - Name: fi.PtrTo(volume.Name), - ID: fi.PtrTo(volume.ID), + Name: new(volume.Name), + ID: new(volume.ID), Lifecycle: v.Lifecycle, - SizeGB: fi.PtrTo(volume.SizeGigaBytes), - Region: fi.PtrTo(volume.Region.Slug), + SizeGB: new(volume.SizeGigaBytes), + Region: new(volume.Region.Slug), }, nil } } diff --git a/upup/pkg/fi/cloudup/dotasks/volume_test.go b/upup/pkg/fi/cloudup/dotasks/volume_test.go index c95f7be1645ad..cb1b759b7d8ec 100644 --- a/upup/pkg/fi/cloudup/dotasks/volume_test.go +++ b/upup/pkg/fi/cloudup/dotasks/volume_test.go @@ -102,15 +102,15 @@ func Test_Find(t *testing.T) { }, }, &Volume{ - Name: fi.PtrTo("test0"), - SizeGB: fi.PtrTo(int64(100)), - Region: fi.PtrTo("nyc1"), + Name: new("test0"), + SizeGB: new(int64(100)), + Region: new("nyc1"), }, &Volume{ - Name: fi.PtrTo("test0"), - ID: fi.PtrTo("100"), - SizeGB: fi.PtrTo(int64(100)), - Region: fi.PtrTo("nyc1"), + Name: new("test0"), + ID: new("100"), + SizeGB: new(int64(100)), + Region: new("nyc1"), }, nil, }, @@ -123,9 +123,9 @@ func Test_Find(t *testing.T) { }, }, &Volume{ - Name: fi.PtrTo("test1"), - SizeGB: fi.PtrTo(int64(100)), - Region: fi.PtrTo("nyc1"), + Name: new("test1"), + SizeGB: new(int64(100)), + Region: new("nyc1"), }, nil, nil, @@ -139,9 +139,9 @@ func Test_Find(t *testing.T) { }, }, &Volume{ - Name: fi.PtrTo("test1"), - SizeGB: fi.PtrTo(int64(100)), - Region: fi.PtrTo("nyc1"), + Name: new("test1"), + SizeGB: new(int64(100)), + Region: new("nyc1"), }, nil, errors.New("error!"), diff --git a/upup/pkg/fi/cloudup/dotasks/vpc.go b/upup/pkg/fi/cloudup/dotasks/vpc.go index 2fb3c4620dddb..c7ccd4ee48403 100644 --- a/upup/pkg/fi/cloudup/dotasks/vpc.go +++ b/upup/pkg/fi/cloudup/dotasks/vpc.go @@ -53,11 +53,11 @@ func (v *VPC) Find(c *fi.CloudupContext) (*VPC, error) { for _, vpc := range vpcs { if vpc.Name == fi.ValueOf(v.Name) { return &VPC{ - Name: fi.PtrTo(vpc.Name), - ID: fi.PtrTo(vpc.ID), + Name: new(vpc.Name), + ID: new(vpc.ID), Lifecycle: v.Lifecycle, - IPRange: fi.PtrTo(vpc.IPRange), - Region: fi.PtrTo(vpc.RegionSlug), + IPRange: new(vpc.IPRange), + Region: new(vpc.RegionSlug), }, nil } } diff --git a/upup/pkg/fi/cloudup/gcetasks/address.go b/upup/pkg/fi/cloudup/gcetasks/address.go index d48e6c6036226..7fe822cf56689 100644 --- a/upup/pkg/fi/cloudup/gcetasks/address.go +++ b/upup/pkg/fi/cloudup/gcetasks/address.go @@ -98,7 +98,7 @@ func findAddressByIP(cloud gce.GCECloud, ip string, subnet string) (*Address, er actual.Name = &addr.Name if addr.Subnetwork != "" { actual.Subnetwork = &Subnet{ - Name: fi.PtrTo(lastComponent(addr.Subnetwork)), + Name: new(lastComponent(addr.Subnetwork)), } } @@ -122,7 +122,7 @@ func (e *Address) find(cloud gce.GCECloud) (*Address, error) { actual.Name = &r.Name if e.Subnetwork != nil { actual.Subnetwork = &Subnet{ - Name: fi.PtrTo(lastComponent(r.Subnetwork)), + Name: new(lastComponent(r.Subnetwork)), } } diff --git a/upup/pkg/fi/cloudup/gcetasks/disk.go b/upup/pkg/fi/cloudup/gcetasks/disk.go index 7d12677a04bd3..bc407d2b2eb80 100644 --- a/upup/pkg/fi/cloudup/gcetasks/disk.go +++ b/upup/pkg/fi/cloudup/gcetasks/disk.go @@ -62,8 +62,8 @@ func (e *Disk) Find(c *fi.CloudupContext) (*Disk, error) { actual := &Disk{} actual.Name = &r.Name - actual.VolumeType = fi.PtrTo(gce.LastComponent(r.Type)) - actual.Zone = fi.PtrTo(gce.LastComponent(r.Zone)) + actual.VolumeType = new(gce.LastComponent(r.Type)) + actual.Zone = new(gce.LastComponent(r.Zone)) actual.SizeGB = &r.SizeGb actual.VolumeIops = &r.ProvisionedIops actual.VolumeThroughput = &r.ProvisionedThroughput diff --git a/upup/pkg/fi/cloudup/gcetasks/firewallrule.go b/upup/pkg/fi/cloudup/gcetasks/firewallrule.go index f4e1bab2a39e2..0874228ec63de 100644 --- a/upup/pkg/fi/cloudup/gcetasks/firewallrule.go +++ b/upup/pkg/fi/cloudup/gcetasks/firewallrule.go @@ -73,7 +73,7 @@ func (e *FirewallRule) Find(c *fi.CloudupContext) (*FirewallRule, error) { actual := &FirewallRule{} actual.Name = &r.Name - actual.Network = &Network{Name: fi.PtrTo(lastComponent(r.Network))} + actual.Network = &Network{Name: new(lastComponent(r.Network))} actual.TargetTags = r.TargetTags actual.SourceRanges = r.SourceRanges actual.SourceTags = r.SourceTags diff --git a/upup/pkg/fi/cloudup/gcetasks/forwardingrule.go b/upup/pkg/fi/cloudup/gcetasks/forwardingrule.go index 2656851a6f7a9..93eb80ba88f18 100644 --- a/upup/pkg/fi/cloudup/gcetasks/forwardingrule.go +++ b/upup/pkg/fi/cloudup/gcetasks/forwardingrule.go @@ -90,7 +90,7 @@ func (e *ForwardingRule) Find(c *fi.CloudupContext) (*ForwardingRule, error) { } actual := &ForwardingRule{ - Name: fi.PtrTo(r.Name), + Name: new(r.Name), IPProtocol: r.IPProtocol, } if r.PortRange != "" { @@ -102,7 +102,7 @@ func (e *ForwardingRule) Find(c *fi.CloudupContext) (*ForwardingRule, error) { if r.Target != "" { actual.TargetPool = &TargetPool{ - Name: fi.PtrTo(lastComponent(r.Target)), + Name: new(lastComponent(r.Target)), } } if r.IPAddress != "" { @@ -114,20 +114,20 @@ func (e *ForwardingRule) Find(c *fi.CloudupContext) (*ForwardingRule, error) { } if r.BackendService != "" { actual.BackendService = &BackendService{ - Name: fi.PtrTo(lastComponent(r.BackendService)), + Name: new(lastComponent(r.BackendService)), } } if r.LoadBalancingScheme != "" { - actual.LoadBalancingScheme = fi.PtrTo(r.LoadBalancingScheme) + actual.LoadBalancingScheme = new(r.LoadBalancingScheme) } if r.Network != "" { actual.Network = &Network{ - Name: fi.PtrTo(lastComponent(r.Network)), + Name: new(lastComponent(r.Network)), } } if r.Subnetwork != "" { actual.Subnetwork = &Subnet{ - Name: fi.PtrTo(lastComponent(r.Subnetwork)), + Name: new(lastComponent(r.Subnetwork)), } } diff --git a/upup/pkg/fi/cloudup/gcetasks/httphealthcheck.go b/upup/pkg/fi/cloudup/gcetasks/httphealthcheck.go index 383eb41916b7b..caf0f9a1b9bf8 100644 --- a/upup/pkg/fi/cloudup/gcetasks/httphealthcheck.go +++ b/upup/pkg/fi/cloudup/gcetasks/httphealthcheck.go @@ -55,9 +55,9 @@ func (e *HTTPHealthcheck) Find(c *fi.CloudupContext) (*HTTPHealthcheck, error) { return nil, fmt.Errorf("error getting HealthCheck %q: %v", name, err) } actual := &HTTPHealthcheck{ - Name: fi.PtrTo(r.Name), - Port: fi.PtrTo(r.Port), - RequestPath: fi.PtrTo(r.RequestPath), + Name: new(r.Name), + Port: new(r.Port), + RequestPath: new(r.RequestPath), SelfLink: r.SelfLink, } // System fields diff --git a/upup/pkg/fi/cloudup/gcetasks/httphealthcheck_test.go b/upup/pkg/fi/cloudup/gcetasks/httphealthcheck_test.go index a43baeaaf0dd9..e55ee1355d599 100644 --- a/upup/pkg/fi/cloudup/gcetasks/httphealthcheck_test.go +++ b/upup/pkg/fi/cloudup/gcetasks/httphealthcheck_test.go @@ -37,11 +37,11 @@ func TestHTTPHealthcheckChange(t *testing.T) { // We define a function so we can rebuild the tasks, because we modify in-place when running buildTasks := func(requestPath string) map[string]fi.CloudupTask { healthcheck := &HTTPHealthcheck{ - Name: fi.PtrTo("api"), + Name: new("api"), Lifecycle: fi.LifecycleSync, - Port: fi.PtrTo(int64(8080)), - RequestPath: fi.PtrTo(requestPath), + Port: new(int64(8080)), + RequestPath: new(requestPath), } return map[string]fi.CloudupTask{ diff --git a/upup/pkg/fi/cloudup/gcetasks/instance.go b/upup/pkg/fi/cloudup/gcetasks/instance.go index 68aad1d615caa..b6d1c5f2ba182 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instance.go +++ b/upup/pkg/fi/cloudup/gcetasks/instance.go @@ -77,15 +77,15 @@ func (e *Instance) Find(c *fi.CloudupContext) (*Instance, error) { actual := &Instance{} actual.Name = &r.Name actual.Tags = append(actual.Tags, r.Tags.Items...) - actual.Zone = fi.PtrTo(lastComponent(r.Zone)) - actual.MachineType = fi.PtrTo(lastComponent(r.MachineType)) + actual.Zone = new(lastComponent(r.Zone)) + actual.MachineType = new(lastComponent(r.MachineType)) actual.CanIPForward = &r.CanIpForward if r.Scheduling != nil { actual.Preemptible = &r.Scheduling.Preemptible } if len(r.NetworkInterfaces) != 0 { ni := r.NetworkInterfaces[0] - actual.Network = &Network{Name: fi.PtrTo(lastComponent(ni.Network))} + actual.Network = &Network{Name: new(lastComponent(ni.Network))} actual.StackType = &ni.StackType if len(ni.AccessConfigs) != 0 { ac := ni.AccessConfigs[0] @@ -127,7 +127,7 @@ func (e *Instance) Find(c *fi.CloudupContext) (*Instance, error) { if err != nil { return nil, fmt.Errorf("error parsing source image URL: %v", err) } - actual.Image = fi.PtrTo(image) + actual.Image = new(image) } else { url, err := gce.ParseGoogleCloudURL(disk.Source) if err != nil { @@ -277,7 +277,7 @@ func (e *Instance) mapToGCE(project string, ipAddressResolver func(*Address) (*s } metadataItems = append(metadataItems, &compute.MetadataItems{ Key: key, - Value: fi.PtrTo(v), + Value: new(v), }) } diff --git a/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go b/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go index f6f8da7cea3c0..4ef5ae21afc0e 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go +++ b/upup/pkg/fi/cloudup/gcetasks/instancegroupmanager.go @@ -61,10 +61,10 @@ func (e *InstanceGroupManager) Find(c *fi.CloudupContext) (*InstanceGroupManager actual := &InstanceGroupManager{} actual.Name = &r.Name - actual.Zone = fi.PtrTo(lastComponent(r.Zone)) + actual.Zone = new(lastComponent(r.Zone)) actual.BaseInstanceName = &r.BaseInstanceName actual.TargetSize = e.TargetSize - actual.InstanceTemplate = &InstanceTemplate{ID: fi.PtrTo(lastComponent(r.InstanceTemplate))} + actual.InstanceTemplate = &InstanceTemplate{ID: new(lastComponent(r.InstanceTemplate))} actual.ListManagedInstancesResults = r.ListManagedInstancesResults if policy := r.UpdatePolicy; policy != nil { @@ -73,7 +73,7 @@ func (e *InstanceGroupManager) Find(c *fi.CloudupContext) (*InstanceGroupManager for _, targetPool := range r.TargetPools { actual.TargetPools = append(actual.TargetPools, &TargetPool{ - Name: fi.PtrTo(lastComponent(targetPool)), + Name: new(lastComponent(targetPool)), }) } // TODO: Sort by name diff --git a/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go b/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go index 41aaa84ad0550..f42a3d7da557c 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go +++ b/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go @@ -125,14 +125,14 @@ func (e *InstanceTemplate) Find(c *fi.CloudupContext) (*InstanceTemplate, error) actual.Tags = append(actual.Tags, p.Tags.Items...) actual.Labels = p.Labels - actual.MachineType = fi.PtrTo(lastComponent(p.MachineType)) + actual.MachineType = new(lastComponent(p.MachineType)) actual.CanIPForward = &p.CanIpForward bootDiskImage, err := ShortenImageURL(cloud.Project(), p.Disks[0].InitializeParams.SourceImage) if err != nil { return nil, fmt.Errorf("error parsing source image URL: %v", err) } - actual.BootDiskImage = fi.PtrTo(bootDiskImage) + actual.BootDiskImage = new(bootDiskImage) actual.BootDiskType = &p.Disks[0].InitializeParams.DiskType actual.BootDiskSizeGB = &p.Disks[0].InitializeParams.DiskSizeGb if p.Disks[0].InitializeParams.ProvisionedIops > 0 { @@ -148,7 +148,7 @@ func (e *InstanceTemplate) Find(c *fi.CloudupContext) (*InstanceTemplate, error) } if len(p.NetworkInterfaces) != 0 { ni := p.NetworkInterfaces[0] - actual.Network = &Network{Name: fi.PtrTo(lastComponent(ni.Network))} + actual.Network = &Network{Name: new(lastComponent(ni.Network))} if ni.StackType != "" { actual.StackType = &ni.StackType } @@ -161,7 +161,7 @@ func (e *InstanceTemplate) Find(c *fi.CloudupContext) (*InstanceTemplate, error) } if ni.Subnetwork != "" { - actual.Subnet = &Subnet{Name: fi.PtrTo(lastComponent(ni.Subnetwork))} + actual.Subnet = &Subnet{Name: new(lastComponent(ni.Subnetwork))} } acs := ni.AccessConfigs @@ -172,9 +172,9 @@ func (e *InstanceTemplate) Find(c *fi.CloudupContext) (*InstanceTemplate, error) if acs[0].Type != accessConfigOneToOneNAT { return nil, fmt.Errorf("unexpected access type in template %q: %s", *actual.Name, acs[0].Type) } - actual.HasExternalIP = fi.PtrTo(true) + actual.HasExternalIP = new(true) } else { - actual.HasExternalIP = fi.PtrTo(false) + actual.HasExternalIP = new(false) } } @@ -205,7 +205,7 @@ func (e *InstanceTemplate) Find(c *fi.CloudupContext) (*InstanceTemplate, error) // if err != nil { // return nil, fmt.Errorf("unable to parse image URL: %q", d.SourceImage) // } - // actual.Image = fi.PtrTo(imageURL.Project + "/" + imageURL.Name) + // actual.Image = new(imageURL.Project + "/" + imageURL.Name) // } // } //} @@ -266,7 +266,7 @@ func buildScheduling(machineTypeInfo *MachineTypeInfo, preemptible *bool, gcpPro if fi.ValueOf(preemptible) { scheduling = &compute.Scheduling{ - AutomaticRestart: fi.PtrTo(false), + AutomaticRestart: new(false), OnHostMaintenance: "TERMINATE", ProvisioningModel: fi.ValueOf(gcpProvisioningModel), Preemptible: true, @@ -275,7 +275,7 @@ func buildScheduling(machineTypeInfo *MachineTypeInfo, preemptible *bool, gcpPro // We default to allowing migration, as it gives higher uptime. // However, if we figure out that the instance does not support migration, we will set this to TERMINATE (so we can create the instance at all). scheduling = &compute.Scheduling{ - AutomaticRestart: fi.PtrTo(true), + AutomaticRestart: new(true), OnHostMaintenance: "MIGRATE", ProvisioningModel: "STANDARD", Preemptible: false, @@ -418,7 +418,7 @@ func (e *InstanceTemplate) mapToGCE(project string, region string) (*compute.Ins } metadataItems = append(metadataItems, &compute.MetadataItems{ Key: key, - Value: fi.PtrTo(v), + Value: new(v), }) } @@ -685,7 +685,7 @@ func (_ *InstanceTemplate) RenderTerraform(t *terraform.TerraformTarget, a, e, c name := fi.ValueOf(e.Name) tf := &terraformInstanceTemplate{ - Lifecycle: &terraform.Lifecycle{CreateBeforeDestroy: fi.PtrTo(true)}, + Lifecycle: &terraform.Lifecycle{CreateBeforeDestroy: new(true)}, NamePrefix: fi.ValueOf(e.NamePrefix) + "-", } diff --git a/upup/pkg/fi/cloudup/gcetasks/network.go b/upup/pkg/fi/cloudup/gcetasks/network.go index 3797d5e69e99c..ff04c8dde4e1a 100644 --- a/upup/pkg/fi/cloudup/gcetasks/network.go +++ b/upup/pkg/fi/cloudup/gcetasks/network.go @@ -216,10 +216,10 @@ func (_ *Network) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *N tf.IPv4Range = e.CIDR case "auto": - tf.AutoCreateSubnetworks = fi.PtrTo(true) + tf.AutoCreateSubnetworks = new(true) case "custom": - tf.AutoCreateSubnetworks = fi.PtrTo(false) + tf.AutoCreateSubnetworks = new(false) } return t.RenderResource("google_compute_network", *e.Name, tf) diff --git a/upup/pkg/fi/cloudup/gcetasks/projectiambinding_test.go b/upup/pkg/fi/cloudup/gcetasks/projectiambinding_test.go index 26ed07b95e3b0..b5110d4b293f5 100644 --- a/upup/pkg/fi/cloudup/gcetasks/projectiambinding_test.go +++ b/upup/pkg/fi/cloudup/gcetasks/projectiambinding_test.go @@ -37,15 +37,15 @@ func TestProjectIAMBinding(t *testing.T) { serviceAccount := &ServiceAccount{ Lifecycle: fi.LifecycleSync, - Email: fi.PtrTo("foo@testproject.iam.gserviceaccount.com"), + Email: new("foo@testproject.iam.gserviceaccount.com"), } binding := &ProjectIAMBinding{ Lifecycle: fi.LifecycleSync, - Project: fi.PtrTo("testproject"), + Project: new("testproject"), MemberServiceAccount: serviceAccount, - Role: fi.PtrTo("roles/owner"), + Role: new("roles/owner"), } return map[string]fi.CloudupTask{ diff --git a/upup/pkg/fi/cloudup/gcetasks/router.go b/upup/pkg/fi/cloudup/gcetasks/router.go index 2bad4a6509258..80e2ade195d3d 100644 --- a/upup/pkg/fi/cloudup/gcetasks/router.go +++ b/upup/pkg/fi/cloudup/gcetasks/router.go @@ -88,8 +88,8 @@ func (r *Router) Find(c *fi.CloudupContext) (*Router, error) { actual := &Router{ Name: &found.Name, Lifecycle: r.Lifecycle, - Network: &Network{Name: fi.PtrTo(lastComponent(found.Network))}, - Region: fi.PtrTo(lastComponent(found.Region)), + Network: &Network{Name: new(lastComponent(found.Network))}, + Region: new(lastComponent(found.Region)), NATIPAllocationOption: &nat.NatIpAllocateOption, SourceSubnetworkIPRangesToNAT: &nat.SourceSubnetworkIpRangesToNat, } diff --git a/upup/pkg/fi/cloudup/gcetasks/serviceaccount_test.go b/upup/pkg/fi/cloudup/gcetasks/serviceaccount_test.go index 1acd2c94377d4..3dd6263badf4c 100644 --- a/upup/pkg/fi/cloudup/gcetasks/serviceaccount_test.go +++ b/upup/pkg/fi/cloudup/gcetasks/serviceaccount_test.go @@ -42,12 +42,12 @@ func TestServiceAccount(t *testing.T) { // We define a function so we can rebuild the tasks, because we modify in-place when running buildTasks := func() map[string]fi.CloudupTask { serviceAccount := &ServiceAccount{ - Name: fi.PtrTo("test"), + Name: new("test"), Lifecycle: fi.LifecycleSync, - Email: fi.PtrTo("test@testproject.iam.gserviceaccount.com"), - Description: fi.PtrTo("description of ServiceAccount"), - DisplayName: fi.PtrTo("display name of ServiceAccount"), + Email: new("test@testproject.iam.gserviceaccount.com"), + Description: new("description of ServiceAccount"), + DisplayName: new("display name of ServiceAccount"), } return map[string]fi.CloudupTask{ diff --git a/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_test.go b/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_test.go index 0480797b35810..a94d4ee3b55c5 100644 --- a/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_test.go +++ b/upup/pkg/fi/cloudup/gcetasks/storagebucketiam_test.go @@ -37,15 +37,15 @@ func TestStorageBucketIAM(t *testing.T) { serviceAccount := &ServiceAccount{ Lifecycle: fi.LifecycleSync, - Email: fi.PtrTo("foo@testproject.iam.gserviceaccount.com"), + Email: new("foo@testproject.iam.gserviceaccount.com"), } binding := &StorageBucketIAM{ Lifecycle: fi.LifecycleSync, - Bucket: fi.PtrTo("bucket1"), + Bucket: new("bucket1"), MemberServiceAccount: serviceAccount, - Role: fi.PtrTo("roles/owner"), + Role: new("roles/owner"), } return map[string]fi.CloudupTask{ diff --git a/upup/pkg/fi/cloudup/gcetasks/subnet.go b/upup/pkg/fi/cloudup/gcetasks/subnet.go index ff74c64b017f3..ff9423bc9ab38 100644 --- a/upup/pkg/fi/cloudup/gcetasks/subnet.go +++ b/upup/pkg/fi/cloudup/gcetasks/subnet.go @@ -72,8 +72,8 @@ func (e *Subnet) Find(c *fi.CloudupContext) (*Subnet, error) { actual := &Subnet{} actual.Name = &s.Name - actual.Network = &Network{Name: fi.PtrTo(lastComponent(s.Network))} - actual.Region = fi.PtrTo(lastComponent(s.Region)) + actual.Network = &Network{Name: new(lastComponent(s.Network))} + actual.Region = new(lastComponent(s.Region)) actual.CIDR = &s.IpCidrRange actual.StackType = &s.StackType actual.Ipv6AccessType = &s.Ipv6AccessType diff --git a/upup/pkg/fi/cloudup/gcetasks/targetpool.go b/upup/pkg/fi/cloudup/gcetasks/targetpool.go index e1692ee7f8004..7c4d84a38a32d 100644 --- a/upup/pkg/fi/cloudup/gcetasks/targetpool.go +++ b/upup/pkg/fi/cloudup/gcetasks/targetpool.go @@ -55,7 +55,7 @@ func (e *TargetPool) Find(c *fi.CloudupContext) (*TargetPool, error) { } actual := &TargetPool{} - actual.Name = fi.PtrTo(r.Name) + actual.Name = new(r.Name) // Avoid spurious changes actual.HealthCheck = e.HealthCheck diff --git a/upup/pkg/fi/cloudup/hetznertasks/firewall.go b/upup/pkg/fi/cloudup/hetznertasks/firewall.go index e6c2d0f3ba4c1..0ae1510f3aa9b 100644 --- a/upup/pkg/fi/cloudup/hetznertasks/firewall.go +++ b/upup/pkg/fi/cloudup/hetznertasks/firewall.go @@ -42,7 +42,7 @@ type Firewall struct { var _ fi.CompareWithID = (*Firewall)(nil) func (v *Firewall) CompareWithID() *string { - return fi.PtrTo(strconv.FormatInt(fi.ValueOf(v.ID), 10)) + return new(strconv.FormatInt(fi.ValueOf(v.ID), 10)) } func (v *Firewall) Find(c *fi.CloudupContext) (*Firewall, error) { @@ -59,8 +59,8 @@ func (v *Firewall) Find(c *fi.CloudupContext) (*Firewall, error) { if firewall.Name == fi.ValueOf(v.Name) { matches := &Firewall{ Lifecycle: v.Lifecycle, - Name: fi.PtrTo(firewall.Name), - ID: fi.PtrTo(firewall.ID), + Name: new(firewall.Name), + ID: new(firewall.ID), Labels: firewall.Labels, } for _, rule := range firewall.Rules { @@ -231,19 +231,19 @@ func (_ *Firewall) RenderTerraform(t *terraform.TerraformTarget, a, e, changes * Name: e.Name, ApplyTo: []*terraformFirewallApplyTo{ { - LabelSelector: fi.PtrTo(e.Selector), + LabelSelector: new(e.Selector), }, }, Labels: e.Labels, } for _, rule := range e.Rules { tfr := &terraformFirewallRule{ - Direction: fi.PtrTo(string(rule.Direction)), - Protocol: fi.PtrTo(string(rule.Protocol)), + Direction: new(string(rule.Direction)), + Protocol: new(string(rule.Protocol)), Port: rule.Port, } for _, ip := range rule.SourceIPs { - tfr.SourceIPs = append(tfr.SourceIPs, fi.PtrTo(ip.String())) + tfr.SourceIPs = append(tfr.SourceIPs, new(ip.String())) } tf.Rules = append(tf.Rules, tfr) } diff --git a/upup/pkg/fi/cloudup/hetznertasks/loadbalancer.go b/upup/pkg/fi/cloudup/hetznertasks/loadbalancer.go index 867965f2abfbe..5a8a22f24f9fe 100644 --- a/upup/pkg/fi/cloudup/hetznertasks/loadbalancer.go +++ b/upup/pkg/fi/cloudup/hetznertasks/loadbalancer.go @@ -56,7 +56,7 @@ type LoadBalancer struct { var _ fi.CompareWithID = (*LoadBalancer)(nil) func (v *LoadBalancer) CompareWithID() *string { - return fi.PtrTo(strconv.FormatInt(fi.ValueOf(v.ID), 10)) + return new(strconv.FormatInt(fi.ValueOf(v.ID), 10)) } var _ fi.HasAddress = (*LoadBalancer)(nil) @@ -118,8 +118,8 @@ func (v *LoadBalancer) Find(c *fi.CloudupContext) (*LoadBalancer, error) { if loadbalancer.Name == fi.ValueOf(v.Name) { matches := &LoadBalancer{ Lifecycle: v.Lifecycle, - Name: fi.PtrTo(loadbalancer.Name), - ID: fi.PtrTo(loadbalancer.ID), + Name: new(loadbalancer.Name), + ID: new(loadbalancer.ID), Labels: loadbalancer.Labels, } @@ -133,8 +133,8 @@ func (v *LoadBalancer) Find(c *fi.CloudupContext) (*LoadBalancer, error) { for _, service := range loadbalancer.Services { loadbalancerService := LoadBalancerService{ Protocol: string(service.Protocol), - ListenerPort: fi.PtrTo(service.ListenPort), - DestinationPort: fi.PtrTo(service.DestinationPort), + ListenerPort: new(service.ListenPort), + DestinationPort: new(service.DestinationPort), } matches.Services = append(matches.Services, &loadbalancerService) } @@ -257,7 +257,7 @@ func (_ *LoadBalancer) RenderHetzner(t *hetzner.HetznerAPITarget, a, e, changes LabelSelector: hcloud.LoadBalancerCreateOptsTargetLabelSelector{ Selector: e.Target, }, - UsePrivateIP: fi.PtrTo(true), + UsePrivateIP: new(true), }, }, Network: &hcloud.Network{ @@ -341,7 +341,7 @@ func (_ *LoadBalancer) RenderHetzner(t *hetzner.HetznerAPITarget, a, e, changes if a.Target == "" { action, _, err := client.AddLabelSelectorTarget(ctx, loadbalancer, hcloud.LoadBalancerAddLabelSelectorTargetOpts{ Selector: e.Target, - UsePrivateIP: fi.PtrTo(true), + UsePrivateIP: new(true), }) if err != nil { return err @@ -427,7 +427,7 @@ func (_ *LoadBalancer) RenderTerraform(t *terraform.TerraformTarget, a, e, chang for _, service := range e.Services { tf := &terraformLoadBalancerService{ LoadBalancerID: e.TerraformLink(), - Protocol: fi.PtrTo(service.Protocol), + Protocol: new(service.Protocol), ListenPort: service.ListenerPort, DestinationPort: service.DestinationPort, } @@ -441,9 +441,9 @@ func (_ *LoadBalancer) RenderTerraform(t *terraform.TerraformTarget, a, e, chang { tf := &terraformLoadBalancerTarget{ LoadBalancerID: e.TerraformLink(), - Type: fi.PtrTo(string(hcloud.LoadBalancerTargetTypeLabelSelector)), - LabelSelector: fi.PtrTo(e.Target), - UsePrivateIP: fi.PtrTo(true), + Type: new(string(hcloud.LoadBalancerTargetTypeLabelSelector)), + LabelSelector: new(e.Target), + UsePrivateIP: new(true), } err := t.RenderResource("hcloud_load_balancer_target", *e.Name, tf) diff --git a/upup/pkg/fi/cloudup/hetznertasks/network.go b/upup/pkg/fi/cloudup/hetznertasks/network.go index 5dd67a832af70..20a37c577edff 100644 --- a/upup/pkg/fi/cloudup/hetznertasks/network.go +++ b/upup/pkg/fi/cloudup/hetznertasks/network.go @@ -72,7 +72,7 @@ func (v *Network) Find(c *fi.CloudupContext) (*Network, error) { matches := &Network{ Name: v.Name, Lifecycle: v.Lifecycle, - ID: fi.PtrTo(strconv.FormatInt(network.ID, 10)), + ID: new(strconv.FormatInt(network.ID, 10)), } if v.ID == nil { @@ -151,7 +151,7 @@ func (_ *Network) RenderHetzner(t *hetzner.HetznerAPITarget, a, e, changes *Netw if err != nil { return err } - e.ID = fi.PtrTo(strconv.FormatInt(network.ID, 10)) + e.ID = new(strconv.FormatInt(network.ID, 10)) } else { var err error @@ -221,7 +221,7 @@ func (_ *Network) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *N { tf := &terraformNetwork{ Name: e.Name, - IPRange: fi.PtrTo(e.IPRange), + IPRange: new(e.IPRange), Labels: e.Labels, } @@ -239,9 +239,9 @@ func (_ *Network) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *N tf := &terraformNetworkSubnet{ NetworkID: e.TerraformLink(), - Type: fi.PtrTo(string(hcloud.NetworkSubnetTypeCloud)), - IPRange: fi.PtrTo(subnetIpRange.String()), - NetworkZone: fi.PtrTo(e.Region), + Type: new(string(hcloud.NetworkSubnetTypeCloud)), + IPRange: new(subnetIpRange.String()), + NetworkZone: new(e.Region), } err = t.RenderResource("hcloud_network_subnet", *e.Name+"-"+subnet, tf) diff --git a/upup/pkg/fi/cloudup/hetznertasks/servergroup.go b/upup/pkg/fi/cloudup/hetznertasks/servergroup.go index 3b80030ff938e..9294b6750921a 100644 --- a/upup/pkg/fi/cloudup/hetznertasks/servergroup.go +++ b/upup/pkg/fi/cloudup/hetznertasks/servergroup.go @@ -226,7 +226,7 @@ func (_ *ServerGroup) RenderHetzner(t *hetzner.HetznerAPITarget, a, e, changes * opts := hcloud.ServerCreateOpts{ Name: name, - StartAfterCreate: fi.PtrTo(true), + StartAfterCreate: new(true), Networks: []*hcloud.Network{ { ID: networkID, @@ -309,19 +309,19 @@ type terraformServerPublicNet struct { func (_ *ServerGroup) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *ServerGroup) error { name := terraformWriter.LiteralWithIndex(fi.ValueOf(e.Name)) tf := &terraformServer{ - Count: fi.PtrTo(e.Count), + Count: new(e.Count), Name: name, - Location: fi.PtrTo(e.Location), - ServerType: fi.PtrTo(e.Size), - Image: fi.PtrTo(e.Image), + Location: new(e.Location), + ServerType: new(e.Size), + Image: new(e.Image), Network: []*terraformServerNetwork{ { ID: e.Network.TerraformLink(), }, }, PublicNet: &terraformServerPublicNet{ - EnableIPv4: fi.PtrTo(e.EnableIPv4), - EnableIPv6: fi.PtrTo(e.EnableIPv6), + EnableIPv4: new(e.EnableIPv4), + EnableIPv6: new(e.EnableIPv6), }, Labels: e.Labels, } diff --git a/upup/pkg/fi/cloudup/hetznertasks/sshkey.go b/upup/pkg/fi/cloudup/hetznertasks/sshkey.go index a30014d9e51c4..300887f4e47d7 100644 --- a/upup/pkg/fi/cloudup/hetznertasks/sshkey.go +++ b/upup/pkg/fi/cloudup/hetznertasks/sshkey.go @@ -44,7 +44,7 @@ type SSHKey struct { var _ fi.CompareWithID = (*SSHKey)(nil) func (v *SSHKey) CompareWithID() *string { - return fi.PtrTo(strconv.FormatInt(fi.ValueOf(v.ID), 10)) + return new(strconv.FormatInt(fi.ValueOf(v.ID), 10)) } func (v *SSHKey) Find(c *fi.CloudupContext) (*SSHKey, error) { @@ -65,7 +65,7 @@ func (v *SSHKey) Find(c *fi.CloudupContext) (*SSHKey, error) { matches := &SSHKey{ Name: v.Name, Lifecycle: v.Lifecycle, - ID: fi.PtrTo(sshkey.ID), + ID: new(sshkey.ID), PublicKey: sshkey.PublicKey, Labels: v.Labels, } @@ -124,7 +124,7 @@ func (_ *SSHKey) RenderHetzner(t *hetzner.HetznerAPITarget, a, e, changes *SSHKe if err != nil { return err } - e.ID = fi.PtrTo(sshkey.ID) + e.ID = new(sshkey.ID) } return nil @@ -139,7 +139,7 @@ type terraformSSHKey struct { func (_ *SSHKey) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *SSHKey) error { tf := &terraformSSHKey{ Name: e.Name, - PublicKey: fi.PtrTo(e.PublicKey), + PublicKey: new(e.PublicKey), Labels: e.Labels, } diff --git a/upup/pkg/fi/cloudup/hetznertasks/volume.go b/upup/pkg/fi/cloudup/hetznertasks/volume.go index 6355c5ceca348..efe1771645e00 100644 --- a/upup/pkg/fi/cloudup/hetznertasks/volume.go +++ b/upup/pkg/fi/cloudup/hetznertasks/volume.go @@ -41,7 +41,7 @@ type Volume struct { var _ fi.CompareWithID = (*Volume)(nil) func (v *Volume) CompareWithID() *string { - return fi.PtrTo(strconv.FormatInt(fi.ValueOf(v.ID), 10)) + return new(strconv.FormatInt(fi.ValueOf(v.ID), 10)) } func (v *Volume) Find(c *fi.CloudupContext) (*Volume, error) { @@ -57,8 +57,8 @@ func (v *Volume) Find(c *fi.CloudupContext) (*Volume, error) { if volume.Name == fi.ValueOf(v.Name) { matches := &Volume{ Lifecycle: v.Lifecycle, - Name: fi.PtrTo(volume.Name), - ID: fi.PtrTo(volume.ID), + Name: new(volume.Name), + ID: new(volume.ID), Size: volume.Size, Labels: volume.Labels, } @@ -149,8 +149,8 @@ type terraformVolume struct { func (_ *Volume) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *Volume) error { tf := &terraformVolume{ Name: e.Name, - Size: fi.PtrTo(e.Size), - Location: fi.PtrTo(e.Location), + Size: new(e.Size), + Location: new(e.Location), Labels: e.Labels, } diff --git a/upup/pkg/fi/cloudup/linodetasks/sshkey.go b/upup/pkg/fi/cloudup/linodetasks/sshkey.go index 9031a1de4ec05..bd9289bf2152e 100644 --- a/upup/pkg/fi/cloudup/linodetasks/sshkey.go +++ b/upup/pkg/fi/cloudup/linodetasks/sshkey.go @@ -72,8 +72,8 @@ func (s *SSHKey) Find(c *fi.CloudupContext) (*SSHKey, error) { } actual := &SSHKey{ - ID: fi.PtrTo(matched.ID), - Name: fi.PtrTo(matched.Label), + ID: new(matched.ID), + Name: new(matched.Label), Lifecycle: s.Lifecycle, } @@ -141,7 +141,7 @@ func (*SSHKey) RenderLinode(t *linode.APITarget, actual, expected, changes *SSHK return fmt.Errorf("error creating Linode (Akamai) SSH key %q: %w", name, err) } - expected.ID = fi.PtrTo(created.ID) + expected.ID = new(created.ID) klog.V(2).Infof("Created Linode (Akamai) SSH key %q (id=%d)", created.Label, created.ID) return nil diff --git a/upup/pkg/fi/cloudup/linodetasks/sshkey_test.go b/upup/pkg/fi/cloudup/linodetasks/sshkey_test.go index 171c6790947ca..939e8ea30bf80 100644 --- a/upup/pkg/fi/cloudup/linodetasks/sshkey_test.go +++ b/upup/pkg/fi/cloudup/linodetasks/sshkey_test.go @@ -45,7 +45,7 @@ func TestSSHKeyFindMatchByName(t *testing.T) { cloud := &linode.MockLinodeCloud{Client_: client} ctx := newTestCloudupContext(t, cloud) - task := &SSHKey{Name: fi.PtrTo("example-k8s-local"), PublicKey: publicKey} + task := &SSHKey{Name: new("example-k8s-local"), PublicKey: publicKey} actual, err := task.Find(ctx) if err != nil { t.Fatalf("Find returned error: %v", err) @@ -69,7 +69,7 @@ func TestSSHKeyFindPublicKeyMismatch(t *testing.T) { cloud := &linode.MockLinodeCloud{Client_: client} ctx := newTestCloudupContext(t, cloud) - _, err := (&SSHKey{Name: fi.PtrTo("example-k8s-local"), PublicKey: publicKey}).Find(ctx) + _, err := (&SSHKey{Name: new("example-k8s-local"), PublicKey: publicKey}).Find(ctx) if err == nil { t.Fatalf("expected public key mismatch error") } @@ -88,7 +88,7 @@ func TestSSHKeyFindDuplicateName(t *testing.T) { cloud := &linode.MockLinodeCloud{Client_: client} ctx := newTestCloudupContext(t, cloud) - _, err := (&SSHKey{Name: fi.PtrTo("example-k8s-local")}).Find(ctx) + _, err := (&SSHKey{Name: new("example-k8s-local")}).Find(ctx) if err == nil { t.Fatalf("expected duplicate name error") } @@ -102,7 +102,7 @@ func TestSSHKeyFindListError(t *testing.T) { cloud := &linode.MockLinodeCloud{Client_: client} ctx := newTestCloudupContext(t, cloud) - _, err := (&SSHKey{Name: fi.PtrTo("example-k8s-local")}).Find(ctx) + _, err := (&SSHKey{Name: new("example-k8s-local")}).Find(ctx) if err == nil { t.Fatalf("expected list error") } @@ -116,7 +116,7 @@ func TestSSHKeyRenderLinodeCreate(t *testing.T) { client := &linode.MockLinodeClient{CreateSSHKeyResponse: &linodego.SSHKey{ID: 42, Label: "example-k8s-local"}} target := linode.NewAPITarget(&linode.MockLinodeCloud{Client_: client}) - expected := &SSHKey{Name: fi.PtrTo("example-k8s-local"), PublicKey: publicKey} + expected := &SSHKey{Name: new("example-k8s-local"), PublicKey: publicKey} if err := (&SSHKey{}).RenderLinode(target, nil, expected, nil); err != nil { t.Fatalf("RenderLinode returned error: %v", err) } @@ -137,8 +137,8 @@ func TestSSHKeyRenderLinodeCreate(t *testing.T) { func TestSSHKeyCheckChangesRejectsPublicKeyChange(t *testing.T) { actualPublicKey := newSSHKeyResource(t, testLinodeSSHPublicKey) expectedPublicKey := newSSHKeyResource(t, testLinodeSSHPublicKey+"-changed") - actual := &SSHKey{Name: fi.PtrTo("example-k8s-local"), ID: fi.PtrTo(42), PublicKey: actualPublicKey} - expected := &SSHKey{Name: fi.PtrTo("example-k8s-local"), ID: fi.PtrTo(42), PublicKey: expectedPublicKey} + actual := &SSHKey{Name: new("example-k8s-local"), ID: new(42), PublicKey: actualPublicKey} + expected := &SSHKey{Name: new("example-k8s-local"), ID: new(42), PublicKey: expectedPublicKey} changes := &SSHKey{PublicKey: expected.PublicKey} if err := (&SSHKey{}).CheckChanges(actual, expected, changes); err == nil { diff --git a/upup/pkg/fi/cloudup/linodetasks/vpc.go b/upup/pkg/fi/cloudup/linodetasks/vpc.go index 390ccd779957e..142579605271b 100644 --- a/upup/pkg/fi/cloudup/linodetasks/vpc.go +++ b/upup/pkg/fi/cloudup/linodetasks/vpc.go @@ -44,7 +44,7 @@ func (v *VPC) CompareWithID() *string { return nil } id := strconv.Itoa(fi.ValueOf(v.ID)) - return fi.PtrTo(id) + return new(id) } func (v *VPC) Find(c *fi.CloudupContext) (*VPC, error) { @@ -76,11 +76,11 @@ func (v *VPC) Find(c *fi.CloudupContext) (*VPC, error) { } actual := &VPC{ - Name: fi.PtrTo(found.Label), - ID: fi.PtrTo(found.ID), + Name: new(found.Label), + ID: new(found.ID), Lifecycle: v.Lifecycle, - Description: fi.PtrTo(found.Description), - Region: fi.PtrTo(found.Region), + Description: new(found.Description), + Region: new(found.Region), } v.ID = actual.ID @@ -121,7 +121,7 @@ func (_ *VPC) RenderLinode(t *linode.APITarget, actual, expected, changes *VPC) if err != nil { return fmt.Errorf("error creating Linode (Akamai) VPC %q: %w", fi.ValueOf(expected.Name), err) } - expected.ID = fi.PtrTo(vpc.ID) + expected.ID = new(vpc.ID) return nil } @@ -137,7 +137,7 @@ func (_ *VPC) RenderLinode(t *linode.APITarget, actual, expected, changes *VPC) if err != nil { return fmt.Errorf("error updating Linode (Akamai) VPC %q: %w", fi.ValueOf(expected.Name), err) } - expected.ID = fi.PtrTo(vpc.ID) + expected.ID = new(vpc.ID) return nil } diff --git a/upup/pkg/fi/cloudup/linodetasks/vpc_test.go b/upup/pkg/fi/cloudup/linodetasks/vpc_test.go index 5f688666439fb..33b73ef6cd0ad 100644 --- a/upup/pkg/fi/cloudup/linodetasks/vpc_test.go +++ b/upup/pkg/fi/cloudup/linodetasks/vpc_test.go @@ -48,7 +48,7 @@ func TestVPCFindMatchByName(t *testing.T) { cloud := &linode.MockLinodeCloud{Client_: client} ctx := newTestCloudupContext(t, cloud) - task := &VPC{Name: fi.PtrTo("example-k8s-local")} + task := &VPC{Name: new("example-k8s-local")} actual, err := task.Find(ctx) if err != nil { t.Fatalf("Find returned error: %v", err) @@ -80,7 +80,7 @@ func TestVPCFindMatchByNameAndRegion(t *testing.T) { cloud := &linode.MockLinodeCloud{Client_: client} ctx := newTestCloudupContext(t, cloud) - task := &VPC{Name: fi.PtrTo("example-k8s-local"), Region: fi.PtrTo("us-east")} + task := &VPC{Name: new("example-k8s-local"), Region: new("us-east")} actual, err := task.Find(ctx) if err != nil { t.Fatalf("Find returned error: %v", err) @@ -98,7 +98,7 @@ func TestVPCFindListError(t *testing.T) { cloud := &linode.MockLinodeCloud{Client_: client} ctx := newTestCloudupContext(t, cloud) - _, err := (&VPC{Name: fi.PtrTo("example-k8s-local")}).Find(ctx) + _, err := (&VPC{Name: new("example-k8s-local")}).Find(ctx) if err == nil { t.Fatalf("expected list error") } @@ -117,7 +117,7 @@ func TestVPCFindDuplicateName(t *testing.T) { cloud := &linode.MockLinodeCloud{Client_: client} ctx := newTestCloudupContext(t, cloud) - _, err := (&VPC{Name: fi.PtrTo("example-k8s-local")}).Find(ctx) + _, err := (&VPC{Name: new("example-k8s-local")}).Find(ctx) if err == nil { t.Fatalf("expected duplicate name error") } @@ -131,9 +131,9 @@ func TestVPCRenderLinodeCreate(t *testing.T) { target := linode.NewAPITarget(&linode.MockLinodeCloud{Client_: client}) expected := &VPC{ - Name: fi.PtrTo("example-k8s-local"), - Description: fi.PtrTo("kOps cluster VPC"), - Region: fi.PtrTo("us-east"), + Name: new("example-k8s-local"), + Description: new("kOps cluster VPC"), + Region: new("us-east"), } if err := (&VPC{}).RenderLinode(target, nil, expected, nil); err != nil { @@ -160,8 +160,8 @@ func TestVPCRenderLinodeUpdate(t *testing.T) { client := &linode.MockLinodeClient{UpdateVPCResponse: &linodego.VPC{ID: 42, Label: "new-name", Description: "new description"}} target := linode.NewAPITarget(&linode.MockLinodeCloud{Client_: client}) - actual := &VPC{ID: fi.PtrTo(42), Name: fi.PtrTo("old-name"), Description: fi.PtrTo("old"), Region: fi.PtrTo("us-east")} - expected := &VPC{ID: fi.PtrTo(42), Name: fi.PtrTo("new-name"), Description: fi.PtrTo("new description"), Region: fi.PtrTo("us-east")} + actual := &VPC{ID: new(42), Name: new("old-name"), Description: new("old"), Region: new("us-east")} + expected := &VPC{ID: new(42), Name: new("new-name"), Description: new("new description"), Region: new("us-east")} changes := &VPC{Name: expected.Name, Description: expected.Description} if err := (&VPC{}).RenderLinode(target, actual, expected, changes); err != nil { @@ -182,8 +182,8 @@ func TestVPCRenderLinodeUpdate(t *testing.T) { } func TestVPCCheckChangesRejectsRegionChange(t *testing.T) { - actual := &VPC{Name: fi.PtrTo("example-k8s-local"), ID: fi.PtrTo(42), Region: fi.PtrTo("us-east")} - expected := &VPC{Name: fi.PtrTo("example-k8s-local"), ID: fi.PtrTo(42), Region: fi.PtrTo("us-west")} + actual := &VPC{Name: new("example-k8s-local"), ID: new(42), Region: new("us-east")} + expected := &VPC{Name: new("example-k8s-local"), ID: new(42), Region: new("us-west")} changes := &VPC{Region: expected.Region} if err := (&VPC{}).CheckChanges(actual, expected, changes); err == nil { diff --git a/upup/pkg/fi/cloudup/new_cluster.go b/upup/pkg/fi/cloudup/new_cluster.go index 2b43df8501ebd..d5f37ea75f599 100644 --- a/upup/pkg/fi/cloudup/new_cluster.go +++ b/upup/pkg/fi/cloudup/new_cluster.go @@ -278,7 +278,7 @@ func NewCluster(opt *NewClusterOptions, clientset simple.Clientset) (*NewCluster AllowContainerRegistry: true, } cluster.Spec.Kubelet = &api.KubeletConfigSpec{ - AnonymousAuth: fi.PtrTo(false), + AnonymousAuth: new(false), } if len(opt.KubernetesFeatureGates) > 0 { @@ -367,17 +367,17 @@ func NewCluster(opt *NewClusterOptions, clientset simple.Clientset) (*NewCluster case api.CloudProviderOpenstack: cluster.Spec.CloudProvider.Openstack = &api.OpenstackSpec{ Router: &api.OpenstackRouter{ - ExternalNetwork: fi.PtrTo(opt.OpenstackExternalNet), + ExternalNetwork: new(opt.OpenstackExternalNet), }, BlockStorage: &api.OpenstackBlockStorageConfig{ - Version: fi.PtrTo("v3"), - IgnoreAZ: fi.PtrTo(opt.OpenstackStorageIgnoreAZ), + Version: new("v3"), + IgnoreAZ: new(opt.OpenstackStorageIgnoreAZ), ClusterName: opt.ClusterName, }, Monitor: &api.OpenstackMonitor{ - Delay: fi.PtrTo("15s"), - Timeout: fi.PtrTo("10s"), - MaxRetries: fi.PtrTo(3), + Delay: new("15s"), + Timeout: new("10s"), + MaxRetries: new(3), }, } initializeOpenstack(opt, cluster) @@ -412,7 +412,7 @@ func NewCluster(opt *NewClusterOptions, clientset simple.Clientset) (*NewCluster } if cluster.GetCloudProvider() == api.CloudProviderAWS { cluster.Spec.ServiceAccountIssuerDiscovery.EnableAWSOIDCProvider = true - cluster.Spec.IAM.UseServiceAccountExternalPermissions = fi.PtrTo(true) + cluster.Spec.IAM.UseServiceAccountExternalPermissions = new(true) } } @@ -466,7 +466,7 @@ func NewCluster(opt *NewClusterOptions, clientset simple.Clientset) (*NewCluster } if cluster.GetCloudProvider() == api.CloudProviderAWS { cluster.Spec.ServiceAccountIssuerDiscovery.EnableAWSOIDCProvider = true - cluster.Spec.IAM.UseServiceAccountExternalPermissions = fi.PtrTo(true) + cluster.Spec.IAM.UseServiceAccountExternalPermissions = new(true) } } @@ -645,10 +645,10 @@ func setupVPC(opt *NewClusterOptions, cluster *api.Cluster, cloud fi.Cloud) erro if featureflag.Spotinst.Enabled() { if opt.SpotinstProduct != "" { - cluster.Spec.CloudProvider.AWS.SpotinstProduct = fi.PtrTo(opt.SpotinstProduct) + cluster.Spec.CloudProvider.AWS.SpotinstProduct = new(opt.SpotinstProduct) } if opt.SpotinstOrientation != "" { - cluster.Spec.CloudProvider.AWS.SpotinstOrientation = fi.PtrTo(opt.SpotinstOrientation) + cluster.Spec.CloudProvider.AWS.SpotinstOrientation = new(opt.SpotinstOrientation) } } @@ -693,10 +693,10 @@ func setupVPC(opt *NewClusterOptions, cluster *api.Cluster, cloud fi.Cloud) erro } if opt.OpenstackDNSServers != "" { - cluster.Spec.CloudProvider.Openstack.Router.DNSServers = fi.PtrTo(opt.OpenstackDNSServers) + cluster.Spec.CloudProvider.Openstack.Router.DNSServers = new(opt.OpenstackDNSServers) } if opt.OpenstackExternalSubnet != "" { - cluster.Spec.CloudProvider.Openstack.Router.ExternalSubnet = fi.PtrTo(opt.OpenstackExternalSubnet) + cluster.Spec.CloudProvider.Openstack.Router.ExternalSubnet = new(opt.OpenstackExternalSubnet) } case api.CloudProviderAzure: // TODO(kenji): Find a right place for this. @@ -1004,8 +1004,8 @@ func setupControlPlane(opt *NewClusterOptions, cluster *api.Cluster, zoneToSubne g := &api.InstanceGroup{} g.Spec.Role = api.InstanceGroupRoleControlPlane - g.Spec.MinSize = fi.PtrTo(int32(1)) - g.Spec.MaxSize = fi.PtrTo(int32(1)) + g.Spec.MinSize = new(int32(1)) + g.Spec.MaxSize = new(int32(1)) g.ObjectMeta.Name = "control-plane-" + name subnets := zoneToSubnetsMap[zone] @@ -1130,8 +1130,8 @@ func setupNodes(opt *NewClusterOptions, cluster *api.Cluster, zoneToSubnetsMap m g := &api.InstanceGroup{} g.Spec.Role = api.InstanceGroupRoleNode - g.Spec.MinSize = fi.PtrTo(nodeCount) - g.Spec.MaxSize = fi.PtrTo(nodeCount) + g.Spec.MinSize = new(nodeCount) + g.Spec.MaxSize = new(nodeCount) g.ObjectMeta.Name = "nodes" for _, zone := range opt.Zones { @@ -1179,8 +1179,8 @@ func setupNodes(opt *NewClusterOptions, cluster *api.Cluster, zoneToSubnetsMap m g := &api.InstanceGroup{} g.Spec.Role = api.InstanceGroupRoleNode - g.Spec.MinSize = fi.PtrTo(count) - g.Spec.MaxSize = fi.PtrTo(count) + g.Spec.MinSize = new(count) + g.Spec.MaxSize = new(count) g.ObjectMeta.Name = "nodes-" + zone subnets := zoneToSubnetsMap[zone] @@ -1232,7 +1232,7 @@ func setupKarpenterNodes(opt *NewClusterOptions) ([]*api.InstanceGroup, error) { g.Spec.Manager = api.InstanceManagerKarpenter g.ObjectMeta.Name = "nodes" if opt.NodeCount > 0 { - g.Spec.MinSize = fi.PtrTo(opt.NodeCount) + g.Spec.MinSize = new(opt.NodeCount) } for i, size := range opt.NodeSizes { @@ -1273,8 +1273,8 @@ func setupAPIServers(opt *NewClusterOptions, cluster *api.Cluster, zoneToSubnets g := &api.InstanceGroup{} g.Spec.Role = api.InstanceGroupRoleAPIServer - g.Spec.MinSize = fi.PtrTo(count) - g.Spec.MaxSize = fi.PtrTo(count) + g.Spec.MinSize = new(count) + g.Spec.MaxSize = new(count) g.ObjectMeta.Name = "apiserver-" + zone subnets := zoneToSubnetsMap[zone] @@ -1463,8 +1463,8 @@ func setupTopology(opt *NewClusterOptions, cluster *api.Cluster, allZones sets.S bastionGroup := &api.InstanceGroup{} bastionGroup.Spec.Role = api.InstanceGroupRoleBastion bastionGroup.ObjectMeta.Name = "bastions" - bastionGroup.Spec.MaxSize = fi.PtrTo(int32(1)) - bastionGroup.Spec.MinSize = fi.PtrTo(int32(1)) + bastionGroup.Spec.MaxSize = new(int32(1)) + bastionGroup.Spec.MinSize = new(int32(1)) bastions = append(bastions, bastionGroup) if cluster.PublishesDNSRecords() { @@ -1601,14 +1601,14 @@ func initializeOpenstack(opt *NewClusterOptions, cluster *api.Cluster) { LbMethod = "SOURCE_IP_PORT" } cluster.Spec.CloudProvider.Openstack.Loadbalancer = &api.OpenstackLoadbalancerConfig{ - FloatingNetwork: fi.PtrTo(opt.OpenstackExternalNet), - Method: fi.PtrTo(LbMethod), - Provider: fi.PtrTo(provider), - UseOctavia: fi.PtrTo(opt.OpenstackLBOctavia), + FloatingNetwork: new(opt.OpenstackExternalNet), + Method: new(LbMethod), + Provider: new(provider), + UseOctavia: new(opt.OpenstackLBOctavia), } if opt.OpenstackLBSubnet != "" { - cluster.Spec.CloudProvider.Openstack.Loadbalancer.FloatingSubnet = fi.PtrTo(opt.OpenstackLBSubnet) + cluster.Spec.CloudProvider.Openstack.Loadbalancer.FloatingSubnet = new(opt.OpenstackLBSubnet) } } @@ -1633,7 +1633,7 @@ func createEtcdCluster(etcdCluster string, controlPlanes []*api.InstanceGroup, e etcd := api.EtcdClusterSpec{ Name: etcdCluster, Manager: &api.EtcdManagerSpec{ - BackupRetentionDays: fi.PtrTo[uint32](90), + BackupRetentionDays: new(uint32(90)), }, } @@ -1669,11 +1669,11 @@ func createEtcdCluster(etcdCluster string, controlPlanes []*api.InstanceGroup, e m.EncryptedVolume = &encryptEtcdStorage } if len(etcdStorageType) > 0 { - m.VolumeType = fi.PtrTo(etcdStorageType) + m.VolumeType = new(etcdStorageType) } m.Name = names[i] - m.InstanceGroup = fi.PtrTo(ig.ObjectMeta.Name) + m.InstanceGroup = new(ig.ObjectMeta.Name) etcd.Members = append(etcd.Members, m) } diff --git a/upup/pkg/fi/cloudup/new_cluster_test.go b/upup/pkg/fi/cloudup/new_cluster_test.go index c655482c48c65..4f1f1c6d78ab6 100644 --- a/upup/pkg/fi/cloudup/new_cluster_test.go +++ b/upup/pkg/fi/cloudup/new_cluster_test.go @@ -277,7 +277,7 @@ func TestSetupNetworking(t *testing.T) { expected: api.Cluster{ Spec: api.ClusterSpec{ KubeProxy: &api.KubeProxyConfig{ - Enabled: fi.PtrTo(false), + Enabled: new(false), }, Networking: api.NetworkingSpec{ KubeRouter: &api.KuberouterNetworkingSpec{}, @@ -316,7 +316,7 @@ func TestSetupNetworking(t *testing.T) { expected: api.Cluster{ Spec: api.ClusterSpec{ KubeProxy: &api.KubeProxyConfig{ - Enabled: fi.PtrTo(false), + Enabled: new(false), }, Networking: api.NetworkingSpec{ Cilium: &api.CiliumNetworkingSpec{ @@ -333,7 +333,7 @@ func TestSetupNetworking(t *testing.T) { expected: api.Cluster{ Spec: api.ClusterSpec{ KubeProxy: &api.KubeProxyConfig{ - Enabled: fi.PtrTo(false), + Enabled: new(false), }, Networking: api.NetworkingSpec{ Cilium: &api.CiliumNetworkingSpec{ diff --git a/upup/pkg/fi/cloudup/openstack/cloud.go b/upup/pkg/fi/cloudup/openstack/cloud.go index 485bd1adddb9d..965b20fbe2c4f 100644 --- a/upup/pkg/fi/cloudup/openstack/cloud.go +++ b/upup/pkg/fi/cloudup/openstack/cloud.go @@ -478,7 +478,7 @@ func buildLoadBalancerClient(c *openstackCloud, spec *kops.OpenstackSpec, provid if err != nil || len(lbNet) != 1 { return fmt.Errorf("could not establish floating network id") } - spec.Loadbalancer.FloatingNetworkID = fi.PtrTo(lbNet[0].ID) + spec.Loadbalancer.FloatingNetworkID = new(lbNet[0].ID) } if spec.Loadbalancer.UseOctavia != nil { diff --git a/upup/pkg/fi/cloudup/openstack/cloud_test.go b/upup/pkg/fi/cloudup/openstack/cloud_test.go index 396d6f2b25b18..f5612caae2716 100644 --- a/upup/pkg/fi/cloudup/openstack/cloud_test.go +++ b/upup/pkg/fi/cloudup/openstack/cloud_test.go @@ -84,7 +84,7 @@ func Test_OpenstackCloud_MakeCloud(t *testing.T) { CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ BlockStorage: &kops.OpenstackBlockStorageConfig{ - IgnoreVolumeMicroVersion: fi.PtrTo(true), + IgnoreVolumeMicroVersion: new(true), }, }, }, @@ -583,7 +583,7 @@ func Test_BuildClients(t *testing.T) { name: "When octavia is set, but no router, an error should be returned", spec: &kops.OpenstackSpec{ Loadbalancer: &kops.OpenstackLoadbalancerConfig{ - UseOctavia: fi.PtrTo(true), + UseOctavia: new(true), }, }, expectLB: true, @@ -594,7 +594,7 @@ func Test_BuildClients(t *testing.T) { name: "When octavia is set, and there is a router, a load-balancer should be returned", spec: &kops.OpenstackSpec{ Loadbalancer: &kops.OpenstackLoadbalancerConfig{ - UseOctavia: fi.PtrTo(true), + UseOctavia: new(true), }, Router: &kops.OpenstackRouter{}, }, @@ -616,13 +616,13 @@ func Test_BuildClients(t *testing.T) { name: "When router is set, but no LB, FIP support should be enabled", spec: &kops.OpenstackSpec{ Router: &kops.OpenstackRouter{ - ExternalNetwork: fi.PtrTo("some-ext-net"), + ExternalNetwork: new("some-ext-net"), }, }, expectLB: false, expectedType: "", expectFloatingEnabled: true, - expectedExtNetName: fi.PtrTo("some-ext-net"), + expectedExtNetName: new("some-ext-net"), }} for _, g := range grid { diff --git a/upup/pkg/fi/cloudup/openstack/instance.go b/upup/pkg/fi/cloudup/openstack/instance.go index 492cb7571fa8f..73f6ac06773b2 100644 --- a/upup/pkg/fi/cloudup/openstack/instance.go +++ b/upup/pkg/fi/cloudup/openstack/instance.go @@ -34,7 +34,6 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "k8s.io/klog/v2" "k8s.io/kops/pkg/cloudinstances" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/util/pkg/vfs" ) @@ -75,7 +74,7 @@ func IsPortInUse(err error) bool { // and will result in a timeout when not reaching status "ACTIVE" in time. func waitForStatusActive(c OpenstackCloud, serverID string, timeout *time.Duration) error { if timeout == nil { - timeout = fi.PtrTo(defaultActiveTimeout) + timeout = new(defaultActiveTimeout) } ctx, cancel := context.WithTimeout(context.TODO(), time.Duration(timeout.Seconds())*time.Second) defer cancel() @@ -114,7 +113,7 @@ func createInstance(c OpenstackCloud, opt servers.CreateOptsBuilder, schedulerHi if port.DeviceID != "" && port.DeviceOwner == "" { klog.Warningf("Port %s is attached to Device that does not exist anymore, reseting the status of DeviceID", portID) _, err := c.UpdatePort(portID, ports.UpdateOpts{ - DeviceID: fi.PtrTo(""), + DeviceID: new(""), }) if err != nil { return false, fmt.Errorf("error updating port %s deviceid: %v", portID, err) @@ -163,10 +162,10 @@ func listServerFloatingIPs(c OpenstackCloud, instanceID string, floatingEnabled for _, props := range addrList { if floatingEnabled { if props.IPType == "floating" { - result = append(result, fi.PtrTo(props.Addr)) + result = append(result, new(props.Addr)) } } else { - result = append(result, fi.PtrTo(props.Addr)) + result = append(result, new(props.Addr)) } } } @@ -281,7 +280,7 @@ func drainSingleLB(c OpenstackCloud, lb loadbalancers.LoadBalancer, instanceName // Setting the member weight to 0 means that the member will not receive new requests but will finish any existing connections. // This “drains” the backend member of active connections. _, err := c.UpdateMemberInPool(pool.ID, member.ID, v2pools.UpdateMemberOpts{ - Weight: fi.PtrTo(0), + Weight: new(0), }) if err != nil { return err diff --git a/upup/pkg/fi/cloudup/openstack/instance_test.go b/upup/pkg/fi/cloudup/openstack/instance_test.go index dac52777b80d4..698c9479b4903 100644 --- a/upup/pkg/fi/cloudup/openstack/instance_test.go +++ b/upup/pkg/fi/cloudup/openstack/instance_test.go @@ -24,7 +24,6 @@ import ( "time" "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" - "k8s.io/kops/upup/pkg/fi" ) type WaitForStatusActiveMock struct { @@ -83,7 +82,7 @@ func Test_WaitForStatusActiveResultsInTimeout(t *testing.T) { serverID := "mock-id" c := createWaitForStatusActiveMock(serverID, "BUILD") - actualErr := waitForStatusActive(c, serverID, fi.PtrTo(time.Second)) + actualErr := waitForStatusActive(c, serverID, new(time.Second)) expectedErr := context.DeadlineExceeded assertTestResults(t, nil, expectedErr, actualErr) diff --git a/upup/pkg/fi/cloudup/openstacktasks/floatingip.go b/upup/pkg/fi/cloudup/openstacktasks/floatingip.go index 0d042c191e2c6..85fd01a991c8b 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/floatingip.go +++ b/upup/pkg/fi/cloudup/openstacktasks/floatingip.go @@ -146,8 +146,8 @@ func (e *FloatingIP) Find(c *fi.CloudupContext) (*FloatingIP, error) { return nil, nil } actual := &FloatingIP{ - Name: fi.PtrTo(fip.Description), - ID: fi.PtrTo(fip.ID), + Name: new(fip.Description), + ID: new(fip.ID), LB: e.LB, Lifecycle: e.Lifecycle, } @@ -165,9 +165,9 @@ func (e *FloatingIP) Find(c *fi.CloudupContext) (*FloatingIP, error) { for _, fip := range fips { if fip.Description == fi.ValueOf(e.Name) { actual := &FloatingIP{ - ID: fi.PtrTo(fips[0].ID), + ID: new(fips[0].ID), Name: e.Name, - IP: fi.PtrTo(fip.FloatingIP), + IP: new(fip.FloatingIP), Lifecycle: e.Lifecycle, } e.ID = actual.ID @@ -256,8 +256,8 @@ func (f *FloatingIP) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, chan return fmt.Errorf("Failed to create floating IP: %v", err) } - e.ID = fi.PtrTo(fip.ID) - e.IP = fi.PtrTo(fip.FloatingIP) + e.ID = new(fip.ID) + e.IP = new(fip.FloatingIP) return nil } diff --git a/upup/pkg/fi/cloudup/openstacktasks/instance.go b/upup/pkg/fi/cloudup/openstacktasks/instance.go index eab5931eb4518..28f63e3319234 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/instance.go +++ b/upup/pkg/fi/cloudup/openstacktasks/instance.go @@ -192,16 +192,16 @@ func (e *Instance) Find(c *fi.CloudupContext) (*Instance, error) { server := filteredList[0] actual := &Instance{ - ID: fi.PtrTo(server.ID), + ID: new(server.ID), Name: e.Name, - SSHKey: fi.PtrTo(server.KeyName), + SSHKey: new(server.KeyName), Lifecycle: e.Lifecycle, Metadata: server.Metadata, - Role: fi.PtrTo(server.Metadata["KopsRole"]), + Role: new(server.Metadata["KopsRole"]), AvailabilityZone: e.AvailabilityZone, GroupName: e.GroupName, ConfigDrive: e.ConfigDrive, - Status: fi.PtrTo(server.Status), + Status: new(server.Status), } ports, err := cloud.ListPorts(ports.ListOpts{ @@ -236,8 +236,8 @@ func (e *Instance) Find(c *fi.CloudupContext) (*Instance, error) { if len(fips) == 1 { fip := fips[0] fipTask := &FloatingIP{ - ID: fi.PtrTo(fip.ID), - Name: fi.PtrTo(fip.Description), + ID: new(fip.ID), + Name: new(fip.Description), } actual.FloatingIP = fipTask @@ -248,7 +248,7 @@ func (e *Instance) Find(c *fi.CloudupContext) (*Instance, error) { // Avoid flapping e.ID = actual.ID - e.Status = fi.PtrTo(activeStatus) + e.Status = new(activeStatus) actual.WellKnownServices = e.WellKnownServices // Immutable fields @@ -380,7 +380,7 @@ func (_ *Instance) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, change if err != nil { return fmt.Errorf("Error creating instance: %v", err) } - e.ID = fi.PtrTo(v.ID) + e.ID = new(v.ID) if e.FloatingIP != nil { err = associateFloatingIP(t, e) diff --git a/upup/pkg/fi/cloudup/openstacktasks/lb.go b/upup/pkg/fi/cloudup/openstacktasks/lb.go index b7666432fa1a5..c81e088bb4539 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lb.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lb.go @@ -118,18 +118,18 @@ func NewLBTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecycle, secGroup := find == nil || find.SecurityGroup != nil actual := &LB{ - ID: fi.PtrTo(lb.ID), - Name: fi.PtrTo(lb.Name), + ID: new(lb.ID), + Name: new(lb.Name), Lifecycle: lifecycle, - PortID: fi.PtrTo(lb.VipPortID), - Subnet: fi.PtrTo(sub.Name), - VipSubnet: fi.PtrTo(lb.VipSubnetID), - Provider: fi.PtrTo(lb.Provider), - FlavorID: fi.PtrTo(lb.FlavorID), + PortID: new(lb.VipPortID), + Subnet: new(sub.Name), + VipSubnet: new(lb.VipSubnetID), + Provider: new(lb.Provider), + FlavorID: new(lb.FlavorID), } if secGroup { - sg, err := getSecurityGroupByName(&SecurityGroup{Name: fi.PtrTo(lb.Name)}, osCloud) + sg, err := getSecurityGroupByName(&SecurityGroup{Name: new(lb.Name)}, osCloud) if err != nil { return nil, err } @@ -216,11 +216,11 @@ func (_ *LB) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *LB) if err != nil { return fmt.Errorf("error creating LB: %v", err) } - e.ID = fi.PtrTo(lb.ID) - e.PortID = fi.PtrTo(lb.VipPortID) - e.VipSubnet = fi.PtrTo(lb.VipSubnetID) - e.Provider = fi.PtrTo(lb.Provider) - e.FlavorID = fi.PtrTo(lb.FlavorID) + e.ID = new(lb.ID) + e.PortID = new(lb.VipPortID) + e.VipSubnet = new(lb.VipSubnetID) + e.Provider = new(lb.Provider) + e.FlavorID = new(lb.FlavorID) if e.SecurityGroup != nil { opts := ports.UpdateOpts{ diff --git a/upup/pkg/fi/cloudup/openstacktasks/lblistener.go b/upup/pkg/fi/cloudup/openstacktasks/lblistener.go index 2030496213944..7ad213aef79af 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lblistener.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lblistener.go @@ -61,9 +61,9 @@ func NewLBListenerTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lif // sort for consistent comparison sort.Strings(listener.AllowedCIDRs) listenerTask := &LBListener{ - ID: fi.PtrTo(listener.ID), - Name: fi.PtrTo(listener.Name), - Port: fi.PtrTo(listener.ProtocolPort), + ID: new(listener.ID), + Name: new(listener.Name), + Port: new(listener.ProtocolPort), AllowedCIDRs: listener.AllowedCIDRs, Lifecycle: lifecycle, } @@ -166,7 +166,7 @@ func (_ *LBListener) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, chan if err != nil { return fmt.Errorf("error creating LB listener: %v", err) } - e.ID = fi.PtrTo(listener.ID) + e.ID = new(listener.ID) return nil } else if len(changes.AllowedCIDRs) > 0 { if useVIPACL && (fi.ValueOf(a.Pool.Loadbalancer.Provider) != "ovn") { diff --git a/upup/pkg/fi/cloudup/openstacktasks/lbpool.go b/upup/pkg/fi/cloudup/openstacktasks/lbpool.go index f3a6ba698aae5..8755f56ad0523 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/lbpool.go +++ b/upup/pkg/fi/cloudup/openstacktasks/lbpool.go @@ -56,8 +56,8 @@ func NewLBPoolTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecyc } a := &LBPool{ - ID: fi.PtrTo(pool.ID), - Name: fi.PtrTo(pool.Name), + ID: new(pool.ID), + Name: new(pool.Name), Lifecycle: lifecycle, } if len(pool.Loadbalancers) == 1 { @@ -146,7 +146,7 @@ func (_ *LBPool) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes if err != nil { return fmt.Errorf("error creating LB pool: %v", err) } - e.ID = fi.PtrTo(pool.ID) + e.ID = new(pool.ID) return nil } diff --git a/upup/pkg/fi/cloudup/openstacktasks/network.go b/upup/pkg/fi/cloudup/openstacktasks/network.go index 486506f88b8a0..ff8dfa5fc9e1d 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/network.go +++ b/upup/pkg/fi/cloudup/openstacktasks/network.go @@ -47,10 +47,10 @@ func NewNetworkTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecy } task := &Network{ - ID: fi.PtrTo(network.ID), - Name: fi.PtrTo(network.Name), + ID: new(network.ID), + Name: new(network.Name), Lifecycle: lifecycle, - Tag: fi.PtrTo(tag), + Tag: new(tag), AvailabilityZoneHints: fi.StringSlice(network.AvailabilityZoneHints), } return task, nil @@ -120,7 +120,7 @@ func (_ *Network) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes opt := networks.CreateOpts{ Name: fi.ValueOf(e.Name), - AdminStateUp: fi.PtrTo(true), + AdminStateUp: new(true), AvailabilityZoneHints: fi.StringSliceValue(e.AvailabilityZoneHints), } @@ -134,7 +134,7 @@ func (_ *Network) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes return fmt.Errorf("Error appending tag to network: %v", err) } - e.ID = fi.PtrTo(v.ID) + e.ID = new(v.ID) klog.V(2).Infof("Creating a new Openstack network, id=%s", v.ID) return nil } else { diff --git a/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go b/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go index 2379aa870850e..b8d8acb98f19a 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go +++ b/upup/pkg/fi/cloudup/openstacktasks/poolassociation.go @@ -106,15 +106,15 @@ func (p *PoolAssociation) Find(context *fi.CloudupContext) (*PoolAssociation, er } actual := &PoolAssociation{ - ID: fi.PtrTo(found.ID), - Name: fi.PtrTo(found.Name), + ID: new(found.ID), + Name: new(found.Name), Pool: pool, ServerPrefix: p.ServerPrefix, ClusterName: p.ClusterName, InterfaceName: p.InterfaceName, ProtocolPort: p.ProtocolPort, Lifecycle: p.Lifecycle, - Weight: fi.PtrTo(found.Weight), + Weight: new(found.Weight), } p.ID = actual.ID return actual, nil @@ -184,7 +184,7 @@ func (_ *PoolAssociation) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, if err != nil { return fmt.Errorf("Failed to create member: %v", err) } - e.ID = fi.PtrTo(member.ID) + e.ID = new(member.ID) } } else { _, err := t.Cloud.UpdateMemberInPool(fi.ValueOf(a.Pool.ID), fi.ValueOf(a.ID), v2pools.UpdateMemberOpts{ diff --git a/upup/pkg/fi/cloudup/openstacktasks/poolmonitor.go b/upup/pkg/fi/cloudup/openstacktasks/poolmonitor.go index 1f2537035ea3a..99d8a68335090 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/poolmonitor.go +++ b/upup/pkg/fi/cloudup/openstacktasks/poolmonitor.go @@ -69,8 +69,8 @@ func (p *PoolMonitor) Find(context *fi.CloudupContext) (*PoolMonitor, error) { } found := rs[0] actual := &PoolMonitor{ - ID: fi.PtrTo(found.ID), - Name: fi.PtrTo(found.Name), + ID: new(found.ID), + Name: new(found.Name), Pool: p.Pool, Lifecycle: p.Lifecycle, } @@ -114,7 +114,7 @@ func (_ *PoolMonitor) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, cha if err != nil { return fmt.Errorf("error creating PoolMonitor: %v", err) } - e.ID = fi.PtrTo(poolMonitor.ID) + e.ID = new(poolMonitor.ID) } return nil } diff --git a/upup/pkg/fi/cloudup/openstacktasks/port.go b/upup/pkg/fi/cloudup/openstacktasks/port.go index 75ec9aa8cc743..d52c7fcbe2560 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/port.go +++ b/upup/pkg/fi/cloudup/openstacktasks/port.go @@ -142,7 +142,7 @@ func newPortTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecycle continue } sgs = append(sgs, &SecurityGroup{ - ID: fi.PtrTo(sgid), + ID: new(sgid), Lifecycle: lifecycle, }) } @@ -153,7 +153,7 @@ func newPortTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecycle subnets := make([]*Subnet, len(port.FixedIPs)) for i, subn := range port.FixedIPs { subnets[i] = &Subnet{ - ID: fi.PtrTo(subn.SubnetID), + ID: new(subn.SubnetID), Lifecycle: lifecycle, } } @@ -176,7 +176,7 @@ func newPortTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecycle if !strings.HasPrefix(t, prefix) { continue } - cloudInstanceGroupName = fi.PtrTo("") + cloudInstanceGroupName = new("") scanString := fmt.Sprintf("%s%%s", prefix) if _, err := fmt.Sscanf(t, scanString, cloudInstanceGroupName); err != nil { klog.V(2).Infof("Error extracting instance group for Port with name: %q", port.Name) @@ -184,10 +184,10 @@ func newPortTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecycle } actual := &Port{ - ID: fi.PtrTo(port.ID), + ID: new(port.ID), InstanceGroupName: cloudInstanceGroupName, - Name: fi.PtrTo(port.Name), - Network: &Network{ID: fi.PtrTo(port.NetworkID)}, + Name: new(port.Name), + Network: &Network{ID: new(port.NetworkID)}, SecurityGroups: sgs, Subnets: subnets, Lifecycle: lifecycle, @@ -269,7 +269,7 @@ func (*Port) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *Por } } } - e.ID = fi.PtrTo(v.ID) + e.ID = new(v.ID) klog.V(2).Infof("Creating a new Openstack port, id=%s", v.ID) return nil } diff --git a/upup/pkg/fi/cloudup/openstacktasks/port_test.go b/upup/pkg/fi/cloudup/openstacktasks/port_test.go index 8d709d01a7e7a..a494470cd76e0 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/port_test.go +++ b/upup/pkg/fi/cloudup/openstacktasks/port_test.go @@ -45,7 +45,7 @@ func Test_Port_GetActualAllowedAddressPairs_ReturnsPortAddressPairsWhenFindIsNil AllowedAddressPairs: expected, } - actual := getActualAllowedAddressPairs(fi.PtrTo(port), nil) + actual := getActualAllowedAddressPairs(new(port), nil) if !reflect.DeepEqual(expected, actual) { t.Errorf("Allowed address pairs differ:\n%v\n\tinstead of\n%v", actual, expected) @@ -81,7 +81,7 @@ func Test_Port_GetAllowedAddressPairs_ReturnsModifiedPortAddressPairsWhenNoChang AllowedAddressPairs: expected, } - actual := getActualAllowedAddressPairs(fi.PtrTo(port), fi.PtrTo(find)) + actual := getActualAllowedAddressPairs(new(port), new(find)) if !reflect.DeepEqual(expected, actual) { t.Errorf("Allowed address pairs differ:\n%v\n\tinstead of\n%v", actual, expected) @@ -121,7 +121,7 @@ func Test_Port_GetActualAllowedAddressPairs_ReturnsModifiedPortAddressPairsOnCha }, } - actual := getActualAllowedAddressPairs(fi.PtrTo(port), fi.PtrTo(find)) + actual := getActualAllowedAddressPairs(new(port), new(find)) if !reflect.DeepEqual(expected, actual) { t.Errorf("Allowed address pairs differ:\n%v\n\tinstead of\n%v", actual, expected) @@ -130,11 +130,11 @@ func Test_Port_GetActualAllowedAddressPairs_ReturnsModifiedPortAddressPairsOnCha func Test_Port_GetDependencies(t *testing.T) { tasks := map[string]fi.CloudupTask{ - "foo": &SecurityGroup{Name: fi.PtrTo("security-group")}, - "bar": &Subnet{Name: fi.PtrTo("subnet")}, - "baz": &Instance{Name: fi.PtrTo("instance")}, - "qux": &FloatingIP{Name: fi.PtrTo("fip")}, - "xxx": &Network{Name: fi.PtrTo("network")}, + "foo": &SecurityGroup{Name: new("security-group")}, + "bar": &Subnet{Name: new("subnet")}, + "baz": &Instance{Name: new("instance")}, + "qux": &FloatingIP{Name: new("fip")}, + "xxx": &Network{Name: new("network")}, } port := &Port{} @@ -142,9 +142,9 @@ func Test_Port_GetDependencies(t *testing.T) { actual := port.GetDependencies(tasks) expected := []fi.CloudupTask{ - &Subnet{Name: fi.PtrTo("subnet")}, - &Network{Name: fi.PtrTo("network")}, - &SecurityGroup{Name: fi.PtrTo("security-group")}, + &Subnet{Name: new("subnet")}, + &Network{Name: new("network")}, + &SecurityGroup{Name: new("security-group")}, } actualSorted := sortedTasks(actual) @@ -176,9 +176,9 @@ func Test_NewPortTaskFromCloud(t *testing.T) { foundPort: nil, modifiedFoundPort: nil, expectedPortTask: &Port{ - ID: fi.PtrTo(""), - Name: fi.PtrTo(""), - Network: &Network{ID: fi.PtrTo("")}, + ID: new(""), + Name: new(""), + Network: &Network{ID: new("")}, SecurityGroups: []*SecurityGroup{}, Subnets: []*Subnet{}, Lifecycle: fi.LifecycleSync, @@ -191,11 +191,11 @@ func Test_NewPortTaskFromCloud(t *testing.T) { cloud: &portCloud{}, cloudPort: &ports.Port{}, foundPort: &Port{}, - modifiedFoundPort: &Port{ID: fi.PtrTo("")}, + modifiedFoundPort: &Port{ID: new("")}, expectedPortTask: &Port{ - ID: fi.PtrTo(""), - Name: fi.PtrTo(""), - Network: &Network{ID: fi.PtrTo("")}, + ID: new(""), + Name: new(""), + Network: &Network{ID: new("")}, SecurityGroups: []*SecurityGroup{}, Subnets: []*Subnet{}, Lifecycle: fi.LifecycleSync, @@ -220,18 +220,18 @@ func Test_NewPortTaskFromCloud(t *testing.T) { }, }, foundPort: &Port{}, - modifiedFoundPort: &Port{ID: fi.PtrTo("id")}, + modifiedFoundPort: &Port{ID: new("id")}, expectedPortTask: &Port{ - ID: fi.PtrTo("id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("sg-2"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-1"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-2"), Lifecycle: fi.LifecycleSync}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("subnet-b"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-a"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-b"), Lifecycle: fi.LifecycleSync}, }, Lifecycle: fi.LifecycleSync, }, @@ -269,17 +269,17 @@ func Test_NewPortTaskFromCloud(t *testing.T) { foundPort: nil, modifiedFoundPort: nil, expectedPortTask: &Port{ - ID: fi.PtrTo("id"), + ID: new("id"), Lifecycle: fi.LifecycleSync, - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("sg-2"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-1"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-2"), Lifecycle: fi.LifecycleSync}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("subnet-b"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-a"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-b"), Lifecycle: fi.LifecycleSync}, }, Tags: []string{ "cluster", @@ -326,7 +326,7 @@ func Test_NewPortTaskFromCloud(t *testing.T) { }, }, foundPort: &Port{ - InstanceGroupName: fi.PtrTo("node-ig"), + InstanceGroupName: new("node-ig"), Tags: []string{ "KopsInstanceGroup=node-ig", }, @@ -341,8 +341,8 @@ func Test_NewPortTaskFromCloud(t *testing.T) { }, }, modifiedFoundPort: &Port{ - ID: fi.PtrTo("id"), - InstanceGroupName: fi.PtrTo("node-ig"), + ID: new("id"), + InstanceGroupName: new("node-ig"), Tags: []string{ "KopsInstanceGroup=node-ig", }, @@ -357,18 +357,18 @@ func Test_NewPortTaskFromCloud(t *testing.T) { }, }, expectedPortTask: &Port{ - ID: fi.PtrTo("id"), - InstanceGroupName: fi.PtrTo("node-ig"), + ID: new("id"), + InstanceGroupName: new("node-ig"), Lifecycle: fi.LifecycleSync, - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("sg-2"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-1"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-2"), Lifecycle: fi.LifecycleSync}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("subnet-b"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-a"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-b"), Lifecycle: fi.LifecycleSync}, }, Tags: []string{ "KopsInstanceGroup=node-ig", @@ -418,18 +418,18 @@ func Test_NewPortTaskFromCloud(t *testing.T) { foundPort: nil, modifiedFoundPort: nil, expectedPortTask: &Port{ - ID: fi.PtrTo("id"), - InstanceGroupName: fi.PtrTo("node-ig"), + ID: new("id"), + InstanceGroupName: new("node-ig"), Lifecycle: fi.LifecycleSync, - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("sg-2"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-1"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-2"), Lifecycle: fi.LifecycleSync}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("subnet-b"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-a"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-b"), Lifecycle: fi.LifecycleSync}, }, Tags: []string{ "cluster", @@ -482,27 +482,27 @@ func Test_NewPortTaskFromCloud(t *testing.T) { }, }, modifiedFoundPort: &Port{ - ID: fi.PtrTo("id"), + ID: new("id"), AdditionalSecurityGroups: []string{ "add-1", "add-2", }, }, expectedPortTask: &Port{ - ID: fi.PtrTo("id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("sg-2"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-1"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-2"), Lifecycle: fi.LifecycleSync}, }, AdditionalSecurityGroups: []string{ "add-1", "add-2", }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("subnet-b"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-a"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-b"), Lifecycle: fi.LifecycleSync}, }, Lifecycle: fi.LifecycleSync, }, @@ -548,7 +548,7 @@ func Test_NewPortTaskFromCloud(t *testing.T) { }, }, modifiedFoundPort: &Port{ - ID: fi.PtrTo("id"), + ID: new("id"), AllowedAddressPairs: []ports.AddressPair{ { IPAddress: "10.0.0.1", @@ -560,14 +560,14 @@ func Test_NewPortTaskFromCloud(t *testing.T) { }, }, expectedPortTask: &Port{ - ID: fi.PtrTo("id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-1"), Lifecycle: fi.LifecycleSync}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-a"), Lifecycle: fi.LifecycleSync}, }, AllowedAddressPairs: []ports.AddressPair{ { @@ -625,7 +625,7 @@ func Test_Port_Find(t *testing.T) { }, }, port: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Lifecycle: fi.LifecycleSync, }, expectedPortTask: nil, @@ -661,20 +661,20 @@ func Test_Port_Find(t *testing.T) { }, }, port: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Lifecycle: fi.LifecycleSync, }, expectedPortTask: &Port{ - ID: fi.PtrTo("id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("sg-2"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-1"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-2"), Lifecycle: fi.LifecycleSync}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("subnet-b"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-a"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-b"), Lifecycle: fi.LifecycleSync}, }, Lifecycle: fi.LifecycleSync, }, @@ -710,21 +710,21 @@ func Test_Port_Find(t *testing.T) { }, }, port: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Lifecycle: fi.LifecycleSync, Tags: []string{"clusterName"}, }, expectedPortTask: &Port{ - ID: fi.PtrTo("id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("sg-2"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-1"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-2"), Lifecycle: fi.LifecycleSync}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("subnet-b"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-a"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-b"), Lifecycle: fi.LifecycleSync}, }, Lifecycle: fi.LifecycleSync, Tags: []string{"clusterName"}, @@ -757,7 +757,7 @@ func Test_Port_Find(t *testing.T) { }, }, port: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Lifecycle: fi.LifecycleSync, }, expectedPortTask: nil, @@ -784,7 +784,7 @@ func Test_Port_Find(t *testing.T) { }, }, port: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Lifecycle: fi.LifecycleSync, }, expectedPortTask: nil, @@ -829,7 +829,7 @@ func Test_Port_Find(t *testing.T) { }, }, port: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Lifecycle: fi.LifecycleSync, Tags: []string{"clusterName"}, AllowedAddressPairs: []ports.AddressPair{ @@ -843,16 +843,16 @@ func Test_Port_Find(t *testing.T) { }, }, expectedPortTask: &Port{ - ID: fi.PtrTo("id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("sg-2"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-1"), Lifecycle: fi.LifecycleSync}, + {ID: new("sg-2"), Lifecycle: fi.LifecycleSync}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a"), Lifecycle: fi.LifecycleSync}, - {ID: fi.PtrTo("subnet-b"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-a"), Lifecycle: fi.LifecycleSync}, + {ID: new("subnet-b"), Lifecycle: fi.LifecycleSync}, }, Lifecycle: fi.LifecycleSync, Tags: []string{"clusterName"}, @@ -895,8 +895,8 @@ func Test_Port_CheckChanges(t *testing.T) { desc: "actual nil all required fields set", actual: nil, expected: &Port{ - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + Name: new("name"), + Network: &Network{ID: new("networkID")}, }, expectedError: nil, }, @@ -905,7 +905,7 @@ func Test_Port_CheckChanges(t *testing.T) { actual: nil, expected: &Port{ Name: nil, - Network: &Network{ID: fi.PtrTo("networkID")}, + Network: &Network{ID: new("networkID")}, }, expectedError: fi.RequiredField("Name"), }, @@ -913,7 +913,7 @@ func Test_Port_CheckChanges(t *testing.T) { desc: "actual nil required field Network nil", actual: nil, expected: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Network: nil, }, expectedError: fi.RequiredField("Network"), @@ -921,11 +921,11 @@ func Test_Port_CheckChanges(t *testing.T) { { desc: "actual not nil all changeable fields set", actual: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Network: nil, }, expected: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Network: nil, }, changes: &Port{ @@ -937,31 +937,31 @@ func Test_Port_CheckChanges(t *testing.T) { { desc: "actual not nil all changeable fields set", actual: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Network: nil, }, expected: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Network: nil, }, changes: &Port{ Name: nil, - Network: &Network{ID: fi.PtrTo("networkID")}, + Network: &Network{ID: new("networkID")}, }, expectedError: fi.CannotChangeField("Network"), }, { desc: "actual not nil unchangeable field Name set", actual: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Network: nil, }, expected: &Port{ - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + Name: new("name"), + Network: &Network{ID: new("networkID")}, }, changes: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Network: nil, }, expectedError: fi.CannotChangeField("Name"), @@ -969,16 +969,16 @@ func Test_Port_CheckChanges(t *testing.T) { { desc: "actual not nil unchangeable field Network set", actual: &Port{ - Name: fi.PtrTo("name"), + Name: new("name"), Network: nil, }, expected: &Port{ Name: nil, - Network: &Network{ID: fi.PtrTo("networkID")}, + Network: &Network{ID: new("networkID")}, }, changes: &Port{ Name: nil, - Network: &Network{ID: fi.PtrTo("networkID")}, + Network: &Network{ID: new("networkID")}, }, expectedError: fi.CannotChangeField("Network"), }, @@ -1008,19 +1008,19 @@ func Test_Port_RenderOpenstack(t *testing.T) { { desc: "actual not nil", actual: &Port{ - ID: fi.PtrTo("actual-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("actual-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, }, expected: &Port{ - ID: fi.PtrTo("expected-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("expected-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, }, expectedAfter: &Port{ - ID: fi.PtrTo("actual-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("actual-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, }, expectedCloudPort: nil, expectedError: nil, @@ -1046,29 +1046,29 @@ func Test_Port_RenderOpenstack(t *testing.T) { }, actual: nil, expected: &Port{ - ID: fi.PtrTo("expected-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("expected-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1")}, - {ID: fi.PtrTo("sg-2")}, + {ID: new("sg-1")}, + {ID: new("sg-2")}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a")}, - {ID: fi.PtrTo("subnet-b")}, + {ID: new("subnet-a")}, + {ID: new("subnet-b")}, }, }, expectedAfter: &Port{ - ID: fi.PtrTo("cloud-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("cloud-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1")}, - {ID: fi.PtrTo("sg-2")}, + {ID: new("sg-1")}, + {ID: new("sg-2")}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a")}, - {ID: fi.PtrTo("subnet-b")}, + {ID: new("subnet-a")}, + {ID: new("subnet-b")}, }, }, expectedCloudPort: &ports.Port{ @@ -1095,14 +1095,14 @@ func Test_Port_RenderOpenstack(t *testing.T) { }, actual: nil, expected: &Port{ - ID: fi.PtrTo("expected-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("expected-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, }, expectedAfter: &Port{ - ID: fi.PtrTo("expected-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("expected-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, }, expectedCloudPort: nil, expectedError: fmt.Errorf("Error creating port: port create error"), @@ -1134,14 +1134,14 @@ func Test_Port_RenderOpenstack(t *testing.T) { }, }, actual: &Port{ - ID: fi.PtrTo("cloud-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("cloud-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1")}, + {ID: new("sg-1")}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a")}, + {ID: new("subnet-a")}, }, AllowedAddressPairs: []ports.AddressPair{ { @@ -1150,14 +1150,14 @@ func Test_Port_RenderOpenstack(t *testing.T) { }, }, expected: &Port{ - ID: fi.PtrTo("expected-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("expected-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1")}, + {ID: new("sg-1")}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a")}, + {ID: new("subnet-a")}, }, AllowedAddressPairs: []ports.AddressPair{ { @@ -1178,14 +1178,14 @@ func Test_Port_RenderOpenstack(t *testing.T) { }, }, expectedAfter: &Port{ - ID: fi.PtrTo("cloud-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("cloud-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1")}, + {ID: new("sg-1")}, }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a")}, + {ID: new("subnet-a")}, }, AllowedAddressPairs: []ports.AddressPair{ { @@ -1241,20 +1241,20 @@ func Test_Port_createOptsFromPortTask(t *testing.T) { }, }, expected: &Port{ - ID: fi.PtrTo("expected-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("expected-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1")}, - {ID: fi.PtrTo("sg-2")}, + {ID: new("sg-1")}, + {ID: new("sg-2")}, }, AdditionalSecurityGroups: []string{ "add-1", "add-2", }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a")}, - {ID: fi.PtrTo("subnet-b")}, + {ID: new("subnet-a")}, + {ID: new("subnet-b")}, }, AllowedAddressPairs: []ports.AddressPair{ { @@ -1302,19 +1302,19 @@ func Test_Port_createOptsFromPortTask(t *testing.T) { }, }, expected: &Port{ - ID: fi.PtrTo("expected-id"), - Name: fi.PtrTo("name"), - Network: &Network{ID: fi.PtrTo("networkID")}, + ID: new("expected-id"), + Name: new("name"), + Network: &Network{ID: new("networkID")}, SecurityGroups: []*SecurityGroup{ - {ID: fi.PtrTo("sg-1")}, - {ID: fi.PtrTo("sg-2")}, + {ID: new("sg-1")}, + {ID: new("sg-2")}, }, AdditionalSecurityGroups: []string{ "add-2", }, Subnets: []*Subnet{ - {ID: fi.PtrTo("subnet-a")}, - {ID: fi.PtrTo("subnet-b")}, + {ID: new("subnet-a")}, + {ID: new("subnet-b")}, }, }, expectedError: fmt.Errorf("Additional SecurityGroup not found for name add-2"), diff --git a/upup/pkg/fi/cloudup/openstacktasks/router.go b/upup/pkg/fi/cloudup/openstacktasks/router.go index 9ccf4754f49ed..4af5da89957cd 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/router.go +++ b/upup/pkg/fi/cloudup/openstacktasks/router.go @@ -42,8 +42,8 @@ func (n *Router) CompareWithID() *string { // NewRouterTaskFromCloud initializes and returns a new Router func NewRouterTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecycle, router *routers.Router, find *Router) (*Router, error) { actual := &Router{ - ID: fi.PtrTo(router.ID), - Name: fi.PtrTo(router.Name), + ID: new(router.ID), + Name: new(router.Name), Lifecycle: lifecycle, AvailabilityZoneHints: fi.StringSlice(router.AvailabilityZoneHints), } @@ -97,7 +97,7 @@ func (_ *Router) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes opt := routers.CreateOpts{ Name: fi.ValueOf(e.Name), - AdminStateUp: fi.PtrTo(true), + AdminStateUp: new(true), AvailabilityZoneHints: fi.StringSliceValue(e.AvailabilityZoneHints), } floatingNet, err := t.Cloud.GetExternalNetwork() @@ -125,7 +125,7 @@ func (_ *Router) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes if err != nil { return fmt.Errorf("Error creating router: %v", err) } - e.ID = fi.PtrTo(v.ID) + e.ID = new(v.ID) klog.V(2).Infof("Creating a new Openstack router, id=%s", v.ID) return nil } diff --git a/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go b/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go index 398fab6661a0d..b448dcc174f5b 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go +++ b/upup/pkg/fi/cloudup/openstacktasks/routerinterface.go @@ -80,7 +80,7 @@ func (i *RouterInterface) Find(context *fi.CloudupContext) (*RouterInterface, er return nil, fmt.Errorf("found multiple interfaces which subnet:%s attach to", subnetID) } actual = &RouterInterface{ - ID: fi.PtrTo(p.ID), + ID: new(p.ID), Name: i.Name, Router: i.Router, Subnet: i.Subnet, @@ -131,7 +131,7 @@ func (_ *RouterInterface) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, return fmt.Errorf("Error creating router interface: %v", err) } - e.ID = fi.PtrTo(v.PortID) + e.ID = new(v.PortID) klog.V(2).Infof("Creating a new Openstack router interface, id=%s", v.PortID) return nil } diff --git a/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go b/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go index e468ca3cfd6db..9cacb35185d55 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go +++ b/upup/pkg/fi/cloudup/openstacktasks/securitygroup.go @@ -78,9 +78,9 @@ func getSecurityGroupByName(s *SecurityGroup, cloud openstack.OpenstackCloud) (* } g := gs[0] actual := &SecurityGroup{ - ID: fi.PtrTo(g.ID), - Name: fi.PtrTo(g.Name), - Description: fi.PtrTo(g.Description), + ID: new(g.ID), + Name: new(g.Name), + Description: new(g.Description), Lifecycle: s.Lifecycle, } actual.RemoveExtraRules = s.RemoveExtraRules @@ -123,7 +123,7 @@ func (_ *SecurityGroup) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, c return fmt.Errorf("error creating SecurityGroup: %v", err) } - e.ID = fi.PtrTo(g.ID) + e.ID = new(g.ID) return nil } diff --git a/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go b/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go index 31877f262f6b1..e8e4a8cda06bb 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go +++ b/upup/pkg/fi/cloudup/openstacktasks/securitygrouprule.go @@ -100,17 +100,17 @@ func (r *SecurityGroupRule) Find(context *fi.CloudupContext) (*SecurityGroupRule } rule := rs[0] actual := &SecurityGroupRule{ - ID: fi.PtrTo(rule.ID), - Direction: fi.PtrTo(rule.Direction), - EtherType: fi.PtrTo(rule.EtherType), + ID: new(rule.ID), + Direction: new(rule.Direction), + EtherType: new(rule.EtherType), PortRangeMax: Int(rule.PortRangeMax), PortRangeMin: Int(rule.PortRangeMin), - Protocol: fi.PtrTo(rule.Protocol), - RemoteIPPrefix: fi.PtrTo(rule.RemoteIPPrefix), + Protocol: new(rule.Protocol), + RemoteIPPrefix: new(rule.RemoteIPPrefix), RemoteGroup: r.RemoteGroup, SecGroup: r.SecGroup, Lifecycle: r.Lifecycle, - Delete: fi.PtrTo(false), + Delete: new(false), } r.ID = actual.ID @@ -178,7 +178,7 @@ func (*SecurityGroupRule) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, return fmt.Errorf("error creating SecurityGroupRule in SG %s: %v", fi.ValueOf(e.SecGroup.GetName()), err) } - e.ID = fi.PtrTo(r.ID) + e.ID = new(r.ID) return nil } diff --git a/upup/pkg/fi/cloudup/openstacktasks/servergroup.go b/upup/pkg/fi/cloudup/openstacktasks/servergroup.go index 742ec4bde903b..d6a81cd31e557 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/servergroup.go +++ b/upup/pkg/fi/cloudup/openstacktasks/servergroup.go @@ -88,16 +88,16 @@ func (s *ServerGroup) Find(context *fi.CloudupContext) (*ServerGroup, error) { val, ok := igMap[igName] if !ok { - igMap[igName] = fi.PtrTo(int32(1)) + igMap[igName] = new(int32(1)) } else { - igMap[igName] = fi.PtrTo(fi.ValueOf(val) + 1) + igMap[igName] = new(fi.ValueOf(val) + 1) } } actual = &ServerGroup{ - Name: fi.PtrTo(serverGroup.Name), + Name: new(serverGroup.Name), ClusterName: s.ClusterName, IGMap: igMap, - ID: fi.PtrTo(serverGroup.ID), + ID: new(serverGroup.ID), Lifecycle: s.Lifecycle, Policies: serverGroup.Policies, } @@ -153,7 +153,7 @@ func (_ *ServerGroup) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, cha if err != nil { return fmt.Errorf("error creating ServerGroup: %v", err) } - e.ID = fi.PtrTo(g.ID) + e.ID = new(g.ID) return nil } else if changes.IGMap != nil { for igName, maxSize := range changes.IGMap { diff --git a/upup/pkg/fi/cloudup/openstacktasks/sshkey.go b/upup/pkg/fi/cloudup/openstacktasks/sshkey.go index ab92de675e59a..1271e09a9f60a 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/sshkey.go +++ b/upup/pkg/fi/cloudup/openstacktasks/sshkey.go @@ -56,7 +56,7 @@ func (e *SSHKey) Find(c *fi.CloudupContext) (*SSHKey, error) { } actual := &SSHKey{ Name: e.Name, - KeyFingerprint: fi.PtrTo(rs.Fingerprint), + KeyFingerprint: new(rs.Fingerprint), } // Avoid spurious changes @@ -134,7 +134,7 @@ func (_ *SSHKey) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes return fmt.Errorf("Error creating keypair: %v", err) } - e.KeyFingerprint = fi.PtrTo(v.Fingerprint) + e.KeyFingerprint = new(v.Fingerprint) klog.V(2).Infof("Creating a new Openstack keypair, id=%s", v.Fingerprint) return nil } diff --git a/upup/pkg/fi/cloudup/openstacktasks/subnet.go b/upup/pkg/fi/cloudup/openstacktasks/subnet.go index 5c4fe38c60738..2415014705259 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/subnet.go +++ b/upup/pkg/fi/cloudup/openstacktasks/subnet.go @@ -67,7 +67,7 @@ func NewSubnetTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecyc nameservers := make([]*string, len(subnet.DNSNameservers)) for i, ns := range subnet.DNSNameservers { - nameservers[i] = fi.PtrTo(ns) + nameservers[i] = new(ns) } tag := "" @@ -76,13 +76,13 @@ func NewSubnetTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle fi.Lifecyc } actual := &Subnet{ - ID: fi.PtrTo(subnet.ID), - Name: fi.PtrTo(subnet.Name), + ID: new(subnet.ID), + Name: new(subnet.Name), Network: networkTask, - CIDR: fi.PtrTo(subnet.CIDR), + CIDR: new(subnet.CIDR), Lifecycle: lifecycle, DNSServers: nameservers, - Tag: fi.PtrTo(tag), + Tag: new(tag), } if find != nil { find.ID = actual.ID @@ -97,7 +97,7 @@ func (s *Subnet) Find(context *fi.CloudupContext) (*Subnet, error) { Name: fi.ValueOf(s.Name), NetworkID: fi.ValueOf(s.Network.ID), CIDR: fi.ValueOf(s.CIDR), - EnableDHCP: fi.PtrTo(true), + EnableDHCP: new(true), IPVersion: 4, } rs, err := cloud.ListSubnets(opt) @@ -150,7 +150,7 @@ func (*Subnet) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *S NetworkID: fi.ValueOf(e.Network.ID), IPVersion: gophercloud.IPv4, CIDR: fi.ValueOf(e.CIDR), - EnableDHCP: fi.PtrTo(true), + EnableDHCP: new(true), } if len(e.DNSServers) > 0 { @@ -170,7 +170,7 @@ func (*Subnet) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *S return fmt.Errorf("Error appending tag to subnet: %v", err) } - e.ID = fi.PtrTo(v.ID) + e.ID = new(v.ID) klog.V(2).Infof("Creating a new Openstack subnet, id=%s", v.ID) return nil } else { diff --git a/upup/pkg/fi/cloudup/openstacktasks/volume.go b/upup/pkg/fi/cloudup/openstacktasks/volume.go index 9863c9dc7b237..5810d54d1f7ef 100644 --- a/upup/pkg/fi/cloudup/openstacktasks/volume.go +++ b/upup/pkg/fi/cloudup/openstacktasks/volume.go @@ -60,11 +60,11 @@ func (c *Volume) Find(context *fi.CloudupContext) (*Volume, error) { } v := volumes[0] actual := &Volume{ - ID: fi.PtrTo(v.ID), - Name: fi.PtrTo(v.Name), - AvailabilityZone: fi.PtrTo(v.AvailabilityZone), - VolumeType: fi.PtrTo(v.VolumeType), - SizeGB: fi.PtrTo(int64(v.Size)), + ID: new(v.ID), + Name: new(v.Name), + AvailabilityZone: new(v.AvailabilityZone), + VolumeType: new(v.VolumeType), + SizeGB: new(int64(v.Size)), Tags: v.Metadata, Lifecycle: c.Lifecycle, } @@ -142,8 +142,8 @@ func (_ *Volume) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes return fmt.Errorf("error creating PersistentVolume: %v", err) } - e.ID = fi.PtrTo(v.ID) - e.AvailabilityZone = fi.PtrTo(v.AvailabilityZone) + e.ID = new(v.ID) + e.AvailabilityZone = new(v.AvailabilityZone) return nil } diff --git a/upup/pkg/fi/cloudup/populate_cluster_spec_test.go b/upup/pkg/fi/cloudup/populate_cluster_spec_test.go index 520126654ba4b..87c0d985add97 100644 --- a/upup/pkg/fi/cloudup/populate_cluster_spec_test.go +++ b/upup/pkg/fi/cloudup/populate_cluster_spec_test.go @@ -92,7 +92,7 @@ func TestPopulateCluster_Subnets(t *testing.T) { c.Spec.Networking.CNI = &kopsapi.CNINetworkingSpec{} c.Spec.ExternalCloudControllerManager = &kopsapi.CloudControllerManagerConfig{} c.Spec.CloudProvider.AWS.EBSCSIDriver = &kopsapi.EBSCSIDriverSpec{ - Enabled: fi.PtrTo(true), + Enabled: new(true), } err := PerformAssignments(c, vfs.Context, cloud) @@ -148,7 +148,7 @@ func TestPopulateCluster_EvictionHard(t *testing.T) { } c.Spec.Kubelet = &kopsapi.KubeletConfigSpec{ - EvictionHard: fi.PtrTo("memory.available<250Mi"), + EvictionHard: new("memory.available<250Mi"), } full, err := mockedPopulateClusterSpec(ctx, c, cloud) @@ -208,7 +208,7 @@ func TestPopulateCluster_Custom_CIDR(t *testing.T) { func TestPopulateCluster_IsolateMasters(t *testing.T) { ctx := context.TODO() cloud, c := buildMinimalCluster() - c.Spec.Networking.IsolateControlPlane = fi.PtrTo(true) + c.Spec.Networking.IsolateControlPlane = new(true) err := PerformAssignments(c, vfs.Context, cloud) if err != nil { @@ -230,7 +230,7 @@ func TestPopulateCluster_IsolateMasters(t *testing.T) { func TestPopulateCluster_IsolateMastersFalse(t *testing.T) { ctx := context.TODO() cloud, c := buildMinimalCluster() - // default: c.Spec.IsolateControlPlane = fi.PtrTo(false) + // default: c.Spec.IsolateControlPlane = new(false) err := PerformAssignments(c, vfs.Context, cloud) if err != nil { diff --git a/upup/pkg/fi/cloudup/populate_instancegroup_spec.go b/upup/pkg/fi/cloudup/populate_instancegroup_spec.go index d7941a3e7370a..77d855783e6e2 100644 --- a/upup/pkg/fi/cloudup/populate_instancegroup_spec.go +++ b/upup/pkg/fi/cloudup/populate_instancegroup_spec.go @@ -102,10 +102,10 @@ func PopulateInstanceGroupSpec(cluster *kops.Cluster, input *kops.InstanceGroup, } if ig.Spec.MinSize == nil { - ig.Spec.MinSize = fi.PtrTo(int32(1)) + ig.Spec.MinSize = new(int32(1)) } if ig.Spec.MaxSize == nil { - ig.Spec.MaxSize = fi.PtrTo(int32(1)) + ig.Spec.MaxSize = new(int32(1)) } } else if ig.Spec.Role.HasBastion() { if ig.Spec.MachineType == "" { @@ -115,10 +115,10 @@ func PopulateInstanceGroupSpec(cluster *kops.Cluster, input *kops.InstanceGroup, } } if ig.Spec.MinSize == nil { - ig.Spec.MinSize = fi.PtrTo(int32(1)) + ig.Spec.MinSize = new(int32(1)) } if ig.Spec.MaxSize == nil { - ig.Spec.MaxSize = fi.PtrTo(int32(1)) + ig.Spec.MaxSize = new(int32(1)) } } else { if ig.IsAPIServerOnly() && !featureflag.APIServerNodes.Enabled() { @@ -144,10 +144,10 @@ func PopulateInstanceGroupSpec(cluster *kops.Cluster, input *kops.InstanceGroup, } if ig.Spec.Manager != kops.InstanceManagerKarpenter { if ig.Spec.MinSize == nil { - ig.Spec.MinSize = fi.PtrTo(int32(2)) + ig.Spec.MinSize = new(int32(2)) } if ig.Spec.MaxSize == nil { - ig.Spec.MaxSize = fi.PtrTo(int32(2)) + ig.Spec.MaxSize = new(int32(2)) } } } @@ -269,7 +269,7 @@ func PopulateInstanceGroupSpec(cluster *kops.Cluster, input *kops.InstanceGroup, } // A few settings in Kubelet override those in ControlPlaneKubelet. I'm not sure why. if cluster.Spec.Kubelet != nil && cluster.Spec.Kubelet.AnonymousAuth != nil && !*cluster.Spec.Kubelet.AnonymousAuth { - igKubeletConfig.AnonymousAuth = fi.PtrTo(false) + igKubeletConfig.AnonymousAuth = new(false) } } else { if cluster.Spec.Kubelet != nil { @@ -321,7 +321,7 @@ func PopulateInstanceGroupSpec(cluster *kops.Cluster, input *kops.InstanceGroup, igKubeletConfig.Taints = taints.List() if useSecureKubelet { - igKubeletConfig.AnonymousAuth = fi.PtrTo(false) + igKubeletConfig.AnonymousAuth = new(false) } ig.Spec.Kubelet = igKubeletConfig diff --git a/upup/pkg/fi/cloudup/populate_instancegroup_spec_test.go b/upup/pkg/fi/cloudup/populate_instancegroup_spec_test.go index 68e70d4c99b41..c66a221a15421 100644 --- a/upup/pkg/fi/cloudup/populate_instancegroup_spec_test.go +++ b/upup/pkg/fi/cloudup/populate_instancegroup_spec_test.go @@ -30,8 +30,8 @@ func buildMinimalNodeInstanceGroup(subnets ...string) *kopsapi.InstanceGroup { g := &kopsapi.InstanceGroup{} g.ObjectMeta.Name = "nodes" g.Spec.Role = kopsapi.InstanceGroupRoleNode - g.Spec.MinSize = fi.PtrTo(int32(1)) - g.Spec.MaxSize = fi.PtrTo(int32(1)) + g.Spec.MinSize = new(int32(1)) + g.Spec.MaxSize = new(int32(1)) g.Spec.Image = "my-image" g.Spec.Subnets = subnets @@ -42,8 +42,8 @@ func buildMinimalMasterInstanceGroup(subnet string) *kopsapi.InstanceGroup { g := &kopsapi.InstanceGroup{} g.ObjectMeta.Name = "master-" + subnet g.Spec.Role = kopsapi.InstanceGroupRoleControlPlane - g.Spec.MinSize = fi.PtrTo(int32(1)) - g.Spec.MaxSize = fi.PtrTo(int32(1)) + g.Spec.MinSize = new(int32(1)) + g.Spec.MaxSize = new(int32(1)) g.Spec.Image = "my-image" g.Spec.Subnets = []string{subnet} @@ -91,7 +91,7 @@ func TestPopulateInstanceGroup_AddTaintsCollision(t *testing.T) { input := buildMinimalNodeInstanceGroup() input.Spec.Taints = []string{"nvidia.com/gpu:NoSchedule"} input.Spec.MachineType = "g4dn.xlarge" - cluster.Spec.Containerd.NvidiaGPU = &kopsapi.NvidiaGPUConfig{Enabled: fi.PtrTo(true)} + cluster.Spec.Containerd.NvidiaGPU = &kopsapi.NvidiaGPUConfig{Enabled: new(true)} channel := &kopsapi.Channel{} @@ -140,11 +140,11 @@ func TestPopulateInstanceGroup_AddTaintsCollision3(t *testing.T) { func TestPopulateInstanceGroup_EvictionHard(t *testing.T) { _, cluster := buildMinimalCluster() cluster.Spec.Kubelet = &kopsapi.KubeletConfigSpec{ - EvictionHard: fi.PtrTo("memory.available<350Mi"), + EvictionHard: new("memory.available<350Mi"), } input := buildMinimalNodeInstanceGroup() input.Spec.Kubelet = &kopsapi.KubeletConfigSpec{ - EvictionHard: fi.PtrTo("memory.available<250Mi"), + EvictionHard: new("memory.available<250Mi"), } channel := &kopsapi.Channel{} @@ -165,7 +165,7 @@ func TestPopulateInstanceGroup_EvictionHard(t *testing.T) { func TestPopulateInstanceGroup_EvictionHard3(t *testing.T) { _, cluster := buildMinimalCluster() cluster.Spec.Kubelet = &kopsapi.KubeletConfigSpec{ - EvictionHard: fi.PtrTo("memory.available<350Mi"), + EvictionHard: new("memory.available<350Mi"), } input := buildMinimalMasterInstanceGroup("us-test-1") @@ -188,7 +188,7 @@ func TestPopulateInstanceGroup_EvictionHard3(t *testing.T) { func TestPopulateInstanceGroup_EvictionHard4(t *testing.T) { _, cluster := buildMinimalCluster() cluster.Spec.ControlPlaneKubelet = &kopsapi.KubeletConfigSpec{ - EvictionHard: fi.PtrTo("memory.available<350Mi"), + EvictionHard: new("memory.available<350Mi"), } input := buildMinimalMasterInstanceGroup("us-test-1") @@ -211,7 +211,7 @@ func TestPopulateInstanceGroup_EvictionHard2(t *testing.T) { _, cluster := buildMinimalCluster() input := buildMinimalNodeInstanceGroup() input.Spec.Kubelet = &kopsapi.KubeletConfigSpec{ - EvictionHard: fi.PtrTo("memory.available<250Mi"), + EvictionHard: new("memory.available<250Mi"), } channel := &kopsapi.Channel{} @@ -233,7 +233,7 @@ func TestPopulateInstanceGroup_AddTaints(t *testing.T) { _, cluster := buildMinimalCluster() input := buildMinimalNodeInstanceGroup() input.Spec.MachineType = "g4dn.xlarge" - cluster.Spec.Containerd.NvidiaGPU = &kopsapi.NvidiaGPUConfig{Enabled: fi.PtrTo(true)} + cluster.Spec.Containerd.NvidiaGPU = &kopsapi.NvidiaGPUConfig{Enabled: new(true)} channel := &kopsapi.Channel{} @@ -268,14 +268,14 @@ func TestPopulateInstanceGroup_GVisorLabelsWorkersOnly(t *testing.T) { { name: "cluster config ignored on worker", ig: buildMinimalNodeInstanceGroup(), - cluster: &kopsapi.GVisorConfig{Enabled: fi.PtrTo(true)}, + cluster: &kopsapi.GVisorConfig{Enabled: new(true)}, }, { name: "worker instance group", ig: func() *kopsapi.InstanceGroup { ig := buildMinimalNodeInstanceGroup() ig.Spec.Containerd = &kopsapi.ContainerdConfig{ - GVisor: &kopsapi.GVisorConfig{Enabled: fi.PtrTo(true)}, + GVisor: &kopsapi.GVisorConfig{Enabled: new(true)}, } return ig }(), diff --git a/upup/pkg/fi/cloudup/scaleway/cloud.go b/upup/pkg/fi/cloudup/scaleway/cloud.go index ee21573d8b3bf..d1fc8834163e0 100644 --- a/upup/pkg/fi/cloudup/scaleway/cloud.go +++ b/upup/pkg/fi/cloudup/scaleway/cloud.go @@ -503,9 +503,9 @@ func (s *scwCloudImplementation) GetServerIP(serverID string, zone scw.Zone) (st ips, err := s.ipamAPI.ListIPs(&ipam.ListIPsRequest{ Region: region, - IsIPv6: fi.PtrTo(false), + IsIPv6: new(false), ResourceID: &serverID, - Zonal: fi.PtrTo(zone.String()), + Zonal: new(zone.String()), }, scw.WithAllPages()) if err != nil { return "", fmt.Errorf("listing IPs for server %s: %w", serverID, err) diff --git a/upup/pkg/fi/cloudup/scaleway/verifier.go b/upup/pkg/fi/cloudup/scaleway/verifier.go index dbee5fd556c9e..6fae2922bfc2c 100644 --- a/upup/pkg/fi/cloudup/scaleway/verifier.go +++ b/upup/pkg/fi/cloudup/scaleway/verifier.go @@ -30,7 +30,6 @@ import ( kopsv "k8s.io/kops" "k8s.io/kops/pkg/bootstrap" "k8s.io/kops/pkg/wellknownports" - "k8s.io/kops/upup/pkg/fi" ) type ScalewayVerifierOptions struct{} @@ -101,9 +100,9 @@ func (v scalewayVerifier) VerifyToken(ctx context.Context, rawRequest *http.Requ ips, err := ipam.NewAPI(scwClient).ListIPs(&ipam.ListIPsRequest{ Region: region, - ResourceID: fi.PtrTo(server.ID), - IsIPv6: fi.PtrTo(false), - Zonal: fi.PtrTo(zone.String()), + ResourceID: new(server.ID), + IsIPv6: new(false), + Zonal: new(zone.String()), }, scw.WithContext(ctx), scw.WithAllPages()) if err != nil { return nil, fmt.Errorf("failed to get IP for server %q: %w", server.Name, err) diff --git a/upup/pkg/fi/cloudup/scalewaytasks/dns_record.go b/upup/pkg/fi/cloudup/scalewaytasks/dns_record.go index 1d7a69170bd0c..33ec3fbd8721f 100644 --- a/upup/pkg/fi/cloudup/scalewaytasks/dns_record.go +++ b/upup/pkg/fi/cloudup/scalewaytasks/dns_record.go @@ -66,12 +66,12 @@ func (d *DNSRecord) Find(context *fi.CloudupContext) (*DNSRecord, error) { recordFound := records.Records[0] return &DNSRecord{ - ID: fi.PtrTo(recordFound.ID), - Name: fi.PtrTo(recordFound.Name), - Data: fi.PtrTo(recordFound.Data), - TTL: fi.PtrTo(recordFound.TTL), + ID: new(recordFound.ID), + Name: new(recordFound.Name), + Data: new(recordFound.Data), + TTL: new(recordFound.TTL), DNSZone: d.DNSZone, - Type: fi.PtrTo(recordFound.Type.String()), + Type: new(recordFound.Type.String()), Lifecycle: d.Lifecycle, }, nil } @@ -177,7 +177,7 @@ func (_ *DNSRecord) RenderTerraform(t *terraform.TerraformTarget, actual, expect Data: expected.Data, DNSZone: expected.DNSZone, Type: expected.Type, - TTL: fi.PtrTo(int32(fi.ValueOf(expected.TTL))), + TTL: new(int32(fi.ValueOf(expected.TTL))), Lifecycle: &terraform.Lifecycle{ IgnoreChanges: []*terraformWriter.Literal{{String: "data"}}, }, diff --git a/upup/pkg/fi/cloudup/scalewaytasks/instance.go b/upup/pkg/fi/cloudup/scalewaytasks/instance.go index ce940a13e58df..bd3bd070610a1 100644 --- a/upup/pkg/fi/cloudup/scalewaytasks/instance.go +++ b/upup/pkg/fi/cloudup/scalewaytasks/instance.go @@ -132,12 +132,12 @@ func (s *Instance) Find(c *fi.CloudupContext) (*Instance, error) { } return &Instance{ - Name: fi.PtrTo(igName), + Name: new(igName), Lifecycle: s.Lifecycle, - Zone: fi.PtrTo(server.Zone.String()), - Role: fi.PtrTo(role), - CommercialType: fi.PtrTo(server.CommercialType), - Image: fi.PtrTo(imageLabel), + Zone: new(server.Zone.String()), + Role: new(role), + CommercialType: new(server.CommercialType), + Image: new(imageLabel), Tags: server.Tags, Count: len(servers), NeedsUpdate: needsUpdate, @@ -226,15 +226,15 @@ func (_ *Instance) RenderScw(t *scaleway.ScwAPITarget, actual, expected, changes CommercialType: fi.ValueOf(expected.CommercialType), Image: expected.Image, Tags: expected.Tags, - RoutedIPEnabled: fi.PtrTo(true), + RoutedIPEnabled: new(true), } // We resize the root volume if needed (for instance types with no local storage) if expected.VolumeSize != nil { createServerRequest.Volumes = map[string]*instance.VolumeServerTemplate{ "0": { - Boot: fi.PtrTo(true), - Size: fi.PtrTo(scw.Size(fi.ValueOf(expected.VolumeSize)) * scw.GB), + Boot: new(true), + Size: new(scw.Size(fi.ValueOf(expected.VolumeSize)) * scw.GB), VolumeType: instance.VolumeVolumeTypeBSSD, }, } @@ -333,8 +333,8 @@ func (_ *Instance) RenderTerraform(t *terraform.TerraformTarget, actual, expecte Type: expected.CommercialType, Tags: expected.Tags, Image: expected.Image, - EnableDynamicIP: fi.PtrTo(true), - ReplaceOnTypeChange: fi.PtrTo(false), + EnableDynamicIP: new(true), + ReplaceOnTypeChange: new(false), Lifecycle: nil, } @@ -360,7 +360,7 @@ func (_ *Instance) RenderTerraform(t *terraform.TerraformTarget, actual, expecte tfInstance.RootVolume = []terraformVolume{ { SizeInGB: expected.VolumeSize, - Boot: fi.PtrTo(true), + Boot: new(true), }, } } diff --git a/upup/pkg/fi/cloudup/scalewaytasks/lb_backend.go b/upup/pkg/fi/cloudup/scalewaytasks/lb_backend.go index ed9a7f2ed20a0..3d5563c662c05 100644 --- a/upup/pkg/fi/cloudup/scalewaytasks/lb_backend.go +++ b/upup/pkg/fi/cloudup/scalewaytasks/lb_backend.go @@ -88,17 +88,17 @@ func (l *LBBackend) Find(context *fi.CloudupContext) (*LBBackend, error) { backend := backendResponse.Backends[0] return &LBBackend{ - Name: fi.PtrTo(backend.Name), + Name: new(backend.Name), Lifecycle: l.Lifecycle, - ID: fi.PtrTo(backend.ID), - Zone: fi.PtrTo(string(backend.LB.Zone)), - ForwardProtocol: fi.PtrTo(string(backend.ForwardProtocol)), - ForwardPort: fi.PtrTo(backend.ForwardPort), - ForwardPortAlgorithm: fi.PtrTo(string(backend.ForwardPortAlgorithm)), - StickySessions: fi.PtrTo(string(backend.StickySessions)), - ProxyProtocol: fi.PtrTo(string(backend.ProxyProtocol)), + ID: new(backend.ID), + Zone: new(string(backend.LB.Zone)), + ForwardProtocol: new(string(backend.ForwardProtocol)), + ForwardPort: new(backend.ForwardPort), + ForwardPortAlgorithm: new(string(backend.ForwardPortAlgorithm)), + StickySessions: new(string(backend.StickySessions)), + ProxyProtocol: new(string(backend.ProxyProtocol)), LoadBalancer: &LoadBalancer{ - Name: fi.PtrTo(backend.LB.Name), + Name: new(backend.LB.Name), }, }, nil } @@ -230,7 +230,7 @@ func (l *LBBackend) RenderTerraform(t *terraform.TerraformTarget, actual, expect Name: expected.Name, ForwardProtocol: expected.ForwardProtocol, ForwardPort: expected.ForwardPort, - ProxyProtocol: fi.PtrTo(strings.TrimPrefix(*expected.ProxyProtocol, "proxy_protocol_")), + ProxyProtocol: new(strings.TrimPrefix(*expected.ProxyProtocol, "proxy_protocol_")), ServerIPs: serverIPs, } return t.RenderResource("scaleway_lb_backend", fi.ValueOf(expected.Name), tf) diff --git a/upup/pkg/fi/cloudup/scalewaytasks/lb_frontend.go b/upup/pkg/fi/cloudup/scalewaytasks/lb_frontend.go index 40e5db51650d9..16b0793253797 100644 --- a/upup/pkg/fi/cloudup/scalewaytasks/lb_frontend.go +++ b/upup/pkg/fi/cloudup/scalewaytasks/lb_frontend.go @@ -87,17 +87,17 @@ func (l *LBFrontend) Find(context *fi.CloudupContext) (*LBFrontend, error) { frontend := frontendResponse.Frontends[0] return &LBFrontend{ - Name: fi.PtrTo(frontend.Name), + Name: new(frontend.Name), Lifecycle: l.Lifecycle, - ID: fi.PtrTo(frontend.ID), - Zone: fi.PtrTo(string(frontend.LB.Zone)), - InboundPort: fi.PtrTo(frontend.InboundPort), + ID: new(frontend.ID), + Zone: new(string(frontend.LB.Zone)), + InboundPort: new(frontend.InboundPort), LoadBalancer: &LoadBalancer{ - Name: fi.PtrTo(frontend.LB.Name), + Name: new(frontend.LB.Name), }, LBBackend: &LBBackend{ - Name: fi.PtrTo(frontend.Backend.Name), - ID: fi.PtrTo(frontend.Backend.ID), + Name: new(frontend.Backend.Name), + ID: new(frontend.Backend.ID), }, }, nil } diff --git a/upup/pkg/fi/cloudup/scalewaytasks/loadbalancer.go b/upup/pkg/fi/cloudup/scalewaytasks/loadbalancer.go index f4348e229563a..0beae74799363 100644 --- a/upup/pkg/fi/cloudup/scalewaytasks/loadbalancer.go +++ b/upup/pkg/fi/cloudup/scalewaytasks/loadbalancer.go @@ -87,9 +87,9 @@ func (l *LoadBalancer) Find(context *fi.CloudupContext) (*LoadBalancer, error) { } return &LoadBalancer{ - Name: fi.PtrTo(loadBalancer.Name), - LBID: fi.PtrTo(loadBalancer.ID), - Zone: fi.PtrTo(string(loadBalancer.Zone)), + Name: new(loadBalancer.Name), + LBID: new(loadBalancer.ID), + Zone: new(string(loadBalancer.Zone)), LBAddresses: lbIPs, Tags: loadBalancer.Tags, Lifecycle: l.Lifecycle, diff --git a/upup/pkg/fi/cloudup/scalewaytasks/sshkey.go b/upup/pkg/fi/cloudup/scalewaytasks/sshkey.go index 471df0a9d87d6..5bfca137696ba 100644 --- a/upup/pkg/fi/cloudup/scalewaytasks/sshkey.go +++ b/upup/pkg/fi/cloudup/scalewaytasks/sshkey.go @@ -64,9 +64,9 @@ func (s *SSHKey) Find(c *fi.CloudupContext) (*SSHKey, error) { klog.V(2).Infof("found matching SSH key named %q", *s.Name) k := keysResp.SSHKeys[0] sshKey := &SSHKey{ - ID: fi.PtrTo(k.ID), - Name: fi.PtrTo(k.Name), - KeyPairFingerPrint: fi.PtrTo(k.Fingerprint), + ID: new(k.ID), + Name: new(k.Name), + KeyPairFingerPrint: new(k.Fingerprint), Lifecycle: s.Lifecycle, } @@ -135,7 +135,7 @@ func (*SSHKey) RenderScw(t *scaleway.ScwAPITarget, actual, expected, changes *SS if err != nil { return fmt.Errorf("error creating SSH keypair: %w", err) } - expected.KeyPairFingerPrint = fi.PtrTo(key.Fingerprint) + expected.KeyPairFingerPrint = new(key.Fingerprint) klog.V(2).Infof("Created a new SSH keypair, id=%q fingerprint=%q", key.ID, key.Fingerprint) return nil @@ -154,7 +154,7 @@ func (_ *SSHKey) RenderTerraform(t *terraform.TerraformTarget, actual, expected, } tf := terraformSSHKey{ Name: expected.Name, - PublicKey: fi.PtrTo(publicKeyStr), + PublicKey: new(publicKeyStr), } return t.RenderResource("scaleway_iam_ssh_key", tfName, tf) } diff --git a/upup/pkg/fi/cloudup/scalewaytasks/volume.go b/upup/pkg/fi/cloudup/scalewaytasks/volume.go index 349ec61c63381..ab0e460e74849 100644 --- a/upup/pkg/fi/cloudup/scalewaytasks/volume.go +++ b/upup/pkg/fi/cloudup/scalewaytasks/volume.go @@ -61,12 +61,12 @@ func (v *Volume) Find(c *fi.CloudupContext) (*Volume, error) { for _, volume := range volumes.Volumes { if volume.Name == fi.ValueOf(v.Name) { return &Volume{ - Name: fi.PtrTo(volume.Name), - ID: fi.PtrTo(volume.ID), + Name: new(volume.Name), + ID: new(volume.ID), Lifecycle: v.Lifecycle, - Size: fi.PtrTo(int64(volume.Size)), - Zone: fi.PtrTo(string(volume.Zone)), - Type: fi.PtrTo(string(volume.VolumeType)), + Size: new(int64(volume.Size)), + Zone: new(string(volume.Zone)), + Type: new(string(volume.VolumeType)), }, nil } } @@ -112,7 +112,7 @@ func (_ *Volume) RenderScw(t *scaleway.ScwAPITarget, actual, expected, changes * Zone: zone, VolumeID: fi.ValueOf(actual.ID), Name: expected.Name, - Tags: fi.PtrTo(expected.Tags), + Tags: new(expected.Tags), Size: scw.SizePtr(scw.Size(fi.ValueOf(expected.Size))), }) if err != nil { @@ -147,7 +147,7 @@ func (_ *Volume) RenderTerraform(t *terraform.TerraformTarget, actual, expected, tfName := strings.ReplaceAll(fi.ValueOf(expected.Name), ".", "-") tf := &terraformVolume{ Name: expected.Name, - SizeInGB: fi.PtrTo(int(fi.ValueOf(expected.Size) / 1e9)), + SizeInGB: new(int(fi.ValueOf(expected.Size) / 1e9)), Type: expected.Type, Tags: expected.Tags, } diff --git a/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go b/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go index 2c13b3d86196a..acbd5d3c3208b 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go +++ b/upup/pkg/fi/cloudup/spotinsttasks/elastigroup.go @@ -209,8 +209,8 @@ func (e *Elastigroup) Find(c *fi.CloudupContext) (*Elastigroup, error) { // Capacity. { - actual.MinSize = fi.PtrTo(int64(fi.ValueOf(group.Capacity.Minimum))) - actual.MaxSize = fi.PtrTo(int64(fi.ValueOf(group.Capacity.Maximum))) + actual.MinSize = new(int64(fi.ValueOf(group.Capacity.Minimum))) + actual.MaxSize = new(int64(fi.ValueOf(group.Capacity.Maximum))) } // Strategy. @@ -222,7 +222,7 @@ func (e *Elastigroup) Find(c *fi.CloudupContext) (*Elastigroup, error) { actual.UtilizeCommitments = group.Strategy.UtilizeCommitments if group.Strategy.DrainingTimeout != nil { - actual.DrainingTimeout = fi.PtrTo(int64(fi.ValueOf(group.Strategy.DrainingTimeout))) + actual.DrainingTimeout = new(int64(fi.ValueOf(group.Strategy.DrainingTimeout))) } } @@ -241,7 +241,7 @@ func (e *Elastigroup) Find(c *fi.CloudupContext) (*Elastigroup, error) { { for _, subnetID := range compute.SubnetIDs { actual.Subnets = append(actual.Subnets, - &awstasks.Subnet{ID: fi.PtrTo(subnetID)}) + &awstasks.Subnet{ID: new(subnetID)}) } if subnetSlicesEqualIgnoreOrder(actual.Subnets, e.Subnets) { actual.Subnets = e.Subnets @@ -284,7 +284,7 @@ func (e *Elastigroup) Find(c *fi.CloudupContext) (*Elastigroup, error) { if lc.SecurityGroupIDs != nil { for _, sgID := range lc.SecurityGroupIDs { actual.SecurityGroups = append(actual.SecurityGroups, - &awstasks.SecurityGroup{ID: fi.PtrTo(sgID)}) + &awstasks.SecurityGroup{ID: new(sgID)}) } } } @@ -302,16 +302,16 @@ func (e *Elastigroup) Find(c *fi.CloudupContext) (*Elastigroup, error) { actual.RootVolumeOpts = new(RootVolumeOpts) } if b.EBS.VolumeType != nil { - actual.RootVolumeOpts.Type = fi.PtrTo(strings.ToLower(fi.ValueOf(b.EBS.VolumeType))) + actual.RootVolumeOpts.Type = new(strings.ToLower(fi.ValueOf(b.EBS.VolumeType))) } if b.EBS.VolumeSize != nil { - actual.RootVolumeOpts.Size = fi.PtrTo(int64(fi.ValueOf(b.EBS.VolumeSize))) + actual.RootVolumeOpts.Size = new(int64(fi.ValueOf(b.EBS.VolumeSize))) } if b.EBS.IOPS != nil { - actual.RootVolumeOpts.IOPS = fi.PtrTo(int64(fi.ValueOf(b.EBS.IOPS))) + actual.RootVolumeOpts.IOPS = new(int64(fi.ValueOf(b.EBS.IOPS))) } if b.EBS.Throughput != nil { - actual.RootVolumeOpts.Throughput = fi.PtrTo(int64(fi.ValueOf(b.EBS.Throughput))) + actual.RootVolumeOpts.Throughput = new(int64(fi.ValueOf(b.EBS.Throughput))) } if b.EBS.Encrypted != nil { actual.RootVolumeOpts.Encryption = b.EBS.Encrypted @@ -359,7 +359,7 @@ func (e *Elastigroup) Find(c *fi.CloudupContext) (*Elastigroup, error) { } } - actual.AssociatePublicIPAddress = fi.PtrTo(associatePublicIP) + actual.AssociatePublicIPAddress = new(associatePublicIP) } // Load balancers. @@ -431,8 +431,8 @@ func (e *Elastigroup) Find(c *fi.CloudupContext) (*Elastigroup, error) { // Instance Metadata Options if lc.MetadataOptions != nil { actual.InstanceMetadataOptions = new(InstanceMetadataOptions) - actual.InstanceMetadataOptions.HTTPTokens = fi.PtrTo(fi.ValueOf(lc.MetadataOptions.HTTPTokens)) - actual.InstanceMetadataOptions.HTTPPutResponseHopLimit = fi.PtrTo(int64(fi.ValueOf(lc.MetadataOptions.HTTPPutResponseHopLimit))) + actual.InstanceMetadataOptions.HTTPTokens = new(fi.ValueOf(lc.MetadataOptions.HTTPTokens)) + actual.InstanceMetadataOptions.HTTPPutResponseHopLimit = new(int64(fi.ValueOf(lc.MetadataOptions.HTTPPutResponseHopLimit))) } } @@ -544,21 +544,21 @@ func (_ *Elastigroup) create(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e // Capacity. { - group.Capacity.SetTarget(fi.PtrTo(int(*e.MinSize))) - group.Capacity.SetMinimum(fi.PtrTo(int(*e.MinSize))) - group.Capacity.SetMaximum(fi.PtrTo(int(*e.MaxSize))) + group.Capacity.SetTarget(new(int(*e.MinSize))) + group.Capacity.SetMinimum(new(int(*e.MinSize))) + group.Capacity.SetMaximum(new(int(*e.MaxSize))) } // Strategy. { group.Strategy.SetRisk(e.SpotPercentage) - group.Strategy.SetAvailabilityVsCost(fi.PtrTo(string(normalizeOrientation(e.Orientation)))) + group.Strategy.SetAvailabilityVsCost(new(string(normalizeOrientation(e.Orientation)))) group.Strategy.SetFallbackToOnDemand(e.FallbackToOnDemand) group.Strategy.SetUtilizeReservedInstances(e.UtilizeReservedInstances) group.Strategy.SetUtilizeCommitments(e.UtilizeCommitments) if e.DrainingTimeout != nil { - group.Strategy.SetDrainingTimeout(fi.PtrTo(int(*e.DrainingTimeout))) + group.Strategy.SetDrainingTimeout(new(int(*e.DrainingTimeout))) } } @@ -632,7 +632,7 @@ func (_ *Elastigroup) create(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e if len(userData) > 0 { encoded := base64.StdEncoding.EncodeToString([]byte(userData)) - group.Compute.LaunchSpecification.SetUserData(fi.PtrTo(encoded)) + group.Compute.LaunchSpecification.SetUserData(new(encoded)) } } } @@ -661,9 +661,9 @@ func (_ *Elastigroup) create(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e { if e.AssociatePublicIPAddress != nil { iface := &aws.NetworkInterface{ - Description: fi.PtrTo("eth0"), - DeviceIndex: fi.PtrTo(0), - DeleteOnTermination: fi.PtrTo(true), + Description: new("eth0"), + DeviceIndex: new(0), + DeleteOnTermination: new(true), AssociatePublicIPAddress: e.AssociatePublicIPAddress, } @@ -720,18 +720,18 @@ func (_ *Elastigroup) create(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e { if opts := e.AutoScalerOpts; opts != nil { k8s := new(aws.KubernetesIntegration) - k8s.SetIntegrationMode(fi.PtrTo("pod")) + k8s.SetIntegrationMode(new("pod")) k8s.SetClusterIdentifier(opts.ClusterID) if opts.Enabled != nil { autoScaler := new(aws.AutoScaleKubernetes) autoScaler.IsEnabled = opts.Enabled - autoScaler.IsAutoConfig = fi.PtrTo(true) + autoScaler.IsAutoConfig = new(true) autoScaler.Cooldown = opts.Cooldown // Headroom. if headroom := opts.Headroom; headroom != nil { - autoScaler.IsAutoConfig = fi.PtrTo(false) + autoScaler.IsAutoConfig = new(false) autoScaler.Headroom = &aws.AutoScaleHeadroom{ CPUPerUnit: headroom.CPUPerUnit, GPUPerUnit: headroom.GPUPerUnit, @@ -766,8 +766,8 @@ func (_ *Elastigroup) create(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e { if e.InstanceMetadataOptions != nil { opt := new(aws.MetadataOptions) - opt.SetHTTPPutResponseHopLimit(fi.PtrTo(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) - opt.SetHTTPTokens(fi.PtrTo(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) + opt.SetHTTPPutResponseHopLimit(new(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) + opt.SetHTTPTokens(new(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) group.Compute.LaunchSpecification.SetMetadataOptions(opt) } } @@ -855,7 +855,7 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e group.Strategy = new(aws.Strategy) } - group.Strategy.SetAvailabilityVsCost(fi.PtrTo(string(normalizeOrientation(e.Orientation)))) + group.Strategy.SetAvailabilityVsCost(new(string(normalizeOrientation(e.Orientation)))) changes.Orientation = nil changed = true } @@ -899,7 +899,7 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e group.Strategy = new(aws.Strategy) } - group.Strategy.SetDrainingTimeout(fi.PtrTo(int(*e.DrainingTimeout))) + group.Strategy.SetDrainingTimeout(new(int(*e.DrainingTimeout))) changes.DrainingTimeout = nil changed = true } @@ -1011,7 +1011,7 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e } encoded := base64.StdEncoding.EncodeToString([]byte(userData)) - group.Compute.LaunchSpecification.SetUserData(fi.PtrTo(encoded)) + group.Compute.LaunchSpecification.SetUserData(new(encoded)) changed = true } @@ -1030,9 +1030,9 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e } iface := &aws.NetworkInterface{ - Description: fi.PtrTo("eth0"), - DeviceIndex: fi.PtrTo(0), - DeleteOnTermination: fi.PtrTo(true), + Description: new("eth0"), + DeviceIndex: new(0), + DeleteOnTermination: new(true), AssociatePublicIPAddress: changes.AssociatePublicIPAddress, } @@ -1278,8 +1278,8 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e } opt := new(aws.MetadataOptions) - opt.SetHTTPPutResponseHopLimit(fi.PtrTo(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) - opt.SetHTTPTokens(fi.PtrTo(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) + opt.SetHTTPPutResponseHopLimit(new(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) + opt.SetHTTPTokens(new(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) group.Compute.LaunchSpecification.SetMetadataOptions(opt) changes.InstanceMetadataOptions = nil changed = true @@ -1297,13 +1297,13 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e group.Capacity = new(aws.Capacity) } - group.Capacity.SetMinimum(fi.PtrTo(int(*e.MinSize))) + group.Capacity.SetMinimum(new(int(*e.MinSize))) changes.MinSize = nil changed = true // Scale up the target capacity, if needed. if int64(*actual.Capacity.Target) < *e.MinSize { - group.Capacity.SetTarget(fi.PtrTo(int(*e.MinSize))) + group.Capacity.SetTarget(new(int(*e.MinSize))) } } if changes.MaxSize != nil { @@ -1311,7 +1311,7 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e group.Capacity = new(aws.Capacity) } - group.Capacity.SetMaximum(fi.PtrTo(int(*e.MaxSize))) + group.Capacity.SetMaximum(new(int(*e.MaxSize))) changes.MaxSize = nil changed = true } @@ -1327,7 +1327,7 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e // Headroom. if headroom := opts.Headroom; headroom != nil { - autoScaler.IsAutoConfig = fi.PtrTo(false) + autoScaler.IsAutoConfig = new(false) autoScaler.Headroom = &aws.AutoScaleHeadroom{ CPUPerUnit: e.AutoScalerOpts.Headroom.CPUPerUnit, GPUPerUnit: e.AutoScalerOpts.Headroom.GPUPerUnit, @@ -1335,7 +1335,7 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e NumOfUnits: e.AutoScalerOpts.Headroom.NumOfUnits, } } else if a.AutoScalerOpts != nil && a.AutoScalerOpts.Headroom != nil { - autoScaler.IsAutoConfig = fi.PtrTo(true) + autoScaler.IsAutoConfig = new(true) autoScaler.SetHeadroom(nil) } @@ -1517,10 +1517,10 @@ func (_ *Elastigroup) RenderTerraform(t *terraform.TerraformTarget, a, e, change DesiredCapacity: e.MinSize, MinSize: e.MinSize, MaxSize: e.MaxSize, - CapacityUnit: fi.PtrTo("instance"), + CapacityUnit: new("instance"), SpotPercentage: e.SpotPercentage, - Orientation: fi.PtrTo(string(normalizeOrientation(e.Orientation))), + Orientation: new(string(normalizeOrientation(e.Orientation))), FallbackToOnDemand: e.FallbackToOnDemand, UtilizeReservedInstances: e.UtilizeReservedInstances, UtilizeCommitments: e.UtilizeCommitments, @@ -1623,9 +1623,9 @@ func (_ *Elastigroup) RenderTerraform(t *terraform.TerraformTarget, a, e, change // Public IP. if e.AssociatePublicIPAddress != nil { tf.NetworkInterfaces = append(tf.NetworkInterfaces, &terraformElastigroupNetworkInterface{ - Description: fi.PtrTo("eth0"), - DeviceIndex: fi.PtrTo(0), - DeleteOnTermination: fi.PtrTo(true), + Description: new("eth0"), + DeviceIndex: new(0), + DeleteOnTermination: new(true), AssociatePublicIPAddress: e.AssociatePublicIPAddress, }) } @@ -1642,12 +1642,12 @@ func (_ *Elastigroup) RenderTerraform(t *terraform.TerraformTarget, a, e, change tf.RootBlockDevice = &terraformElastigroupBlockDevice{ DeviceName: rootDevice.DeviceName, - VolumeType: fi.PtrTo(string(rootDevice.EbsVolumeType)), + VolumeType: new(string(rootDevice.EbsVolumeType)), VolumeSize: ptrInt32ToPtrInt64(rootDevice.EbsVolumeSize), VolumeIOPS: ptrInt32ToPtrInt64(rootDevice.EbsVolumeIops), VolumeThroughput: ptrInt32ToPtrInt64(rootDevice.EbsVolumeThroughput), Encrypted: rootDevice.EbsEncrypted, - DeleteOnTermination: fi.PtrTo(true), + DeleteOnTermination: new(true), } ephemeralDevices, err := buildEphemeralDevices(cloud, e.OnDemandInstanceType) @@ -1679,18 +1679,18 @@ func (_ *Elastigroup) RenderTerraform(t *terraform.TerraformTarget, a, e, change { if opts := e.AutoScalerOpts; opts != nil { tf.Integration = &terraformElastigroupIntegration{ - IntegrationMode: fi.PtrTo("pod"), + IntegrationMode: new("pod"), ClusterIdentifier: opts.ClusterID, } if opts.Enabled != nil { tf.Integration.Enabled = opts.Enabled - tf.Integration.AutoConfig = fi.PtrTo(true) + tf.Integration.AutoConfig = new(true) tf.Integration.Cooldown = opts.Cooldown // Headroom. if headroom := opts.Headroom; headroom != nil { - tf.Integration.AutoConfig = fi.PtrTo(false) + tf.Integration.AutoConfig = new(false) tf.Integration.Headroom = &terraformAutoScalerHeadroom{ CPUPerUnit: headroom.CPUPerUnit, GPUPerUnit: headroom.GPUPerUnit, @@ -1712,8 +1712,8 @@ func (_ *Elastigroup) RenderTerraform(t *terraform.TerraformTarget, a, e, change tf.Integration.Labels = make([]*terraformKV, 0, len(labels)) for k, v := range labels { tf.Integration.Labels = append(tf.Integration.Labels, &terraformKV{ - Key: fi.PtrTo(k), - Value: fi.PtrTo(v), + Key: new(k), + Value: new(v), }) } } @@ -1746,8 +1746,8 @@ func (e *Elastigroup) buildTags() []*aws.Tag { for key, value := range e.Tags { tags = append(tags, &aws.Tag{ - Key: fi.PtrTo(key), - Value: fi.PtrTo(value), + Key: new(key), + Value: new(value), }) } @@ -1758,8 +1758,8 @@ func (e *Elastigroup) buildAutoScaleLabels(labelsMap map[string]string) []*aws.A labels := make([]*aws.AutoScaleLabel, 0, len(labelsMap)) for key, value := range labelsMap { labels = append(labels, &aws.AutoScaleLabel{ - Key: fi.PtrTo(key), - Value: fi.PtrTo(value), + Key: new(key), + Value: new(value), }) } @@ -1780,12 +1780,12 @@ func (e *Elastigroup) buildLoadBalancers(cloud awsup.AWSCloud) ([]*aws.LoadBalan "load balancer to attach: %s", lbName) } lbs[i] = &aws.LoadBalancer{ - Type: fi.PtrTo("CLASSIC"), + Type: new("CLASSIC"), Name: lbDesc.LoadBalancerName, } } else { lbs[i] = &aws.LoadBalancer{ - Type: fi.PtrTo("CLASSIC"), + Type: new("CLASSIC"), Name: lb.LoadBalancerName, } } @@ -1797,7 +1797,7 @@ func (e *Elastigroup) buildTargetGroups() []*aws.LoadBalancer { tgs := make([]*aws.LoadBalancer, len(e.TargetGroups)) for i, tg := range e.TargetGroups { tgs[i] = &aws.LoadBalancer{ - Type: fi.PtrTo("TARGET_GROUP"), + Type: new("TARGET_GROUP"), Arn: tg.ARN, } } @@ -1813,8 +1813,8 @@ func buildEphemeralDevices(cloud awsup.AWSCloud, machineType *string) ([]*awstas bdms := make([]*awstasks.BlockDeviceMapping, len(info.EphemeralDevices())) for i, ed := range info.EphemeralDevices() { bdms[i] = &awstasks.BlockDeviceMapping{ - DeviceName: fi.PtrTo(ed.DeviceName), - VirtualName: fi.PtrTo(ed.VirtualName), + DeviceName: new(ed.DeviceName), + VirtualName: new(ed.VirtualName), } } @@ -1834,7 +1834,7 @@ func buildRootDevice(cloud awsup.AWSCloud, volumeOpts *RootVolumeOpts, EbsVolumeSize: ptrInt64ToPtrInt32(volumeOpts.Size), EbsVolumeType: ec2types.VolumeType(fi.ValueOf(volumeOpts.Type)), EbsEncrypted: volumeOpts.Encryption, - EbsDeleteOnTermination: fi.PtrTo(true), + EbsDeleteOnTermination: new(true), } // IOPS is not supported for gp2 volumes. @@ -1858,20 +1858,20 @@ func (e *Elastigroup) convertBlockDeviceMapping(in *awstasks.BlockDeviceMapping) if in.EbsDeleteOnTermination != nil || in.EbsVolumeSize != nil || len(in.EbsVolumeType) > 0 { out.EBS = &aws.EBS{ - VolumeType: fi.PtrTo(string(in.EbsVolumeType)), - VolumeSize: fi.PtrTo(int(fi.ValueOf(in.EbsVolumeSize))), + VolumeType: new(string(in.EbsVolumeType)), + VolumeSize: new(int(fi.ValueOf(in.EbsVolumeSize))), Encrypted: in.EbsEncrypted, DeleteOnTermination: in.EbsDeleteOnTermination, } // IOPS is not valid for gp2 volumes. if in.EbsVolumeIops != nil && in.EbsVolumeType != ec2types.VolumeTypeGp2 { - out.EBS.IOPS = fi.PtrTo(int(fi.ValueOf(in.EbsVolumeIops))) + out.EBS.IOPS = new(int(fi.ValueOf(in.EbsVolumeIops))) } // Throughput is only valid for gp3 volumes. if in.EbsVolumeThroughput != nil && in.EbsVolumeType == ec2types.VolumeTypeGp3 { - out.EBS.Throughput = fi.PtrTo(int(fi.ValueOf(in.EbsVolumeThroughput))) + out.EBS.Throughput = new(int(fi.ValueOf(in.EbsVolumeThroughput))) } } @@ -1880,27 +1880,27 @@ func (e *Elastigroup) convertBlockDeviceMapping(in *awstasks.BlockDeviceMapping) func (e *Elastigroup) applyDefaults() { if e.FallbackToOnDemand == nil { - e.FallbackToOnDemand = fi.PtrTo(true) + e.FallbackToOnDemand = new(true) } if e.UtilizeReservedInstances == nil { - e.UtilizeReservedInstances = fi.PtrTo(true) + e.UtilizeReservedInstances = new(true) } if e.Product == nil || (e.Product != nil && fi.ValueOf(e.Product) == "") { - e.Product = fi.PtrTo("Linux/UNIX") + e.Product = new("Linux/UNIX") } if e.Orientation == nil || (e.Orientation != nil && fi.ValueOf(e.Orientation) == "") { - e.Orientation = fi.PtrTo("balanced") + e.Orientation = new("balanced") } if e.Monitoring == nil { - e.Monitoring = fi.PtrTo(false) + e.Monitoring = new(false) } if e.HealthCheckType == nil { - e.HealthCheckType = fi.PtrTo("K8S_NODE") + e.HealthCheckType = new("K8S_NODE") } } diff --git a/upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go b/upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go index 0fbc09cf91626..63216cda7150b 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go +++ b/upup/pkg/fi/cloudup/spotinsttasks/launch_spec.go @@ -152,8 +152,8 @@ func (o *LaunchSpec) Find(c *fi.CloudupContext) (*LaunchSpec, error) { // Capacity. { if spec.ResourceLimits != nil { - actual.MinSize = fi.PtrTo(int64(fi.ValueOf(spec.ResourceLimits.MinInstanceCount))) - actual.MaxSize = fi.PtrTo(int64(fi.ValueOf(spec.ResourceLimits.MaxInstanceCount))) + actual.MinSize = new(int64(fi.ValueOf(spec.ResourceLimits.MinInstanceCount))) + actual.MaxSize = new(int64(fi.ValueOf(spec.ResourceLimits.MaxInstanceCount))) } } @@ -161,7 +161,7 @@ func (o *LaunchSpec) Find(c *fi.CloudupContext) (*LaunchSpec, error) { { // convert spec from api that reply for multi arch data only in spec.images if len(spec.Images) > 1 { - spec.SetImageId(fi.PtrTo(fi.ValueOf(spec.Images[0].ImageId))) + spec.SetImageId(new(fi.ValueOf(spec.Images[0].ImageId))) actual.OtherArchitectureImages = append(actual.OtherArchitectureImages, fi.ValueOf(spec.Images[1].ImageId)) } actual.ImageID = spec.ImageID @@ -211,7 +211,7 @@ func (o *LaunchSpec) Find(c *fi.CloudupContext) (*LaunchSpec, error) { { if spec.RootVolumeSize != nil { actual.RootVolumeOpts = new(RootVolumeOpts) - actual.RootVolumeOpts.Size = fi.PtrTo(int64(*spec.RootVolumeSize)) + actual.RootVolumeOpts.Size = new(int64(*spec.RootVolumeSize)) } } @@ -226,16 +226,16 @@ func (o *LaunchSpec) Find(c *fi.CloudupContext) (*LaunchSpec, error) { actual.RootVolumeOpts = new(RootVolumeOpts) } if b.EBS.VolumeType != nil { - actual.RootVolumeOpts.Type = fi.PtrTo(strings.ToLower(fi.ValueOf(b.EBS.VolumeType))) + actual.RootVolumeOpts.Type = new(strings.ToLower(fi.ValueOf(b.EBS.VolumeType))) } if b.EBS.VolumeSize != nil { - actual.RootVolumeOpts.Size = fi.PtrTo(int64(fi.ValueOf(b.EBS.VolumeSize))) + actual.RootVolumeOpts.Size = new(int64(fi.ValueOf(b.EBS.VolumeSize))) } if b.EBS.IOPS != nil { - actual.RootVolumeOpts.IOPS = fi.PtrTo(int64(fi.ValueOf(b.EBS.IOPS))) + actual.RootVolumeOpts.IOPS = new(int64(fi.ValueOf(b.EBS.IOPS))) } if b.EBS.Throughput != nil { - actual.RootVolumeOpts.Throughput = fi.PtrTo(int64(fi.ValueOf(b.EBS.Throughput))) + actual.RootVolumeOpts.Throughput = new(int64(fi.ValueOf(b.EBS.Throughput))) } if b.EBS.Encrypted != nil { actual.RootVolumeOpts.Encryption = b.EBS.Encrypted @@ -250,7 +250,7 @@ func (o *LaunchSpec) Find(c *fi.CloudupContext) (*LaunchSpec, error) { if spec.SecurityGroupIDs != nil { for _, sgID := range spec.SecurityGroupIDs { actual.SecurityGroups = append(actual.SecurityGroups, - &awstasks.SecurityGroup{ID: fi.PtrTo(sgID)}) + &awstasks.SecurityGroup{ID: new(sgID)}) } } } @@ -260,7 +260,7 @@ func (o *LaunchSpec) Find(c *fi.CloudupContext) (*LaunchSpec, error) { if spec.SubnetIDs != nil { for _, subnetID := range spec.SubnetIDs { actual.Subnets = append(actual.Subnets, - &awstasks.Subnet{ID: fi.PtrTo(subnetID)}) + &awstasks.Subnet{ID: new(subnetID)}) } if subnetSlicesEqualIgnoreOrder(actual.Subnets, o.Subnets) { actual.Subnets = o.Subnets @@ -339,7 +339,7 @@ func (o *LaunchSpec) Find(c *fi.CloudupContext) (*LaunchSpec, error) { { if strategy := spec.Strategy; strategy != nil { if strategy.SpotPercentage != nil { - actual.SpotPercentage = fi.PtrTo(int64(fi.ValueOf(strategy.SpotPercentage))) + actual.SpotPercentage = new(int64(fi.ValueOf(strategy.SpotPercentage))) } } } @@ -347,8 +347,8 @@ func (o *LaunchSpec) Find(c *fi.CloudupContext) (*LaunchSpec, error) { // Instance Metadata Options if spec.InstanceMetadataOptions != nil { actual.InstanceMetadataOptions = new(InstanceMetadataOptions) - actual.InstanceMetadataOptions.HTTPTokens = fi.PtrTo(fi.ValueOf(spec.InstanceMetadataOptions.HTTPTokens)) - actual.InstanceMetadataOptions.HTTPPutResponseHopLimit = fi.PtrTo(int64(fi.ValueOf(spec.InstanceMetadataOptions.HTTPPutResponseHopLimit))) + actual.InstanceMetadataOptions.HTTPTokens = new(fi.ValueOf(spec.InstanceMetadataOptions.HTTPTokens)) + actual.InstanceMetadataOptions.HTTPPutResponseHopLimit = new(int64(fi.ValueOf(spec.InstanceMetadataOptions.HTTPPutResponseHopLimit))) } // Avoid spurious changes. @@ -404,8 +404,8 @@ func (_ *LaunchSpec) create(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err { if e.MinSize != nil || e.MaxSize != nil { spec.ResourceLimits = new(aws.ResourceLimits) - spec.ResourceLimits.SetMinInstanceCount(fi.PtrTo(int(*e.MinSize))) - spec.ResourceLimits.SetMaxInstanceCount(fi.PtrTo(int(*e.MaxSize))) + spec.ResourceLimits.SetMinInstanceCount(new(int(*e.MinSize))) + spec.ResourceLimits.SetMaxInstanceCount(new(int(*e.MaxSize))) } } @@ -439,7 +439,7 @@ func (_ *LaunchSpec) create(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err if len(userData) > 0 { encoded := base64.StdEncoding.EncodeToString([]byte(userData)) - spec.SetUserData(fi.PtrTo(encoded)) + spec.SetUserData(new(encoded)) } } } @@ -532,8 +532,8 @@ func (_ *LaunchSpec) create(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err var labels []*aws.Label for k, v := range opts.Labels { labels = append(labels, &aws.Label{ - Key: fi.PtrTo(k), - Value: fi.PtrTo(v), + Key: new(k), + Value: new(v), }) } spec.SetLabels(labels) @@ -544,9 +544,9 @@ func (_ *LaunchSpec) create(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err taints := make([]*aws.Taint, len(opts.Taints)) for i, taint := range opts.Taints { taints[i] = &aws.Taint{ - Key: fi.PtrTo(taint.Key), - Value: fi.PtrTo(taint.Value), - Effect: fi.PtrTo(string(taint.Effect)), + Key: new(taint.Key), + Value: new(taint.Value), + Effect: new(string(taint.Effect)), } } spec.SetTaints(taints) @@ -557,7 +557,7 @@ func (_ *LaunchSpec) create(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err // Strategy. { if e.SpotPercentage != nil { - spec.Strategy.SetSpotPercentage(fi.PtrTo(int(*e.SpotPercentage))) + spec.Strategy.SetSpotPercentage(new(int(*e.SpotPercentage))) } } @@ -571,8 +571,8 @@ func (_ *LaunchSpec) create(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err { if e.InstanceMetadataOptions != nil { opt := new(aws.LaunchspecInstanceMetadataOptions) - opt.SetHTTPPutResponseHopLimit(fi.PtrTo(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) - opt.SetHTTPTokens(fi.PtrTo(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) + opt.SetHTTPPutResponseHopLimit(new(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) + opt.SetHTTPTokens(new(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) spec.SetLaunchspecInstanceMetadataOptions(opt) } } @@ -618,7 +618,7 @@ func (_ *LaunchSpec) update(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err spec.ResourceLimits = new(aws.ResourceLimits) } - spec.ResourceLimits.SetMinInstanceCount(fi.PtrTo(int(*e.MinSize))) + spec.ResourceLimits.SetMinInstanceCount(new(int(*e.MinSize))) changes.MinSize = nil changed = true } @@ -627,7 +627,7 @@ func (_ *LaunchSpec) update(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err spec.ResourceLimits = new(aws.ResourceLimits) } - spec.ResourceLimits.SetMaxInstanceCount(fi.PtrTo(int(*e.MaxSize))) + spec.ResourceLimits.SetMaxInstanceCount(new(int(*e.MaxSize))) changes.MaxSize = nil changed = true } @@ -671,7 +671,7 @@ func (_ *LaunchSpec) update(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err if len(userData) > 0 { encoded := base64.StdEncoding.EncodeToString([]byte(userData)) - spec.SetUserData(fi.PtrTo(encoded)) + spec.SetUserData(new(encoded)) changed = true } @@ -788,8 +788,8 @@ func (_ *LaunchSpec) update(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err labels := make([]*aws.Label, 0, len(e.AutoScalerOpts.Labels)) for k, v := range e.AutoScalerOpts.Labels { labels = append(labels, &aws.Label{ - Key: fi.PtrTo(k), - Value: fi.PtrTo(v), + Key: new(k), + Value: new(v), }) } @@ -803,9 +803,9 @@ func (_ *LaunchSpec) update(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err taints := make([]*aws.Taint, 0, len(e.AutoScalerOpts.Taints)) for _, taint := range e.AutoScalerOpts.Taints { taints = append(taints, &aws.Taint{ - Key: fi.PtrTo(taint.Key), - Value: fi.PtrTo(taint.Value), - Effect: fi.PtrTo(string(taint.Effect)), + Key: new(taint.Key), + Value: new(taint.Value), + Effect: new(string(taint.Effect)), }) } @@ -826,7 +826,7 @@ func (_ *LaunchSpec) update(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err spec.Strategy = new(aws.LaunchSpecStrategy) } - spec.Strategy.SetSpotPercentage(fi.PtrTo(int(fi.ValueOf(e.SpotPercentage)))) + spec.Strategy.SetSpotPercentage(new(int(fi.ValueOf(e.SpotPercentage)))) changes.SpotPercentage = nil changed = true } @@ -844,8 +844,8 @@ func (_ *LaunchSpec) update(cloud awsup.AWSCloud, a, e, changes *LaunchSpec) err { if changes.InstanceMetadataOptions != nil { opt := new(aws.LaunchspecInstanceMetadataOptions) - opt.SetHTTPPutResponseHopLimit(fi.PtrTo(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) - opt.SetHTTPTokens(fi.PtrTo(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) + opt.SetHTTPPutResponseHopLimit(new(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) + opt.SetHTTPTokens(new(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) spec.SetLaunchspecInstanceMetadataOptions(opt) changes.InstanceMetadataOptions = nil changed = true @@ -1048,12 +1048,12 @@ func (_ *LaunchSpec) RenderTerraform(t *terraform.TerraformTarget, a, e, changes tf.BlockDeviceMappings = append(tf.BlockDeviceMappings, &terraformBlockDeviceMapping{ DeviceName: rootDevice.DeviceName, EBS: &terraformBlockDeviceMappingEBS{ - VolumeType: fi.PtrTo(string(rootDevice.EbsVolumeType)), + VolumeType: new(string(rootDevice.EbsVolumeType)), VolumeSize: ptrInt32ToPtrInt64(rootDevice.EbsVolumeSize), VolumeIOPS: ptrInt32ToPtrInt64(rootDevice.EbsVolumeIops), VolumeThroughput: ptrInt32ToPtrInt64(rootDevice.EbsVolumeThroughput), Encrypted: rootDevice.EbsEncrypted, - DeleteOnTermination: fi.PtrTo(true), + DeleteOnTermination: new(true), }, }) } @@ -1090,8 +1090,8 @@ func (_ *LaunchSpec) RenderTerraform(t *terraform.TerraformTarget, a, e, changes tf.Labels = make([]*terraformKV, 0, len(opts.Labels)) for k, v := range opts.Labels { tf.Labels = append(tf.Labels, &terraformKV{ - Key: fi.PtrTo(k), - Value: fi.PtrTo(v), + Key: new(k), + Value: new(v), }) } } @@ -1101,11 +1101,11 @@ func (_ *LaunchSpec) RenderTerraform(t *terraform.TerraformTarget, a, e, changes tf.Taints = make([]*terraformTaint, len(opts.Taints)) for i, taint := range opts.Taints { t := &terraformTaint{ - Key: fi.PtrTo(taint.Key), - Effect: fi.PtrTo(string(taint.Effect)), + Key: new(taint.Key), + Effect: new(string(taint.Effect)), } if taint.Value != "" { - t.Value = fi.PtrTo(taint.Value) + t.Value = new(taint.Value) } tf.Taints[i] = t } @@ -1141,8 +1141,8 @@ func (o *LaunchSpec) buildTags() []*aws.Tag { for key, value := range o.Tags { tags = append(tags, &aws.Tag{ - Key: fi.PtrTo(key), - Value: fi.PtrTo(value), + Key: new(key), + Value: new(value), }) } @@ -1157,19 +1157,19 @@ func (o *LaunchSpec) convertBlockDeviceMapping(in *awstasks.BlockDeviceMapping) if in.EbsDeleteOnTermination != nil || in.EbsVolumeSize != nil || len(in.EbsVolumeType) > 0 { out.EBS = &aws.EBS{ - VolumeType: fi.PtrTo(string(in.EbsVolumeType)), - VolumeSize: fi.PtrTo(int(fi.ValueOf(in.EbsVolumeSize))), + VolumeType: new(string(in.EbsVolumeType)), + VolumeSize: new(int(fi.ValueOf(in.EbsVolumeSize))), DeleteOnTermination: in.EbsDeleteOnTermination, } // IOPS is not valid for gp2 volumes. if in.EbsVolumeIops != nil && in.EbsVolumeType != ec2types.VolumeTypeGp2 { - out.EBS.IOPS = fi.PtrTo(int(fi.ValueOf(in.EbsVolumeIops))) + out.EBS.IOPS = new(int(fi.ValueOf(in.EbsVolumeIops))) } // Throughput is only valid for gp3 volumes. if in.EbsVolumeThroughput != nil && in.EbsVolumeType == ec2types.VolumeTypeGp3 { - out.EBS.Throughput = fi.PtrTo(int(fi.ValueOf(in.EbsVolumeThroughput))) + out.EBS.Throughput = new(int(fi.ValueOf(in.EbsVolumeThroughput))) } } diff --git a/upup/pkg/fi/cloudup/spotinsttasks/ocean.go b/upup/pkg/fi/cloudup/spotinsttasks/ocean.go index edd6a144d5120..8e00099640e51 100644 --- a/upup/pkg/fi/cloudup/spotinsttasks/ocean.go +++ b/upup/pkg/fi/cloudup/spotinsttasks/ocean.go @@ -149,8 +149,8 @@ func (o *Ocean) Find(c *fi.CloudupContext) (*Ocean, error) { // Capacity. { if !fi.ValueOf(ocean.Compute.LaunchSpecification.UseAsTemplateOnly) { - actual.MinSize = fi.PtrTo(int64(fi.ValueOf(ocean.Capacity.Minimum))) - actual.MaxSize = fi.PtrTo(int64(fi.ValueOf(ocean.Capacity.Maximum))) + actual.MinSize = new(int64(fi.ValueOf(ocean.Capacity.Minimum))) + actual.MaxSize = new(int64(fi.ValueOf(ocean.Capacity.Maximum))) } } @@ -162,15 +162,15 @@ func (o *Ocean) Find(c *fi.CloudupContext) (*Ocean, error) { actual.UtilizeCommitments = strategy.UtilizeCommitments if strategy.DrainingTimeout != nil { - actual.DrainingTimeout = fi.PtrTo(int64(fi.ValueOf(strategy.DrainingTimeout))) + actual.DrainingTimeout = new(int64(fi.ValueOf(strategy.DrainingTimeout))) } if strategy.GracePeriod != nil { - actual.GracePeriod = fi.PtrTo(int64(fi.ValueOf(strategy.GracePeriod))) + actual.GracePeriod = new(int64(fi.ValueOf(strategy.GracePeriod))) } actual.SpreadNodesBy = strategy.SpreadNodesBy if strategy.ClusterOrientation != nil && strategy.ClusterOrientation.AvailabilityVsCost != nil { - actual.AvailabilityVsCost = fi.PtrTo(fi.ValueOf(strategy.ClusterOrientation.AvailabilityVsCost)) + actual.AvailabilityVsCost = new(fi.ValueOf(strategy.ClusterOrientation.AvailabilityVsCost)) } } } @@ -184,7 +184,7 @@ func (o *Ocean) Find(c *fi.CloudupContext) (*Ocean, error) { if subnets := compute.SubnetIDs; subnets != nil { for _, subnetID := range subnets { actual.Subnets = append(actual.Subnets, - &awstasks.Subnet{ID: fi.PtrTo(subnetID)}) + &awstasks.Subnet{ID: new(subnetID)}) } if subnetSlicesEqualIgnoreOrder(actual.Subnets, o.Subnets) { actual.Subnets = o.Subnets @@ -243,7 +243,7 @@ func (o *Ocean) Find(c *fi.CloudupContext) (*Ocean, error) { if lc.SecurityGroupIDs != nil { for _, sgID := range lc.SecurityGroupIDs { actual.SecurityGroups = append(actual.SecurityGroups, - &awstasks.SecurityGroup{ID: fi.PtrTo(sgID)}) + &awstasks.SecurityGroup{ID: new(sgID)}) } } } @@ -287,7 +287,7 @@ func (o *Ocean) Find(c *fi.CloudupContext) (*Ocean, error) { // Root volume options. if lc.RootVolumeSize != nil { actual.RootVolumeOpts = new(RootVolumeOpts) - actual.RootVolumeOpts.Size = fi.PtrTo(int64(*lc.RootVolumeSize)) + actual.RootVolumeOpts.Size = new(int64(*lc.RootVolumeSize)) } // Monitoring. @@ -303,13 +303,13 @@ func (o *Ocean) Find(c *fi.CloudupContext) (*Ocean, error) { // Instance Metadata Options if lc.InstanceMetadataOptions != nil { actual.InstanceMetadataOptions = new(InstanceMetadataOptions) - actual.InstanceMetadataOptions.HTTPTokens = fi.PtrTo(fi.ValueOf(lc.InstanceMetadataOptions.HTTPTokens)) - actual.InstanceMetadataOptions.HTTPPutResponseHopLimit = fi.PtrTo(int64(fi.ValueOf(lc.InstanceMetadataOptions.HTTPPutResponseHopLimit))) + actual.InstanceMetadataOptions.HTTPTokens = new(fi.ValueOf(lc.InstanceMetadataOptions.HTTPTokens)) + actual.InstanceMetadataOptions.HTTPPutResponseHopLimit = new(int64(fi.ValueOf(lc.InstanceMetadataOptions.HTTPPutResponseHopLimit))) } // if lc.ResourceTagSpecification != nil { - actual.ResourceTagSpecificationVolumes = fi.PtrTo(fi.ValueOf(lc.ResourceTagSpecification.Volumes.ShouldTag)) + actual.ResourceTagSpecificationVolumes = new(fi.ValueOf(lc.ResourceTagSpecification.Volumes.ShouldTag)) } } @@ -395,15 +395,15 @@ func (_ *Ocean) create(cloud awsup.AWSCloud, a, e, changes *Ocean) error { // General. { ocean.SetName(e.Name) - ocean.SetRegion(fi.PtrTo(cloud.Region())) + ocean.SetRegion(new(cloud.Region())) } // Capacity. { if !fi.ValueOf(e.UseAsTemplateOnly) { - ocean.Capacity.SetTarget(fi.PtrTo(int(*e.MinSize))) - ocean.Capacity.SetMinimum(fi.PtrTo(int(*e.MinSize))) - ocean.Capacity.SetMaximum(fi.PtrTo(int(*e.MaxSize))) + ocean.Capacity.SetTarget(new(int(*e.MinSize))) + ocean.Capacity.SetMinimum(new(int(*e.MinSize))) + ocean.Capacity.SetMaximum(new(int(*e.MaxSize))) } } @@ -414,16 +414,16 @@ func (_ *Ocean) create(cloud awsup.AWSCloud, a, e, changes *Ocean) error { ocean.Strategy.SetUtilizeCommitments(e.UtilizeCommitments) if e.DrainingTimeout != nil { - ocean.Strategy.SetDrainingTimeout(fi.PtrTo(int(*e.DrainingTimeout))) + ocean.Strategy.SetDrainingTimeout(new(int(*e.DrainingTimeout))) } if e.GracePeriod != nil { - ocean.Strategy.SetGracePeriod(fi.PtrTo(int(*e.GracePeriod))) + ocean.Strategy.SetGracePeriod(new(int(*e.GracePeriod))) } ocean.Strategy.SetSpreadNodesBy(e.SpreadNodesBy) if e.AvailabilityVsCost != nil { orientation := new(aws.ClusterOrientation) - ocean.Strategy.SetClusterOrientation(orientation.SetAvailabilityVsCost(fi.PtrTo(*e.AvailabilityVsCost))) + ocean.Strategy.SetClusterOrientation(orientation.SetAvailabilityVsCost(new(*e.AvailabilityVsCost))) } } @@ -490,8 +490,8 @@ func (_ *Ocean) create(cloud awsup.AWSCloud, a, e, changes *Ocean) error { { if e.InstanceMetadataOptions != nil { opt := new(aws.InstanceMetadataOptions) - opt.SetHTTPPutResponseHopLimit(fi.PtrTo(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) - opt.SetHTTPTokens(fi.PtrTo(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) + opt.SetHTTPPutResponseHopLimit(new(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) + opt.SetHTTPTokens(new(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) ocean.Compute.LaunchSpecification.SetInstanceMetadataOptions(opt) } } @@ -500,7 +500,7 @@ func (_ *Ocean) create(cloud awsup.AWSCloud, a, e, changes *Ocean) error { if e.ResourceTagSpecificationVolumes != nil { opt := new(aws.ResourceTagSpecification) vol := new(aws.Volumes) - vol.SetShouldTag(fi.PtrTo(fi.ValueOf(e.ResourceTagSpecificationVolumes))) + vol.SetShouldTag(new(fi.ValueOf(e.ResourceTagSpecificationVolumes))) opt.SetVolumes(vol) ocean.Compute.LaunchSpecification.SetResourceTagSpecification(opt) } @@ -516,7 +516,7 @@ func (_ *Ocean) create(cloud awsup.AWSCloud, a, e, changes *Ocean) error { if len(userData) > 0 { encoded := base64.StdEncoding.EncodeToString([]byte(userData)) - ocean.Compute.LaunchSpecification.SetUserData(fi.PtrTo(encoded)) + ocean.Compute.LaunchSpecification.SetUserData(new(encoded)) } } } @@ -536,7 +536,7 @@ func (_ *Ocean) create(cloud awsup.AWSCloud, a, e, changes *Ocean) error { // Volume size. if opts.Size != nil { - ocean.Compute.LaunchSpecification.SetRootVolumeSize(fi.PtrTo(int(*opts.Size))) + ocean.Compute.LaunchSpecification.SetRootVolumeSize(new(int(*opts.Size))) } // EBS optimization. @@ -598,7 +598,7 @@ func (_ *Ocean) create(cloud awsup.AWSCloud, a, e, changes *Ocean) error { if down := autoScaler.Down; down == nil { autoScaler.Down = new(aws.AutoScalerDown) } - autoScaler.Down.SetAggressiveScaleDown(aggressiveScaleDown.SetIsEnabled(fi.PtrTo(*e.AutoScalerAggressiveScaleDown))) + autoScaler.Down.SetAggressiveScaleDown(aggressiveScaleDown.SetIsEnabled(new(*e.AutoScalerAggressiveScaleDown))) } } @@ -705,7 +705,7 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error { ocean.Strategy = new(aws.Strategy) } - ocean.Strategy.SetDrainingTimeout(fi.PtrTo(int(*e.DrainingTimeout))) + ocean.Strategy.SetDrainingTimeout(new(int(*e.DrainingTimeout))) changes.DrainingTimeout = nil changed = true } @@ -716,7 +716,7 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error { ocean.Strategy = new(aws.Strategy) } - ocean.Strategy.SetGracePeriod(fi.PtrTo(int(*e.GracePeriod))) + ocean.Strategy.SetGracePeriod(new(int(*e.GracePeriod))) changes.GracePeriod = nil changed = true } @@ -738,7 +738,7 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error { } orientation := new(aws.ClusterOrientation) - ocean.Strategy.SetClusterOrientation(orientation.SetAvailabilityVsCost(fi.PtrTo(*changes.AvailabilityVsCost))) + ocean.Strategy.SetClusterOrientation(orientation.SetAvailabilityVsCost(new(*changes.AvailabilityVsCost))) changes.AvailabilityVsCost = nil changed = true } @@ -872,7 +872,7 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error { ocean.Compute.LaunchSpecification = new(aws.LaunchSpecification) } opt := new(aws.ResourceTagSpecification) - opt.Volumes.SetShouldTag(fi.PtrTo(fi.ValueOf(e.ResourceTagSpecificationVolumes))) + opt.Volumes.SetShouldTag(new(fi.ValueOf(e.ResourceTagSpecificationVolumes))) ocean.Compute.LaunchSpecification.SetResourceTagSpecification(opt) changes.ResourceTagSpecificationVolumes = nil changed = true @@ -920,8 +920,8 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error { } opt := new(aws.InstanceMetadataOptions) - opt.SetHTTPPutResponseHopLimit(fi.PtrTo(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) - opt.SetHTTPTokens(fi.PtrTo(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) + opt.SetHTTPPutResponseHopLimit(new(int(fi.ValueOf(e.InstanceMetadataOptions.HTTPPutResponseHopLimit)))) + opt.SetHTTPTokens(new(fi.ValueOf(e.InstanceMetadataOptions.HTTPTokens))) ocean.Compute.LaunchSpecification.SetInstanceMetadataOptions(opt) changes.InstanceMetadataOptions = nil changed = true @@ -946,7 +946,7 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error { } encoded := base64.StdEncoding.EncodeToString([]byte(userData)) - ocean.Compute.LaunchSpecification.SetUserData(fi.PtrTo(encoded)) + ocean.Compute.LaunchSpecification.SetUserData(new(encoded)) changed = true } @@ -1018,7 +1018,7 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error { ocean.Compute.LaunchSpecification = new(aws.LaunchSpecification) } - ocean.Compute.LaunchSpecification.SetRootVolumeSize(fi.PtrTo(int(*opts.Size))) + ocean.Compute.LaunchSpecification.SetRootVolumeSize(new(int(*opts.Size))) changed = true } @@ -1050,13 +1050,13 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error { ocean.Capacity = new(aws.Capacity) } - ocean.Capacity.SetMinimum(fi.PtrTo(int(*e.MinSize))) + ocean.Capacity.SetMinimum(new(int(*e.MinSize))) changes.MinSize = nil changed = true // Scale up the target capacity, if needed. if int64(*actual.Capacity.Target) < *e.MinSize { - ocean.Capacity.SetTarget(fi.PtrTo(int(*e.MinSize))) + ocean.Capacity.SetTarget(new(int(*e.MinSize))) } } if changes.MaxSize != nil { @@ -1064,7 +1064,7 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error { ocean.Capacity = new(aws.Capacity) } - ocean.Capacity.SetMaximum(fi.PtrTo(int(*e.MaxSize))) + ocean.Capacity.SetMaximum(new(int(*e.MaxSize))) changes.MaxSize = nil changed = true } @@ -1106,7 +1106,7 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error { if down := autoScaler.Down; down == nil { autoScaler.Down = new(aws.AutoScalerDown) } - autoScaler.Down.SetAggressiveScaleDown(aggressiveScaleDown.SetIsEnabled(fi.PtrTo(*changes.AutoScalerAggressiveScaleDown))) + autoScaler.Down.SetAggressiveScaleDown(aggressiveScaleDown.SetIsEnabled(new(*changes.AutoScalerAggressiveScaleDown))) changes.AutoScalerAggressiveScaleDown = nil } @@ -1184,7 +1184,7 @@ func (_ *Ocean) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *Oce tf := &terraformOcean{ Name: e.Name, - Region: fi.PtrTo(cloud.Region()), + Region: new(cloud.Region()), UseAsTemplateOnly: e.UseAsTemplateOnly, FallbackToOnDemand: e.FallbackToOnDemand, UtilizeReservedInstances: e.UtilizeReservedInstances, @@ -1360,8 +1360,8 @@ func (o *Ocean) buildTags() []*aws.Tag { for key, value := range o.Tags { tags = append(tags, &aws.Tag{ - Key: fi.PtrTo(key), - Value: fi.PtrTo(value), + Key: new(key), + Value: new(value), }) } @@ -1398,7 +1398,7 @@ func ptrInt32ToPtrInt64(i *int32) *int64 { return nil } v := int64(*i) - return fi.PtrTo(v) + return new(v) } func ptrInt64ToPtrInt32(i *int64) *int32 { @@ -1406,5 +1406,5 @@ func ptrInt64ToPtrInt32(i *int64) *int32 { return nil } v := int32(*i) - return fi.PtrTo(v) + return new(v) } diff --git a/upup/pkg/fi/cloudup/template_functions_karpenter.go b/upup/pkg/fi/cloudup/template_functions_karpenter.go index b1152a991fb84..554e0bf102b63 100644 --- a/upup/pkg/fi/cloudup/template_functions_karpenter.go +++ b/upup/pkg/fi/cloudup/template_functions_karpenter.go @@ -296,7 +296,7 @@ func (tf *TemplateFunctions) buildKarpenterNodePool(ig *kops.InstanceGroup) (*ka Template: template, } if ig.Spec.MinSize != nil && *ig.Spec.MinSize > 0 { - spec.Replicas = fi.PtrTo(int64(*ig.Spec.MinSize)) + spec.Replicas = new(int64(*ig.Spec.MinSize)) } if ig.Spec.MaxSize != nil { spec.Limits = &karpenterNodePoolLimits{Nodes: strconv.FormatInt(int64(*ig.Spec.MaxSize), 10)} @@ -355,9 +355,9 @@ func (tf *TemplateFunctions) karpenterAssociatePublicIP(ig *kops.InstanceGroup) if ig.Spec.AssociatePublicIP != nil { return ig.Spec.AssociatePublicIP, nil } - return fi.PtrTo(true), nil + return new(true), nil case kops.SubnetTypeDualStack, kops.SubnetTypePrivate: - return fi.PtrTo(false), nil + return new(false), nil default: return nil, fmt.Errorf("unknown subnet type %q for InstanceGroup %q", subnets[0].Type, ig.Name) } diff --git a/upup/pkg/fi/cloudup/template_functions_karpenter_test.go b/upup/pkg/fi/cloudup/template_functions_karpenter_test.go index 50047e860a467..447f281c6ed1b 100644 --- a/upup/pkg/fi/cloudup/template_functions_karpenter_test.go +++ b/upup/pkg/fi/cloudup/template_functions_karpenter_test.go @@ -41,18 +41,18 @@ func TestKarpenterNodePoolStaticCapacity(t *testing.T) { }, { desc: "static", - minSize: fi.PtrTo(int32(4)), + minSize: new(int32(4)), hasReplicas: true, }, { desc: "dynamic with maxSize", - maxSize: fi.PtrTo(int32(10)), + maxSize: new(int32(10)), limitsNodes: "10", }, { desc: "static with maxSize", - minSize: fi.PtrTo(int32(4)), - maxSize: fi.PtrTo(int32(10)), + minSize: new(int32(4)), + maxSize: new(int32(10)), hasReplicas: true, limitsNodes: "10", }, @@ -204,7 +204,7 @@ func TestKarpenterCapacityTypes(t *testing.T) { desc: "max price", ig: &kops.InstanceGroup{ Spec: kops.InstanceGroupSpec{ - MaxPrice: fi.PtrTo("0.10"), + MaxPrice: new("0.10"), }, }, expected: []string{"spot"}, @@ -214,7 +214,7 @@ func TestKarpenterCapacityTypes(t *testing.T) { ig: &kops.InstanceGroup{ Spec: kops.InstanceGroupSpec{ MixedInstancesPolicy: &kops.MixedInstancesPolicySpec{ - OnDemandAboveBase: fi.PtrTo(int64(50)), + OnDemandAboveBase: new(int64(50)), }, }, }, @@ -247,8 +247,8 @@ func TestBuildKarpenterKubeletConfiguration(t *testing.T) { }, { desc: "maxPods set", - kubelet: &kops.KubeletConfigSpec{MaxPods: fi.PtrTo(int32(50))}, - expected: &karpenterKubeletConfiguration{MaxPods: fi.PtrTo(int32(50))}, + kubelet: &kops.KubeletConfigSpec{MaxPods: new(int32(50))}, + expected: &karpenterKubeletConfiguration{MaxPods: new(int32(50))}, }, { desc: "systemReserved and kubeReserved set", @@ -264,12 +264,12 @@ func TestBuildKarpenterKubeletConfiguration(t *testing.T) { { desc: "all supported fields set", kubelet: &kops.KubeletConfigSpec{ - MaxPods: fi.PtrTo(int32(50)), + MaxPods: new(int32(50)), SystemReserved: map[string]string{"cpu": "500m"}, KubeReserved: map[string]string{"memory": "1G"}, }, expected: &karpenterKubeletConfiguration{ - MaxPods: fi.PtrTo(int32(50)), + MaxPods: new(int32(50)), SystemReserved: map[string]string{"cpu": "500m"}, KubeReserved: map[string]string{"memory": "1G"}, }, @@ -322,40 +322,40 @@ func TestKarpenterAssociatePublicIP(t *testing.T) { { desc: "public subnet defaults to true", subnets: []string{"public"}, - expected: fi.PtrTo(true), + expected: new(true), }, { desc: "utility subnet defaults to true", subnets: []string{"utility"}, - expected: fi.PtrTo(true), + expected: new(true), }, { desc: "public subnet honors explicit false", subnets: []string{"public"}, - associatePublicIP: fi.PtrTo(false), - expected: fi.PtrTo(false), + associatePublicIP: new(false), + expected: new(false), }, { desc: "public subnet honors explicit true", subnets: []string{"public"}, - associatePublicIP: fi.PtrTo(true), - expected: fi.PtrTo(true), + associatePublicIP: new(true), + expected: new(true), }, { desc: "private subnet is false", subnets: []string{"private"}, - expected: fi.PtrTo(false), + expected: new(false), }, { desc: "dualstack subnet is false", subnets: []string{"dualstack"}, - expected: fi.PtrTo(false), + expected: new(false), }, { desc: "private subnet ignores explicit true", subnets: []string{"private"}, - associatePublicIP: fi.PtrTo(true), - expected: fi.PtrTo(false), + associatePublicIP: new(true), + expected: new(false), }, { desc: "no subnets is an error", diff --git a/upup/pkg/fi/cloudup/template_functions_test.go b/upup/pkg/fi/cloudup/template_functions_test.go index 4422f3005ffb0..404446037a725 100644 --- a/upup/pkg/fi/cloudup/template_functions_test.go +++ b/upup/pkg/fi/cloudup/template_functions_test.go @@ -161,7 +161,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { Openstack: &kops.OpenstackSpec{}, }, ExternalCloudControllerManager: &kops.CloudControllerManagerConfig{ - AllocateNodeCIDRs: fi.PtrTo(true), + AllocateNodeCIDRs: new(true), }, }}, expectedArgv: []string{ @@ -179,7 +179,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { Openstack: &kops.OpenstackSpec{}, }, ExternalCloudControllerManager: &kops.CloudControllerManagerConfig{ - ConfigureCloudRoutes: fi.PtrTo(true), + ConfigureCloudRoutes: new(true), }, }}, expectedArgv: []string{ @@ -197,7 +197,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { Openstack: &kops.OpenstackSpec{}, }, ExternalCloudControllerManager: &kops.CloudControllerManagerConfig{ - CIDRAllocatorType: fi.PtrTo("RangeAllocator"), + CIDRAllocatorType: new("RangeAllocator"), }, }}, expectedArgv: []string{ @@ -215,7 +215,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { Openstack: &kops.OpenstackSpec{}, }, ExternalCloudControllerManager: &kops.CloudControllerManagerConfig{ - UseServiceAccountCredentials: fi.PtrTo(false), + UseServiceAccountCredentials: new(false), }, }}, expectedArgv: []string{ @@ -232,7 +232,7 @@ func Test_TemplateFunctions_CloudControllerConfigArgv(t *testing.T) { Openstack: &kops.OpenstackSpec{}, }, ExternalCloudControllerManager: &kops.CloudControllerManagerConfig{ - LeaderElection: &kops.LeaderElectionConfiguration{LeaderElect: fi.PtrTo(true)}, + LeaderElection: &kops.LeaderElectionConfiguration{LeaderElect: new(true)}, }, }}, expectedArgv: []string{ @@ -451,12 +451,12 @@ func TestTemplateFunctions_TaskHelpers(t *testing.T) { tf.Cluster = &kops.Cluster{} tf.tasks = map[string]fi.CloudupTask{ "ManagedFile/zeta": &fitasks.ManagedFile{ - Name: fi.PtrTo("zeta"), - Location: fi.PtrTo("addons/zeta.yaml"), + Name: new("zeta"), + Location: new("addons/zeta.yaml"), }, "ManagedFile/alpha": &fitasks.ManagedFile{ - Name: fi.PtrTo("alpha"), - Location: fi.PtrTo("addons/alpha.yaml"), + Name: new("alpha"), + Location: new("addons/alpha.yaml"), }, } @@ -529,8 +529,8 @@ func TestGetClusterAutoscalerNodeGroupsGCE(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: name}, Spec: kops.InstanceGroupSpec{ Role: kops.InstanceGroupRoleNode, - MinSize: fi.PtrTo(minSize), - MaxSize: fi.PtrTo(maxSize), + MinSize: new(minSize), + MaxSize: new(maxSize), Zones: zones, }, } diff --git a/upup/pkg/fi/cloudup/validation_test.go b/upup/pkg/fi/cloudup/validation_test.go index 4c70ecde488c4..bd3cc1e024f3e 100644 --- a/upup/pkg/fi/cloudup/validation_test.go +++ b/upup/pkg/fi/cloudup/validation_test.go @@ -25,7 +25,6 @@ import ( "k8s.io/klog/v2" api "k8s.io/kops/pkg/apis/kops" "k8s.io/kops/pkg/apis/kops/validation" - "k8s.io/kops/upup/pkg/fi" "k8s.io/kops/util/pkg/vfs" ) @@ -124,11 +123,11 @@ func TestValidateFull_UpdatePolicy_Valid(t *testing.T) { }, { label: "automatic", - policy: fi.PtrTo(api.UpdatePolicyAutomatic), + policy: new(api.UpdatePolicyAutomatic), }, { label: "external", - policy: fi.PtrTo(api.UpdatePolicyExternal), + policy: new(api.UpdatePolicyExternal), }, } { t.Run(test.label, func(t *testing.T) { diff --git a/upup/pkg/fi/dryruntarget_test.go b/upup/pkg/fi/dryruntarget_test.go index a2f3f394da985..9af81c23b3a86 100644 --- a/upup/pkg/fi/dryruntarget_test.go +++ b/upup/pkg/fi/dryruntarget_test.go @@ -73,12 +73,12 @@ func Test_DryrunTarget_PrintReport(t *testing.T) { target := newDryRunTarget[CloudupSubContext](builder, checkExisting, &stdout) tasks := map[string]CloudupTask{} a := &testTask{ - Name: PtrTo("TestName"), + Name: new("TestName"), Lifecycle: LifecycleSync, Tags: map[string]string{"key": "value"}, } e := &testTask{ - Name: PtrTo("TestName"), + Name: new("TestName"), Lifecycle: LifecycleSync, Tags: map[string]string{"key": "value"}, } diff --git a/upup/pkg/fi/fitasks/keypair_test.go b/upup/pkg/fi/fitasks/keypair_test.go index 430a24ecac8c2..9064725789c9c 100644 --- a/upup/pkg/fi/fitasks/keypair_test.go +++ b/upup/pkg/fi/fitasks/keypair_test.go @@ -25,10 +25,10 @@ import ( func TestKeypairDeps(t *testing.T) { ca := &Keypair{ - Name: fi.PtrTo("ca"), + Name: new("ca"), } cert := &Keypair{ - Name: fi.PtrTo("cert"), + Name: new("cert"), Signer: ca, } diff --git a/upup/pkg/fi/fitasks/managedfile.go b/upup/pkg/fi/fitasks/managedfile.go index 5098c7d9d7cef..c9a93c42c83d3 100644 --- a/upup/pkg/fi/fitasks/managedfile.go +++ b/upup/pkg/fi/fitasks/managedfile.go @@ -87,7 +87,7 @@ func (e *ManagedFile) Find(c *fi.CloudupContext) (*ManagedFile, error) { actual.PublicACL = &public if e.PublicACL == nil { - e.PublicACL = fi.PtrTo(false) + e.PublicACL = new(false) } } @@ -99,7 +99,7 @@ func (e *ManagedFile) Find(c *fi.CloudupContext) (*ManagedFile, error) { actual.PublicACL = &public if e.PublicACL == nil { - e.PublicACL = fi.PtrTo(false) + e.PublicACL = new(false) } } diff --git a/upup/pkg/fi/nodeup/command.go b/upup/pkg/fi/nodeup/command.go index b2d44ea009c1e..062c80894bac3 100644 --- a/upup/pkg/fi/nodeup/command.go +++ b/upup/pkg/fi/nodeup/command.go @@ -444,7 +444,7 @@ func completeWarmingLifecycleAction(ctx context.Context, cloud awsup.AWSCloud, m AutoScalingGroupName: &asgName, InstanceId: &modelContext.InstanceID, LifecycleHookName: &hookName, - LifecycleActionResult: fi.PtrTo("CONTINUE"), + LifecycleActionResult: new("CONTINUE"), }) if err != nil { return fmt.Errorf("failed to complete lifecycle hook %q for %q: %v", hookName, modelContext.InstanceID, err) diff --git a/upup/pkg/fi/nodeup/nodetasks/bindmount.go b/upup/pkg/fi/nodeup/nodetasks/bindmount.go index ed7767571cf54..fb835facaf6af 100644 --- a/upup/pkg/fi/nodeup/nodetasks/bindmount.go +++ b/upup/pkg/fi/nodeup/nodetasks/bindmount.go @@ -51,7 +51,7 @@ func (e *BindMount) Dir() string { var _ fi.HasName = (*BindMount)(nil) func (e *BindMount) GetName() *string { - return fi.PtrTo("BindMount-" + e.Mountpoint) + return new("BindMount-" + e.Mountpoint) } var _ fi.NodeupHasDependencies = (*BindMount)(nil) diff --git a/upup/pkg/fi/nodeup/nodetasks/chattr.go b/upup/pkg/fi/nodeup/nodetasks/chattr.go index 205321fbe8eb8..d24dc356dafef 100644 --- a/upup/pkg/fi/nodeup/nodetasks/chattr.go +++ b/upup/pkg/fi/nodeup/nodetasks/chattr.go @@ -42,7 +42,7 @@ func (s *Chattr) String() string { var _ fi.HasName = (*Chattr)(nil) func (e *Chattr) GetName() *string { - return fi.PtrTo("Chattr-" + e.File) + return new("Chattr-" + e.File) } var _ fi.NodeupHasDependencies = (*Chattr)(nil) diff --git a/upup/pkg/fi/nodeup/nodetasks/file.go b/upup/pkg/fi/nodeup/nodetasks/file.go index 28fc6b1e247d0..e1cec8f72e11b 100644 --- a/upup/pkg/fi/nodeup/nodetasks/file.go +++ b/upup/pkg/fi/nodeup/nodetasks/file.go @@ -134,7 +134,7 @@ func findFile(p string) (*File, error) { actual := &File{} actual.Path = p - actual.Mode = fi.PtrTo(fi.FileModeToString(stat.Mode() & os.ModePerm)) + actual.Mode = new(fi.FileModeToString(stat.Mode() & os.ModePerm)) uid := int(stat.Sys().(*syscall.Stat_t).Uid) owner, err := fi.LookupUserByID(uid) @@ -142,9 +142,9 @@ func findFile(p string) (*File, error) { return nil, err } if owner != nil { - actual.Owner = fi.PtrTo(owner.Name) + actual.Owner = new(owner.Name) } else { - actual.Owner = fi.PtrTo(strconv.Itoa(uid)) + actual.Owner = new(strconv.Itoa(uid)) } gid := int(stat.Sys().(*syscall.Stat_t).Gid) @@ -153,9 +153,9 @@ func findFile(p string) (*File, error) { return nil, err } if group != nil { - actual.Group = fi.PtrTo(group.Name) + actual.Group = new(group.Name) } else { - actual.Group = fi.PtrTo(strconv.Itoa(gid)) + actual.Group = new(strconv.Itoa(gid)) } if (stat.Mode() & os.ModeSymlink) != 0 { @@ -165,7 +165,7 @@ func findFile(p string) (*File, error) { } actual.Type = FileType_Symlink - actual.Symlink = fi.PtrTo(target) + actual.Symlink = new(target) } else if (stat.Mode() & os.ModeDir) != 0 { actual.Type = FileType_Directory } else { diff --git a/upup/pkg/fi/nodeup/nodetasks/file_test.go b/upup/pkg/fi/nodeup/nodetasks/file_test.go index 2f77760da8ffc..5e32aef72c2ac 100644 --- a/upup/pkg/fi/nodeup/nodetasks/file_test.go +++ b/upup/pkg/fi/nodeup/nodetasks/file_test.go @@ -40,7 +40,7 @@ func TestFileDependencies(t *testing.T) { Home: "/home/owner", }, child: &File{ - Owner: fi.PtrTo("owner"), + Owner: new("owner"), Path: childFileName, Contents: fi.NewStringResource("I depend on an owner"), Type: FileType_File, diff --git a/upup/pkg/fi/nodeup/nodetasks/issue_cert.go b/upup/pkg/fi/nodeup/nodetasks/issue_cert.go index 82f4620da7243..2f11389c23cc9 100644 --- a/upup/pkg/fi/nodeup/nodetasks/issue_cert.go +++ b/upup/pkg/fi/nodeup/nodetasks/issue_cert.go @@ -92,14 +92,14 @@ func (i *IssueCert) AddFileTasks(c *fi.NodeupModelBuilderContext, dir string, na c.EnsureTask(&File{ Path: dir, Type: FileType_Directory, - Mode: fi.PtrTo("0755"), + Mode: new("0755"), }) c.AddTask(&File{ Path: filepath.Join(dir, name+".crt"), Contents: certResource, Type: FileType_File, - Mode: fi.PtrTo("0644"), + Mode: new("0644"), Owner: owner, }) @@ -107,7 +107,7 @@ func (i *IssueCert) AddFileTasks(c *fi.NodeupModelBuilderContext, dir string, na Path: filepath.Join(dir, name+".key"), Contents: keyResource, Type: FileType_File, - Mode: fi.PtrTo("0600"), + Mode: new("0600"), Owner: owner, }) @@ -116,7 +116,7 @@ func (i *IssueCert) AddFileTasks(c *fi.NodeupModelBuilderContext, dir string, na Path: filepath.Join(dir, caName+".crt"), Contents: caResource, Type: FileType_File, - Mode: fi.PtrTo("0644"), + Mode: new("0644"), Owner: owner, }) } diff --git a/upup/pkg/fi/nodeup/nodetasks/package.go b/upup/pkg/fi/nodeup/nodetasks/package.go index 425f811821fca..28f7bf05c31f8 100644 --- a/upup/pkg/fi/nodeup/nodetasks/package.go +++ b/upup/pkg/fi/nodeup/nodetasks/package.go @@ -178,11 +178,11 @@ func (e *Package) findDpkg(c *fi.NodeupContext) (*Package, error) { case "ii": installed = true installedVersion = version - healthy = fi.PtrTo(true) + healthy = new(true) case "iF", "iU": installed = true installedVersion = version - healthy = fi.PtrTo(false) + healthy = new(false) case "rc": // removed installed = false @@ -204,7 +204,7 @@ func (e *Package) findDpkg(c *fi.NodeupContext) (*Package, error) { return &Package{ Name: e.Name, - Version: fi.PtrTo(installedVersion), + Version: new(installedVersion), Healthy: healthy, }, nil } @@ -243,7 +243,7 @@ func (e *Package) findYum(c *fi.NodeupContext) (*Package, error) { installed = true installedVersion = tokens[1] // If we implement unhealthy; be sure to implement repair in Render - healthy = fi.PtrTo(true) + healthy = new(true) } if !installed { @@ -252,7 +252,7 @@ func (e *Package) findYum(c *fi.NodeupContext) (*Package, error) { return &Package{ Name: e.Name, - Version: fi.PtrTo(installedVersion), + Version: new(installedVersion), Healthy: healthy, }, nil } diff --git a/upup/pkg/fi/nodeup/nodetasks/prefix.go b/upup/pkg/fi/nodeup/nodetasks/prefix.go index 17f36e8b5924a..b8d0810b2bbb5 100644 --- a/upup/pkg/fi/nodeup/nodetasks/prefix.go +++ b/upup/pkg/fi/nodeup/nodetasks/prefix.go @@ -97,8 +97,8 @@ func (_ *Prefix) RenderLocal(t *local.LocalTarget, a, e, changes *Prefix) error } response, err := t.Cloud.(awsup.AWSCloud).EC2().AssignIpv6Addresses(ctx, &ec2.AssignIpv6AddressesInput{ - Ipv6PrefixCount: fi.PtrTo(int32(1)), - NetworkInterfaceId: fi.PtrTo(interfaceId), + Ipv6PrefixCount: new(int32(1)), + NetworkInterfaceId: new(interfaceId), }) if err != nil { return fmt.Errorf("failed to assign prefix: %w", err) diff --git a/upup/pkg/fi/nodeup/nodetasks/service.go b/upup/pkg/fi/nodeup/nodetasks/service.go index e2d3c791b2474..0f3e28b8cba47 100644 --- a/upup/pkg/fi/nodeup/nodetasks/service.go +++ b/upup/pkg/fi/nodeup/nodetasks/service.go @@ -125,13 +125,13 @@ func (i *InstallService) InitDefaults() *InstallService { func (s *Service) InitDefaults() *Service { // Default some values to true: Running, SmartRestart, ManageState if s.Running == nil { - s.Running = fi.PtrTo(true) + s.Running = new(true) } if s.SmartRestart == nil { - s.SmartRestart = fi.PtrTo(true) + s.SmartRestart = new(true) } if s.ManageState == nil { - s.ManageState = fi.PtrTo(true) + s.ManageState = new(true) } // Default Enabled to be the same as running @@ -208,13 +208,13 @@ func (e *Service) Find(_ *fi.NodeupContext) (*Service, error) { return &Service{ Name: e.Name, Definition: nil, - Running: fi.PtrTo(false), + Running: new(false), }, nil } actual := &Service{ Name: e.Name, - Definition: fi.PtrTo(string(d)), + Definition: new(string(d)), // Avoid spurious changes ManageState: e.ManageState, @@ -229,27 +229,27 @@ func (e *Service) Find(_ *fi.NodeupContext) (*Service, error) { activeState := properties["ActiveState"] switch activeState { case "active": - actual.Running = fi.PtrTo(true) + actual.Running = new(true) case "failed", "inactive": - actual.Running = fi.PtrTo(false) + actual.Running = new(false) default: klog.Warningf("Unknown ActiveState=%q; will treat as not running", activeState) - actual.Running = fi.PtrTo(false) + actual.Running = new(false) } wantedBy := properties["WantedBy"] switch wantedBy { case "": - actual.Enabled = fi.PtrTo(false) + actual.Enabled = new(false) // TODO: Can probably do better here! case "multi-user.target", "graphical.target multi-user.target": - actual.Enabled = fi.PtrTo(true) + actual.Enabled = new(true) default: klog.Warningf("Unknown WantedBy=%q; will treat as not enabled", wantedBy) - actual.Enabled = fi.PtrTo(false) + actual.Enabled = new(false) } return actual, nil diff --git a/upup/pkg/fi/values.go b/upup/pkg/fi/values.go index b6d4d2ef7ae9c..8247c3f00eb84 100644 --- a/upup/pkg/fi/values.go +++ b/upup/pkg/fi/values.go @@ -23,11 +23,6 @@ import ( "strconv" ) -// PtrTo returns a pointer to a copy of any value. -func PtrTo[T any](v T) *T { - return &v -} - // ValueOf returns the value of a pointer or its zero value func ValueOf[T any](v *T) T { if v == nil { diff --git a/util/pkg/env/standard_test.go b/util/pkg/env/standard_test.go index 2916dae9eaead..0eab14fe67e4c 100644 --- a/util/pkg/env/standard_test.go +++ b/util/pkg/env/standard_test.go @@ -20,7 +20,6 @@ import ( "testing" "k8s.io/kops/pkg/apis/kops" - "k8s.io/kops/upup/pkg/fi" ) func TestBuildSystemComponentEnvVars(t *testing.T) { @@ -94,7 +93,7 @@ func TestBuildSystemComponentEnvVars(t *testing.T) { spec: &kops.ClusterSpec{ CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ - InsecureSkipVerify: fi.PtrTo(false), + InsecureSkipVerify: new(false), }, }, }, @@ -106,7 +105,7 @@ func TestBuildSystemComponentEnvVars(t *testing.T) { spec: &kops.ClusterSpec{ CloudProvider: kops.CloudProviderSpec{ Openstack: &kops.OpenstackSpec{ - InsecureSkipVerify: fi.PtrTo(true), + InsecureSkipVerify: new(true), }, }, },