From c745bb044a1c0e5ee5847f554541ae02f298a028 Mon Sep 17 00:00:00 2001 From: vflaux <38909103+vflaux@users.noreply.github.com> Date: Sun, 29 Mar 2026 19:42:12 +0200 Subject: [PATCH] chore(go): upgrade to go1.26 (#6314) * chore(go): upgrade to go1.26 * chore: use the new new() capability * chore(lint): update golanci-lint * chore(endpoint): add EndpointKey.String() test --- endpoint/endpoint.go | 4 + endpoint/endpoint_test.go | 29 ++ go.mod | 2 +- go.tool.mod | 2 +- internal/testutils/helpers.go | 27 -- internal/testutils/helpers_test.go | 47 --- provider/azure/azure.go | 21 +- provider/azure/azure_private_dns.go | 17 +- provider/azure/azure_privatedns_test.go | 27 +- provider/azure/azure_test.go | 33 ++- provider/azure/common.go | 5 +- provider/azure/common_test.go | 9 +- .../cloudflare/cloudflare_regional_test.go | 9 +- provider/dnsimple/dnsimple_test.go | 10 +- provider/exoscale/exoscale_test.go | 20 +- provider/oci/oci_test.go | 270 +++++++++--------- provider/scaleway/scaleway_test.go | 12 +- registry/dynamodb/registry.go | 2 +- source/annotations/processors.go | 2 +- source/gateway_httproute_test.go | 28 +- source/ingress_fqdn_test.go | 14 +- source/ingress_test.go | 12 +- source/istio_gateway_test.go | 8 +- source/service_fqdn_test.go | 38 +-- source/service_test.go | 86 +++--- tests/integration/toolkit/toolkit.go | 4 +- 26 files changed, 341 insertions(+), 397 deletions(-) delete mode 100644 internal/testutils/helpers.go delete mode 100644 internal/testutils/helpers_test.go diff --git a/endpoint/endpoint.go b/endpoint/endpoint.go index 6994287be..12e1314e1 100644 --- a/endpoint/endpoint.go +++ b/endpoint/endpoint.go @@ -236,6 +236,10 @@ type EndpointKey struct { Target string } +func (ep EndpointKey) String() string { + return fmt.Sprintf(`{%q %q %q "%d" %q}`, ep.DNSName, ep.RecordType, ep.SetIdentifier, ep.RecordTTL, ep.Target) +} + type ObjectRef = events.ObjectReference // Endpoint is a high-level way of a connection between a service and an IP diff --git a/endpoint/endpoint_test.go b/endpoint/endpoint_test.go index 9e8ea73b2..139321fab 100644 --- a/endpoint/endpoint_test.go +++ b/endpoint/endpoint_test.go @@ -1925,3 +1925,32 @@ func TestNewPTREndpoint(t *testing.T) { }) } } + +func TestEndpointKey_String(t *testing.T) { + tests := []struct { + name string + key EndpointKey + want string + }{ + { + name: "empty key", + key: EndpointKey{}, + want: `{"" "" "" "0" ""}`}, + { + name: "complete key", + key: EndpointKey{ + DNSName: "example.com", + RecordType: RecordTypeA, + SetIdentifier: "test-set", + RecordTTL: 300, + Target: "127.0.0.1", + }, + want: `{"example.com" "A" "test-set" "300" "127.0.0.1"}`, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + assert.Equal(t, tt.want, tt.key.String()) + }) + } +} diff --git a/go.mod b/go.mod index b92dba303..4c5fd346a 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module sigs.k8s.io/external-dns -go 1.25.8 +go 1.26.1 require ( cloud.google.com/go/compute/metadata v0.9.0 diff --git a/go.tool.mod b/go.tool.mod index dd7a949fb..ea7b44b11 100644 --- a/go.tool.mod +++ b/go.tool.mod @@ -1,6 +1,6 @@ module sigs.k8s.io/external-dns/tools -go 1.25.7 +go 1.26.1 tool ( github.com/google/yamlfmt/cmd/yamlfmt diff --git a/internal/testutils/helpers.go b/internal/testutils/helpers.go deleted file mode 100644 index 0b49ca942..000000000 --- a/internal/testutils/helpers.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright 2025 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package testutils - -// ToPtr returns a pointer to the given value of any type. -// Example usage: -// -// foo := 42 -// fooPtr := ToPtr(foo) -// fmt.Println(*fooPtr) // Output: 42 -func ToPtr[T any](v T) *T { - return &v -} diff --git a/internal/testutils/helpers_test.go b/internal/testutils/helpers_test.go deleted file mode 100644 index 15c05bc67..000000000 --- a/internal/testutils/helpers_test.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright 2025 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package testutils - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestStringPtr(t *testing.T) { - original := "hello" - ptr := ToPtr(original) - if ptr == nil { - t.Fatal("StringPtr returned nil") - } - if *ptr != original { - t.Fatalf("expected %q, got %q", original, *ptr) - } - - // Ensure the pointer value is independent of the original variable - original = "world" - if *ptr == original { - t.Error("pointer value changed with the original variable") - } -} - -func TestIsPointer(t *testing.T) { - value := "test" - ptr := ToPtr(value) - - assert.IsType(t, *ptr, value) -} diff --git a/provider/azure/azure.go b/provider/azure/azure.go index 8eb3d3eac..069c9c33a 100644 --- a/provider/azure/azure.go +++ b/provider/azure/azure.go @@ -30,7 +30,6 @@ import ( "sigs.k8s.io/external-dns/provider/blueprint" azcoreruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" dns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns" "sigs.k8s.io/external-dns/endpoint" @@ -372,12 +371,12 @@ func (p *AzureProvider) newRecordSet(endpoint *endpoint.Endpoint) (dns.RecordSet aRecords := make([]*dns.ARecord, len(endpoint.Targets)) for i, target := range endpoint.Targets { aRecords[i] = &dns.ARecord{ - IPv4Address: to.Ptr(target), + IPv4Address: new(target), } } return dns.RecordSet{ Properties: &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), ARecords: aRecords, }, }, nil @@ -385,21 +384,21 @@ func (p *AzureProvider) newRecordSet(endpoint *endpoint.Endpoint) (dns.RecordSet aaaaRecords := make([]*dns.AaaaRecord, len(endpoint.Targets)) for i, target := range endpoint.Targets { aaaaRecords[i] = &dns.AaaaRecord{ - IPv6Address: to.Ptr(target), + IPv6Address: new(target), } } return dns.RecordSet{ Properties: &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), AaaaRecords: aaaaRecords, }, }, nil case dns.RecordTypeCNAME: return dns.RecordSet{ Properties: &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), CnameRecord: &dns.CnameRecord{ - Cname: to.Ptr(endpoint.Targets[0]), + Cname: new(endpoint.Targets[0]), }, }, }, nil @@ -414,7 +413,7 @@ func (p *AzureProvider) newRecordSet(endpoint *endpoint.Endpoint) (dns.RecordSet } return dns.RecordSet{ Properties: &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), MxRecords: mxRecords, }, }, nil @@ -422,19 +421,19 @@ func (p *AzureProvider) newRecordSet(endpoint *endpoint.Endpoint) (dns.RecordSet nsRecords := make([]*dns.NsRecord, len(endpoint.Targets)) for i, target := range endpoint.Targets { nsRecords[i] = &dns.NsRecord{ - Nsdname: to.Ptr(target), + Nsdname: new(target), } } return dns.RecordSet{ Properties: &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), NsRecords: nsRecords, }, }, nil case dns.RecordTypeTXT: return dns.RecordSet{ Properties: &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), TxtRecords: []*dns.TxtRecord{ { Value: []*string{ diff --git a/provider/azure/azure_private_dns.go b/provider/azure/azure_private_dns.go index 6ad3ea636..e0152dda3 100644 --- a/provider/azure/azure_private_dns.go +++ b/provider/azure/azure_private_dns.go @@ -24,7 +24,6 @@ import ( "time" azcoreruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" privatedns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" log "github.com/sirupsen/logrus" @@ -375,12 +374,12 @@ func (p *AzurePrivateDNSProvider) newRecordSet(endpoint *endpoint.Endpoint) (pri aRecords := make([]*privatedns.ARecord, len(endpoint.Targets)) for i, target := range endpoint.Targets { aRecords[i] = &privatedns.ARecord{ - IPv4Address: to.Ptr(target), + IPv4Address: new(target), } } return privatedns.RecordSet{ Properties: &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), ARecords: aRecords, }, }, nil @@ -388,21 +387,21 @@ func (p *AzurePrivateDNSProvider) newRecordSet(endpoint *endpoint.Endpoint) (pri aaaaRecords := make([]*privatedns.AaaaRecord, len(endpoint.Targets)) for i, target := range endpoint.Targets { aaaaRecords[i] = &privatedns.AaaaRecord{ - IPv6Address: to.Ptr(target), + IPv6Address: new(target), } } return privatedns.RecordSet{ Properties: &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), AaaaRecords: aaaaRecords, }, }, nil case privatedns.RecordTypeCNAME: return privatedns.RecordSet{ Properties: &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), CnameRecord: &privatedns.CnameRecord{ - Cname: to.Ptr(endpoint.Targets[0]), + Cname: new(endpoint.Targets[0]), }, }, }, nil @@ -417,14 +416,14 @@ func (p *AzurePrivateDNSProvider) newRecordSet(endpoint *endpoint.Endpoint) (pri } return privatedns.RecordSet{ Properties: &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), MxRecords: mxRecords, }, }, nil case privatedns.RecordTypeTXT: return privatedns.RecordSet{ Properties: &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), TxtRecords: []*privatedns.TxtRecord{ { Value: []*string{ diff --git a/provider/azure/azure_privatedns_test.go b/provider/azure/azure_privatedns_test.go index aef2cb833..58f039276 100644 --- a/provider/azure/azure_privatedns_test.go +++ b/provider/azure/azure_privatedns_test.go @@ -21,7 +21,6 @@ import ( "testing" azcoreruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" privatedns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" "sigs.k8s.io/external-dns/provider/blueprint" @@ -124,8 +123,8 @@ func (client *mockPrivateRecordSetsClient) CreateOrUpdate(_ context.Context, _ s func createMockPrivateZone(zone string, id string) *privatedns.PrivateZone { return &privatedns.PrivateZone{ - ID: to.Ptr(id), - Name: to.Ptr(zone), + ID: new(id), + Name: new(zone), } } @@ -133,11 +132,11 @@ func privateARecordSetPropertiesGetter(values []string, ttl int64) *privatedns.R aRecords := make([]*privatedns.ARecord, len(values)) for i, value := range values { aRecords[i] = &privatedns.ARecord{ - IPv4Address: to.Ptr(value), + IPv4Address: new(value), } } return &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), ARecords: aRecords, } } @@ -146,20 +145,20 @@ func privateAAAARecordSetPropertiesGetter(values []string, ttl int64) *privatedn aaaaRecords := make([]*privatedns.AaaaRecord, len(values)) for i, value := range values { aaaaRecords[i] = &privatedns.AaaaRecord{ - IPv6Address: to.Ptr(value), + IPv6Address: new(value), } } return &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), AaaaRecords: aaaaRecords, } } func privateCNameRecordSetPropertiesGetter(values []string, ttl int64) *privatedns.RecordSetProperties { return &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), CnameRecord: &privatedns.CnameRecord{ - Cname: to.Ptr(values[0]), + Cname: new(values[0]), }, } } @@ -171,14 +170,14 @@ func privateMXRecordSetPropertiesGetter(values []string, ttl int64) *privatedns. mxRecords[i] = &mxRecord } return &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), MxRecords: mxRecords, } } func privateTxtRecordSetPropertiesGetter(values []string, ttl int64) *privatedns.RecordSetProperties { return &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), TxtRecords: []*privatedns.TxtRecord{ { Value: []*string{&values[0]}, @@ -189,7 +188,7 @@ func privateTxtRecordSetPropertiesGetter(values []string, ttl int64) *privatedns func privateOthersRecordSetPropertiesGetter(_ []string, ttl int64) *privatedns.RecordSetProperties { return &privatedns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), } } @@ -219,8 +218,8 @@ func createPrivateMockRecordSetMultiWithTTL(name, recordType string, ttl int64, getterFunc = privateOthersRecordSetPropertiesGetter } return &privatedns.RecordSet{ - Name: to.Ptr(name), - Type: to.Ptr("Microsoft.Network/privateDnsZones/" + recordType), + Name: new(name), + Type: new("Microsoft.Network/privateDnsZones/" + recordType), Properties: getterFunc(values, ttl), } } diff --git a/provider/azure/azure_test.go b/provider/azure/azure_test.go index 4d78bb749..901a79236 100644 --- a/provider/azure/azure_test.go +++ b/provider/azure/azure_test.go @@ -21,7 +21,6 @@ import ( "testing" azcoreruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" dns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns" "github.com/stretchr/testify/assert" @@ -122,8 +121,8 @@ func (client *mockRecordSetsClient) CreateOrUpdate(_ context.Context, _ string, func createMockZone(zone string, id string) *dns.Zone { return &dns.Zone{ - ID: to.Ptr(id), - Name: to.Ptr(zone), + ID: new(id), + Name: new(zone), } } @@ -131,11 +130,11 @@ func aRecordSetPropertiesGetter(values []string, ttl int64) *dns.RecordSetProper aRecords := make([]*dns.ARecord, len(values)) for i, value := range values { aRecords[i] = &dns.ARecord{ - IPv4Address: to.Ptr(value), + IPv4Address: new(value), } } return &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), ARecords: aRecords, } } @@ -144,20 +143,20 @@ func aaaaRecordSetPropertiesGetter(values []string, ttl int64) *dns.RecordSetPro aaaaRecords := make([]*dns.AaaaRecord, len(values)) for i, value := range values { aaaaRecords[i] = &dns.AaaaRecord{ - IPv6Address: to.Ptr(value), + IPv6Address: new(value), } } return &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), AaaaRecords: aaaaRecords, } } func cNameRecordSetPropertiesGetter(values []string, ttl int64) *dns.RecordSetProperties { return &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), CnameRecord: &dns.CnameRecord{ - Cname: to.Ptr(values[0]), + Cname: new(values[0]), }, } } @@ -169,7 +168,7 @@ func mxRecordSetPropertiesGetter(values []string, ttl int64) *dns.RecordSetPrope mxRecords[i] = &mxRecord } return &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), MxRecords: mxRecords, } } @@ -178,21 +177,21 @@ func nsRecordSetPropertiesGetter(values []string, ttl int64) *dns.RecordSetPrope nsRecords := make([]*dns.NsRecord, len(values)) for i, value := range values { nsRecords[i] = &dns.NsRecord{ - Nsdname: to.Ptr(value), + Nsdname: new(value), } } return &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), NsRecords: nsRecords, } } func txtRecordSetPropertiesGetter(values []string, ttl int64) *dns.RecordSetProperties { return &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), TxtRecords: []*dns.TxtRecord{ { - Value: []*string{to.Ptr(values[0])}, + Value: []*string{new(values[0])}, }, }, } @@ -200,7 +199,7 @@ func txtRecordSetPropertiesGetter(values []string, ttl int64) *dns.RecordSetProp func othersRecordSetPropertiesGetter(_ []string, ttl int64) *dns.RecordSetProperties { return &dns.RecordSetProperties{ - TTL: to.Ptr(ttl), + TTL: new(ttl), } } @@ -232,8 +231,8 @@ func createMockRecordSetMultiWithTTL(name, recordType string, ttl int64, values getterFunc = othersRecordSetPropertiesGetter } return &dns.RecordSet{ - Name: to.Ptr(name), - Type: to.Ptr("Microsoft.Network/dnszones/" + recordType), + Name: new(name), + Type: new("Microsoft.Network/dnszones/" + recordType), Properties: getterFunc(values, ttl), } } diff --git a/provider/azure/common.go b/provider/azure/common.go index 688a0a57f..5885535b2 100644 --- a/provider/azure/common.go +++ b/provider/azure/common.go @@ -22,7 +22,6 @@ import ( "strconv" "strings" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" dns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns" privatedns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" ) @@ -41,7 +40,7 @@ func parseMxTarget[T dns.MxRecord | privatedns.MxRecord](mxTarget string) (T, er } return T{ - Preference: to.Ptr(int32(preference)), - Exchange: to.Ptr(exchange), + Preference: new(int32(preference)), + Exchange: new(exchange), }, nil } diff --git a/provider/azure/common_test.go b/provider/azure/common_test.go index b85fb5f4b..8a7e9a3af 100644 --- a/provider/azure/common_test.go +++ b/provider/azure/common_test.go @@ -20,7 +20,6 @@ import ( "fmt" "testing" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" dns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dns/armdns" privatedns "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns" @@ -42,8 +41,8 @@ func Test_parseMxTarget(t *testing.T) { name: "valid mx target", args: "10 example.com", want: dns.MxRecord{ - Preference: to.Ptr(int32(10)), - Exchange: to.Ptr("example.com"), + Preference: new(int32(10)), + Exchange: new("example.com"), }, wantErr: assert.NoError, }, @@ -51,8 +50,8 @@ func Test_parseMxTarget(t *testing.T) { name: "valid mx target with a subdomain", args: "99 foo-bar.example.com", want: dns.MxRecord{ - Preference: to.Ptr(int32(99)), - Exchange: to.Ptr("foo-bar.example.com"), + Preference: new(int32(99)), + Exchange: new("foo-bar.example.com"), }, wantErr: assert.NoError, }, diff --git a/provider/cloudflare/cloudflare_regional_test.go b/provider/cloudflare/cloudflare_regional_test.go index 7a69672f3..f36687cdf 100644 --- a/provider/cloudflare/cloudflare_regional_test.go +++ b/provider/cloudflare/cloudflare_regional_test.go @@ -31,7 +31,6 @@ import ( "github.com/stretchr/testify/require" "sigs.k8s.io/external-dns/endpoint" - "sigs.k8s.io/external-dns/internal/testutils" logtest "sigs.k8s.io/external-dns/internal/testutils/log" "sigs.k8s.io/external-dns/plan" "sigs.k8s.io/external-dns/source/annotations" @@ -1204,21 +1203,21 @@ func TestCloudflareAdjustEndpointsRegionalServices(t *testing.T) { recordType: "A", regionalServicesConfig: RegionalServicesConfig{Enabled: true, RegionKey: "us"}, initialRegionKey: "", - expectedRegionKey: testutils.ToPtr("us"), + expectedRegionKey: new("us"), }, { name: "AAAA record with regional services enabled", recordType: "AAAA", regionalServicesConfig: RegionalServicesConfig{Enabled: true, RegionKey: "us"}, initialRegionKey: "", - expectedRegionKey: testutils.ToPtr("us"), + expectedRegionKey: new("us"), }, { name: "CNAME record with regional services enabled", recordType: "CNAME", regionalServicesConfig: RegionalServicesConfig{Enabled: true, RegionKey: "us"}, initialRegionKey: "", - expectedRegionKey: testutils.ToPtr("us"), + expectedRegionKey: new("us"), }, // Unsupported types should NOT get region key even when enabled @@ -1252,7 +1251,7 @@ func TestCloudflareAdjustEndpointsRegionalServices(t *testing.T) { recordType: "A", regionalServicesConfig: RegionalServicesConfig{Enabled: true, RegionKey: "us"}, initialRegionKey: "eu", - expectedRegionKey: testutils.ToPtr("eu"), + expectedRegionKey: new("eu"), }, } diff --git a/provider/dnsimple/dnsimple_test.go b/provider/dnsimple/dnsimple_test.go index 57964c304..52e43561b 100644 --- a/provider/dnsimple/dnsimple_test.go +++ b/provider/dnsimple/dnsimple_test.go @@ -116,10 +116,10 @@ func TestDnsimpleServices(t *testing.T) { // Setup mock services // Note: AnythingOfType doesn't work with interfaces https://github.com/stretchr/testify/issues/519 mockDNS := &mockDnsimpleZoneServiceInterface{} - mockDNS.On("ListZones", t.Context(), "1", &dnsimple.ZoneListOptions{ListOptions: dnsimple.ListOptions{Page: dnsimple.Int(1)}}).Return(&dnsimpleListZonesResponse, nil) - mockDNS.On("ListZones", t.Context(), "2", &dnsimple.ZoneListOptions{ListOptions: dnsimple.ListOptions{Page: dnsimple.Int(1)}}).Return(nil, fmt.Errorf("Account ID not found")) - mockDNS.On("ListRecords", t.Context(), "1", "example.com", &dnsimple.ZoneRecordListOptions{ListOptions: dnsimple.ListOptions{Page: dnsimple.Int(1)}}).Return(&dnsimpleListRecordsResponse, nil) - mockDNS.On("ListRecords", t.Context(), "1", "example-beta.com", &dnsimple.ZoneRecordListOptions{ListOptions: dnsimple.ListOptions{Page: dnsimple.Int(1)}}).Return(&dnsimple.ZoneRecordsResponse{Response: dnsimple.Response{Pagination: &dnsimple.Pagination{}}}, nil) + mockDNS.On("ListZones", t.Context(), "1", &dnsimple.ZoneListOptions{ListOptions: dnsimple.ListOptions{Page: new(1)}}).Return(&dnsimpleListZonesResponse, nil) + mockDNS.On("ListZones", t.Context(), "2", &dnsimple.ZoneListOptions{ListOptions: dnsimple.ListOptions{Page: new(1)}}).Return(nil, fmt.Errorf("Account ID not found")) + mockDNS.On("ListRecords", t.Context(), "1", "example.com", &dnsimple.ZoneRecordListOptions{ListOptions: dnsimple.ListOptions{Page: new(1)}}).Return(&dnsimpleListRecordsResponse, nil) + mockDNS.On("ListRecords", t.Context(), "1", "example-beta.com", &dnsimple.ZoneRecordListOptions{ListOptions: dnsimple.ListOptions{Page: new(1)}}).Return(&dnsimple.ZoneRecordsResponse{Response: dnsimple.Response{Pagination: &dnsimple.Pagination{}}}, nil) for _, record := range records { recordName := record.Name @@ -135,7 +135,7 @@ func TestDnsimpleServices(t *testing.T) { Data: []dnsimple.ZoneRecord{record}, } - mockDNS.On("ListRecords", t.Context(), "1", record.ZoneID, &dnsimple.ZoneRecordListOptions{Name: &recordName, ListOptions: dnsimple.ListOptions{Page: dnsimple.Int(1)}}).Return(&dnsimpleRecordResponse, nil) + mockDNS.On("ListRecords", t.Context(), "1", record.ZoneID, &dnsimple.ZoneRecordListOptions{Name: &recordName, ListOptions: dnsimple.ListOptions{Page: new(1)}}).Return(&dnsimpleRecordResponse, nil) mockDNS.On("CreateRecord", t.Context(), "1", record.ZoneID, simpleRecord).Return(&dnsimple.ZoneRecordResponse{}, nil) mockDNS.On("DeleteRecord", t.Context(), "1", record.ZoneID, record.ID).Return(&dnsimple.ZoneRecordResponse{}, nil) mockDNS.On("UpdateRecord", t.Context(), "1", record.ZoneID, record.ID, simpleRecord).Return(&dnsimple.ZoneRecordResponse{}, nil) diff --git a/provider/exoscale/exoscale_test.go b/provider/exoscale/exoscale_test.go index 7e99180a7..4c8a43544 100644 --- a/provider/exoscale/exoscale_test.go +++ b/provider/exoscale/exoscale_test.go @@ -57,25 +57,21 @@ var defaultTTL int64 = 3600 var domainIDs = []string{uuid.New().String(), uuid.New().String(), uuid.New().String(), uuid.New().String()} var groups = map[string][]egoscale.DNSDomainRecord{ domainIDs[0]: { - {ID: strPtr(uuid.New().String()), Name: strPtr("v1"), Type: strPtr("TXT"), Content: strPtr("test"), TTL: &defaultTTL}, - {ID: strPtr(uuid.New().String()), Name: strPtr("v2"), Type: strPtr("CNAME"), Content: strPtr("test"), TTL: &defaultTTL}, + {ID: new(uuid.New().String()), Name: new("v1"), Type: new("TXT"), Content: new("test"), TTL: &defaultTTL}, + {ID: new(uuid.New().String()), Name: new("v2"), Type: new("CNAME"), Content: new("test"), TTL: &defaultTTL}, }, domainIDs[1]: { - {ID: strPtr(uuid.New().String()), Name: strPtr("v2"), Type: strPtr("A"), Content: strPtr("test"), TTL: &defaultTTL}, - {ID: strPtr(uuid.New().String()), Name: strPtr("v3"), Type: strPtr("ALIAS"), Content: strPtr("test"), TTL: &defaultTTL}, + {ID: new(uuid.New().String()), Name: new("v2"), Type: new("A"), Content: new("test"), TTL: &defaultTTL}, + {ID: new(uuid.New().String()), Name: new("v3"), Type: new("ALIAS"), Content: new("test"), TTL: &defaultTTL}, }, domainIDs[2]: { - {ID: strPtr(uuid.New().String()), Name: strPtr("v1"), Type: strPtr("TXT"), Content: strPtr("test"), TTL: &defaultTTL}, + {ID: new(uuid.New().String()), Name: new("v1"), Type: new("TXT"), Content: new("test"), TTL: &defaultTTL}, }, domainIDs[3]: { - {ID: strPtr(uuid.New().String()), Name: strPtr("v4"), Type: strPtr("ALIAS"), Content: strPtr("test"), TTL: &defaultTTL}, + {ID: new(uuid.New().String()), Name: new("v4"), Type: new("ALIAS"), Content: new("test"), TTL: &defaultTTL}, }, } -func strPtr(s string) *string { - return &s -} - type ExoscaleClientStub struct{} func NewExoscaleClientStub() EgoscaleClientI { @@ -85,8 +81,8 @@ func NewExoscaleClientStub() EgoscaleClientI { func (ep *ExoscaleClientStub) ListDNSDomains(_ context.Context, _ string) ([]egoscale.DNSDomain, error) { domains := []egoscale.DNSDomain{ - {ID: &domainIDs[0], UnicodeName: strPtr("foo.com")}, - {ID: &domainIDs[1], UnicodeName: strPtr("bar.com")}, + {ID: &domainIDs[0], UnicodeName: new("foo.com")}, + {ID: &domainIDs[1], UnicodeName: new("bar.com")}, } return domains, nil } diff --git a/provider/oci/oci_test.go b/provider/oci/oci_test.go index 9a059dc2d..dc39966b4 100644 --- a/provider/oci/oci_test.go +++ b/provider/oci/oci_test.go @@ -50,12 +50,12 @@ var ( Name: &zoneNameBaz, } testGlobalZoneSummaryFoo = dns.ZoneSummary{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), } testGlobalZoneSummaryBar = dns.ZoneSummary{ - Id: common.String("ocid1.dns-zone.oc1..502aeddba262b92fd13ed7874f6f1404"), - Name: common.String("bar.com"), + Id: new("ocid1.dns-zone.oc1..502aeddba262b92fd13ed7874f6f1404"), + Name: new("bar.com"), } ) @@ -74,7 +74,7 @@ func (c *mockOCIDNSClient) ListZones(_ context.Context, request dns.ListZonesReq if request.Page == nil || *request.Page == "0" { return dns.ListZonesResponse{ Items: buildZoneResponseItems(request.Scope, []dns.ZoneSummary{testPrivateZoneSummaryBaz}, []dns.ZoneSummary{testGlobalZoneSummaryFoo}), - OpcNextPage: common.String("1"), + OpcNextPage: new("1"), }, nil } return dns.ListZonesResponse{ @@ -93,32 +93,32 @@ func (c *mockOCIDNSClient) GetZoneRecords(_ context.Context, request dns.GetZone case "ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959": if request.Page == nil || *request.Page == "0" { response.Items = []dns.Record{{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }, { - Domain: common.String("foo.foo.com"), - Rdata: common.String("heritage=external-dns,external-dns/owner=default,external-dns/resource=service/default/my-svc"), + Domain: new("foo.foo.com"), + Rdata: new("heritage=external-dns,external-dns/owner=default,external-dns/resource=service/default/my-svc"), Rtype: common.String(endpoint.RecordTypeTXT), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }} - response.OpcNextPage = common.String("1") + response.OpcNextPage = new("1") } else { response.Items = []dns.Record{{ - Domain: common.String("bar.foo.com"), - Rdata: common.String("bar.com."), + Domain: new("bar.foo.com"), + Rdata: new("bar.com."), Rtype: common.String(endpoint.RecordTypeCNAME), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }} } case "ocid1.dns-zone.oc1..502aeddba262b92fd13ed7874f6f1404": if request.Page == nil || *request.Page == "0" { response.Items = []dns.Record{{ - Domain: common.String("foo.bar.com"), - Rdata: common.String("127.0.0.1"), + Domain: new("foo.bar.com"), + Rdata: new("127.0.0.1"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }} } } @@ -291,8 +291,8 @@ func TestOCIZones(t *testing.T) { zoneScope: "GLOBAL", expected: map[string]dns.ZoneSummary{ fooZoneId: { - Id: common.String(fooZoneId), - Name: common.String("foo.com"), + Id: new(fooZoneId), + Name: new("foo.com"), }, }, }, @@ -303,8 +303,8 @@ func TestOCIZones(t *testing.T) { zoneScope: "GLOBAL", expected: map[string]dns.ZoneSummary{ fooZoneId: { - Id: common.String(fooZoneId), - Name: common.String("foo.com"), + Id: new(fooZoneId), + Name: new("foo.com"), }, }, }, @@ -380,10 +380,10 @@ func TestNewRecordOperation(t *testing.T) { endpoint.TTL(defaultTTL), "127.0.0.1"), expected: dns.RecordOperation{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), - Rtype: common.String("A"), - Ttl: common.Int(300), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), + Rtype: new("A"), + Ttl: new(300), Operation: dns.RecordOperationOperationAdd, }, }, { @@ -395,10 +395,10 @@ func TestNewRecordOperation(t *testing.T) { endpoint.TTL(defaultTTL), "heritage=external-dns,external-dns/owner=default,external-dns/resource=service/default/my-svc"), expected: dns.RecordOperation{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("heritage=external-dns,external-dns/owner=default,external-dns/resource=service/default/my-svc"), - Rtype: common.String("TXT"), - Ttl: common.Int(300), + Domain: new("foo.foo.com"), + Rdata: new("heritage=external-dns,external-dns/owner=default,external-dns/resource=service/default/my-svc"), + Rtype: new("TXT"), + Ttl: new(300), Operation: dns.RecordOperationOperationAdd, }, }, { @@ -410,10 +410,10 @@ func TestNewRecordOperation(t *testing.T) { endpoint.TTL(defaultTTL), "bar.com."), expected: dns.RecordOperation{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("bar.com."), - Rtype: common.String("CNAME"), - Ttl: common.Int(300), + Domain: new("foo.foo.com"), + Rdata: new("bar.com."), + Rtype: new("CNAME"), + Ttl: new(300), Operation: dns.RecordOperationOperationAdd, }, }, @@ -438,46 +438,46 @@ func TestOperationsByZone(t *testing.T) { name: "basic", zones: map[string]dns.ZoneSummary{ "foo": { - Id: common.String("foo"), - Name: common.String("foo.com"), + Id: new("foo"), + Name: new("foo.com"), }, "bar": { - Id: common.String("bar"), - Name: common.String("bar.com"), + Id: new("bar"), + Name: new("bar.com"), }, }, ops: []dns.RecordOperation{ { - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), - Rtype: common.String("A"), - Ttl: common.Int(300), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), + Rtype: new("A"), + Ttl: new(300), Operation: dns.RecordOperationOperationAdd, }, { - Domain: common.String("foo.bar.com"), - Rdata: common.String("127.0.0.1"), - Rtype: common.String("A"), - Ttl: common.Int(300), + Domain: new("foo.bar.com"), + Rdata: new("127.0.0.1"), + Rtype: new("A"), + Ttl: new(300), Operation: dns.RecordOperationOperationAdd, }, }, expected: map[string][]dns.RecordOperation{ "foo": { { - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), - Rtype: common.String("A"), - Ttl: common.Int(300), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), + Rtype: new("A"), + Ttl: new(300), Operation: dns.RecordOperationOperationAdd, }, }, "bar": { { - Domain: common.String("foo.bar.com"), - Rdata: common.String("127.0.0.1"), - Rtype: common.String("A"), - Ttl: common.Int(300), + Domain: new("foo.bar.com"), + Rdata: new("127.0.0.1"), + Rtype: new("A"), + Ttl: new(300), Operation: dns.RecordOperationOperationAdd, }, }, @@ -486,30 +486,30 @@ func TestOperationsByZone(t *testing.T) { name: "does_not_include_zones_with_no_changes", zones: map[string]dns.ZoneSummary{ "foo": { - Id: common.String("foo"), - Name: common.String("foo.com"), + Id: new("foo"), + Name: new("foo.com"), }, "bar": { - Id: common.String("bar"), - Name: common.String("bar.com"), + Id: new("bar"), + Name: new("bar.com"), }, }, ops: []dns.RecordOperation{ { - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), - Rtype: common.String("A"), - Ttl: common.Int(300), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), + Rtype: new("A"), + Ttl: new(300), Operation: dns.RecordOperationOperationAdd, }, }, expected: map[string][]dns.RecordOperation{ "foo": { { - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), - Rtype: common.String("A"), - Ttl: common.Int(300), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), + Rtype: new("A"), + Ttl: new(300), Operation: dns.RecordOperationOperationAdd, }, }, @@ -631,20 +631,20 @@ func (c *mutableMockOCIDNSClient) PatchZoneRecords(_ context.Context, request dn // right...? func TestMutableMockOCIDNSClient(t *testing.T) { zones := []dns.ZoneSummary{{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), }} records := map[string][]dns.Record{ "ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959": {{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }, { - Domain: common.String("foo.foo.com"), - Rdata: common.String("heritage=external-dns,external-dns/owner=default,external-dns/resource=service/default/my-svc"), + Domain: new("foo.foo.com"), + Rdata: new("heritage=external-dns,external-dns/owner=default,external-dns/resource=service/default/my-svc"), Rtype: common.String(endpoint.RecordTypeTXT), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }}, } client := newMutableMockOCIDNSClient(zones, records) @@ -665,13 +665,13 @@ func TestMutableMockOCIDNSClient(t *testing.T) { // Remove the A record. _, err = client.PatchZoneRecords(t.Context(), dns.PatchZoneRecordsRequest{ - ZoneNameOrId: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + ZoneNameOrId: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), PatchZoneRecordsDetails: dns.PatchZoneRecordsDetails{ Items: []dns.RecordOperation{{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), - Rtype: common.String("A"), - Ttl: common.Int(300), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), + Rtype: new("A"), + Ttl: new(300), Operation: dns.RecordOperationOperationRemove, }}, }, @@ -688,13 +688,13 @@ func TestMutableMockOCIDNSClient(t *testing.T) { // Add the A record back. _, err = client.PatchZoneRecords(t.Context(), dns.PatchZoneRecordsRequest{ - ZoneNameOrId: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + ZoneNameOrId: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), PatchZoneRecordsDetails: dns.PatchZoneRecordsDetails{ Items: []dns.RecordOperation{{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), - Rtype: common.String("A"), - Ttl: common.Int(300), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), + Rtype: new("A"), + Ttl: new(300), Operation: dns.RecordOperationOperationAdd, }}, }, @@ -724,8 +724,8 @@ func TestOCIApplyChanges(t *testing.T) { { name: "add", zones: []dns.ZoneSummary{{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), }}, changes: &plan.Changes{ Create: []*endpoint.Endpoint{endpoint.NewEndpointWithTTL( @@ -744,20 +744,20 @@ func TestOCIApplyChanges(t *testing.T) { }, { name: "remove", zones: []dns.ZoneSummary{{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), }}, records: map[string][]dns.Record{ "ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959": {{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }, { - Domain: common.String("foo.foo.com"), - Rdata: common.String("heritage=external-dns,external-dns/owner=default,external-dns/resource=service/default/my-svc"), + Domain: new("foo.foo.com"), + Rdata: new("heritage=external-dns,external-dns/owner=default,external-dns/resource=service/default/my-svc"), Rtype: common.String(endpoint.RecordTypeTXT), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }}, }, changes: &plan.Changes{ @@ -777,15 +777,15 @@ func TestOCIApplyChanges(t *testing.T) { }, { name: "update", zones: []dns.ZoneSummary{{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), }}, records: map[string][]dns.Record{ "ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959": {{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }}, }, changes: &plan.Changes{ @@ -811,15 +811,15 @@ func TestOCIApplyChanges(t *testing.T) { }, { name: "dry_run_no_changes", zones: []dns.ZoneSummary{{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), }}, records: map[string][]dns.Record{ "ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959": {{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }}, }, changes: &plan.Changes{ @@ -840,25 +840,25 @@ func TestOCIApplyChanges(t *testing.T) { }, { name: "add_remove_update", zones: []dns.ZoneSummary{{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), }}, records: map[string][]dns.Record{ "ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959": {{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("127.0.0.1"), + Domain: new("foo.foo.com"), + Rdata: new("127.0.0.1"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }, { - Domain: common.String("car.foo.com"), - Rdata: common.String("bar.com."), + Domain: new("car.foo.com"), + Rdata: new("bar.com."), Rtype: common.String(endpoint.RecordTypeCNAME), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }, { - Domain: common.String("bar.foo.com"), - Rdata: common.String("baz.com."), + Domain: new("bar.foo.com"), + Rdata: new("baz.com."), Rtype: common.String(endpoint.RecordTypeCNAME), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }}, }, changes: &plan.Changes{ @@ -904,8 +904,8 @@ func TestOCIApplyChanges(t *testing.T) { { name: "combine_multi_target", zones: []dns.ZoneSummary{{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), }}, changes: &plan.Changes{ @@ -930,20 +930,20 @@ func TestOCIApplyChanges(t *testing.T) { { name: "remove_from_multi_target", zones: []dns.ZoneSummary{{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), }}, records: map[string][]dns.Record{ "ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959": {{ - Domain: common.String("foo.foo.com"), - Rdata: common.String("192.168.1.2"), + Domain: new("foo.foo.com"), + Rdata: new("192.168.1.2"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }, { - Domain: common.String("foo.foo.com"), - Rdata: common.String("192.168.2.5"), + Domain: new("foo.foo.com"), + Rdata: new("192.168.2.5"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }}, }, changes: &plan.Changes{ @@ -963,15 +963,15 @@ func TestOCIApplyChanges(t *testing.T) { { name: "update_multi_target", zones: []dns.ZoneSummary{{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), }}, records: map[string][]dns.Record{ "ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959": {{ - Domain: common.String("first.foo.com"), - Rdata: common.String("10.77.4.5"), + Domain: new("first.foo.com"), + Rdata: new("10.77.4.5"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }}, }, changes: &plan.Changes{ @@ -998,15 +998,15 @@ func TestOCIApplyChanges(t *testing.T) { { name: "increase_multi_target", zones: []dns.ZoneSummary{{ - Id: common.String("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), - Name: common.String("foo.com"), + Id: new("ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959"), + Name: new("foo.com"), }}, records: map[string][]dns.Record{ "ocid1.dns-zone.oc1..e1e042ef0bfbb5c251b9713fd7bf8959": {{ - Domain: common.String("first.foo.com"), - Rdata: common.String("10.77.4.5"), + Domain: new("first.foo.com"), + Rdata: new("10.77.4.5"), Rtype: common.String(endpoint.RecordTypeA), - Ttl: common.Int(defaultTTL), + Ttl: new(defaultTTL), }}, }, changes: &plan.Changes{ diff --git a/provider/scaleway/scaleway_test.go b/provider/scaleway/scaleway_test.go index 4d6326aa2..55ec82073 100644 --- a/provider/scaleway/scaleway_test.go +++ b/provider/scaleway/scaleway_test.go @@ -402,7 +402,7 @@ func TestScalewayProvider_generateApplyRequests(t *testing.T) { { Delete: &domain.RecordChangeDelete{ IDFields: &domain.RecordIdentifier{ - Data: scw.StringPtr("3.3.3.3"), + Data: new("3.3.3.3"), Name: "me", Type: domain.RecordTypeA, }, @@ -411,7 +411,7 @@ func TestScalewayProvider_generateApplyRequests(t *testing.T) { { Delete: &domain.RecordChangeDelete{ IDFields: &domain.RecordIdentifier{ - Data: scw.StringPtr("1.1.1.1"), + Data: new("1.1.1.1"), Name: "here", Type: domain.RecordTypeA, }, @@ -420,7 +420,7 @@ func TestScalewayProvider_generateApplyRequests(t *testing.T) { { Delete: &domain.RecordChangeDelete{ IDFields: &domain.RecordIdentifier{ - Data: scw.StringPtr("1.1.1.2"), + Data: new("1.1.1.2"), Name: "here", Type: domain.RecordTypeA, }, @@ -461,7 +461,7 @@ func TestScalewayProvider_generateApplyRequests(t *testing.T) { { Delete: &domain.RecordChangeDelete{ IDFields: &domain.RecordIdentifier{ - Data: scw.StringPtr("1.1.1.1"), + Data: new("1.1.1.1"), Name: "here.is.my", Type: domain.RecordTypeA, }, @@ -470,7 +470,7 @@ func TestScalewayProvider_generateApplyRequests(t *testing.T) { { Delete: &domain.RecordChangeDelete{ IDFields: &domain.RecordIdentifier{ - Data: scw.StringPtr("4.4.4.4"), + Data: new("4.4.4.4"), Name: "my", Type: domain.RecordTypeA, }, @@ -479,7 +479,7 @@ func TestScalewayProvider_generateApplyRequests(t *testing.T) { { Delete: &domain.RecordChangeDelete{ IDFields: &domain.RecordIdentifier{ - Data: scw.StringPtr("5.5.5.5"), + Data: new("5.5.5.5"), Name: "my", Type: domain.RecordTypeA, }, diff --git a/registry/dynamodb/registry.go b/registry/dynamodb/registry.go index e7324e9a9..f2ffc866c 100644 --- a/registry/dynamodb/registry.go +++ b/registry/dynamodb/registry.go @@ -372,7 +372,7 @@ func (im *DynamoDBRegistry) ApplyChanges(ctx context.Context, changes *plan.Chan if err != nil { return fmt.Errorf("deleting dynamodb record: %w", err) } - return fmt.Errorf("deleting dynamodb record %q: %s: %s", record, response.Error.Code, *response.Error.Message) + return fmt.Errorf("deleting dynamodb record %v: %s: %s", record, response.Error.Code, *response.Error.Message) }) } diff --git a/source/annotations/processors.go b/source/annotations/processors.go index ab511ec06..6ccea9f7e 100644 --- a/source/annotations/processors.go +++ b/source/annotations/processors.go @@ -47,7 +47,7 @@ func TTLFromAnnotations(annotations map[string]string, resource string) endpoint return ttlNotConfigured } if ttlValue < ttlMinimum || ttlValue > ttlMaximum { - log.Warnf("TTL value %q must be between [%d, %d]", ttlValue, ttlMinimum, ttlMaximum) + log.Warnf("TTL value %d must be between [%d, %d]", ttlValue, ttlMinimum, ttlMaximum) return ttlNotConfigured } return endpoint.TTL(ttlValue) diff --git a/source/gateway_httproute_test.go b/source/gateway_httproute_test.go index 600817249..31b3c654c 100644 --- a/source/gateway_httproute_test.go +++ b/source/gateway_httproute_test.go @@ -571,12 +571,12 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { { Name: "foo", Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("foo.example.internal"), + Hostname: new(v1.Hostname("foo.example.internal")), }, { Name: "bar", Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("bar.example.internal"), + Hostname: new(v1.Hostname("bar.example.internal")), }, }, }, @@ -612,12 +612,12 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { { Name: "foo", Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("foo.example.internal"), + Hostname: new(v1.Hostname("foo.example.internal")), }, { Name: "bar", Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("bar.example.internal"), + Hostname: new(v1.Hostname("bar.example.internal")), }, }, }, @@ -653,19 +653,19 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { { Name: "foo", Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("foo.example.internal"), + Hostname: new(v1.Hostname("foo.example.internal")), Port: 80, }, { Name: "bar", Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("bar.example.internal"), + Hostname: new(v1.Hostname("bar.example.internal")), Port: 80, }, { Name: "qux", Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("qux.example.internal"), + Hostname: new(v1.Hostname("qux.example.internal")), Port: 8080, }, }, @@ -700,7 +700,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { Spec: v1.GatewaySpec{ Listeners: []v1.Listener{{ Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("*.example.internal"), + Hostname: new(v1.Hostname("*.example.internal")), }}, }, Status: gatewayStatus("1.2.3.4"), @@ -732,7 +732,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { Spec: v1.GatewaySpec{ Listeners: []v1.Listener{{ Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("foo.example.internal"), + Hostname: new(v1.Hostname("foo.example.internal")), }}, }, Status: gatewayStatus("1.2.3.4"), @@ -764,7 +764,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { Spec: v1.GatewaySpec{ Listeners: []v1.Listener{{ Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("*.example.internal"), + Hostname: new(v1.Hostname("*.example.internal")), }}, }, Status: gatewayStatus("1.2.3.4"), @@ -796,7 +796,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { Spec: v1.GatewaySpec{ Listeners: []v1.Listener{{ Protocol: v1.HTTPProtocolType, - Hostname: hostnamePtr("foo.example.internal"), + Hostname: new(v1.Hostname("foo.example.internal")), }}, }, Status: gatewayStatus("1.2.3.4"), @@ -1120,7 +1120,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { ObjectMeta: objectMeta("default", "one"), Spec: v1.GatewaySpec{ Listeners: []v1.Listener{{ - Hostname: hostnamePtr("*.one.internal"), + Hostname: new(v1.Hostname("*.one.internal")), Protocol: v1.HTTPProtocolType, }}, }, @@ -1130,7 +1130,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { ObjectMeta: objectMeta("default", "two"), Spec: v1.GatewaySpec{ Listeners: []v1.Listener{{ - Hostname: hostnamePtr("*.two.internal"), + Hostname: new(v1.Hostname("*.two.internal")), Protocol: v1.HTTPProtocolType, }}, }, @@ -1694,5 +1694,3 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) { }) } } - -func hostnamePtr(val v1.Hostname) *v1.Hostname { return &val } diff --git a/source/ingress_fqdn_test.go b/source/ingress_fqdn_test.go index 6a07c235e..287f3f2cf 100644 --- a/source/ingress_fqdn_test.go +++ b/source/ingress_fqdn_test.go @@ -46,7 +46,7 @@ func TestIngressSourceFqdnTemplatingExamples(t *testing.T) { Namespace: "default", }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("my-ingress"), + IngressClassName: new("my-ingress"), Rules: []networkv1.IngressRule{ { Host: "example.org", @@ -62,7 +62,7 @@ func TestIngressSourceFqdnTemplatingExamples(t *testing.T) { }, }, }, - PathType: testutils.ToPtr(networkv1.PathTypePrefix), + PathType: new(networkv1.PathTypePrefix), Path: "/", }, }, @@ -95,7 +95,7 @@ func TestIngressSourceFqdnTemplatingExamples(t *testing.T) { Namespace: "default", }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("my-ingress"), + IngressClassName: new("my-ingress"), Rules: []networkv1.IngressRule{ {Host: "example.org"}, }, @@ -126,7 +126,7 @@ func TestIngressSourceFqdnTemplatingExamples(t *testing.T) { }, }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("my-ingress"), + IngressClassName: new("my-ingress"), Rules: []networkv1.IngressRule{ {Host: "example.org"}, }, @@ -155,7 +155,7 @@ func TestIngressSourceFqdnTemplatingExamples(t *testing.T) { Namespace: "default", }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("my-ingress"), + IngressClassName: new("my-ingress"), Rules: []networkv1.IngressRule{ { Host: "example.org", @@ -188,7 +188,7 @@ func TestIngressSourceFqdnTemplatingExamples(t *testing.T) { Namespace: "default", }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("ingress-with-override"), + IngressClassName: new("ingress-with-override"), Rules: []networkv1.IngressRule{ {Host: "foo.bar.com"}, {Host: "bar.bar.com"}, @@ -226,7 +226,7 @@ func TestIngressSourceFqdnTemplatingExamples(t *testing.T) { Namespace: "default", }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("ingress-with-override"), + IngressClassName: new("ingress-with-override"), Rules: []networkv1.IngressRule{ { Host: "foo.bar.com", diff --git a/source/ingress_test.go b/source/ingress_test.go index bbec43c9d..ba3089286 100644 --- a/source/ingress_test.go +++ b/source/ingress_test.go @@ -1517,7 +1517,7 @@ func TestIngressWithConfiguration(t *testing.T) { }, }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("nginx"), + IngressClassName: new("nginx"), Rules: []networkv1.IngressRule{ {Host: "app.example.com"}, }, @@ -1549,7 +1549,7 @@ func TestIngressWithConfiguration(t *testing.T) { Annotations: map[string]string{}, }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("alb"), + IngressClassName: new("alb"), TLS: []networkv1.IngressTLS{ { Hosts: []string{"*.example.com"}, @@ -1585,7 +1585,7 @@ func TestIngressWithConfiguration(t *testing.T) { Namespace: "default", }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("alb"), + IngressClassName: new("alb"), TLS: []networkv1.IngressTLS{ { Hosts: []string{"*.example.com"}, @@ -1621,7 +1621,7 @@ func TestIngressWithConfiguration(t *testing.T) { }, }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("alb"), + IngressClassName: new("alb"), Rules: []networkv1.IngressRule{ {Host: "some.subdomain.mydomain.com"}, }, @@ -1661,7 +1661,7 @@ func TestIngressWithConfiguration(t *testing.T) { }, }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("alb"), + IngressClassName: new("alb"), Rules: []networkv1.IngressRule{ {Host: "some.subdomain.mydomain.com"}, }, @@ -1693,7 +1693,7 @@ func TestIngressWithConfiguration(t *testing.T) { Namespace: "default", }, Spec: networkv1.IngressSpec{ - IngressClassName: testutils.ToPtr("alb"), + IngressClassName: new("alb"), Rules: []networkv1.IngressRule{ {Host: "app.example.com"}, }, diff --git a/source/istio_gateway_test.go b/source/istio_gateway_test.go index 113595571..118230d0d 100644 --- a/source/istio_gateway_test.go +++ b/source/istio_gateway_test.go @@ -1802,7 +1802,7 @@ func TestSingleGatewayMultipleServicesPointingToSameLoadBalancer(t *testing.T) { ClusterIPs: []string{"10.118.223.3"}, ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyCluster, IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, - IPFamilyPolicy: testutils.ToPtr(v1.IPFamilyPolicySingleStack), + IPFamilyPolicy: new(v1.IPFamilyPolicySingleStack), Ports: []v1.ServicePort{ { Name: "http2", @@ -1823,7 +1823,7 @@ func TestSingleGatewayMultipleServicesPointingToSameLoadBalancer(t *testing.T) { Ingress: []v1.LoadBalancerIngress{ { IP: "34.66.66.77", - IPMode: testutils.ToPtr(v1.LoadBalancerIPModeVIP), + IPMode: new(v1.LoadBalancerIPModeVIP), }, }, }, @@ -1844,7 +1844,7 @@ func TestSingleGatewayMultipleServicesPointingToSameLoadBalancer(t *testing.T) { ClusterIPs: []string{"10.118.220.130"}, ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyCluster, IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, - IPFamilyPolicy: testutils.ToPtr(v1.IPFamilyPolicySingleStack), + IPFamilyPolicy: new(v1.IPFamilyPolicySingleStack), Ports: []v1.ServicePort{ { Name: "upd-dns", @@ -1865,7 +1865,7 @@ func TestSingleGatewayMultipleServicesPointingToSameLoadBalancer(t *testing.T) { Ingress: []v1.LoadBalancerIngress{ { IP: "34.66.66.77", - IPMode: testutils.ToPtr(v1.LoadBalancerIPModeVIP), + IPMode: new(v1.LoadBalancerIPModeVIP), }, }, }, diff --git a/source/service_fqdn_test.go b/source/service_fqdn_test.go index 66f85dbb0..489206cbd 100644 --- a/source/service_fqdn_test.go +++ b/source/service_fqdn_test.go @@ -218,8 +218,8 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { Addresses: []string{"100.66.2.246"}, - Hostname: testutils.ToPtr("ip-10-1-164-158.internal"), - NodeName: testutils.ToPtr("test-node"), + Hostname: new("ip-10-1-164-158.internal"), + NodeName: new("test-node"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-1", @@ -228,8 +228,8 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { }, { Addresses: []string{"100.66.2.247"}, - Hostname: testutils.ToPtr("ip-10-1-164-158.internal"), - NodeName: testutils.ToPtr("test-node"), + Hostname: new("ip-10-1-164-158.internal"), + NodeName: new("test-node"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-2", @@ -281,8 +281,8 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { Addresses: []string{"100.66.2.246"}, - Hostname: testutils.ToPtr("ip-10-1-164-158.internal"), - NodeName: testutils.ToPtr("test-node"), + Hostname: new("ip-10-1-164-158.internal"), + NodeName: new("test-node"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-1", @@ -291,8 +291,8 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { }, { Addresses: []string{"100.66.2.247"}, - Hostname: testutils.ToPtr("ip-10-1-164-158.internal"), - NodeName: testutils.ToPtr("test-node"), + Hostname: new("ip-10-1-164-158.internal"), + NodeName: new("test-node"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-2", @@ -321,7 +321,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { ClusterIP: "192.51.100.22", ExternalIPs: []string{"198.51.100.30"}, // https://kubernetes.io/docs/reference/networking/virtual-ips/#traffic-distribution - TrafficDistribution: testutils.ToPtr("PreferSameZone"), + TrafficDistribution: new("PreferSameZone"), }, Status: v1.ServiceStatus{}, }, @@ -337,7 +337,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { Type: v1.ServiceTypeClusterIP, ClusterIP: "192.51.100.5", ExternalIPs: []string{"198.51.100.32"}, - TrafficDistribution: testutils.ToPtr("PreferSameZone"), + TrafficDistribution: new("PreferSameZone"), }, }, { @@ -352,7 +352,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { Type: v1.ServiceTypeClusterIP, ClusterIP: "192.51.100.33", ExternalIPs: []string{"198.51.100.70"}, - TrafficDistribution: testutils.ToPtr("PreferClose"), + TrafficDistribution: new("PreferClose"), }, }, }, @@ -480,7 +480,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { Addresses: []string{"100.66.2.241"}, - Hostname: testutils.ToPtr("ip-10-1-164-158.internal"), + Hostname: new("ip-10-1-164-158.internal"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-1", @@ -501,7 +501,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { Addresses: []string{"100.66.2.244"}, - Hostname: testutils.ToPtr("ip-10-1-164-152.internal"), + Hostname: new("ip-10-1-164-152.internal"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-2", @@ -522,7 +522,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { Addresses: []string{"100.66.2.246"}, - Hostname: testutils.ToPtr("ip-10-1-164-158.internal"), + Hostname: new("ip-10-1-164-158.internal"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-3", @@ -531,7 +531,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { }, { Addresses: []string{"100.66.2.247"}, - Hostname: testutils.ToPtr("ip-10-1-164-158.internal"), + Hostname: new("ip-10-1-164-158.internal"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-4", @@ -611,7 +611,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { Addresses: []string{"100.66.2.241"}, - Hostname: testutils.ToPtr("ip-10-1-164-158.internal"), + Hostname: new("ip-10-1-164-158.internal"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-1", @@ -632,7 +632,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { Addresses: []string{"100.66.2.244"}, - Hostname: testutils.ToPtr("ip-10-1-164-152.internal"), + Hostname: new("ip-10-1-164-152.internal"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-2", @@ -653,7 +653,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { Addresses: []string{"100.66.2.246"}, - Hostname: testutils.ToPtr("ip-10-1-164-158.internal"), + Hostname: new("ip-10-1-164-158.internal"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-3", @@ -662,7 +662,7 @@ func TestServiceSourceFqdnTemplatingExamples(t *testing.T) { }, { Addresses: []string{"100.66.2.247"}, - Hostname: testutils.ToPtr("ip-10-1-164-158.internal"), + Hostname: new("ip-10-1-164-158.internal"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "pod-4", diff --git a/source/service_test.go b/source/service_test.go index ee508a80f..a3fb2a328 100644 --- a/source/service_test.go +++ b/source/service_test.go @@ -3366,7 +3366,7 @@ func TestMultipleServicesPointingToSameLoadBalancer(t *testing.T) { ClusterIPs: []string{"10.118.223.3"}, ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyCluster, IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, - IPFamilyPolicy: testutils.ToPtr(v1.IPFamilyPolicySingleStack), + IPFamilyPolicy: new(v1.IPFamilyPolicySingleStack), Ports: []v1.ServicePort{ { Name: "http2", @@ -3387,7 +3387,7 @@ func TestMultipleServicesPointingToSameLoadBalancer(t *testing.T) { Ingress: []v1.LoadBalancerIngress{ { IP: "34.66.66.77", - IPMode: testutils.ToPtr(v1.LoadBalancerIPModeVIP), + IPMode: new(v1.LoadBalancerIPModeVIP), }, }, }, @@ -3411,7 +3411,7 @@ func TestMultipleServicesPointingToSameLoadBalancer(t *testing.T) { ClusterIPs: []string{"10.118.220.130"}, ExternalTrafficPolicy: v1.ServiceExternalTrafficPolicyCluster, IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, - IPFamilyPolicy: testutils.ToPtr(v1.IPFamilyPolicySingleStack), + IPFamilyPolicy: new(v1.IPFamilyPolicySingleStack), Ports: []v1.ServicePort{ { Name: "upd-dns", @@ -3432,7 +3432,7 @@ func TestMultipleServicesPointingToSameLoadBalancer(t *testing.T) { Ingress: []v1.LoadBalancerIngress{ { IP: "34.66.66.77", - IPMode: testutils.ToPtr(v1.LoadBalancerIPModeVIP), + IPMode: new(v1.LoadBalancerIPModeVIP), }, }, }, @@ -3484,9 +3484,9 @@ func TestMultipleHeadlessServicesPointingToPodsOnTheSameNode(t *testing.T) { Type: v1.ServiceTypeClusterIP, ClusterIP: v1.ClusterIPNone, ClusterIPs: []string{v1.ClusterIPNone}, - InternalTrafficPolicy: testutils.ToPtr(v1.ServiceInternalTrafficPolicyCluster), + InternalTrafficPolicy: new(v1.ServiceInternalTrafficPolicyCluster), IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, - IPFamilyPolicy: testutils.ToPtr(v1.IPFamilyPolicySingleStack), + IPFamilyPolicy: new(v1.IPFamilyPolicySingleStack), Ports: []v1.ServicePort{ { Name: "web", @@ -3519,9 +3519,9 @@ func TestMultipleHeadlessServicesPointingToPodsOnTheSameNode(t *testing.T) { Type: v1.ServiceTypeClusterIP, ClusterIP: v1.ClusterIPNone, ClusterIPs: []string{v1.ClusterIPNone}, - InternalTrafficPolicy: testutils.ToPtr(v1.ServiceInternalTrafficPolicyCluster), + InternalTrafficPolicy: new(v1.ServiceInternalTrafficPolicyCluster), IPFamilies: []v1.IPFamily{v1.IPv4Protocol}, - IPFamilyPolicy: testutils.ToPtr(v1.IPFamilyPolicySingleStack), + IPFamilyPolicy: new(v1.IPFamilyPolicySingleStack), Ports: []v1.ServicePort{ { Name: "web", @@ -3680,47 +3680,47 @@ func TestMultipleHeadlessServicesPointingToPodsOnTheSameNode(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { Addresses: []string{"10.244.1.2"}, - Hostname: testutils.ToPtr("kafka-0"), - NodeName: testutils.ToPtr("local-dev-worker"), + Hostname: new("kafka-0"), + NodeName: new("local-dev-worker"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "kafka-0", Namespace: "default", }, Conditions: discoveryv1.EndpointConditions{ - Ready: testutils.ToPtr(true), - Serving: testutils.ToPtr(true), - Terminating: testutils.ToPtr(false), + Ready: new(true), + Serving: new(true), + Terminating: new(false), }, }, { Addresses: []string{"10.244.1.3"}, - Hostname: testutils.ToPtr("kafka-1"), - NodeName: testutils.ToPtr("local-dev-worker"), + Hostname: new("kafka-1"), + NodeName: new("local-dev-worker"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "kafka-1", Namespace: "default", }, Conditions: discoveryv1.EndpointConditions{ - Ready: testutils.ToPtr(true), - Serving: testutils.ToPtr(true), - Terminating: testutils.ToPtr(false), + Ready: new(true), + Serving: new(true), + Terminating: new(false), }, }, { Addresses: []string{"10.244.1.4"}, - Hostname: testutils.ToPtr("kafka-2"), - NodeName: testutils.ToPtr("local-dev-worker"), + Hostname: new("kafka-2"), + NodeName: new("local-dev-worker"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "kafka-2", Namespace: "default", }, Conditions: discoveryv1.EndpointConditions{ - Ready: testutils.ToPtr(true), - Serving: testutils.ToPtr(true), - Terminating: testutils.ToPtr(false), + Ready: new(true), + Serving: new(true), + Terminating: new(false), }, }, }, @@ -3740,47 +3740,47 @@ func TestMultipleHeadlessServicesPointingToPodsOnTheSameNode(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { Addresses: []string{"10.244.1.2"}, - Hostname: testutils.ToPtr("kafka-0"), - NodeName: testutils.ToPtr("local-dev-worker"), + Hostname: new("kafka-0"), + NodeName: new("local-dev-worker"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "kafka-0", Namespace: "default", }, Conditions: discoveryv1.EndpointConditions{ - Ready: testutils.ToPtr(true), - Serving: testutils.ToPtr(true), - Terminating: testutils.ToPtr(false), + Ready: new(true), + Serving: new(true), + Terminating: new(false), }, }, { Addresses: []string{"10.244.1.3"}, - Hostname: testutils.ToPtr("kafka-1"), - NodeName: testutils.ToPtr("local-dev-worker"), + Hostname: new("kafka-1"), + NodeName: new("local-dev-worker"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "kafka-1", Namespace: "default", }, Conditions: discoveryv1.EndpointConditions{ - Ready: testutils.ToPtr(true), - Serving: testutils.ToPtr(true), - Terminating: testutils.ToPtr(false), + Ready: new(true), + Serving: new(true), + Terminating: new(false), }, }, { Addresses: []string{"10.244.1.4"}, - Hostname: testutils.ToPtr("kafka-2"), - NodeName: testutils.ToPtr("local-dev-worker"), + Hostname: new("kafka-2"), + NodeName: new("local-dev-worker"), TargetRef: &v1.ObjectReference{ Kind: "Pod", Name: "kafka-2", Namespace: "default", }, Conditions: discoveryv1.EndpointConditions{ - Ready: testutils.ToPtr(true), - Serving: testutils.ToPtr(true), - Terminating: testutils.ToPtr(false), + Ready: new(true), + Serving: new(true), + Terminating: new(false), }, }, }, @@ -5254,7 +5254,7 @@ func TestProcessEndpointSlices_PublishPodIPsPodNil(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { TargetRef: &v1.ObjectReference{Kind: "Pod", Name: "missing-pod"}, - Conditions: discoveryv1.EndpointConditions{Ready: testutils.ToPtr(true)}, + Conditions: discoveryv1.EndpointConditions{Ready: new(true)}, }, }, } @@ -5280,7 +5280,7 @@ func TestProcessEndpointSlices_PublishPodIPsUnsupportedAddressType(t *testing.T) Endpoints: []discoveryv1.Endpoint{ { TargetRef: &v1.ObjectReference{Kind: "Pod", Name: "some-pod"}, - Conditions: discoveryv1.EndpointConditions{Ready: testutils.ToPtr(true)}, + Conditions: discoveryv1.EndpointConditions{Ready: new(true)}, }, }, } @@ -5306,7 +5306,7 @@ func TestProcessEndpointSlices_PublishPodIPsFalse(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { TargetRef: &v1.ObjectReference{Kind: "Pod", Name: "test-pod"}, - Conditions: discoveryv1.EndpointConditions{Ready: testutils.ToPtr(true)}, + Conditions: discoveryv1.EndpointConditions{Ready: new(true)}, Addresses: []string{"10.0.0.1"}, }, }, @@ -5336,7 +5336,7 @@ func TestProcessEndpointSlices_NotReadyWithPublishNotReady(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { TargetRef: &v1.ObjectReference{Kind: "Pod", Name: "test-pod"}, - Conditions: discoveryv1.EndpointConditions{Ready: testutils.ToPtr(false)}, // Not ready + Conditions: discoveryv1.EndpointConditions{Ready: new(false)}, // Not ready Addresses: []string{"10.0.0.1"}, }, }, @@ -5602,7 +5602,7 @@ func TestProcessEndpointSlices_PodWithHostname(t *testing.T) { Endpoints: []discoveryv1.Endpoint{ { TargetRef: &v1.ObjectReference{Kind: "Pod", Name: "test-pod"}, - Conditions: discoveryv1.EndpointConditions{Ready: testutils.ToPtr(true)}, + Conditions: discoveryv1.EndpointConditions{Ready: new(true)}, Addresses: []string{"10.0.0.1"}, }, }, diff --git a/tests/integration/toolkit/toolkit.go b/tests/integration/toolkit/toolkit.go index 6687aa459..c4fd18d03 100644 --- a/tests/integration/toolkit/toolkit.go +++ b/tests/integration/toolkit/toolkit.go @@ -33,8 +33,6 @@ import ( "sigs.k8s.io/external-dns/pkg/apis/externaldns" - "sigs.k8s.io/external-dns/internal/testutils" - "sigs.k8s.io/external-dns/source" "sigs.k8s.io/external-dns/source/wrappers" ) @@ -138,7 +136,7 @@ func generatePodsAndEndpointSlice(svc *corev1.Service, deps *PodDependencies) ([ Name: podName, }, Conditions: discoveryv1.EndpointConditions{ - Ready: testutils.ToPtr(true), + Ready: new(true), }, }) }