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

fix: ci lint for mod registry and image #1

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion image/default_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ func (d DefaultImageService) uploadLayers(repo string, layers []v1.Layer, blobs
errCh <- err
return err
}
defer utils.CleanFile(file)
defer func() {
_ = utils.CleanFile(file)
justadogistaken marked this conversation as resolved.
Show resolved Hide resolved
}()
if _, err = file.Seek(0, 0); err != nil {
errCh <- err
return err
Expand Down
13 changes: 10 additions & 3 deletions image/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ func GetClusterFileFromImageManifest(imageName string) string {
func GetClusterFileFromBaseImage(imageName string) string {
mountTarget, _ := utils.MkTmpdir()
mountUpper, _ := utils.MkTmpdir()
defer utils.CleanDirs(mountTarget, mountUpper)
defer func() {
_ = utils.CleanDirs(mountTarget, mountUpper)
justadogistaken marked this conversation as resolved.
Show resolved Hide resolved
}()

if err := NewImageService().PullIfNotExist(imageName); err != nil {
return ""
Expand All @@ -107,9 +109,14 @@ func GetClusterFileFromBaseImage(imageName string) string {
}

err = driver.Mount(mountTarget, mountUpper, layers...)
defer driver.Unmount(mountTarget)
clusterFile := filepath.Join(mountTarget, "etc", common.DefaultClusterFileName)
if err != nil {
return ""
}
defer func() {
_ = driver.Unmount(mountTarget)
}()

clusterFile := filepath.Join(mountTarget, "etc", common.DefaultClusterFileName)
data, err := ioutil.ReadFile(clusterFile)
if err != nil {
return ""
Expand Down
6 changes: 3 additions & 3 deletions registry/tokentransport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ func oauthFlow(w http.ResponseWriter, r *http.Request) {
if strings.HasPrefix(r.URL.Path, "/oauth2/accesstoken") {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"access_token":"abcdef1234"}`))
_, _ = w.Write([]byte(`{"access_token":"abcdef1234"}`))
return
}
if strings.HasPrefix(r.URL.Path, "/oauth2/token") {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"token":"abcdef1234"}`))
_, _ = w.Write([]byte(`{"token":"abcdef1234"}`))
return
}
auth := r.Header.Get("authorization")
Expand All @@ -63,7 +63,7 @@ func oauthFlow(w http.ResponseWriter, r *http.Request) {
w.Header().Set("www-authenticate", `Bearer realm="`+authURI+`/oauth2/token",service="my.endpoint.here"`)
}
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte(`{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}`))
_, _ = w.Write([]byte(`{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":null}]}`))
return
}
w.WriteHeader(http.StatusOK)
Expand Down