forked from argoproj-labs/argocd-image-updater
-
Notifications
You must be signed in to change notification settings - Fork 2
/
update.go
632 lines (549 loc) · 21.2 KB
/
update.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
package argocd
import (
"context"
"fmt"
"path/filepath"
"strings"
"sync"
"text/template"
"time"
"golang.org/x/exp/slices"
"github.com/argoproj-labs/argocd-image-updater/ext/git"
"github.com/argoproj-labs/argocd-image-updater/pkg/common"
"github.com/argoproj-labs/argocd-image-updater/pkg/image"
"github.com/argoproj-labs/argocd-image-updater/pkg/kube"
"github.com/argoproj-labs/argocd-image-updater/pkg/log"
"github.com/argoproj-labs/argocd-image-updater/pkg/registry"
"github.com/argoproj-labs/argocd-image-updater/pkg/tag"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/application"
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
"github.com/miracl/conflate"
"gopkg.in/yaml.v2"
)
// Stores some statistics about the results of a run
type ImageUpdaterResult struct {
NumApplicationsProcessed int
NumImagesFound int
NumImagesUpdated int
NumImagesConsidered int
NumSkipped int
NumErrors int
}
type UpdateConfiguration struct {
NewRegFN registry.NewRegistryClient
ArgoClient ArgoCD
KubeClient *kube.KubernetesClient
UpdateApp *ApplicationImages
DryRun bool
GitCommitUser string
GitCommitEmail string
GitCommitMessage *template.Template
DisableKubeEvents bool
IgnorePlatforms bool
}
type GitCredsSource func(app *v1alpha1.Application) (git.Creds, error)
type WriteBackMethod int
const (
WriteBackApplication WriteBackMethod = 0
WriteBackGit WriteBackMethod = 1
)
// WriteBackConfig holds information on how to write back the changes to an Application
type WriteBackConfig struct {
Method WriteBackMethod
ArgoClient ArgoCD
// If GitClient is not nil, the client will be used for updates. Otherwise, a new client will be created.
GitClient git.Client
GetCreds GitCredsSource
GitBranch string
GitWriteBranch string
GitCommitUser string
GitCommitEmail string
GitCommitMessage string
KustomizeBase string
Target string
GitRepo string
}
// The following are helper structs to only marshal the fields we require
type kustomizeImages struct {
Images *v1alpha1.KustomizeImages `json:"images"`
}
type kustomizeOverride struct {
Kustomize kustomizeImages `json:"kustomize"`
}
type helmParameters struct {
Parameters []v1alpha1.HelmParameter `json:"parameters"`
}
type helmOverride struct {
Helm helmParameters `json:"helm"`
}
// ChangeEntry represents an image that has been changed by Image Updater
type ChangeEntry struct {
Image *image.ContainerImage
OldTag *tag.ImageTag
NewTag *tag.ImageTag
}
// SyncIterationState holds shared state of a running update operation
type SyncIterationState struct {
lock sync.Mutex
repositoryLocks map[string]*sync.Mutex
}
// NewSyncIterationState returns a new instance of SyncIterationState
func NewSyncIterationState() *SyncIterationState {
return &SyncIterationState{
repositoryLocks: make(map[string]*sync.Mutex),
}
}
// GetRepositoryLock returns the lock for a specified repository
func (state *SyncIterationState) GetRepositoryLock(repository string) *sync.Mutex {
state.lock.Lock()
defer state.lock.Unlock()
lock, exists := state.repositoryLocks[repository]
if !exists {
lock = &sync.Mutex{}
state.repositoryLocks[repository] = lock
}
return lock
}
// RequiresLocking returns true if write-back method requires repository locking
func (wbc *WriteBackConfig) RequiresLocking() bool {
switch wbc.Method {
case WriteBackGit:
return true
default:
return false
}
}
// UpdateApplication update all images of a single application. Will run in a goroutine.
func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationState) ImageUpdaterResult {
var needUpdate bool = false
result := ImageUpdaterResult{}
app := updateConf.UpdateApp.Application.GetName()
changeList := make([]ChangeEntry, 0)
// Get all images that are deployed with the current application
applicationImages := GetImagesFromApplication(&updateConf.UpdateApp.Application)
result.NumApplicationsProcessed += 1
// Loop through all images of current application, and check whether one of
// its images is eligible for updating.
//
// Whether an image qualifies for update is dependent on semantic version
// constraints which are part of the application's annotation values.
//
for _, applicationImage := range updateConf.UpdateApp.Images {
updateableImage := applicationImages.ContainsImage(applicationImage, false)
if updateableImage == nil {
log.WithContext().AddField("application", app).Debugf("Image '%s' seems not to be live in this application, skipping", applicationImage.ImageName)
result.NumSkipped += 1
continue
}
// In some cases, the running image has no tag set. We create a dummy
// tag, without name, digest and a timestamp of zero. This dummy tag
// will trigger an update on the first run.
if updateableImage.ImageTag == nil {
updateableImage.ImageTag = tag.NewImageTag("", time.Unix(0, 0), "")
}
result.NumImagesConsidered += 1
imgCtx := log.WithContext().
AddField("application", app).
AddField("registry", updateableImage.RegistryURL).
AddField("image_name", updateableImage.ImageName).
AddField("image_tag", updateableImage.ImageTag).
AddField("alias", applicationImage.ImageAlias)
if updateableImage.KustomizeImage != nil {
imgCtx.AddField("kustomize_image", updateableImage.KustomizeImage)
}
imgCtx.Debugf("Considering this image for update")
rep, err := registry.GetRegistryEndpoint(applicationImage.RegistryURL)
if err != nil {
imgCtx.Errorf("Could not get registry endpoint from configuration: %v", err)
result.NumErrors += 1
continue
}
var vc image.VersionConstraint
if applicationImage.ImageTag != nil {
vc.Constraint = applicationImage.ImageTag.TagName
imgCtx.Debugf("Using version constraint '%s' when looking for a new tag", vc.Constraint)
} else {
imgCtx.Debugf("Using no version constraint when looking for a new tag")
}
vc.Strategy = applicationImage.GetParameterUpdateStrategy(updateConf.UpdateApp.Application.Annotations)
vc.MatchFunc, vc.MatchArgs = applicationImage.GetParameterMatch(updateConf.UpdateApp.Application.Annotations)
vc.IgnoreList = applicationImage.GetParameterIgnoreTags(updateConf.UpdateApp.Application.Annotations)
vc.Options = applicationImage.
GetPlatformOptions(updateConf.UpdateApp.Application.Annotations, updateConf.IgnorePlatforms).
WithMetadata(vc.Strategy.NeedsMetadata()).
WithLogger(imgCtx.AddField("application", app))
// If a strategy needs meta-data and tagsortmode is set for the
// registry, let the user know.
if rep.TagListSort > registry.TagListSortUnsorted && vc.Strategy.NeedsMetadata() {
imgCtx.Infof("taglistsort is set to '%s' but update strategy '%s' requires metadata. Results may not be what you expect.", rep.TagListSort.String(), vc.Strategy.String())
}
// The endpoint can provide default credentials for pulling images
err = rep.SetEndpointCredentials(updateConf.KubeClient)
if err != nil {
imgCtx.Errorf("Could not set registry endpoint credentials: %v", err)
result.NumErrors += 1
continue
}
imgCredSrc := applicationImage.GetParameterPullSecret(updateConf.UpdateApp.Application.Annotations)
var creds *image.Credential = &image.Credential{}
if imgCredSrc != nil {
creds, err = imgCredSrc.FetchCredentials(rep.RegistryAPI, updateConf.KubeClient)
if err != nil {
imgCtx.Warnf("Could not fetch credentials: %v", err)
result.NumErrors += 1
continue
}
}
regClient, err := updateConf.NewRegFN(rep, creds.Username, creds.Password)
if err != nil {
imgCtx.Errorf("Could not create registry client: %v", err)
result.NumErrors += 1
continue
}
// Get list of available image tags from the repository
tags, err := rep.GetTags(applicationImage, regClient, &vc)
if err != nil {
imgCtx.Errorf("Could not get tags from registry: %v", err)
result.NumErrors += 1
continue
}
imgCtx.Tracef("List of available tags found: %v", tags.Tags())
// Get the latest available tag matching any constraint that might be set
// for allowed updates.
latest, err := updateableImage.GetNewestVersionFromTags(&vc, tags)
if err != nil {
imgCtx.Errorf("Unable to find newest version from available tags: %v", err)
result.NumErrors += 1
continue
}
// If we have no latest tag information, it means there was no tag which
// has met our version constraint (or there was no semantic versioned tag
// at all in the repository)
if latest == nil {
imgCtx.Debugf("No suitable image tag for upgrade found in list of available tags.")
result.NumSkipped += 1
continue
}
// If the user has specified digest as update strategy, but the running
// image is configured to use a tag and no digest, we need to set an
// initial dummy digest, so that tag.Equals() will return false.
// TODO: Fix this. This is just a workaround.
if vc.Strategy == image.StrategyDigest {
if !updateableImage.ImageTag.IsDigest() {
log.Tracef("Setting dummy digest for image %s", updateableImage.GetFullNameWithTag())
updateableImage.ImageTag.TagDigest = "dummy"
}
}
if needsUpdate(updateableImage, applicationImage, latest) {
imgCtx.Infof("Setting new image to %s", applicationImage.WithTag(latest).GetFullNameWithTag())
needUpdate = true
err = setAppImage(&updateConf.UpdateApp.Application, applicationImage.WithTag(latest))
if err != nil {
imgCtx.Errorf("Error while trying to update image: %v", err)
result.NumErrors += 1
continue
} else {
containerImageNew := applicationImage.WithTag(latest)
imgCtx.Infof("Successfully updated image '%s' to '%s', but pending spec update (dry run=%v)", updateableImage.GetFullNameWithTag(), containerImageNew.GetFullNameWithTag(), updateConf.DryRun)
changeList = append(changeList, ChangeEntry{containerImageNew, updateableImage.ImageTag, containerImageNew.ImageTag})
result.NumImagesUpdated += 1
}
} else {
// We need to explicitly set the up-to-date images in the spec too, so
// that we correctly marshal out the parameter overrides to include all
// images, regardless of those were updated or not.
err = setAppImage(&updateConf.UpdateApp.Application, applicationImage.WithTag(updateableImage.ImageTag))
if err != nil {
imgCtx.Errorf("Error while trying to update image: %v", err)
result.NumErrors += 1
}
imgCtx.Debugf("Image '%s' already on latest allowed version", updateableImage.GetFullNameWithTag())
}
}
wbc, err := getWriteBackConfig(&updateConf.UpdateApp.Application, updateConf.KubeClient, updateConf.ArgoClient)
if err != nil {
return result
}
if wbc.Method == WriteBackGit {
if updateConf.GitCommitUser != "" {
wbc.GitCommitUser = updateConf.GitCommitUser
}
if updateConf.GitCommitEmail != "" {
wbc.GitCommitEmail = updateConf.GitCommitEmail
}
if len(changeList) > 0 && updateConf.GitCommitMessage != nil {
wbc.GitCommitMessage = TemplateCommitMessage(updateConf.GitCommitMessage, updateConf.UpdateApp.Application.Name, changeList)
}
}
if needUpdate {
logCtx := log.WithContext().AddField("application", app)
log.Debugf("Using commit message: %s", wbc.GitCommitMessage)
if !updateConf.DryRun {
logCtx.Infof("Committing %d parameter update(s) for application %s", result.NumImagesUpdated, app)
err := commitChangesLocked(&updateConf.UpdateApp.Application, wbc, state, changeList)
if err != nil {
logCtx.Errorf("Could not update application spec: %v", err)
result.NumErrors += 1
result.NumImagesUpdated = 0
} else {
logCtx.Infof("Successfully updated the live application spec")
if !updateConf.DisableKubeEvents && updateConf.KubeClient != nil {
annotations := map[string]string{}
for i, c := range changeList {
annotations[fmt.Sprintf("argocd-image-updater.image-%d/full-image-name", i)] = c.Image.GetFullNameWithoutTag()
annotations[fmt.Sprintf("argocd-image-updater.image-%d/image-name", i)] = c.Image.ImageName
annotations[fmt.Sprintf("argocd-image-updater.image-%d/old-tag", i)] = c.OldTag.String()
annotations[fmt.Sprintf("argocd-image-updater.image-%d/new-tag", i)] = c.NewTag.String()
}
message := fmt.Sprintf("Successfully updated application '%s'", app)
_, err = updateConf.KubeClient.CreateApplicationEvent(&updateConf.UpdateApp.Application, "ImagesUpdated", message, annotations)
if err != nil {
logCtx.Warnf("Event could not be sent: %v", err)
}
}
}
} else {
logCtx.Infof("Dry run - not committing %d changes to application", result.NumImagesUpdated)
}
}
return result
}
func needsUpdate(updateableImage *image.ContainerImage, applicationImage *image.ContainerImage, latest *tag.ImageTag) bool {
// If the latest tag does not match image's current tag or the kustomize image is different, it means we have an update candidate.
return !updateableImage.ImageTag.Equals(latest) || applicationImage.KustomizeImage != nil && applicationImage.DiffersFrom(updateableImage, false)
}
func setAppImage(app *v1alpha1.Application, img *image.ContainerImage) error {
var err error
if appType := GetApplicationType(app); appType == ApplicationTypeKustomize {
err = SetKustomizeImage(app, img)
} else if appType == ApplicationTypeHelm {
err = SetHelmImage(app, img)
} else {
err = fmt.Errorf("could not update application %s - neither Helm nor Kustomize application", app)
}
return err
}
// marshalParamsOverride marshals the parameter overrides of a given application
// into YAML bytes
func marshalParamsOverride(app *v1alpha1.Application, originalData []byte) ([]byte, error) {
var override []byte
var err error
appType := GetApplicationType(app)
appSource := getApplicationSource(app)
switch appType {
case ApplicationTypeKustomize:
if appSource.Kustomize == nil {
return []byte{}, nil
}
var params kustomizeOverride
newParams := kustomizeOverride{
Kustomize: kustomizeImages{
Images: &appSource.Kustomize.Images,
},
}
if len(originalData) == 0 {
override, err = yaml.Marshal(newParams)
break
}
err = yaml.Unmarshal(originalData, ¶ms)
if err != nil {
override, err = yaml.Marshal(newParams)
break
}
mergeKustomizeOverride(¶ms, &newParams)
override, err = yaml.Marshal(params)
case ApplicationTypeHelm:
if appSource.Helm == nil {
return []byte{}, nil
}
if strings.HasPrefix(app.Annotations[common.WriteBackTargetAnnotation], common.HelmPrefix) {
images := GetImagesFromApplication(app)
for _, c := range images {
helmAnnotationParamName, helmAnnotationParamVersion := getHelmParamNamesFromAnnotation(app.Annotations, c.ImageName)
if helmAnnotationParamName == "" {
return nil, fmt.Errorf("could not find an image-name annotation for image %s", c.ImageName)
}
if helmAnnotationParamVersion == "" {
return nil, fmt.Errorf("could not find an image-tag annotation for image %s", c.ImageName)
}
helmParamName := getHelmParam(appSource.Helm.Parameters, helmAnnotationParamName)
if helmParamName == nil {
return nil, fmt.Errorf("%s parameter not found", helmAnnotationParamName)
}
helmParamVersion := getHelmParam(appSource.Helm.Parameters, helmAnnotationParamVersion)
if helmParamVersion == nil {
return nil, fmt.Errorf("%s parameter not found", helmAnnotationParamVersion)
}
// Build string with YAML format to merge with originalData values
helmValues := fmt.Sprintf("%s: %s\n%s: %s", helmAnnotationParamName, helmParamName.Value, helmAnnotationParamVersion, helmParamVersion.Value)
var mergedParams *conflate.Conflate
mergedParams, err = conflate.FromData(originalData, []byte(helmValues))
if err != nil {
return nil, err
}
override, err = mergedParams.MarshalYAML()
}
} else {
var params helmOverride
newParams := helmOverride{
Helm: helmParameters{
Parameters: appSource.Helm.Parameters,
},
}
outputParams := appSource.Helm.ValuesYAML()
log.WithContext().AddField("application", app).Debugf("values: '%s'", outputParams)
if len(originalData) == 0 {
override, err = yaml.Marshal(newParams)
break
}
err = yaml.Unmarshal(originalData, ¶ms)
if err != nil {
override, err = yaml.Marshal(newParams)
break
}
mergeHelmOverride(¶ms, &newParams)
override, err = yaml.Marshal(params)
}
default:
err = fmt.Errorf("unsupported application type")
}
if err != nil {
return nil, err
}
return override, nil
}
func mergeHelmOverride(t *helmOverride, o *helmOverride) {
for _, param := range o.Helm.Parameters {
idx := slices.IndexFunc(t.Helm.Parameters, func(tp v1alpha1.HelmParameter) bool { return tp.Name == param.Name })
if idx != -1 {
t.Helm.Parameters[idx] = param
continue
}
t.Helm.Parameters = append(t.Helm.Parameters, param)
}
}
func mergeKustomizeOverride(t *kustomizeOverride, o *kustomizeOverride) {
for _, image := range *o.Kustomize.Images {
idx := t.Kustomize.Images.Find(image)
if idx != -1 {
(*t.Kustomize.Images)[idx] = image
continue
}
*t.Kustomize.Images = append(*t.Kustomize.Images, image)
}
}
func getWriteBackConfig(app *v1alpha1.Application, kubeClient *kube.KubernetesClient, argoClient ArgoCD) (*WriteBackConfig, error) {
wbc := &WriteBackConfig{}
// Default write-back is to use Argo CD API
wbc.Method = WriteBackApplication
wbc.ArgoClient = argoClient
wbc.Target = parseDefaultTarget(app.Name, getApplicationSource(app).Path)
// If we have no update method, just return our default
method, ok := app.Annotations[common.WriteBackMethodAnnotation]
if !ok || strings.TrimSpace(method) == "argocd" {
return wbc, nil
}
method = strings.TrimSpace(method)
creds := "repocreds"
if index := strings.Index(method, ":"); index > 0 {
creds = method[index+1:]
method = method[:index]
}
// We might support further methods later
switch strings.TrimSpace(method) {
case "git":
wbc.Method = WriteBackGit
target, ok := app.Annotations[common.WriteBackTargetAnnotation]
if ok && strings.HasPrefix(target, common.KustomizationPrefix) {
wbc.KustomizeBase = parseKustomizeBase(target, getApplicationSource(app).Path)
} else if ok && strings.HasPrefix(target, common.HelmPrefix) { // This keeps backward compatibility
wbc.Target = parseTarget(target, getApplicationSource(app).Path)
} else if ok { // This keeps backward compatibility
wbc.Target = app.Annotations[common.WriteBackTargetAnnotation]
}
if err := parseGitConfig(app, kubeClient, wbc, creds); err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("invalid update mechanism: %s", method)
}
return wbc, nil
}
func parseDefaultTarget(appName string, path string) string {
defaultTargetFile := fmt.Sprintf(common.DefaultTargetFilePattern, appName)
return filepath.Join(path, defaultTargetFile)
}
func parseKustomizeBase(target string, sourcePath string) (kustomizeBase string) {
if target == common.KustomizationPrefix {
return filepath.Join(sourcePath, ".")
} else if base := target[len(common.KustomizationPrefix)+1:]; strings.HasPrefix(base, "/") {
return base[1:]
} else {
return filepath.Join(sourcePath, base)
}
}
// parseTarget extracts the target path to set in the writeBackConfig configuration
func parseTarget(writeBackTarget string, sourcePath string) string {
if writeBackTarget == common.HelmPrefix {
return filepath.Join(sourcePath, "./", common.DefaultHelmValuesFilename)
} else if base := writeBackTarget[len(common.HelmPrefix)+1:]; strings.HasPrefix(base, "/") {
return base[1:]
} else {
return filepath.Join(sourcePath, base)
}
}
func parseGitConfig(app *v1alpha1.Application, kubeClient *kube.KubernetesClient, wbc *WriteBackConfig, creds string) error {
branch, ok := app.Annotations[common.GitBranchAnnotation]
if ok {
branches := strings.Split(strings.TrimSpace(branch), ":")
if len(branches) > 2 {
return fmt.Errorf("invalid format for git-branch annotation: %v", branch)
}
wbc.GitBranch = branches[0]
if len(branches) == 2 {
wbc.GitWriteBranch = branches[1]
}
}
wbc.GitRepo = getApplicationSource(app).RepoURL
repo, ok := app.Annotations[common.GitRepositoryAnnotation]
if ok {
wbc.GitRepo = repo
}
credsSource, err := getGitCredsSource(creds, kubeClient, wbc)
if err != nil {
return fmt.Errorf("invalid git credentials source: %v", err)
}
wbc.GetCreds = credsSource
return nil
}
func commitChangesLocked(app *v1alpha1.Application, wbc *WriteBackConfig, state *SyncIterationState, changeList []ChangeEntry) error {
if wbc.RequiresLocking() {
lock := state.GetRepositoryLock(wbc.GitRepo)
lock.Lock()
defer lock.Unlock()
}
return commitChanges(app, wbc, changeList)
}
// commitChanges commits any changes required for updating one or more images
// after the UpdateApplication cycle has finished.
func commitChanges(app *v1alpha1.Application, wbc *WriteBackConfig, changeList []ChangeEntry) error {
switch wbc.Method {
case WriteBackApplication:
_, err := wbc.ArgoClient.UpdateSpec(context.TODO(), &application.ApplicationUpdateSpecRequest{
Name: &app.Name,
Spec: &app.Spec,
})
if err != nil {
return err
}
case WriteBackGit:
// if the kustomize base is set, the target is a kustomization
if wbc.KustomizeBase != "" {
return commitChangesGit(app, wbc, changeList, writeKustomization)
}
return commitChangesGit(app, wbc, changeList, writeOverrides)
default:
return fmt.Errorf("unknown write back method set: %d", wbc.Method)
}
return nil
}