Skip to content

Commit

Permalink
Fix and ignore from staticcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
whywaita committed Sep 12, 2024
1 parent bd95658 commit 5908681
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
11 changes: 8 additions & 3 deletions api/myshoes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/datastore/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
)
1 change: 1 addition & 0 deletions pkg/datastore/mysql/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/docker/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 0 additions & 7 deletions pkg/runner/runner_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5908681

Please sign in to comment.