@@ -18,14 +18,14 @@ package common
1818
1919import (
2020 "context"
21- "log"
2221 "os"
2322 "reflect"
2423 "strconv"
2524 "strings"
2625
2726 mf "github.com/manifestival/manifestival"
2827 "github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
28+ "go.uber.org/zap"
2929 "golang.org/x/exp/slices"
3030 appsv1 "k8s.io/api/apps/v1"
3131 batchv1 "k8s.io/api/batch/v1"
@@ -308,7 +308,8 @@ func SplitsByEqual(arg string) ([]string, bool) {
308308}
309309
310310// TaskImages replaces step and params images.
311- func TaskImages (images map [string ]string ) mf.Transformer {
311+ func TaskImages (ctx context.Context , images map [string ]string ) mf.Transformer {
312+ logger := logging .FromContext (ctx )
312313 return func (u * unstructured.Unstructured ) error {
313314 if u .GetKind () != "ClusterTask" && u .GetKind () != "Task" {
314315 return nil
@@ -321,7 +322,7 @@ func TaskImages(images map[string]string) mf.Transformer {
321322 if ! found {
322323 return nil
323324 }
324- replaceStepsImages (steps , images )
325+ replaceStepsImages (steps , images , logger )
325326 err = unstructured .SetNestedField (u .Object , steps , "spec" , "steps" )
326327 if err != nil {
327328 return err
@@ -334,47 +335,43 @@ func TaskImages(images map[string]string) mf.Transformer {
334335 if ! found {
335336 return nil
336337 }
337- replaceParamsImage (params , images )
338- err = unstructured .SetNestedField (u .Object , params , "spec" , "params" )
339- if err != nil {
340- return err
341- }
342- return nil
338+ replaceParamsImage (params , images , logger )
339+ return unstructured .SetNestedField (u .Object , params , "spec" , "params" )
343340 }
344341}
345342
346- func replaceStepsImages (steps []interface {}, override map [string ]string ) {
343+ func replaceStepsImages (steps []interface {}, override map [string ]string , logger * zap. SugaredLogger ) {
347344 for _ , s := range steps {
348345 step := s .(map [string ]interface {})
349346 name , ok := step ["name" ].(string )
350347 if ! ok {
351- log . Println ("Unable to get the step" , " step" , s )
348+ logger . Debugf ("Unable to get the step %v step" , s )
352349 continue
353350 }
354351
355352 name = formKey ("" , name )
356353 image , found := override [name ]
357354 if ! found || image == "" {
358- log . Println ("Image not found" , " step" , name , " action" , " skip" )
355+ logger . Debugf ("Image not found step %s action skip" , name )
359356 continue
360357 }
361358 step ["image" ] = image
362359 }
363360}
364361
365- func replaceParamsImage (params []interface {}, override map [string ]string ) {
362+ func replaceParamsImage (params []interface {}, override map [string ]string , logger * zap. SugaredLogger ) {
366363 for _ , p := range params {
367364 param := p .(map [string ]interface {})
368365 name , ok := param ["name" ].(string )
369366 if ! ok {
370- log . Println ("Unable to get the pram" , " param" , p )
367+ logger . Debugf ("Unable to get the pram %v param" , p )
371368 continue
372369 }
373370
374371 name = formKey (ParamPrefix , name )
375372 image , found := override [name ]
376373 if ! found || image == "" {
377- log . Println ("Image not found" , " step" , name , " action" , " skip" )
374+ logger . Debugf ("Image not found step %s action skip" , name )
378375 continue
379376 }
380377 param ["default" ] = image
0 commit comments