Skip to content
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
4 changes: 2 additions & 2 deletions pkg/argocd/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ func commitChangesGit(app *v1alpha1.Application, wbc *WriteBackConfig, changeLis
return nil
}

func writeOverrides(app *v1alpha1.Application, _ *WriteBackConfig, gitC git.Client) (err error, skip bool) {
func writeOverrides(app *v1alpha1.Application, wbc *WriteBackConfig, gitC git.Client) (err error, skip bool) {
logCtx := log.WithContext().AddField("application", app.GetName())
targetExists := true
targetFile := path.Join(gitC.Root(), app.Spec.Source.Path, fmt.Sprintf(".argocd-source-%s.yaml", app.Name))
targetFile := path.Join(gitC.Root(), wbc.Target)
_, err = os.Stat(targetFile)
if err != nil {
if !os.IsNotExist(err) {
Expand Down
8 changes: 8 additions & 0 deletions pkg/argocd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type WriteBackConfig struct {
GitCommitEmail string
GitCommitMessage string
KustomizeBase string
Target string
}

// The following are helper structs to only marshal the fields we require
Expand Down Expand Up @@ -415,6 +416,7 @@ func getWriteBackConfig(app *v1alpha1.Application, kubeClient *kube.KubernetesCl
// Default write-back is to use Argo CD API
wbc.Method = WriteBackApplication
wbc.ArgoClient = argoClient
wbc.Target = parseDefaultTarget(app.Name, app.Spec.Source.Path)

// If we have no update method, just return our default
method, ok := app.Annotations[common.WriteBackMethodAnnotation]
Expand Down Expand Up @@ -446,6 +448,12 @@ func getWriteBackConfig(app *v1alpha1.Application, kubeClient *kube.KubernetesCl
return wbc, nil
}

func parseDefaultTarget(appName string, path string) string {
defaultTargetFile := fmt.Sprintf(common.DefaultTargetFilePattern, appName)

return filepath.Join(path, defaultTargetFile)
}

func parseTarget(target string, sourcePath string) (kustomizeBase string) {
if target == common.KustomizationPrefix {
return filepath.Join(sourcePath, ".")
Expand Down
3 changes: 3 additions & 0 deletions pkg/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ const (
KustomizationPrefix = "kustomization"
)

// DefaultTargetFilePattern configurations related to the write-back functionality
const DefaultTargetFilePattern = ".argocd-source-%s.yaml"

// The default Git commit message's template
const DefaultGitCommitMessage = `build: automatic update of {{ .AppName }}

Expand Down