diff --git a/api/myshoes/client.go b/api/myshoes/client.go index 454fa37..0f71179 100644 --- a/api/myshoes/client.go +++ b/api/myshoes/client.go @@ -37,15 +37,20 @@ func NewClient(endpoint string, client *http.Client, logger *log.Logger) (*Clien } l := logger if l == nil { - // Default is discard logger - l = log.New(io.Discard, "", log.LstdFlags) + return &Client{ + HTTPClient: *httpClient, + URL: u, + + // Default is discard logger + Logger: log.New(io.Discard, "", log.LstdFlags), + }, nil } return &Client{ HTTPClient: *httpClient, URL: u, - Logger: logger, + Logger: l, }, nil } diff --git a/pkg/datastore/interface.go b/pkg/datastore/interface.go index 5bb5c29..9e63626 100644 --- a/pkg/datastore/interface.go +++ b/pkg/datastore/interface.go @@ -156,7 +156,7 @@ type TargetStatus string // TargetStatus variables const ( - TargetStatusActive TargetStatus = "active" + TargetStatusActive TargetStatus = "active" //lint:ignore SA9004 this is status TargetStatusRunning = "running" TargetStatusSuspend = "suspend" TargetStatusDeleted = "deleted" @@ -215,7 +215,7 @@ type RunnerStatus string // RunnerStatus variables const ( - RunnerStatusCreated RunnerStatus = "created" + RunnerStatusCreated RunnerStatus = "created" //lint:ignore SA9004 this is status RunnerStatusCompleted = "completed" RunnerStatusReachHardLimit = "reach_hard_limit" ) diff --git a/pkg/datastore/mysql/target_test.go b/pkg/datastore/mysql/target_test.go index 25c1a85..64a3da8 100644 --- a/pkg/datastore/mysql/target_test.go +++ b/pkg/datastore/mysql/target_test.go @@ -542,6 +542,7 @@ func TestMySQL_UpdateStatus(t *testing.T) { t.Fatalf("failed to create target: %+v", err) } + //lint:ignore SA1019 only execute in test err := testDatastore.UpdateTargetStatus(context.Background(), tID, test.input.status, test.input.description) if !test.err && err != nil { t.Fatalf("failed to update status: %+v", err) diff --git a/pkg/docker/ratelimit.go b/pkg/docker/ratelimit.go index 660fa72..1e0fbf1 100644 --- a/pkg/docker/ratelimit.go +++ b/pkg/docker/ratelimit.go @@ -29,6 +29,9 @@ var cacheMap = make(map[int]tokenCache, 1) func getToken() (string, error) { url := "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" req, err := http.NewRequest("GET", url, nil) + if err != nil { + return "", fmt.Errorf("create request: %w", err) + } if config.Config.DockerHubCredential.Password != "" && config.Config.DockerHubCredential.Username != "" { req.SetBasicAuth(config.Config.DockerHubCredential.Username, config.Config.DockerHubCredential.Password) } @@ -75,6 +78,9 @@ func GetRateLimit() (RateLimit, error) { } url := "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" req, err := http.NewRequest("HEAD", url, nil) + if err != nil { + return RateLimit{}, fmt.Errorf("create request: %w", err) + } req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token)) resp, err := http.DefaultClient.Do(req) if err != nil { diff --git a/pkg/runner/runner_delete.go b/pkg/runner/runner_delete.go index 1ef337d..b2b55dd 100644 --- a/pkg/runner/runner_delete.go +++ b/pkg/runner/runner_delete.go @@ -20,13 +20,6 @@ import ( "google.golang.org/grpc/status" ) -// Runner is a runner implement -type Runner struct { - status string - github *github.Runner - ds *datastore.Runner -} - var ( // ConcurrencyDeleting is value of concurrency ConcurrencyDeleting atomic.Int64