File tree Expand file tree Collapse file tree 3 files changed +51
-2
lines changed Expand file tree Collapse file tree 3 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -1835,6 +1835,44 @@ spec:
1835
1835
name: sidecar
1836
1836
imagePullPolicy: OnFailure
1837
1837
` ,
1838
+ },
1839
+ "replacement contain jsonfield" : {
1840
+ input : `apiVersion: v1
1841
+ kind: ConfigMap
1842
+ metadata:
1843
+ name: target-configmap
1844
+ data:
1845
+ config.json: |-
1846
+ {
1847
+ "config": {
1848
+ "id": "42",
1849
+ "hostname": "REPLACE_TARGET_HOSTNAME"
1850
+ }
1851
+ }
1852
+ ` ,
1853
+ replacements : `replacements:
1854
+ - source:
1855
+ kind: ConfigMap
1856
+ name: target-configmap
1857
+ fieldPath: metadata.name
1858
+ targets:
1859
+ - select:
1860
+ kind: ConfigMap
1861
+ fieldPaths:
1862
+ - data.config\.json.config.hostname
1863
+ ` ,
1864
+ expected : `apiVersion: v1
1865
+ kind: ConfigMap
1866
+ metadata:
1867
+ name: target-configmap
1868
+ data:
1869
+ config.json: |-
1870
+ {
1871
+ "config": {
1872
+ "id": "42",
1873
+ "hostname": "target-configmap"
1874
+ }
1875
+ }` ,
1838
1876
},
1839
1877
"multiple field paths in target" : {
1840
1878
input : `apiVersion: v1
@@ -2779,7 +2817,7 @@ spec:
2779
2817
name: myingress
2780
2818
fieldPaths:
2781
2819
- spec.tls.0.hosts.0
2782
- - spec.tls.0.secretName
2820
+ - spec.tls.0.secretName
2783
2821
options:
2784
2822
create: true
2785
2823
` ,
Original file line number Diff line number Diff line change @@ -830,6 +830,10 @@ func (e *InvalidNodeKindError) Error() string {
830
830
return msg
831
831
}
832
832
833
+ func (e * InvalidNodeKindError ) Unwrap () error {
834
+ return errors .Errorf ("InvalidNodeKindError" )
835
+ }
836
+
833
837
func (e * InvalidNodeKindError ) ActualNodeKind () Kind {
834
838
return e .node .YNode ().Kind
835
839
}
Original file line number Diff line number Diff line change @@ -137,10 +137,17 @@ func (p *PathMatcher) visitEveryElem(elem *RNode) error {
137
137
func (p * PathMatcher ) doField (rn * RNode ) (* RNode , error ) {
138
138
// lookup the field
139
139
field , err := rn .Pipe (Get (p .Path [0 ]))
140
- if err != nil || (! IsCreate (p .Create ) && field == nil ) {
140
+ if err != nil {
141
+ if errors .Is (err , & InvalidNodeKindError {}) {
142
+ fmt .Println (err )
143
+ }
141
144
return nil , err
142
145
}
143
146
147
+ if ! IsCreate (p .Create ) && field == nil {
148
+ return nil , nil
149
+ }
150
+
144
151
if IsCreate (p .Create ) && field == nil {
145
152
var nextPart string
146
153
if len (p .Path ) > 1 {
You can’t perform that action at this time.
0 commit comments