@@ -49,16 +49,17 @@ func validateHandler(context *cli.Context) error {
4949 }
5050
5151 v = validateCmd {
52- typ : context .String ("type" ),
53- refs : context .StringSlice ("ref" ),
52+ stdout : log .New (os .Stdout , "" , 0 ),
53+ typ : context .String ("type" ),
54+ refs : context .StringSlice ("ref" ),
5455 }
5556
5657 var errs []string
5758 for _ , arg := range context .Args () {
5859 err := validatePath (arg )
5960
6061 if err == nil {
61- fmt .Printf ("%s: OK\n " , arg )
62+ v . stdout .Printf ("%s: OK\n " , arg )
6263 continue
6364 }
6465
@@ -77,7 +78,7 @@ func validateHandler(context *cli.Context) error {
7778 if len (errs ) > 0 {
7879 return fmt .Errorf ("%d errors detected: \n %s" , len (errs ), strings .Join (errs , "\n " ))
7980 }
80- fmt .Println ("Validation succeeded" )
81+ v . stdout .Println ("Validation succeeded" )
8182 return nil
8283}
8384
@@ -93,10 +94,6 @@ func validatePath(name string) error {
9394 }
9495 }
9596
96- if v .stdout == nil {
97- v .stdout = log .New (os .Stdout , "oci-image-tool: " , 0 )
98- }
99-
10097 switch typ {
10198 case image .TypeImageLayout :
10299 return image .ValidateLayout (name , v .refs , v .stdout )
@@ -105,7 +102,7 @@ func validatePath(name string) error {
105102 }
106103
107104 if len (v .refs ) != 0 {
108- fmt .Printf ("WARNING: type %q does not support refs, which are only appropriate if type is image or imageLayout.\n " , typ )
105+ v . stdout .Printf ("WARNING: type %q does not support refs, which are only appropriate if type is image or imageLayout.\n " , typ )
109106 }
110107
111108 f , err := os .Open (name )
0 commit comments