diff --git a/cmd/apps/argocd_app.go b/cmd/apps/argocd_app.go index a11ad5b72..1941044fd 100644 --- a/cmd/apps/argocd_app.go +++ b/cmd/apps/argocd_app.go @@ -56,8 +56,8 @@ func MakeInstallArgoCD() *cobra.Command { } const ArgoCDInfoMsg = ` -# Get the ArgoCD CLI -arkade install argocd +# Install the "argocd" CLI: +arkade get argocd # Port-forward the ArgoCD API server kubectl port-forward svc/argocd-server -n argocd 8443:443 & diff --git a/cmd/system/containerd.go b/cmd/system/containerd.go index 00fcb493d..488231b6e 100644 --- a/cmd/system/containerd.go +++ b/cmd/system/containerd.go @@ -150,14 +150,19 @@ func MakeInstallContainerd() *cobra.Command { return err } - content, err := io.ReadAll(response.Body) + defer response.Body.Close() + + body, err := io.ReadAll(response.Body) if err != nil { return err } + if response.StatusCode != http.StatusOK { + return fmt.Errorf("error fetching systemd unit file, status code: %d, body: %s", response.StatusCode, string(body)) + } - content = bytes.ReplaceAll(content, []byte("/usr/local/bin/containerd"), []byte(installPath+"/containerd")) + body = bytes.ReplaceAll(body, []byte("/usr/local/bin/containerd"), []byte(installPath+"/containerd")) - if err := createSystemdUnit(systemdUnitName, content); err != nil { + if err := createSystemdUnit(systemdUnitName, body); err != nil { return err } } diff --git a/cmd/system/go.go b/cmd/system/go.go index 4ee8fb9ce..deed1f799 100644 --- a/cmd/system/go.go +++ b/cmd/system/go.go @@ -121,9 +121,6 @@ func getGoVersion() (string, error) { return "", err } - if res.StatusCode != http.StatusOK { - return "", fmt.Errorf("unexpected status code: %d", res.StatusCode) - } if res.Body == nil { return "", fmt.Errorf("unexpected empty body") } @@ -131,6 +128,10 @@ func getGoVersion() (string, error) { defer res.Body.Close() body, _ := io.ReadAll(res.Body) + if res.StatusCode != http.StatusOK { + return "", fmt.Errorf("unexpected status code: %d", res.StatusCode) + } + content := strings.TrimSpace(string(body)) version, _, ok := strings.Cut(content, "\n") if !ok { diff --git a/cmd/system/node.go b/cmd/system/node.go index 0811c74f0..8a8e7686f 100644 --- a/cmd/system/node.go +++ b/cmd/system/node.go @@ -29,10 +29,19 @@ func getLatestNodeVersion(version, channel string) (*string, error) { return nil, err } + if res.Body != nil { + defer res.Body.Close() + } + body, err := io.ReadAll(res.Body) if err != nil { return nil, err } + + if res.StatusCode != http.StatusOK { + return nil, fmt.Errorf("could not find latest version for %s, (%d), body: %s", version, res.StatusCode, string(body)) + } + regex := regexp.MustCompile(`(?m)node-v(\d+.\d+.\d+)-linux-.*`) result := regex.FindStringSubmatch(string(body))