Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ linters:
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. [fast: true, auto-fix: false]
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. [fast: false, auto-fix: false]
- prealloc # Finds slice declarations that could potentially be pre-allocated [fast: true, auto-fix: false]
- predeclared # find code that shadows one of Go's predeclared identifiers [fast: true, auto-fix: false]
- promlinter # Check Prometheus metrics naming via promlint [fast: true, auto-fix: false]
- protogetter # Reports direct reads from proto message fields when getters should be used [fast: false, auto-fix: true]
- reassign # Checks that package variables are not reassigned [fast: false, auto-fix: false]
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. [fast: false, auto-fix: false]
- rowserrcheck # checks whether Err of rows is checked successfully [fast: false, auto-fix: false]
- sloglint # ensure consistent code style when using log/slog [fast: false, auto-fix: false]
- sqlclosecheck # Checks that sql.Rows and sql.Stmt are closed. [fast: false, auto-fix: false]
- staticcheck #(megacheck): Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false, auto-fix: false]
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17 [fast: false, auto-fix: false]
- testifylint # Checks usage of github.com/stretchr/testify. [fast: false, auto-fix: false]
- thelper # thelper detects golang test helpers without t.Helper() call and checks the consistency of test helpers [fast: false, auto-fix: false]
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes [fast: false, auto-fix: false]
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code [fast: false, auto-fix: false]
- unconvert # Remove unnecessary type conversions [fast: false, auto-fix: false]
- unused #(megacheck): Checks Go code for unused constants, variables, functions and types [fast: false, auto-fix: false]
Expand Down
12 changes: 6 additions & 6 deletions api/domain/v2beta1/domain_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (s *API) WaitForDNSZone(
DNSZoneStatusError: {},
}

dns, err := async.WaitSync(&async.WaitSyncConfig{
dnsZone, err := async.WaitSync(&async.WaitSyncConfig{
Get: func() (interface{}, bool, error) {
listReq := &ListDNSZonesRequest{
DNSZones: req.DNSZones,
Expand All @@ -58,7 +58,7 @@ func (s *API) WaitForDNSZone(
listReq.DNSZone = &req.DNSZone
}

// listing dns zones and take the first one
// listing dnsZone zones and take the first one
DNSZones, err := s.ListDNSZones(listReq, opts...)
if err != nil {
return nil, false, err
Expand All @@ -68,11 +68,11 @@ func (s *API) WaitForDNSZone(
return nil, true, errors.New(ErrCodeNoSuchDNSZone)
}

Dns := DNSZones.DNSZones[0]
zone := DNSZones.DNSZones[0]

_, isTerminal := terminalStatus[Dns.Status]
_, isTerminal := terminalStatus[zone.Status]

return Dns, isTerminal, nil
return zone, isTerminal, nil
},
Timeout: timeout,
IntervalStrategy: async.LinearIntervalStrategy(retryInterval),
Expand All @@ -81,7 +81,7 @@ func (s *API) WaitForDNSZone(
return nil, errors.Wrap(err, "waiting for DNS failed")
}

return dns.(*DNSZone), nil
return dnsZone.(*DNSZone), nil
}

// WaitForDNSRecordExistRequest is used by WaitForDNSRecordExist method.
Expand Down
2 changes: 1 addition & 1 deletion api/edge_services/v1alpha1/edge_services_utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package edge_services
package edge_services //nolint:revive

import (
"time"
Expand Down
12 changes: 6 additions & 6 deletions api/instance/v1/instance_metadata_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewMetadataAPI() *MetadataAPI {
return &MetadataAPI{}
}

func (meta *MetadataAPI) getMetadataUrl() string {
func (meta *MetadataAPI) getMetadataURL() string {
if meta.MetadataURL != nil {
return *meta.MetadataURL
}
Expand All @@ -48,7 +48,7 @@ func (meta *MetadataAPI) getMetadataUrl() string {

// GetMetadata returns the metadata available from the server
func (meta *MetadataAPI) GetMetadata() (m *Metadata, err error) {
resp, err := http.Get(meta.getMetadataUrl() + "/conf?format=json")
resp, err := http.Get(meta.getMetadataURL() + "/conf?format=json")
if err != nil {
return nil, errors.Wrap(err, "error getting metadataURL")
}
Expand Down Expand Up @@ -178,7 +178,7 @@ func (meta *MetadataAPI) ListUserData() (res *UserData, err error) {
},
}

resp, err := userdataClient.Get(meta.getMetadataUrl() + "/user_data?format=json")
resp, err := userdataClient.Get(meta.getMetadataURL() + "/user_data?format=json")
if err != nil {
retries++ // retry with a different source port
continue
Expand Down Expand Up @@ -219,7 +219,7 @@ func (meta *MetadataAPI) GetUserData(key string) ([]byte, error) {
},
}

resp, err := userdataClient.Get(meta.getMetadataUrl() + "/user_data/" + key)
resp, err := userdataClient.Get(meta.getMetadataURL() + "/user_data/" + key)
if err != nil {
retries++ // retry with a different source port
continue
Expand Down Expand Up @@ -259,7 +259,7 @@ func (meta *MetadataAPI) SetUserData(key string, value []byte) error {
}).DialContext,
},
}
request, err := http.NewRequest(http.MethodPatch, meta.getMetadataUrl()+"/user_data/"+key, bytes.NewBuffer(value))
request, err := http.NewRequest(http.MethodPatch, meta.getMetadataURL()+"/user_data/"+key, bytes.NewBuffer(value))
if err != nil {
return errors.Wrap(err, "error creating patch userdata request")
}
Expand Down Expand Up @@ -298,7 +298,7 @@ func (meta *MetadataAPI) DeleteUserData(key string) error {
}).DialContext,
},
}
request, err := http.NewRequest(http.MethodDelete, meta.getMetadataUrl()+"/user_data/"+key, bytes.NewBufferString(""))
request, err := http.NewRequest(http.MethodDelete, meta.getMetadataURL()+"/user_data/"+key, bytes.NewBufferString(""))
if err != nil {
return errors.Wrap(err, "error creating delete userdata request")
}
Expand Down
4 changes: 2 additions & 2 deletions api/instance/v1/instance_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *API) AttachIP(req *AttachIPRequest, opts ...scw.RequestOption) (*Attach
Zone: req.Zone,
IP: req.IP,
Server: &NullableStringValue{Value: req.ServerID},
})
}, opts...)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func (s *API) DetachIP(req *DetachIPRequest, opts ...scw.RequestOption) (*Detach
Zone: req.Zone,
IP: req.IP,
Server: &NullableStringValue{Null: true},
})
}, opts...)
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions api/instance/v1/server_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func (s *API) GetAllServerUserData(req *GetAllServerUserDataRequest, opts ...scw
allUserDataRes, err := s.ListServerUserData(&ListServerUserDataRequest{
Zone: req.Zone,
ServerID: req.ServerID,
})
}, opts...)
if err != nil {
return nil, err
}
Expand All @@ -327,7 +327,7 @@ func (s *API) GetAllServerUserData(req *GetAllServerUserDataRequest, opts ...scw
Zone: req.Zone,
ServerID: req.ServerID,
Key: key,
})
}, opts...)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -369,7 +369,7 @@ func (s *API) SetAllServerUserData(req *SetAllServerUserDataRequest, opts ...scw
allUserDataRes, err := s.ListServerUserData(&ListServerUserDataRequest{
Zone: req.Zone,
ServerID: req.ServerID,
})
}, opts...)
if err != nil {
return err
}
Expand All @@ -384,7 +384,7 @@ func (s *API) SetAllServerUserData(req *SetAllServerUserDataRequest, opts ...scw
Zone: req.Zone,
ServerID: req.ServerID,
Key: key,
})
}, opts...)
if err != nil {
return err
}
Expand All @@ -397,7 +397,7 @@ func (s *API) SetAllServerUserData(req *SetAllServerUserDataRequest, opts ...scw
ServerID: req.ServerID,
Key: key,
Content: value,
})
}, opts...)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion api/k8s/v1/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (s *API) GetClusterKubeConfig(req *GetClusterKubeConfigRequest, opts ...scw
kubeconfigFile, err := s.getClusterKubeConfig(&GetClusterKubeConfigRequest{
Region: req.Region,
ClusterID: req.ClusterID,
})
}, opts...)
if err != nil {
return nil, errors.Wrap(err, "error getting cluster kubeconfig")
}
Expand Down
2 changes: 1 addition & 1 deletion api/serverless_sqldb/v1alpha1/serverless_sqldb_utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package serverless_sqldb
package serverless_sqldb //nolint:revive

import (
"time"
Expand Down
11 changes: 11 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scalewaysdkgo

import (
"fmt"
"log"
"time"

"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
Expand All @@ -16,6 +17,7 @@ func Example_apiClient() {
)
if err != nil {
// handle error
log.Fatal(err)
}

// Create SDK objects for specific Scaleway Products
Expand All @@ -31,12 +33,14 @@ func Example_apiClientWithConfig() {
config, err := scw.LoadConfig()
if err != nil {
// handle error
log.Fatal(err)
}

// Use active profile
profile, err := config.GetActiveProfile()
if err != nil {
// handle error
log.Fatal(err)
}

// Create a Scaleway client
Expand All @@ -46,6 +50,7 @@ func Example_apiClientWithConfig() {
)
if err != nil {
// handle error
log.Fatal(err)
}

// Create SDK objects for specific Scaleway Products
Expand All @@ -63,6 +68,7 @@ func Example_listServers() {
)
if err != nil {
// handle error
log.Fatal(err)
}

// Create SDK objects for Scaleway Instance product
Expand All @@ -74,6 +80,7 @@ func Example_listServers() {
})
if err != nil {
// handle error
log.Fatal(err)
}

// Do something with the response...
Expand All @@ -87,6 +94,7 @@ func Example_listServersWithZones() {
)
if err != nil {
// handle error
log.Fatal(err)
}

// Create SDK objects for Scaleway Instance product
Expand All @@ -98,6 +106,7 @@ func Example_listServersWithZones() {
scw.WithZones(scw.ZoneFrPar1, scw.ZoneNlAms1, scw.ZonePlWaw1))
if err != nil {
// handle error
log.Fatal(err)
}

// Do something with the response...
Expand Down Expand Up @@ -188,6 +197,7 @@ func Example_createLoadBalancer() {
)
if err != nil {
// handle error
log.Fatal(err)
}

// Create SDK objects for Scaleway LoadConfig Balancer product
Expand All @@ -200,6 +210,7 @@ func Example_createLoadBalancer() {
})
if err != nil {
// handle error
log.Fatal(err)
}

// Do something with the newly created LB...
Expand Down
1 change: 1 addition & 0 deletions internal/async/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func getMock(iterations int, sleepTime time.Duration) func() (interface{}, bool,
}

func TestWaitSync(t *testing.T) {
t.Parallel()
testsCases := []struct {
name string
config *WaitSyncConfig
Expand Down
4 changes: 2 additions & 2 deletions scw/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var (
testFloat32 float32 = 46
testFloat64 float64 = 47
testDuration time.Duration = 48
testTime time.Time = time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC)
testSize Size = 3 * GB
testTime = time.Date(2009, 11, 10, 23, 0, 0, 0, time.UTC)
testSize = 3 * GB
)

func TestStringPtr(t *testing.T) {
Expand Down