Reformat code to meet lint standards

This commit is contained in:
Rick Henry 2021-12-07 14:38:34 +00:00
parent 023eb23ef9
commit 6fc68a82db
No known key found for this signature in database
GPG Key ID: 07243CA36106218D
2 changed files with 456 additions and 457 deletions

View File

@ -21,14 +21,14 @@ import (
"fmt"
"os"
"github.com/ukfast/sdk-go/pkg/service/safedns"
log "github.com/sirupsen/logrus"
ukf_client "github.com/ukfast/sdk-go/pkg/client"
ukf_connection "github.com/ukfast/sdk-go/pkg/connection"
ukfClient "github.com/ukfast/sdk-go/pkg/client"
ukfConnection "github.com/ukfast/sdk-go/pkg/connection"
"github.com/ukfast/sdk-go/pkg/service/safedns"
"sigs.k8s.io/external-dns/provider"
"sigs.k8s.io/external-dns/endpoint"
"sigs.k8s.io/external-dns/plan"
"sigs.k8s.io/external-dns/provider"
)
// SafeDNS is an interface that is a subset of the SafeDNS service API that are actually used.
@ -38,8 +38,8 @@ type SafeDNS interface {
DeleteZoneRecord(zoneName string, recordID int) error
GetZone(zoneName string) (safedns.Zone, error)
GetZoneRecord(zoneName string, recordID int) (safedns.Record, error)
GetZoneRecords(zoneName string, parameters ukf_connection.APIRequestParameters) ([]safedns.Record, error)
GetZones(parameters ukf_connection.APIRequestParameters) ([]safedns.Zone, error)
GetZoneRecords(zoneName string, parameters ukfConnection.APIRequestParameters) ([]safedns.Record, error)
GetZones(parameters ukfConnection.APIRequestParameters) ([]safedns.Zone, error)
PatchZoneRecord(zoneName string, recordID int, patch safedns.PatchRecordRequest) (int, error)
UpdateZoneRecord(zoneName string, record safedns.Record) (int, error)
}
@ -51,7 +51,7 @@ type SafeDNSProvider struct {
// Only consider hosted zones managing domains ending in this suffix
domainFilter endpoint.DomainFilter
DryRun bool
APIRequestParams ukf_connection.APIRequestParameters
APIRequestParams ukfConnection.APIRequestParameters
}
// ZoneRecord is a datatype to simplify management of a record in a zone.
@ -67,18 +67,18 @@ type ZoneRecord struct {
func NewSafeDNSProvider(domainFilter endpoint.DomainFilter, dryRun bool) (*SafeDNSProvider, error) {
token, ok := os.LookupEnv("SAFEDNS_TOKEN")
if !ok {
return nil, fmt.Errorf("No SAFEDNS_TOKEN found in environment")
return nil, fmt.Errorf("no SAFEDNS_TOKEN found in environment")
}
ukfAPIConnection := ukf_connection.NewAPIKeyCredentialsAPIConnection(token)
ukfClient := ukf_client.NewClient(ukfAPIConnection)
ukfAPIConnection := ukfConnection.NewAPIKeyCredentialsAPIConnection(token)
ukfClient := ukfClient.NewClient(ukfAPIConnection)
safeDNS := ukfClient.SafeDNSService()
provider := &SafeDNSProvider{
Client: safeDNS,
domainFilter: domainFilter,
DryRun: dryRun,
APIRequestParams: *ukf_connection.NewAPIRequestParameters(),
APIRequestParams: *ukfConnection.NewAPIRequestParameters(),
}
return provider, nil
}
@ -104,7 +104,7 @@ func (p *SafeDNSProvider) Zones(ctx context.Context) ([]safedns.Zone, error) {
return zones, nil
}
func (p *SafeDNSProvider) ZoneRecords(ctx context.Context) ([]ZoneRecord, error){
func (p *SafeDNSProvider) ZoneRecords(ctx context.Context) ([]ZoneRecord, error) {
zones, err := p.Zones(ctx)
if err != nil {
return nil, err
@ -168,7 +168,7 @@ func (p *SafeDNSProvider) ApplyChanges(ctx context.Context, changes *plan.Change
for _, endpoint := range changes.Create {
_, ZoneName := zoneNameIDMapper.FindZone(endpoint.DNSName)
for _, target := range endpoint.Targets {
request := safedns.CreateRecordRequest {
request := safedns.CreateRecordRequest{
Name: endpoint.DNSName,
Type: endpoint.RecordType,
Content: target,

View File

@ -24,8 +24,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
ukfConnection "github.com/ukfast/sdk-go/pkg/connection"
"github.com/ukfast/sdk-go/pkg/service/safedns"
ukf_connection "github.com/ukfast/sdk-go/pkg/connection"
"sigs.k8s.io/external-dns/endpoint"
"sigs.k8s.io/external-dns/plan"
@ -56,12 +56,12 @@ func (m *MockSafeDNSService) GetZoneRecord(zoneName string, recordID int) (safed
return args.Get(0).(safedns.Record), args.Error(1)
}
func (m *MockSafeDNSService) GetZoneRecords(zoneName string, parameters ukf_connection.APIRequestParameters) ([]safedns.Record, error) {
func (m *MockSafeDNSService) GetZoneRecords(zoneName string, parameters ukfConnection.APIRequestParameters) ([]safedns.Record, error) {
args := m.Called(zoneName, parameters)
return args.Get(0).([]safedns.Record), args.Error(1)
}
func (m *MockSafeDNSService) GetZones(parameters ukf_connection.APIRequestParameters) ([]safedns.Zone, error) {
func (m *MockSafeDNSService) GetZones(parameters ukfConnection.APIRequestParameters) ([]safedns.Zone, error) {
args := m.Called(parameters)
return args.Get(0).([]safedns.Zone), args.Error(1)
}
@ -76,7 +76,6 @@ func (m *MockSafeDNSService) UpdateZoneRecord(zoneName string, record safedns.Re
return args.Int(0), args.Error(1)
}
// Utility functions
func createZones() []safedns.Zone {
return []safedns.Zone{
@ -244,7 +243,7 @@ func TestRecords(t *testing.T) {
assert.Equal(t, expected, actual)
}
func TestSafeDNSApplyChanges( t *testing.T) {
func TestSafeDNSApplyChanges(t *testing.T) {
mockSafeDNSService := MockSafeDNSService{}
provider := &SafeDNSProvider{