Skip to content

Commit f91491a

Browse files
jnovickchengfang
authored andcommitted
Create directory automatically
* 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. Signed-off-by: Joshua Novick <joshua.novick@hunters.ai>
1 parent c9ed948 commit f91491a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/argocd/git.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ func writeOverrides(app *v1alpha1.Application, wbc *WriteBackConfig, gitC git.Cl
291291
}
292292
}
293293

294+
dir := filepath.Dir(targetFile)
295+
err = os.MkdirAll(dir, 0700)
296+
if err != nil {
297+
return
298+
}
299+
294300
err = os.WriteFile(targetFile, override, 0600)
295301
if err != nil {
296302
return

0 commit comments

Comments
 (0)