@@ -30,7 +30,7 @@ func TestReadCurrentVersion(t *testing.T) {
3030 {
3131 name : "invalid yaml" ,
3232 args : args {
33- f : []byte ("wibble&&3..\n fff" ),
33+ f : []byte ("wibble&&3..\n fff" ),
3434 notation : "image.tag" ,
3535 },
3636 want : "" ,
@@ -39,7 +39,7 @@ func TestReadCurrentVersion(t *testing.T) {
3939 {
4040 name : "simple yaml" ,
4141 args : args {
42- f : createSimpleYaml ("v1.2.99" ),
42+ f : createSimpleYaml ("v1.2.99" ),
4343 notation : "image.tag" ,
4444 },
4545 want : "v1.2.99" ,
@@ -48,7 +48,7 @@ func TestReadCurrentVersion(t *testing.T) {
4848 {
4949 name : "invalid notation to yaml" ,
5050 args : args {
51- f : createSimpleYaml ("v1.2.99" ),
51+ f : createSimpleYaml ("v1.2.99" ),
5252 notation : "image.nope" ,
5353 },
5454 want : "" ,
@@ -57,12 +57,21 @@ func TestReadCurrentVersion(t *testing.T) {
5757 {
5858 name : "array notation" ,
5959 args : args {
60- f : createSimpleArrayYaml ("v1.9" ),
60+ f : createSimpleArrayYaml ("v1.9" ),
6161 notation : "images[3].tag" ,
6262 },
6363 want : "v1.9" ,
6464 wantErr : false ,
6565 },
66+ {
67+ name : "helm example" ,
68+ args : args {
69+ f : createHelmYaml ("v1.9" ),
70+ notation : "dependencies[0].version" ,
71+ },
72+ want : "v1.9" ,
73+ wantErr : false ,
74+ },
6675 }
6776
6877 fmt .Println (string (createSimpleArrayYaml ("v1.2.99" )))
@@ -106,7 +115,30 @@ func createSimpleArrayYaml(t string) []byte {
106115 marshal , err := yaml .Marshal (& struct {
107116 Images []tag `yaml:"images"`
108117 }{
109- Images : []tag {{Tag : "v1" },{Tag : "v2" },{Tag : "v3" },{Tag : t }},
118+ Images : []tag {{Tag : "v1" }, {Tag : "v2" }, {Tag : "v3" }, {Tag : t }},
119+ })
120+ if err != nil {
121+ return nil
122+ }
123+
124+ return marshal
125+ }
126+
127+ func createHelmYaml (t string ) []byte {
128+ type dependencies struct {
129+ Name string `yaml:"name"`
130+ Version string `yaml:"version"`
131+ Repository string `yaml:"repository"`
132+ }
133+
134+ marshal , err := yaml .Marshal (& struct {
135+ Dependencies []dependencies `yaml:"dependencies"`
136+ }{
137+ Dependencies : []dependencies {{
138+ Name : "example-test" ,
139+ Version : t ,
140+ Repository : "gsdevme/test" ,
141+ }},
110142 })
111143 if err != nil {
112144 return nil
0 commit comments