File tree 2 files changed +5
-23
lines changed
pkg/apis/cartographer/v1alpha1
2 files changed +5
-23
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,8 @@ func (w *WorkloadSpec) Merge(updates *WorkloadSpec) {
222
222
if updates .Image != "" {
223
223
w .MergeImage (updates .Image )
224
224
}
225
- if s := updates .Source ; s != nil {
225
+ if updates .Source != nil {
226
+ s := updates .Source .DeepCopy ()
226
227
if s .Git != nil {
227
228
w .MergeGit (* s .Git )
228
229
}
@@ -326,7 +327,7 @@ func (w *WorkloadSpec) ResetSource() {
326
327
}
327
328
328
329
func (w * WorkloadSpec ) MergeGit (git GitSource ) {
329
- stash := w .Source
330
+ stash := w .Source . DeepCopy ()
330
331
image := w .Image
331
332
w .ResetSource ()
332
333
@@ -348,13 +349,13 @@ func (w *WorkloadSpec) MergeGit(git GitSource) {
348
349
}
349
350
350
351
func (w * WorkloadSpec ) MergeSourceImage (image string ) {
351
- stash := w .Source
352
+ stash := w .Source . DeepCopy ()
352
353
w .ResetSource ()
353
354
354
355
w .Source = & Source {
355
356
Image : image ,
356
357
}
357
- if stash != nil && stash .Image != "" {
358
+ if stash != nil && stash .Subpath != "" {
358
359
w .Source .Subpath = stash .Subpath
359
360
}
360
361
}
Original file line number Diff line number Diff line change @@ -1884,25 +1884,6 @@ func TestWorkloadSpec_MergeSourceImage(t *testing.T) {
1884
1884
Subpath : "my-subpath" ,
1885
1885
},
1886
1886
},
1887
- }, {
1888
- name : "update deleting subpath" ,
1889
- seed : & WorkloadSpec {
1890
- Source : & Source {
1891
- Git : & GitSource {
1892
- URL :
"[email protected] :example/repo.git" ,
1893
- Ref : GitRef {
1894
- Branch : "main" ,
1895
- },
1896
- },
1897
- Subpath : "my-subpath" ,
1898
- },
1899
- },
1900
- sourceImage : "my-registry.nip.io/my-folder/my-image:latest@sha:my-sha1234567890" ,
1901
- want : & WorkloadSpec {
1902
- Source : & Source {
1903
- Image : "my-registry.nip.io/my-folder/my-image:latest@sha:my-sha1234567890" ,
1904
- },
1905
- },
1906
1887
}}
1907
1888
1908
1889
for _ , test := range tests {
You can’t perform that action at this time.
0 commit comments