Skip to content

Commit 8fee80c

Browse files
authored
Fix gocritic warnings (#563)
- Add missing space after // in a comment (proxy.go) - Rewrite if/else if/else to switch in pullImageWithAuth (run.go) - Replace single-case type switch with if in test helper (job_test.go)
1 parent 1fdc225 commit 8fee80c

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

internal/infra/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func (p *Proxy) Close() (err error) {
182182
}()
183183

184184
// Check the error code if the container has already exited, so we can pass it along to the caller. If the proxy
185-
//crashes we want the CLI to error out.
185+
// crashes we want the CLI to error out.
186186
containerInfo, inspectErr := p.cli.ContainerInspect(context.Background(), p.containerID)
187187
if inspectErr != nil {
188188
return fmt.Errorf("failed to inspect proxy container: %w", inspectErr)

internal/infra/run.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,8 @@ func pullImage(ctx context.Context, cli *client.Client, imageName string) error
608608
func pullImageWithAuth(ctx context.Context, cli *client.Client, imageName string) error {
609609
var imagePullOptions image.PullOptions
610610

611-
if strings.HasPrefix(imageName, "ghcr.io/") {
612-
611+
switch {
612+
case strings.HasPrefix(imageName, "ghcr.io/"):
613613
token := os.Getenv("LOCAL_GITHUB_ACCESS_TOKEN")
614614
if token != "" {
615615
auth := base64.StdEncoding.EncodeToString([]byte("x:" + token))
@@ -619,7 +619,7 @@ func pullImageWithAuth(ctx context.Context, cli *client.Client, imageName string
619619
} else {
620620
log.Println("Failed to find credentials for GitHub container registry.")
621621
}
622-
} else if strings.Contains(imageName, ".azurecr.io/") {
622+
case strings.Contains(imageName, ".azurecr.io/"):
623623
username := os.Getenv("AZURE_REGISTRY_USERNAME")
624624
password := os.Getenv("AZURE_REGISTRY_PASSWORD")
625625

@@ -641,7 +641,7 @@ func pullImageWithAuth(ctx context.Context, cli *client.Client, imageName string
641641
} else {
642642
log.Println("Failed to find credentials for Azure container registry.")
643643
}
644-
} else {
644+
default:
645645
log.Printf("Failed to find credentials for pulling image: %s\n.", imageName)
646646
}
647647

internal/model/job_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ func compareMap(t *testing.T, parent string, expected map[string]any, actual int
291291
case []any:
292292
// Also check structs that are in arrays.
293293
for _, v := range expectedValue {
294-
switch v := v.(type) {
295-
case map[string]any:
294+
if v, ok := v.(map[string]any); ok {
296295
structField := actualType.Field(fieldIndex)
297296
name := yamlTagCleaner(structField.Tag.Get("yaml"))
298297
compareMap(t, parent+"->"+name, v, actualValue.Interface())

0 commit comments

Comments
 (0)