Skip to content

Commit 4f776c0

Browse files
Merge pull request #27192 from kolyshkin/modernize-2
Misc nits
2 parents 116e458 + ef0a7dd commit 4f776c0

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

pkg/api/handlers/compat/images_build.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -923,10 +923,8 @@ func handleBuildContexts(r *http.Request, query url.Values, anchorDir string, mu
923923

924924
logrus.Debugf("name: %q, context: %q", name, value)
925925

926-
switch {
927-
case strings.HasPrefix(value, "url:"):
928-
value = strings.TrimPrefix(value, "url:")
929-
tempDir, subdir, err := buildahDefine.TempDirForURL(anchorDir, "buildah", value)
926+
if urlValue, ok := strings.CutPrefix(value, "url:"); ok {
927+
tempDir, subdir, err := buildahDefine.TempDirForURL(anchorDir, "buildah", urlValue)
930928
if err != nil {
931929
return nil, fmt.Errorf("downloading URL %q: %w", name, err)
932930
}
@@ -940,15 +938,14 @@ func handleBuildContexts(r *http.Request, query url.Values, anchorDir string, mu
940938
}
941939

942940
logrus.Debugf("Downloaded URL context %q to %q", name, contextPath)
943-
case strings.HasPrefix(value, "image:"):
944-
value = strings.TrimPrefix(value, "image:")
941+
} else if imageValue, ok := strings.CutPrefix(value, "image:"); ok {
945942
out.AdditionalBuildContexts[name] = &buildahDefine.AdditionalBuildContext{
946943
IsURL: false,
947944
IsImage: true,
948-
Value: value,
945+
Value: imageValue,
949946
}
950947

951-
logrus.Debugf("Using image context %q: %q", name, value)
948+
logrus.Debugf("Using image context %q: %q", name, imageValue)
952949
}
953950
}
954951

@@ -979,8 +976,7 @@ func handleBuildContexts(r *http.Request, query url.Values, anchorDir string, mu
979976

980977
fieldName := part.FormName()
981978

982-
switch {
983-
case fieldName == "MainContext":
979+
if fieldName == "MainContext" {
984980
mainDir, err := extractTarFile(anchorDir, part)
985981
if err != nil {
986982
return nil, fmt.Errorf("extracting main context in multipart: %w", err)
@@ -989,10 +985,7 @@ func handleBuildContexts(r *http.Request, query url.Values, anchorDir string, mu
989985
return nil, fmt.Errorf("main context directory is empty")
990986
}
991987
out.ContextDirectory = mainDir
992-
993-
case strings.HasPrefix(fieldName, "build-context-"):
994-
contextName := strings.TrimPrefix(fieldName, "build-context-")
995-
988+
} else if contextName, ok := strings.CutPrefix(fieldName, "build-context-"); ok {
996989
// Create temp directory directly under anchorDir
997990
additionalAnchor, err := os.MkdirTemp(anchorDir, contextName+"-*")
998991
if err != nil {
@@ -1039,7 +1032,7 @@ func handleBuildContexts(r *http.Request, query url.Values, anchorDir string, mu
10391032
IsImage: false,
10401033
Value: additionalAnchor,
10411034
}
1042-
default:
1035+
} else {
10431036
logrus.Debugf("Ignoring unknown multipart field: %s", fieldName)
10441037
}
10451038
}

pkg/machine/e2e/basic_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ const TESTIMAGE = "quay.io/libpod/testimage:20241011"
2525
var _ = Describe("run basic podman commands", func() {
2626

2727
It("Basic ops", func() {
28-
// golangci-lint has trouble with actually skipping tests marked Skip
29-
// so skip it on cirrus envs and where CIRRUS_CI isn't set.
3028
name := randomString()
3129
i := new(initMachine)
3230
session, err := mb.setName(name).setCmd(i.withImage(mb.imagePath).withNow()).run()

pkg/machine/wsl/util_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func wrapMaybe(err error, message string) error {
175175
return errors.New(message)
176176
}
177177

178-
func wrapMaybef(err error, format string, args ...interface{}) error {
178+
func wrapMaybef(err error, format string, args ...any) error {
179179
if err != nil {
180180
return fmt.Errorf(format+": %w", append(args, err)...)
181181
}

0 commit comments

Comments
 (0)