types/ptr: deprecate ptr.To, use Go 1.26 new
Updates #18682 Change-Id: I62f6aa0de2a15ef8c1435032c6aa74a181c25f8f Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
8cfbaa717d
commit
2a64c03c95
@@ -36,7 +36,6 @@ import (
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/tstest"
|
||||
"tailscale.com/types/opt"
|
||||
"tailscale.com/types/ptr"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -49,7 +48,7 @@ var (
|
||||
"some-annotation": "from-the-proxy-class",
|
||||
}
|
||||
|
||||
defaultReplicas = ptr.To(int32(2))
|
||||
defaultReplicas = new(int32(2))
|
||||
defaultStaticEndpointConfig = &tsapi.StaticEndpointsConfig{
|
||||
NodePort: &tsapi.NodePortConfig{
|
||||
Ports: []tsapi.PortRange{
|
||||
@@ -107,7 +106,7 @@ func TestProxyGroupWithStaticEndpoints(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
replicas: ptr.To(int32(4)),
|
||||
replicas: new(int32(4)),
|
||||
nodes: []testNode{
|
||||
{
|
||||
name: "foobar",
|
||||
@@ -150,7 +149,7 @@ func TestProxyGroupWithStaticEndpoints(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
replicas: ptr.To(int32(4)),
|
||||
replicas: new(int32(4)),
|
||||
nodes: []testNode{
|
||||
{
|
||||
name: "foobar",
|
||||
@@ -192,7 +191,7 @@ func TestProxyGroupWithStaticEndpoints(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
replicas: ptr.To(int32(4)),
|
||||
replicas: new(int32(4)),
|
||||
nodes: []testNode{
|
||||
{
|
||||
name: "foobar",
|
||||
@@ -234,7 +233,7 @@ func TestProxyGroupWithStaticEndpoints(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
replicas: ptr.To(int32(3)),
|
||||
replicas: new(int32(3)),
|
||||
nodes: []testNode{
|
||||
{name: "node1", addresses: []testNodeAddr{{ip: "10.0.0.1", addrType: corev1.NodeExternalIP}}, labels: map[string]string{"foo/bar": "baz"}},
|
||||
{name: "node2", addresses: []testNodeAddr{{ip: "10.0.0.2", addrType: corev1.NodeExternalIP}}, labels: map[string]string{"foo/bar": "baz"}},
|
||||
@@ -294,7 +293,7 @@ func TestProxyGroupWithStaticEndpoints(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
replicas: ptr.To(int32(4)),
|
||||
replicas: new(int32(4)),
|
||||
nodes: []testNode{
|
||||
{
|
||||
name: "foobar",
|
||||
@@ -942,7 +941,7 @@ func TestProxyGroup(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("scale_up_to_3", func(t *testing.T) {
|
||||
pg.Spec.Replicas = ptr.To[int32](3)
|
||||
pg.Spec.Replicas = new(int32(3))
|
||||
mustUpdate(t, fc, "", pg.Name, func(p *tsapi.ProxyGroup) {
|
||||
p.Spec = pg.Spec
|
||||
})
|
||||
@@ -965,7 +964,7 @@ func TestProxyGroup(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("scale_down_to_1", func(t *testing.T) {
|
||||
pg.Spec.Replicas = ptr.To[int32](1)
|
||||
pg.Spec.Replicas = new(int32(1))
|
||||
mustUpdate(t, fc, "", pg.Name, func(p *tsapi.ProxyGroup) {
|
||||
p.Spec = pg.Spec
|
||||
})
|
||||
@@ -1062,7 +1061,7 @@ func TestProxyGroupTypes(t *testing.T) {
|
||||
},
|
||||
Spec: tsapi.ProxyGroupSpec{
|
||||
Type: tsapi.ProxyGroupTypeEgress,
|
||||
Replicas: ptr.To[int32](0),
|
||||
Replicas: new(int32(0)),
|
||||
},
|
||||
}
|
||||
mustCreate(t, fc, pg)
|
||||
@@ -1137,7 +1136,7 @@ func TestProxyGroupTypes(t *testing.T) {
|
||||
},
|
||||
Spec: tsapi.ProxyGroupSpec{
|
||||
Type: tsapi.ProxyGroupTypeEgress,
|
||||
Replicas: ptr.To[int32](0),
|
||||
Replicas: new(int32(0)),
|
||||
ProxyClass: "test",
|
||||
},
|
||||
}
|
||||
@@ -1174,7 +1173,7 @@ func TestProxyGroupTypes(t *testing.T) {
|
||||
},
|
||||
Spec: tsapi.ProxyGroupSpec{
|
||||
Type: tsapi.ProxyGroupTypeIngress,
|
||||
Replicas: ptr.To[int32](0),
|
||||
Replicas: new(int32(0)),
|
||||
},
|
||||
}
|
||||
if err := fc.Create(t.Context(), pg); err != nil {
|
||||
@@ -1228,9 +1227,9 @@ func TestProxyGroupTypes(t *testing.T) {
|
||||
},
|
||||
Spec: tsapi.ProxyGroupSpec{
|
||||
Type: tsapi.ProxyGroupTypeKubernetesAPIServer,
|
||||
Replicas: ptr.To[int32](2),
|
||||
Replicas: new(int32(2)),
|
||||
KubeAPIServer: &tsapi.KubeAPIServerConfig{
|
||||
Mode: ptr.To(tsapi.APIServerProxyModeNoAuth),
|
||||
Mode: new(tsapi.APIServerProxyModeNoAuth),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1268,9 +1267,9 @@ func TestKubeAPIServerStatusConditionFlow(t *testing.T) {
|
||||
},
|
||||
Spec: tsapi.ProxyGroupSpec{
|
||||
Type: tsapi.ProxyGroupTypeKubernetesAPIServer,
|
||||
Replicas: ptr.To[int32](1),
|
||||
Replicas: new(int32(1)),
|
||||
KubeAPIServer: &tsapi.KubeAPIServerConfig{
|
||||
Mode: ptr.To(tsapi.APIServerProxyModeNoAuth),
|
||||
Mode: new(tsapi.APIServerProxyModeNoAuth),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1354,9 +1353,9 @@ func TestKubeAPIServerType_DoesNotOverwriteServicesConfig(t *testing.T) {
|
||||
},
|
||||
Spec: tsapi.ProxyGroupSpec{
|
||||
Type: tsapi.ProxyGroupTypeKubernetesAPIServer,
|
||||
Replicas: ptr.To[int32](1),
|
||||
Replicas: new(int32(1)),
|
||||
KubeAPIServer: &tsapi.KubeAPIServerConfig{
|
||||
Mode: ptr.To(tsapi.APIServerProxyModeNoAuth), // Avoid needing to pre-create the static ServiceAccount.
|
||||
Mode: new(tsapi.APIServerProxyModeNoAuth), // Avoid needing to pre-create the static ServiceAccount.
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1368,18 +1367,18 @@ func TestKubeAPIServerType_DoesNotOverwriteServicesConfig(t *testing.T) {
|
||||
cfg := conf.VersionedConfig{
|
||||
Version: "v1alpha1",
|
||||
ConfigV1Alpha1: &conf.ConfigV1Alpha1{
|
||||
AuthKey: ptr.To("secret-authkey"),
|
||||
State: ptr.To(fmt.Sprintf("kube:%s", pgPodName(pg.Name, 0))),
|
||||
App: ptr.To(kubetypes.AppProxyGroupKubeAPIServer),
|
||||
LogLevel: ptr.To("debug"),
|
||||
AuthKey: new("secret-authkey"),
|
||||
State: new(fmt.Sprintf("kube:%s", pgPodName(pg.Name, 0))),
|
||||
App: new(kubetypes.AppProxyGroupKubeAPIServer),
|
||||
LogLevel: new("debug"),
|
||||
|
||||
Hostname: ptr.To("test-k8s-apiserver-0"),
|
||||
Hostname: new("test-k8s-apiserver-0"),
|
||||
APIServerProxy: &conf.APIServerProxyConfig{
|
||||
Enabled: opt.NewBool(true),
|
||||
Mode: ptr.To(kubetypes.APIServerProxyModeNoAuth),
|
||||
Mode: new(kubetypes.APIServerProxyModeNoAuth),
|
||||
IssueCerts: opt.NewBool(true),
|
||||
},
|
||||
LocalPort: ptr.To(uint16(9002)),
|
||||
LocalPort: new(uint16(9002)),
|
||||
HealthCheckEnabled: opt.NewBool(true),
|
||||
},
|
||||
}
|
||||
@@ -1403,7 +1402,7 @@ func TestKubeAPIServerType_DoesNotOverwriteServicesConfig(t *testing.T) {
|
||||
|
||||
// Now simulate the kube-apiserver services reconciler updating config,
|
||||
// then check the proxygroup reconciler doesn't overwrite it.
|
||||
cfg.APIServerProxy.ServiceName = ptr.To(tailcfg.ServiceName("svc:some-svc-name"))
|
||||
cfg.APIServerProxy.ServiceName = new(tailcfg.ServiceName("svc:some-svc-name"))
|
||||
cfg.AdvertiseServices = []string{"svc:should-not-be-overwritten"}
|
||||
cfgB, err = json.Marshal(cfg)
|
||||
if err != nil {
|
||||
@@ -1459,7 +1458,7 @@ func TestIngressAdvertiseServicesConfigPreserved(t *testing.T) {
|
||||
},
|
||||
Spec: tsapi.ProxyGroupSpec{
|
||||
Type: tsapi.ProxyGroupTypeIngress,
|
||||
Replicas: ptr.To[int32](1),
|
||||
Replicas: new(int32(1)),
|
||||
},
|
||||
})
|
||||
expectReconciled(t, reconciler, "", pgName)
|
||||
@@ -1473,7 +1472,7 @@ func TestIngressAdvertiseServicesConfigPreserved(t *testing.T) {
|
||||
AcceptDNS: "false",
|
||||
AcceptRoutes: "false",
|
||||
Locked: "false",
|
||||
Hostname: ptr.To(fmt.Sprintf("%s-%d", pgName, 0)),
|
||||
Hostname: new(fmt.Sprintf("%s-%d", pgName, 0)),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -1609,7 +1608,7 @@ func TestValidateProxyGroup(t *testing.T) {
|
||||
}
|
||||
if tc.noauth {
|
||||
pg.Spec.KubeAPIServer = &tsapi.KubeAPIServerConfig{
|
||||
Mode: ptr.To(tsapi.APIServerProxyModeNoAuth),
|
||||
Mode: new(tsapi.APIServerProxyModeNoAuth),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1875,7 +1874,7 @@ func TestProxyGroupLetsEncryptStaging(t *testing.T) {
|
||||
},
|
||||
Spec: tsapi.ProxyGroupSpec{
|
||||
Type: tt.pgType,
|
||||
Replicas: ptr.To[int32](1),
|
||||
Replicas: new(int32(1)),
|
||||
ProxyClass: tt.proxyClassPerResource,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user