Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CircleCI configuration (from sylabs 219), Resolve lint issues (from sylabs 220) (v1) #73

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Install Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.54
version: v1.56
skip-pkg-cache: true
skip-build-cache: true

Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ linters:
- errcheck
- errchkjson
- gochecknoinits
- goconst
# - goconst
- gocritic
- gocyclo
- goerr113
Expand Down
34 changes: 17 additions & 17 deletions client/push_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018-2023, Sylabs Inc. All rights reserved.
// Copyright (c) 2018-2024, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand Down Expand Up @@ -182,7 +182,7 @@ func (m *v2ImageUploadMockService) MockImageFileCompleteEndpoint(w http.Response
func mockS3Server(t *testing.T, statusCode int) *httptest.Server {
t.Helper()

return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
if statusCode != http.StatusOK {
w.WriteHeader(statusCode)
return
Expand Down Expand Up @@ -244,19 +244,19 @@ func Test_UploadImageBadPath(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
h := http.NewServeMux()
h.HandleFunc("/v1/imagefile/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/imagefile/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
commonHandler(t, http.StatusOK, w)
}))

h.HandleFunc("/v1/tags/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/tags/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
resp := TagMap{"test": "testValue"}

if err := json.NewEncoder(w).Encode(&resp); err != nil {
t.Fatalf("Error encoding JSON response: %v", err)
}
}))

h.HandleFunc("/v1/entities/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/entities/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
uploadImageHelperHandler(t, http.StatusOK, w)
resp := Entity{ID: "testID"}

Expand All @@ -265,7 +265,7 @@ func Test_UploadImageBadPath(t *testing.T) {
}
}))

h.HandleFunc("/v1/collections/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/collections/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
uploadImageHelperHandler(t, http.StatusOK, w)
resp := Collection{
ID: "testID",
Expand All @@ -275,7 +275,7 @@ func Test_UploadImageBadPath(t *testing.T) {
}
}))

h.HandleFunc("/v1/containers/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/containers/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
uploadImageHelperHandler(t, http.StatusOK, w)

resp := Container{ID: "test"}
Expand All @@ -285,7 +285,7 @@ func Test_UploadImageBadPath(t *testing.T) {
}
}))

h.HandleFunc("/v1/images/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/images/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
uploadImageHelperHandler(t, http.StatusOK, w)

commonHandler(t, http.StatusOK, w)
Expand Down Expand Up @@ -389,19 +389,19 @@ func Test_UploadImage(t *testing.T) {
defer s3Server.Close()

h := http.NewServeMux()
h.HandleFunc("/v1/imagefile/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/imagefile/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
commonHandler(t, tt.statusCode, w)
}))

h.HandleFunc("/v1/tags/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/tags/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
resp := TagMap{"test": "testValue"}

if err := json.NewEncoder(w).Encode(&resp); err != nil {
t.Fatalf("Error encoding JSON response: %v", err)
}
}))

h.HandleFunc("/v1/entities/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/entities/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
uploadImageHelperHandler(t, tt.codes.entity, w)
resp := Entity{ID: "testID"}

Expand All @@ -410,7 +410,7 @@ func Test_UploadImage(t *testing.T) {
}
}))

h.HandleFunc("/v1/collections/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/collections/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
uploadImageHelperHandler(t, tt.codes.collection, w)
resp := Collection{
ID: "testID",
Expand All @@ -420,7 +420,7 @@ func Test_UploadImage(t *testing.T) {
}
}))

h.HandleFunc("/v1/containers/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/containers/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
uploadImageHelperHandler(t, tt.codes.container, w)

resp := Container{ID: "test"}
Expand All @@ -430,7 +430,7 @@ func Test_UploadImage(t *testing.T) {
}
}))

h.HandleFunc("/v1/images/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v1/images/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
uploadImageHelperHandler(t, tt.codes.image, w)

commonHandler(t, tt.statusCode, w)
Expand Down Expand Up @@ -472,7 +472,7 @@ func Test_postFileWrapper(t *testing.T) {
defer s3Server.Close()

h := http.NewServeMux()
h.HandleFunc("/v1/imagefile/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
h.HandleFunc("/v1/imagefile/", http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}))

libraryServer := httptest.NewServer(h)
defer libraryServer.Close()
Expand Down Expand Up @@ -851,7 +851,7 @@ func Test_legacyPostFileV2URL(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
h := http.NewServeMux()
h.HandleFunc("/v2/imagefile/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v2/imagefile/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
commonHandler(t, http.StatusOK, w)

resp := UploadImageResponse{Data: UploadImage{UploadURL: tt.url}}
Expand Down Expand Up @@ -1060,7 +1060,7 @@ func Test_abortMultipartUpload(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
h := http.NewServeMux()
h.HandleFunc("/v2/imagefile/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
h.HandleFunc("/v2/imagefile/", http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
uploadImageHelperHandler(t, tt.statusCode, w)
}))

Expand Down
8 changes: 2 additions & 6 deletions client/util.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018-2022, Sylabs Inc. All rights reserved.
// Copyright (c) 2018-2024, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
Expand Down Expand Up @@ -74,11 +74,7 @@ func ParseLibraryPath(libraryRef string) (entity string, collection string, cont
container = refParts[0]
default:
// malformed libraryRef; must conform to "library://entity/collection/container[:tag[,tag]...]"
entity = ""
collection = ""
container = ""
tags = []string{}
return entity, collection, container, tags
return "", "", "", []string{}
}

if strings.Contains(container, ":") {
Expand Down
Loading