diff options
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r-- | pkg/api/handlers/compat/containers_attach.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/compat/containers_create.go | 6 | ||||
-rw-r--r-- | pkg/api/handlers/compat/exec.go | 6 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images.go | 12 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_build.go | 6 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_history.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_push.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_remove.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_tag.go | 4 | ||||
-rw-r--r-- | pkg/api/handlers/compat/info.go | 3 | ||||
-rw-r--r-- | pkg/api/handlers/compat/system.go | 2 |
11 files changed, 23 insertions, 24 deletions
diff --git a/pkg/api/handlers/compat/containers_attach.go b/pkg/api/handlers/compat/containers_attach.go index e804e628a..c37dc09af 100644 --- a/pkg/api/handlers/compat/containers_attach.go +++ b/pkg/api/handlers/compat/containers_attach.go @@ -86,7 +86,7 @@ func AttachContainer(w http.ResponseWriter, r *http.Request) { // For Docker compatibility, we need to re-initialize containers in these states. if state == define.ContainerStateConfigured || state == define.ContainerStateExited || state == define.ContainerStateStopped { if err := ctr.Init(r.Context(), ctr.PodID() != ""); err != nil { - utils.Error(w, http.StatusConflict, fmt.Errorf("error preparing container %s for attach: %w", ctr.ID(), err)) + utils.Error(w, http.StatusConflict, fmt.Errorf("preparing container %s for attach: %w", ctr.ID(), err)) return } } else if !(state == define.ContainerStateCreated || state == define.ContainerStateRunning) { diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go index d4f5d5f36..a86b0b0d5 100644 --- a/pkg/api/handlers/compat/containers_create.go +++ b/pkg/api/handlers/compat/containers_create.go @@ -64,7 +64,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { imageName, err := utils.NormalizeToDockerHub(r, body.Config.Image) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } body.Config.Image = imageName @@ -76,7 +76,7 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { return } - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error looking up image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("looking up image: %w", err)) return } @@ -480,7 +480,7 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C } if err := os.MkdirAll(vol, 0o755); err != nil { if !os.IsExist(err) { - return nil, nil, fmt.Errorf("error making volume mountpoint for volume %s: %w", vol, err) + return nil, nil, fmt.Errorf("making volume mountpoint for volume %s: %w", vol, err) } } } diff --git a/pkg/api/handlers/compat/exec.go b/pkg/api/handlers/compat/exec.go index 1b4dead8b..17f199a8b 100644 --- a/pkg/api/handlers/compat/exec.go +++ b/pkg/api/handlers/compat/exec.go @@ -26,7 +26,7 @@ func ExecCreateHandler(w http.ResponseWriter, r *http.Request) { input := new(handlers.ExecCreateConfig) if err := json.NewDecoder(r.Body).Decode(&input); err != nil { - utils.InternalServerError(w, fmt.Errorf("error decoding request body as JSON: %w", err)) + utils.InternalServerError(w, fmt.Errorf("decoding request body as JSON: %w", err)) return } @@ -114,7 +114,7 @@ func ExecInspectHandler(w http.ResponseWriter, r *http.Request) { session, err := sessionCtr.ExecSession(sessionID) if err != nil { - utils.InternalServerError(w, fmt.Errorf("error retrieving exec session %s from container %s: %w", sessionID, sessionCtr.ID(), err)) + utils.InternalServerError(w, fmt.Errorf("retrieving exec session %s from container %s: %w", sessionID, sessionCtr.ID(), err)) return } @@ -174,7 +174,7 @@ func ExecStartHandler(w http.ResponseWriter, r *http.Request) { } logErr := func(e error) { - logrus.Error(fmt.Errorf("error attaching to container %s exec session %s: %w", sessionCtr.ID(), sessionID, e)) + logrus.Error(fmt.Errorf("attaching to container %s exec session %s: %w", sessionCtr.ID(), sessionID, e)) } var size *resize.TerminalSize diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 39bd165d6..0493c6ffb 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -59,7 +59,7 @@ func ExportImage(w http.ResponseWriter, r *http.Request) { name := utils.GetName(r) possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -155,7 +155,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) { destImage = fmt.Sprintf("%s:%s", query.Repo, query.Tag) possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, destImage) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } destImage = possiblyNormalizedName @@ -209,7 +209,7 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) { if query.Repo != "" { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, reference) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } reference = possiblyNormalizedName @@ -272,7 +272,7 @@ func CreateImageFromImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, mergeNameAndTagOrDigest(query.FromImage, query.Tag)) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -390,7 +390,7 @@ func GetImage(w http.ResponseWriter, r *http.Request) { name := utils.GetName(r) possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -541,7 +541,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) { for i, img := range query.Names { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, img) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } images[i] = possiblyNormalizedName diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 7ba1029a7..4035b4315 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -343,7 +343,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { if len(tags) > 0 { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, tags[0]) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } output = possiblyNormalizedName @@ -376,7 +376,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { for i := 1; i < len(tags); i++ { possiblyNormalizedTag, err := utils.NormalizeToDockerHub(r, tags[i]) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } additionalTags = append(additionalTags, possiblyNormalizedTag) @@ -578,7 +578,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { if fromImage != "" { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, fromImage) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } fromImage = possiblyNormalizedName diff --git a/pkg/api/handlers/compat/images_history.go b/pkg/api/handlers/compat/images_history.go index ebb5acdd9..1b83d274a 100644 --- a/pkg/api/handlers/compat/images_history.go +++ b/pkg/api/handlers/compat/images_history.go @@ -16,7 +16,7 @@ func HistoryImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } diff --git a/pkg/api/handlers/compat/images_push.go b/pkg/api/handlers/compat/images_push.go index f29808124..a1173de0b 100644 --- a/pkg/api/handlers/compat/images_push.go +++ b/pkg/api/handlers/compat/images_push.go @@ -69,7 +69,7 @@ func PushImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, imageName) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } imageName = possiblyNormalizedName diff --git a/pkg/api/handlers/compat/images_remove.go b/pkg/api/handlers/compat/images_remove.go index b59bfd0b1..71d6a644f 100644 --- a/pkg/api/handlers/compat/images_remove.go +++ b/pkg/api/handlers/compat/images_remove.go @@ -37,7 +37,7 @@ func RemoveImage(w http.ResponseWriter, r *http.Request) { name := utils.GetName(r) possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } diff --git a/pkg/api/handlers/compat/images_tag.go b/pkg/api/handlers/compat/images_tag.go index a1da7a4b9..e9f6dedd0 100644 --- a/pkg/api/handlers/compat/images_tag.go +++ b/pkg/api/handlers/compat/images_tag.go @@ -17,7 +17,7 @@ func TagImage(w http.ResponseWriter, r *http.Request) { name := utils.GetName(r) possiblyNormalizedName, err := utils.NormalizeToDockerHub(r, name) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } @@ -42,7 +42,7 @@ func TagImage(w http.ResponseWriter, r *http.Request) { possiblyNormalizedTag, err := utils.NormalizeToDockerHub(r, tagName) if err != nil { - utils.Error(w, http.StatusInternalServerError, fmt.Errorf("error normalizing image: %w", err)) + utils.Error(w, http.StatusInternalServerError, fmt.Errorf("normalizing image: %w", err)) return } diff --git a/pkg/api/handlers/compat/info.go b/pkg/api/handlers/compat/info.go index d82513284..60bbd40fe 100644 --- a/pkg/api/handlers/compat/info.go +++ b/pkg/api/handlers/compat/info.go @@ -2,7 +2,6 @@ package compat import ( "fmt" - "io/ioutil" "net/http" "os" goRuntime "runtime" @@ -198,7 +197,7 @@ func getRuntimes(configInfo *config.Config) map[string]docker.Runtime { func getFdCount() (count int) { count = -1 - if entries, err := ioutil.ReadDir("/proc/self/fd"); err == nil { + if entries, err := os.ReadDir("/proc/self/fd"); err == nil { count = len(entries) } return diff --git a/pkg/api/handlers/compat/system.go b/pkg/api/handlers/compat/system.go index 97bc9eac2..23f116d16 100644 --- a/pkg/api/handlers/compat/system.go +++ b/pkg/api/handlers/compat/system.go @@ -76,7 +76,7 @@ func GetDiskUsage(w http.ResponseWriter, r *http.Request) { Scope: "local", Status: nil, UsageData: &docker.VolumeUsageData{ - RefCount: 1, + RefCount: int64(o.Links), Size: o.Size, }, } |