Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions channels/pkg/channels/addons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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,
},
}
Expand Down Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand Down Expand Up @@ -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,
},
}
Expand Down
3 changes: 1 addition & 2 deletions channels/pkg/cmd/apply_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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",
},
Expand Down
3 changes: 1 addition & 2 deletions cloudmock/openstack/mockcompute/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions clusterapi/pkg/builders/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 1 addition & 2 deletions cmd/kops-controller/controllers/awsipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
},
Expand Down
12 changes: 6 additions & 6 deletions cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}

Expand All @@ -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)
}
}

Expand All @@ -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)
}
}

Expand All @@ -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 != "" {
Expand All @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/kops/get_keypairs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions examples/kops-api-example/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion nodeup/pkg/bootstrap/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions nodeup/pkg/model/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions nodeup/pkg/model/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
36 changes: 18 additions & 18 deletions nodeup/pkg/model/containerd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
2 changes: 1 addition & 1 deletion nodeup/pkg/model/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
})
}

Expand Down
6 changes: 2 additions & 4 deletions nodeup/pkg/model/convenience.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nodeup/pkg/model/etcd_manager_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
})

}
Expand Down
8 changes: 4 additions & 4 deletions nodeup/pkg/model/gvisor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading
Loading