Skip to content

Commit 18faa8c

Browse files
committed
fixed bugs and tests
Signed-off-by: Aleksandr Petrov <burnb83@gmail.com>
1 parent 89f0d0f commit 18faa8c

File tree

5 files changed

+24
-39
lines changed

5 files changed

+24
-39
lines changed

go.mod

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ require (
1414
github.com/distribution/distribution/v3 v3.0.0-20230722181636-7b502560cad4
1515
github.com/go-git/go-git/v5 v5.11.0
1616
github.com/google/uuid v1.3.1
17-
github.com/miracl/conflate v1.3.2
1817
github.com/opencontainers/go-digest v1.0.0
1918
github.com/opencontainers/image-spec v1.1.0-rc4
2019
github.com/patrickmn/go-cache v2.1.0+incompatible
@@ -36,25 +35,6 @@ require (
3635
sigs.k8s.io/kustomize/kyaml v0.13.9
3736
)
3837

39-
require (
40-
cloud.google.com/go v0.110.7 // indirect
41-
cloud.google.com/go/iam v1.1.1 // indirect
42-
cloud.google.com/go/storage v1.33.0 // indirect
43-
github.com/BurntSushi/toml v0.3.1 // indirect
44-
github.com/ghodss/yaml v1.0.0 // indirect
45-
github.com/google/s2a-go v0.1.4 // indirect
46-
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
47-
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
48-
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
49-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
50-
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
51-
go.opencensus.io v0.24.0 // indirect
52-
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
53-
google.golang.org/api v0.132.0 // indirect
54-
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
55-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
56-
)
57-
5838
require (
5939
cloud.google.com/go/compute v1.23.0 // indirect
6040
cloud.google.com/go/compute/metadata v0.2.3 // indirect
@@ -165,6 +145,8 @@ require (
165145
golang.org/x/tools v0.13.0 // indirect
166146
google.golang.org/appengine v1.6.7 // indirect
167147
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect
148+
google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130 // indirect
149+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
168150
google.golang.org/grpc v1.59.0 // indirect
169151
google.golang.org/protobuf v1.33.0 // indirect
170152
gopkg.in/inf.v0 v0.9.1 // indirect

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,7 @@ github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV
481481
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
482482
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
483483
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
484-
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
485-
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
486-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
487484
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
488-
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
489485
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
490486
github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
491487
github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=

pkg/argocd/argocd.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,16 @@ func GetImagesFromApplication(app *v1alpha1.Application) image.ContainerImageLis
484484
annotations := app.Annotations
485485
imagesFromAnnotations := parseImageList(annotations)
486486

487-
appImgs := make(map[string]struct{}, len(app.Status.Summary.Images))
487+
appImgs := make(map[string]*image.ContainerImage, len(app.Status.Summary.Images))
488488
for _, imageStr := range app.Status.Summary.Images {
489489
img := image.NewFromIdentifier(imageStr)
490-
appImgs[img.ImageName] = struct{}{}
490+
appImgs[img.ImageName] = img
491491
}
492492

493493
for _, img := range *imagesFromAnnotations {
494-
if _, ok := appImgs[img.ImageName]; ok {
495-
images = append(images, img)
494+
if appImg, ok := appImgs[img.ImageName]; ok {
495+
appImg.ImageAlias = img.ImageAlias
496+
images = append(images, appImg)
496497
}
497498
}
498499

pkg/argocd/update.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,16 @@ func mergeHelmValues(values map[interface{}]interface{}, newValues map[string]st
499499
for fieldPath, newValue := range newValues {
500500
fields := strings.Split(fieldPath, ".")
501501
lastFieldIndex := len(fields) - 1
502+
node := values
502503
for i, name := range fields {
503504
if i == lastFieldIndex {
504-
values[name] = newValue
505-
} else {
506-
values = values[name].(map[interface{}]interface{})
505+
node[name] = newValue
506+
507+
break
508+
} else if _, ok := node[name]; !ok {
509+
node[name] = make(map[interface{}]interface{})
507510
}
511+
node = node[name].(map[interface{}]interface{})
508512
}
509513
}
510514
}

pkg/argocd/update_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,8 +1364,9 @@ helm:
13641364

13651365
t.Run("Valid Helm source with Helm values file", func(t *testing.T) {
13661366
expected := `
1367-
image.name: nginx
1368-
image.tag: v1.0.0
1367+
image:
1368+
name: nginx
1369+
tag: v1.0.0
13691370
replicas: 1
13701371
`
13711372
app := v1alpha1.Application{
@@ -1410,8 +1411,9 @@ replicas: 1
14101411
}
14111412

14121413
originalData := []byte(`
1413-
image.name: nginx
1414-
image.tag: v0.0.0
1414+
image:
1415+
name: nginx
1416+
tag: v0.0.0
14151417
replicas: 1
14161418
`)
14171419
yaml, err := marshalParamsOverride(&app, originalData)
@@ -1461,7 +1463,7 @@ replicas: 1
14611463
},
14621464
}
14631465

1464-
originalData := []byte(`random content`)
1466+
originalData := []byte(`random: content`)
14651467
_, err := marshalParamsOverride(&app, originalData)
14661468
assert.Error(t, err)
14671469
assert.Equal(t, "could not find an image-tag annotation for image nginx", err.Error())
@@ -1508,7 +1510,7 @@ replicas: 1
15081510
},
15091511
}
15101512

1511-
originalData := []byte(`random content`)
1513+
originalData := []byte(`random: content`)
15121514
_, err := marshalParamsOverride(&app, originalData)
15131515
assert.Error(t, err)
15141516
assert.Equal(t, "could not find an image-name annotation for image nginx", err.Error())
@@ -1556,7 +1558,7 @@ replicas: 1
15561558
},
15571559
}
15581560

1559-
originalData := []byte(`random content`)
1561+
originalData := []byte(`random: content`)
15601562
_, err := marshalParamsOverride(&app, originalData)
15611563
assert.Error(t, err)
15621564
assert.Equal(t, "wrongimage.name parameter not found", err.Error())
@@ -1604,7 +1606,7 @@ replicas: 1
16041606
},
16051607
}
16061608

1607-
originalData := []byte(`random content`)
1609+
originalData := []byte(`random: content`)
16081610
_, err := marshalParamsOverride(&app, originalData)
16091611
assert.Error(t, err)
16101612
assert.Equal(t, "wrongimage.tag parameter not found", err.Error())

0 commit comments

Comments
 (0)