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
1 change: 0 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
exit 1
fi


# https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#verify
- name: Verify linter configuration and Lint go code
uses: golangci/golangci-lint-action@v9
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ linters:
- gocritic # Analyze source code for various issues, including bugs, performance hiccups, and non-idiomatic coding practices. https://golangci-lint.run/docs/linters/configuration/#gocritic
- gochecknoinits # Checks that there are no init() functions in the code. https://golangci-lint.run/docs/linters/configuration/#gochecknoinits
- goconst # Finds repeated strings that could be replaced by a constant. https://golangci-lint.run/docs/linters/configuration/#goconst
- modernize # A suite of analyzers that suggest simplifications to Go code, using modern language and library features. https://golangci-lint.run/docs/linters/configuration/#modernize

# tests
- testifylint # Checks usage of github.com/stretchr/testify. https://golangci-lint.run/docs/linters/configuration/#testifylint
Expand Down
8 changes: 4 additions & 4 deletions apis/v1alpha1/dnsendpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ import (
// +versionName=v1alpha1
type DNSEndpoint struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
metav1.ObjectMeta `json:"metadata"`

Spec DNSEndpointSpec `json:"spec,omitempty"`
Status DNSEndpointStatus `json:"status,omitempty"`
Spec DNSEndpointSpec `json:"spec"`
Status DNSEndpointStatus `json:"status"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// DNSEndpointList is a list of DNSEndpoint objects
type DNSEndpointList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
metav1.ListMeta `json:"metadata"`
Items []DNSEndpoint `json:"items"`
}

Expand Down
16 changes: 8 additions & 8 deletions endpoint/domain_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,58 +635,58 @@ func TestRegexDomainFilterIsConfigured(t *testing.T) {
func TestDomainFilterDeserializeError(t *testing.T) {
for _, tt := range []struct {
name string
serialized map[string]interface{}
serialized map[string]any
expectedError string
}{
{
name: "invalid json",
serialized: map[string]interface{}{
serialized: map[string]any{
"include": 3,
},
expectedError: "json: cannot unmarshal number into Go struct field domainFilterSerde.include of type []string",
},
{
name: "include and regex",
serialized: map[string]interface{}{
serialized: map[string]any{
"include": []string{"example.com"},
"regexInclude": "example.com",
},
expectedError: "cannot have both domain list and regex",
},
{
name: "exclude and regex",
serialized: map[string]interface{}{
serialized: map[string]any{
"exclude": []string{"example.com"},
"regexInclude": "example.com",
},
expectedError: "cannot have both domain list and regex",
},
{
name: "include and regexExclude",
serialized: map[string]interface{}{
serialized: map[string]any{
"include": []string{"example.com"},
"regexExclude": "example.com",
},
expectedError: "cannot have both domain list and regex",
},
{
name: "exclude and regexExclude",
serialized: map[string]interface{}{
serialized: map[string]any{
"exclude": []string{"example.com"},
"regexExclude": "example.com",
},
expectedError: "cannot have both domain list and regex",
},
{
name: "invalid regex",
serialized: map[string]interface{}{
serialized: map[string]any{
"regexInclude": "*",
},
expectedError: "invalid regexInclude: error parsing regexp: missing argument to repetition operator: `*`",
},
{
name: "invalid regexExclude",
serialized: map[string]interface{}{
serialized: map[string]any{
"regexExclude": "*",
},
expectedError: "invalid regexExclude: error parsing regexp: missing argument to repetition operator: `*`",
Expand Down
6 changes: 3 additions & 3 deletions internal/gen/docs/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ func TestWriteToFile(t *testing.T) {
func TestFuncs(t *testing.T) {
tests := []struct {
tpl, expect string
vars interface{}
vars any
}{
{
tpl: `{{ backtick 3 }}`,
expect: "```",
vars: map[string]interface{}{},
vars: map[string]any{},
},
{
tpl: `{{ capitalize .name }}`,
expect: "Capital",
vars: map[string]interface{}{"name": "capital"},
vars: map[string]any{"name": "capital"},
},
}

Expand Down
2 changes: 1 addition & 1 deletion internal/testutils/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func GenerateTestEndpointsByType(typeCounts map[string]int) []*endpoint.Endpoint
var result []*endpoint.Endpoint
idx := 0
for rt, count := range typeCounts {
for i := 0; i < count; i++ {
for range count {
result = append(result, &endpoint.Endpoint{
DNSName: fmt.Sprintf("%s-%d.example.com", strings.ToLower(rt), idx),
Targets: endpoint.Targets{fmt.Sprintf("192.0.2.%d", idx)},
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/externaldns/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ func (cfg *Config) String() string {
// prevent logging of sensitive information
temp := *cfg

t := reflect.TypeOf(temp)
t := reflect.TypeFor[Config]()
for i := 0; i < t.NumField(); i++ {
f := t.Field(i)
if val, ok := f.Tag.Lookup("secure"); ok && val == "yes" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/events/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (ec *Controller) run(ctx context.Context) {
defer log.Info("event Controller terminated")
defer utilruntime.HandleCrash()
var waitGroup wait.Group
for i := 0; i < workers; i++ {
for range workers {
waitGroup.StartWithContext(ctx, func(ctx context.Context) {
for ec.processNextWorkItem(ctx) {
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/events/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package events

import (
"context"
"fmt"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -68,7 +67,7 @@ users:
user:
token: fake-token
`
err = os.WriteFile(mockKubeCfgPath, []byte(fmt.Sprintf(kubeCfgTemplate, svr.URL)), os.FileMode(0755))
err = os.WriteFile(mockKubeCfgPath, fmt.Appendf(nil, kubeCfgTemplate, svr.URL), os.FileMode(0755))
require.NoError(t, err)

cfg := NewConfig(
Expand All @@ -95,8 +94,7 @@ func TestController_Run_NoEmitEvents(t *testing.T) {

func TestController_Run_EmitEvents(t *testing.T) {
log.SetLevel(log.ErrorLevel)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()

eventCreated := make(chan struct{})
kubeClient := fake.NewClientset()
Expand Down
2 changes: 1 addition & 1 deletion pkg/http/http_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestRoundTripper_Concurrent(t *testing.T) {
var wg sync.WaitGroup
wg.Add(numGoroutines)

for i := 0; i < numGoroutines; i++ {
for range numGoroutines {
go func() {
defer wg.Done()
body, err := api.doStuff()
Expand Down
4 changes: 2 additions & 2 deletions provider/akamai/akamai.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (p AkamaiProvider) Records(context.Context) ([]*endpoint.Endpoint, error) {
log.Debugf("Skipping endpoint. Record name %s doesn't match containing zone %s.", recordset.Name, zone)
continue
}
var temp interface{} = int64(recordset.TTL)
var temp any = int64(recordset.TTL)
ttl := endpoint.TTL(temp.(int64))
endpoints = append(endpoints, endpoint.NewEndpointWithTTL(recordset.Name,
recordset.Type,
Expand Down Expand Up @@ -352,7 +352,7 @@ func trimTxtRdata(rdata []string, rtype string) []string {
}

func ttlAsInt(src endpoint.TTL) int {
var temp interface{} = int64(src)
var temp any = int64(src)
temp64 := temp.(int64)
var ttl = defaultTTL
if temp64 > 0 && temp64 <= int64(maxInt) {
Expand Down
30 changes: 15 additions & 15 deletions provider/akamai/akamai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import (

type edgednsStubData struct {
objType string // zone, record, recordsets
output []interface{}
updateRecords []interface{}
createRecords []interface{}
output []any
updateRecords []any
createRecords []any
}

type edgednsStub struct {
Expand Down Expand Up @@ -73,7 +73,7 @@ func (r *edgednsStub) createStubDataEntry(objtype string) {
return
}

func (r *edgednsStub) setOutput(objtype string, output []interface{}) {
func (r *edgednsStub) setOutput(objtype string, output []any) {
log.Debugf("Setting output to %v", output)
r.createStubDataEntry(objtype)
stubdata := r.stubData[objtype]
Expand All @@ -83,7 +83,7 @@ func (r *edgednsStub) setOutput(objtype string, output []interface{}) {
return
}

func (r *edgednsStub) setUpdateRecords(objtype string, records []interface{}) {
func (r *edgednsStub) setUpdateRecords(objtype string, records []any) {
log.Debugf("Setting updaterecords to %v", records)
r.createStubDataEntry(objtype)
stubdata := r.stubData[objtype]
Expand All @@ -93,7 +93,7 @@ func (r *edgednsStub) setUpdateRecords(objtype string, records []interface{}) {
return
}

func (r *edgednsStub) setCreateRecords(objtype string, records []interface{}) {
func (r *edgednsStub) setCreateRecords(objtype string, records []any) {
log.Debugf("Setting createrecords to %v", records)
r.createStubDataEntry(objtype)
stubdata := r.stubData[objtype]
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestFetchZonesZoneIDFilter(t *testing.T) {
idfilter := provider.NewZoneIDFilter([]string{"Test"})
c, err := createAkamaiStubProvider(stub, domfilter, idfilter)
assert.NoError(t, err)
stub.setOutput("zone", []interface{}{"test1.testzone.com", "test2.testzone.com"})
stub.setOutput("zone", []any{"test1.testzone.com", "test2.testzone.com"})

x, _ := c.fetchZones()
y, err := json.Marshal(x)
Expand All @@ -173,7 +173,7 @@ func TestFetchZonesEmpty(t *testing.T) {
idfilter := provider.NewZoneIDFilter([]string{"Nonexistent"})
c, err := createAkamaiStubProvider(stub, domfilter, idfilter)
require.NoError(t, err)
stub.setOutput("zone", []interface{}{})
stub.setOutput("zone", []any{})

x, _ := c.fetchZones()
y, err := json.Marshal(x)
Expand All @@ -190,8 +190,8 @@ func TestAkamaiRecords(t *testing.T) {
idfilter := provider.ZoneIDFilter{}
c, err := createAkamaiStubProvider(stub, domfilter, idfilter)
require.NoError(t, err)
stub.setOutput("zone", []interface{}{"test1.testzone.com"})
recordsets := make([]interface{}, 0)
stub.setOutput("zone", []any{"test1.testzone.com"})
recordsets := make([]any, 0)
recordsets = append(recordsets, dns.Recordset{
Name: "www.example.com",
Type: endpoint.RecordTypeA,
Expand Down Expand Up @@ -225,8 +225,8 @@ func TestAkamaiRecordsEmpty(t *testing.T) {
idfilter := provider.NewZoneIDFilter([]string{"Nonexistent"})
c, err := createAkamaiStubProvider(stub, domfilter, idfilter)
require.NoError(t, err)
stub.setOutput("zone", []interface{}{"test1.testzone.com"})
recordsets := make([]interface{}, 0)
stub.setOutput("zone", []any{"test1.testzone.com"})
recordsets := make([]any, 0)
stub.setOutput("recordset", recordsets)

x, _ := c.Records(context.Background())
Expand All @@ -239,8 +239,8 @@ func TestAkamaiRecordsFilters(t *testing.T) {
idfilter := provider.ZoneIDFilter{}
c, err := createAkamaiStubProvider(stub, domfilter, idfilter)
assert.NoError(t, err)
stub.setOutput("zone", []interface{}{"www.exclude.me"})
recordsets := make([]interface{}, 0)
stub.setOutput("zone", []any{"www.exclude.me"})
recordsets := make([]any, 0)
recordsets = append(recordsets, dns.Recordset{
Name: "www.example.com",
Type: endpoint.RecordTypeA,
Expand Down Expand Up @@ -374,7 +374,7 @@ func TestAkamaiApplyChanges(t *testing.T) {
c, err := createAkamaiStubProvider(stub, domfilter, idfilter)
assert.NoError(t, err)

stub.setOutput("zone", []interface{}{"example.com"})
stub.setOutput("zone", []any{"example.com"})
changes := &plan.Changes{}
changes.Create = []*endpoint.Endpoint{
{DNSName: "www.example.com", RecordType: "A", Targets: endpoint.Targets{"target"}, RecordTTL: 300},
Expand Down
30 changes: 8 additions & 22 deletions provider/alibabacloud/alibaba_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"os"
"slices"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -601,13 +602,9 @@ func (p *AlibabaCloudProvider) deleteRecords(recordMap map[string][]alidns.Recor
value = p.unescapeTXTRecordValue(value)
}

for _, target := range endpoint.Targets {
// Find matched record to delete
if value == target {
p.deleteRecord(record.RecordId)
found = true
break
}
if slices.Contains(endpoint.Targets, value) {
p.deleteRecord(record.RecordId)
found = true
}
}
if !found {
Expand Down Expand Up @@ -955,13 +952,9 @@ func (p *AlibabaCloudProvider) deletePrivateZoneRecords(zones map[string]*alibab
if record.Type == "TXT" {
value = p.unescapeTXTRecordValue(value)
}
for _, target := range endpoint.Targets {
// Find matched record to delete
if value == target {
p.deletePrivateZoneRecord(record.RecordId)
found = true
break
}
if slices.Contains(endpoint.Targets, value) {
p.deletePrivateZoneRecord(record.RecordId)
found = true
}
}
}
Expand Down Expand Up @@ -1047,14 +1040,7 @@ func (p *AlibabaCloudProvider) updatePrivateZoneRecords(zones map[string]*alibab
if record.Type == "TXT" {
value = p.unescapeTXTRecordValue(value)
}
found := false
for _, target := range endpoint.Targets {
// Find matched record to delete
if value == target {
found = true
break
}
}
found := slices.Contains(endpoint.Targets, value)
if found {
if !p.equalsPrivateZone(record, endpoint) {
// Update record
Expand Down
9 changes: 3 additions & 6 deletions provider/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -1112,12 +1112,9 @@ func findChangesInQueue(changes Route53Changes, queue Route53Changes) (Route53Ch

for _, c := range changes {
found := false
for _, qc := range queue {
if c == qc {
foundChanges = append(foundChanges, c)
found = true
break
}
if slices.Contains(queue, c) {
foundChanges = append(foundChanges, c)
found = true
}
if !found {
notFoundChanges = append(notFoundChanges, c)
Expand Down
Loading
Loading