cmd: do not default for images, handle it specifically

Signed-off-by: Alfredo Deza <adeza@anchore.com>
This commit is contained in:
Alfredo Deza
2020-07-15 09:59:40 -04:00
parent 2f626bf9fd
commit a6e1866cdb
2 changed files with 38 additions and 63 deletions
+26 -26
View File
@@ -22,7 +22,6 @@ func Identify(s scope.Scope) *Distro {
}
for path, fn := range identityFiles {
// this is always a slice with a single ref, the API is odd because it was meant for images
refs, err := s.FilesByPath(path)
if err != nil {
log.Errorf("unable to get path refs from %s: %s", path, err)
@@ -32,33 +31,34 @@ func Identify(s scope.Scope) *Distro {
if len(refs) == 0 {
continue
}
ref := refs[0]
contents, err := s.MultipleFileContentsByRef(ref)
log.Infof("contents are: %+v", contents)
content, ok := contents[ref]
// XXX is it possible to get a ref and no contents at all?
if !ok {
continue
for _, ref := range refs {
contents, err := s.MultipleFileContentsByRef(ref)
content, ok := contents[ref]
if !ok {
log.Infof("no content present for ref: %s", ref)
continue
}
if err != nil {
log.Debugf("unable to get contents from %s: %s", path, err)
continue
}
if content == "" {
log.Debugf("no contents in file, skipping: %s", path)
continue
}
distro := fn(content)
if distro == nil {
continue
}
return distro
}
if err != nil {
log.Debugf("unable to get contents from %s: %s", path, err)
continue
}
if content == "" {
log.Debugf("no contents in file, skipping: %s", path)
continue
}
distro := fn(content)
if distro == nil {
continue
}
return distro
}
// TODO: is it useful to know partially detected distros? where the ID is known but not the version (and viceversa?)
return nil