Skip to content

Commit

Permalink
fix: linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
belokobylskii.i committed Mar 22, 2024
1 parent d22746b commit 6818bc1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion cmd/webhook/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ var rootCmd = &cobra.Command{
Long: "provider webhook for the Selectel DNS service",
Run: func(cmd *cobra.Command, args []string) {
logger := getLogger()
defer logger.Sync()
defer func(logger *zap.Logger) {
err := logger.Sync()
if err != nil {
log.Printf("Synchronization of logs failed with error: %v", err)
}
}(logger)

endpointDomainFilter := endpoint.DomainFilter{Filters: domainFilter}

Expand Down
2 changes: 1 addition & 1 deletion internal/selprovider/apply_changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func getChangeTypeChanges(changeType ChangeType) *plan.Changes {
}
}

func getApplyChangesBasicTestCases( //nolint:funlen // Test cases are long
func getApplyChangesBasicTestCases(
validZoneResponse []byte,
validRRSetResponse []byte,
invalidZoneResponse []byte,
Expand Down
4 changes: 3 additions & 1 deletion internal/selprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ type Provider struct {
rrSetFetcherClient *rrSetFetcher
}

// getDomainsClient returns v2.DNSClient with provided keystone and user-agent from httpclient.DefaultUserAgent
// getDomainsClient returns v2.DNSClient with provided keystone and user-agent from httpclient.DefaultUserAgent.
func (p *Provider) getDomainsClient() (domains.DNSClient[domains.Zone, domains.RRSet], error) {
token, err := p.keystoneProvider.GetToken()
if err != nil {
p.logger.Error("authorization error during getting keystone token", zap.Error(err))

return nil, err
}

httpClient := httpclient.Default()
headers := http.Header{}
headers.Add("X-Auth-Token", token)
headers.Add("User-Agent", httpclient.DefaultUserAgent)

return domains.NewClient(p.endpoint, &httpClient, headers), nil
}

Expand Down
1 change: 1 addition & 0 deletions internal/selprovider/records_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func TestZoneEndpoint403Records(t *testing.T) {
}

func getDefaultKeystoneProvider(t *testing.T, callTimes int) KeystoneProvider {
t.Helper()
ctrl := gomock.NewController(t)
t.Cleanup(ctrl.Finish)

Expand Down
1 change: 0 additions & 1 deletion internal/selprovider/rrset_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

type rrSetFetcher struct {
domainFilter endpoint.DomainFilter
projectId string
logger *zap.Logger
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/keystone/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func defaultOSClient(endpoint string) (*gophercloud.ProviderClient, error) {
client, err := openstack.NewClient(endpoint)
client.HTTPClient = httpclient.Default()
client.UserAgent.Prepend(httpclient.DefaultUserAgent)

return client, err
}

Expand Down Expand Up @@ -57,6 +58,7 @@ func (p Provider) GetToken() (string, error) {
client, err := defaultOSClient(p.credentials.IdentityEndpoint)
if err != nil {
p.logger.Error("error during creating default openstack client", zap.Error(err))

return "", err
}
err = openstack.Authenticate(client, opts)
Expand Down

0 comments on commit 6818bc1

Please sign in to comment.