From 55f423c4560c4eda770160f97ea3263445266924 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Fri, 8 Apr 2022 23:11:37 +0300 Subject: [PATCH 1/2] make sure workdir is owned by autopilot user --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index becc7484..7a8bdfdb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,7 +40,7 @@ RUN make local DEV_MODE=false ### Run FROM alpine:3.15 as autopilot -WORKDIR /go/src/github.com/argoproj-labs/argocd-autopilot +WORKDIR /home/autopilot RUN apk -U add --no-cache git @@ -50,6 +50,7 @@ COPY --from=base /etc/passwd /etc/passwd COPY --from=base /etc/group /etc/group COPY --chown=autopilot:autopilot --from=autopilot-build /go/src/github.com/argoproj-labs/argocd-autopilot/dist/* /usr/local/bin/argocd-autopilot +RUN chown -R autopilot:autopilot /home/autopilot USER autopilot:autopilot ENTRYPOINT [ "argocd-autopilot" ] From 65f11d3f2ac359486f697cb4c832125ef5e68ad0 Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Sun, 10 Apr 2022 09:29:12 +0300 Subject: [PATCH 2/2] added clearer errors for `generateManifests` --- pkg/application/application.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/application/application.go b/pkg/application/application.go index 34065db4..f9e42473 100644 --- a/pkg/application/application.go +++ b/pkg/application/application.go @@ -507,27 +507,27 @@ func fixResourcesPaths(k *kusttypes.Kustomization, newKustDir string) error { var generateManifests = func(k *kusttypes.Kustomization) ([]byte, error) { td, err := ioutil.TempDir(".", "auto-pilot") if err != nil { - return nil, err + return nil, fmt.Errorf("failed creating temp dir: %w", err) } defer os.RemoveAll(td) absTd, err := filepath.Abs(td) if err != nil { - return nil, err + return nil, fmt.Errorf("failed getting abs path for \"%s\": %w", td, err) } if err = fixResourcesPaths(k, absTd); err != nil { - return nil, err + return nil, fmt.Errorf("failed fixing resources paths: %w", err) } kyaml, err := yaml.Marshal(k) if err != nil { - return nil, err + return nil, fmt.Errorf("failed marshaling yaml: %w", err) } kustomizationPath := filepath.Join(td, "kustomization.yaml") if err = ioutil.WriteFile(kustomizationPath, kyaml, 0400); err != nil { - return nil, err + return nil, fmt.Errorf("failed writing file to \"%s\": %w", kustomizationPath, err) } log.G().WithFields(log.Fields{ @@ -541,7 +541,7 @@ var generateManifests = func(k *kusttypes.Kustomization) ([]byte, error) { fs := filesys.MakeFsOnDisk() res, err := kust.Run(fs, td) if err != nil { - return nil, err + return nil, fmt.Errorf("failed running kustomization: %w", err) } return res.AsYaml()