Skip to content

Commit 854270f

Browse files
committed
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 7d93c7a commit 854270f

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
@@ -284,6 +284,12 @@ func writeOverrides(app *v1alpha1.Application, wbc *WriteBackConfig, gitC git.Cl
284284
}
285285
}
286286

287+
dir := filepath.Dir(targetFile)
288+
err = os.MkdirAll(dir, 0700)
289+
if err != nil {
290+
return
291+
}
292+
287293
err = os.WriteFile(targetFile, override, 0600)
288294
if err != nil {
289295
return

0 commit comments

Comments
 (0)