@@ -30,7 +30,7 @@ func TestReadCurrentVersion(t *testing.T) {
30
30
{
31
31
name : "invalid yaml" ,
32
32
args : args {
33
- f : []byte ("wibble&&3..\n fff" ),
33
+ f : []byte ("wibble&&3..\n fff" ),
34
34
notation : "image.tag" ,
35
35
},
36
36
want : "" ,
@@ -39,7 +39,7 @@ func TestReadCurrentVersion(t *testing.T) {
39
39
{
40
40
name : "simple yaml" ,
41
41
args : args {
42
- f : createSimpleYaml ("v1.2.99" ),
42
+ f : createSimpleYaml ("v1.2.99" ),
43
43
notation : "image.tag" ,
44
44
},
45
45
want : "v1.2.99" ,
@@ -48,7 +48,7 @@ func TestReadCurrentVersion(t *testing.T) {
48
48
{
49
49
name : "invalid notation to yaml" ,
50
50
args : args {
51
- f : createSimpleYaml ("v1.2.99" ),
51
+ f : createSimpleYaml ("v1.2.99" ),
52
52
notation : "image.nope" ,
53
53
},
54
54
want : "" ,
@@ -57,12 +57,21 @@ func TestReadCurrentVersion(t *testing.T) {
57
57
{
58
58
name : "array notation" ,
59
59
args : args {
60
- f : createSimpleArrayYaml ("v1.9" ),
60
+ f : createSimpleArrayYaml ("v1.9" ),
61
61
notation : "images[3].tag" ,
62
62
},
63
63
want : "v1.9" ,
64
64
wantErr : false ,
65
65
},
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
+ },
66
75
}
67
76
68
77
fmt .Println (string (createSimpleArrayYaml ("v1.2.99" )))
@@ -106,7 +115,30 @@ func createSimpleArrayYaml(t string) []byte {
106
115
marshal , err := yaml .Marshal (& struct {
107
116
Images []tag `yaml:"images"`
108
117
}{
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
+ }},
110
142
})
111
143
if err != nil {
112
144
return nil
0 commit comments