@@ -18,7 +18,6 @@ import (
1818 "encoding/json"
1919 "fmt"
2020 "io"
21- "log"
2221 "os"
2322 "path/filepath"
2423 "strings"
@@ -29,42 +28,42 @@ import (
2928
3029// ValidateLayout walks through the given file tree and validates the manifest
3130// pointed to by the given refs or returns an error if the validation failed.
32- func ValidateLayout (src string , refs []string , out * log. Logger ) error {
33- return validate (newPathWalker (src ), refs , out )
31+ func ValidateLayout (src string , refs []string ) error {
32+ return validate (newPathWalker (src ), refs )
3433}
3534
3635// ValidateZip walks through the given file tree and validates the manifest
3736// pointed to by the given refs or returns an error if the validation failed.
38- func ValidateZip (src string , refs []string , out * log. Logger ) error {
39- return validate (newZipWalker (src ), refs , out )
37+ func ValidateZip (src string , refs []string ) error {
38+ return validate (newZipWalker (src ), refs )
4039}
4140
4241// ValidateFile opens the tar file given by the filename, then calls ValidateReader
43- func ValidateFile (tarFile string , refs []string , out * log. Logger ) error {
42+ func ValidateFile (tarFile string , refs []string ) error {
4443 f , err := os .Open (tarFile )
4544 if err != nil {
4645 return errors .Wrap (err , "unable to open file" )
4746 }
4847 defer f .Close ()
4948
50- return Validate (f , refs , out )
49+ return Validate (f , refs )
5150}
5251
5352// Validate walks through a tar stream and validates the manifest.
5453// * Check that all refs point to extant blobs
5554// * Checks that all referred blobs are valid
5655// * Checks that mime-types are correct
5756// returns error on validation failure
58- func Validate (r io.ReadSeeker , refs []string , out * log. Logger ) error {
59- return validate (newTarWalker (r ), refs , out )
57+ func Validate (r io.ReadSeeker , refs []string ) error {
58+ return validate (newTarWalker (r ), refs )
6059}
6160
6261var validRefMediaTypes = []string {
6362 v1 .MediaTypeImageManifest ,
6463 v1 .MediaTypeImageIndex ,
6564}
6665
67- func validate (w walker , refs []string , out * log. Logger ) error {
66+ func validate (w walker , refs []string ) error {
6867 if err := layoutValidate (w ); err != nil {
6968 return err
7069 }
@@ -77,7 +76,7 @@ func validate(w walker, refs []string, out *log.Logger) error {
7776 // TODO(runcom): ugly, we'll need a better way and library
7877 // to express log levels.
7978 // see https://github.com/opencontainers/image-spec/issues/288
80- out . Print ("WARNING: no descriptors found" )
79+ fmt . Println ("WARNING: no descriptors found" )
8180 }
8281
8382 if len (refs ) == 0 {
@@ -137,9 +136,7 @@ func validate(w walker, refs []string, out *log.Logger) error {
137136 }
138137 }
139138
140- if out != nil {
141- out .Printf ("reference %q: OK" , ref )
142- }
139+ fmt .Printf ("reference %q: OK\n " , ref )
143140 }
144141
145142 return nil
0 commit comments