@@ -56,21 +56,35 @@ func makeUpdateImagesFilter(originalRepo, replacement string) kio.Filter {
5656 })
5757
5858 return kio .FilterFunc (func (objs []* yaml.RNode ) ([]* yaml.RNode , error ) {
59+ tees := []yaml.Filter {
60+ yaml .Tee (
61+ yaml .Lookup ("initContainers" ),
62+ replaceImageInEachContainer ,
63+ ),
64+ yaml .Tee (
65+ yaml .Lookup ("containers" ),
66+ replaceImageInEachContainer ,
67+ ),
68+ }
69+
5970 for _ , obj := range objs {
60- if err := obj .PipeE (
61- yaml .Lookup ("spec" , "template" , "spec" ),
62- yaml .Tee (
63- yaml .Lookup ("initContainers" ),
64- replaceImageInEachContainer ,
65- ),
66- yaml .Tee (
67- yaml .Lookup ("containers" ),
68- replaceImageInEachContainer ,
69- ),
70- ); err != nil {
71+ lookup := yaml .Lookup ("spec" , "template" , "spec" )
72+ switch kind (obj ) {
73+ case "CronJob" :
74+ lookup = yaml .Lookup ("spec" , "jobTemplate" , "spec" , "template" , "spec" )
75+ }
76+ if err := obj .PipeE (append ([]yaml.Filter {lookup }, tees ... )... ); err != nil {
7177 return nil , err
7278 }
7379 }
7480 return objs , nil
7581 })
7682}
83+
84+ func kind (a * yaml.RNode ) string {
85+ f := a .Field (yaml .KindField )
86+ if f != nil {
87+ return yaml .GetValue (f .Value )
88+ }
89+ return ""
90+ }
0 commit comments