Skip to content

Commit

Permalink
Create directory automatically
Browse files Browse the repository at this point in the history
* When writing to a new file, create the directory for the file if it
  does not already exist
* This is useful if writing `helmvalues` to a new directory that is
  solely used for updating the image version. The ArgoCD Application can
  add a second source and reference the file with the
  `ignoreMissingValueFiles` flag turned on as an additional values file
* If the directory already exists, this command does nothing.
  • Loading branch information
jnovick committed Feb 29, 2024
1 parent 7d93c7a commit 4a7cbe0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/argocd/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ func writeOverrides(app *v1alpha1.Application, wbc *WriteBackConfig, gitC git.Cl
}
}

dir := filepath.Dir(targetFile)
err = os.MkdirAll(dir, 0700)
if err != nil {
return
}

err = os.WriteFile(targetFile, override, 0600)
if err != nil {
return
Expand Down

0 comments on commit 4a7cbe0

Please sign in to comment.