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

make sure workdir is owned by autopilot user #275

Merged
Merged
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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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" ]
12 changes: 6 additions & 6 deletions pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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()
Expand Down