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
@@ -25,7 +25,6 @@ import (
|
||||
tsapi "tailscale.com/k8s-operator/apis/v1alpha1"
|
||||
"tailscale.com/kube/kubetypes"
|
||||
"tailscale.com/tstest"
|
||||
"tailscale.com/types/ptr"
|
||||
"tailscale.com/util/mak"
|
||||
)
|
||||
|
||||
@@ -59,7 +58,7 @@ func TestTailscaleIngress(t *testing.T) {
|
||||
|
||||
fullName, shortName := findGenName(t, fc, "default", "test", "ingress")
|
||||
opts := configOpts{
|
||||
replicas: ptr.To[int32](1),
|
||||
replicas: new(int32(1)),
|
||||
stsName: shortName,
|
||||
secretName: fullName,
|
||||
namespace: "default",
|
||||
@@ -109,7 +108,7 @@ func TestTailscaleIngress(t *testing.T) {
|
||||
|
||||
// 4. Resources get cleaned up when Ingress class is unset
|
||||
mustUpdate(t, fc, "default", "test", func(ing *networkingv1.Ingress) {
|
||||
ing.Spec.IngressClassName = ptr.To("nginx")
|
||||
ing.Spec.IngressClassName = new("nginx")
|
||||
})
|
||||
expectReconciled(t, ingR, "default", "test")
|
||||
expectReconciled(t, ingR, "default", "test") // deleting Ingress STS requires two reconciles
|
||||
@@ -639,7 +638,7 @@ func TestEmptyPath(t *testing.T) {
|
||||
name: "empty_path_with_prefix_type",
|
||||
paths: []networkingv1.HTTPIngressPath{
|
||||
{
|
||||
PathType: ptrPathType(networkingv1.PathTypePrefix),
|
||||
PathType: new(networkingv1.PathTypePrefix),
|
||||
Path: "",
|
||||
Backend: *backend(),
|
||||
},
|
||||
@@ -652,7 +651,7 @@ func TestEmptyPath(t *testing.T) {
|
||||
name: "empty_path_with_implementation_specific_type",
|
||||
paths: []networkingv1.HTTPIngressPath{
|
||||
{
|
||||
PathType: ptrPathType(networkingv1.PathTypeImplementationSpecific),
|
||||
PathType: new(networkingv1.PathTypeImplementationSpecific),
|
||||
Path: "",
|
||||
Backend: *backend(),
|
||||
},
|
||||
@@ -665,7 +664,7 @@ func TestEmptyPath(t *testing.T) {
|
||||
name: "empty_path_with_exact_type",
|
||||
paths: []networkingv1.HTTPIngressPath{
|
||||
{
|
||||
PathType: ptrPathType(networkingv1.PathTypeExact),
|
||||
PathType: new(networkingv1.PathTypeExact),
|
||||
Path: "",
|
||||
Backend: *backend(),
|
||||
},
|
||||
@@ -679,12 +678,12 @@ func TestEmptyPath(t *testing.T) {
|
||||
name: "two_competing_but_not_identical_paths_including_one_empty",
|
||||
paths: []networkingv1.HTTPIngressPath{
|
||||
{
|
||||
PathType: ptrPathType(networkingv1.PathTypeImplementationSpecific),
|
||||
PathType: new(networkingv1.PathTypeImplementationSpecific),
|
||||
Path: "",
|
||||
Backend: *backend(),
|
||||
},
|
||||
{
|
||||
PathType: ptrPathType(networkingv1.PathTypeImplementationSpecific),
|
||||
PathType: new(networkingv1.PathTypeImplementationSpecific),
|
||||
Path: "/",
|
||||
Backend: *backend(),
|
||||
},
|
||||
@@ -760,11 +759,6 @@ func TestEmptyPath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// ptrPathType is a helper function to return a pointer to the pathtype string (required for TestEmptyPath)
|
||||
func ptrPathType(p networkingv1.PathType) *networkingv1.PathType {
|
||||
return &p
|
||||
}
|
||||
|
||||
func ingressClass() *networkingv1.IngressClass {
|
||||
return &networkingv1.IngressClass{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "tailscale"},
|
||||
@@ -799,7 +793,7 @@ func ingress() *networkingv1.Ingress {
|
||||
UID: "1234-UID",
|
||||
},
|
||||
Spec: networkingv1.IngressSpec{
|
||||
IngressClassName: ptr.To("tailscale"),
|
||||
IngressClassName: new("tailscale"),
|
||||
DefaultBackend: backend(),
|
||||
TLS: []networkingv1.IngressTLS{
|
||||
{Hosts: []string{"default-test"}},
|
||||
@@ -817,7 +811,7 @@ func ingressWithPaths(paths []networkingv1.HTTPIngressPath) *networkingv1.Ingres
|
||||
UID: types.UID("1234-UID"),
|
||||
},
|
||||
Spec: networkingv1.IngressSpec{
|
||||
IngressClassName: ptr.To("tailscale"),
|
||||
IngressClassName: new("tailscale"),
|
||||
Rules: []networkingv1.IngressRule{
|
||||
{
|
||||
Host: "foo.tailnetxyz.ts.net",
|
||||
@@ -878,7 +872,7 @@ func TestTailscaleIngressWithHTTPRedirect(t *testing.T) {
|
||||
|
||||
fullName, shortName := findGenName(t, fc, "default", "test", "ingress")
|
||||
opts := configOpts{
|
||||
replicas: ptr.To[int32](1),
|
||||
replicas: new(int32(1)),
|
||||
stsName: shortName,
|
||||
secretName: fullName,
|
||||
namespace: "default",
|
||||
|
||||
Reference in New Issue
Block a user