Skip to content

Commit

Permalink
Fix: handle nil tag digests (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
felicianotech committed Nov 14, 2021
1 parent c18abb0 commit cdc65c5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sonar/docker/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ func GetAllTags(image string) ([]Tag, error) {
aTag.Size = uint64(v.(map[string]interface{})["full_size"].(float64))
aTag.Date, err = time.Parse(time.RFC3339, v.(map[string]interface{})["last_updated"].(string))
anImage := v.(map[string]interface{})["images"].([]interface{})[0]
aTag.Digest = anImage.(map[string]interface{})["digest"].(string)

// There are cases where the digest for a tag can be missing. Not
// sure why. Until then, check for this edge case and set to an
// empty string (don't set) when digest isn't available.
if anImage.(map[string]interface{})["digest"] != nil {
aTag.Digest = anImage.(map[string]interface{})["digest"].(string)
}

if err != nil {
return nil, err
}
Expand Down

0 comments on commit cdc65c5

Please sign in to comment.