Skip to content

Instantly share code, notes, and snippets.

@ncdc
Created September 27, 2017 21:02
Show Gist options
  • Save ncdc/9d74e55c0613faf8ff1ea56c4d871e2d to your computer and use it in GitHub Desktop.
Save ncdc/9d74e55c0613faf8ff1ea56c4d871e2d to your computer and use it in GitHub Desktop.
@ helpers.go:41 @ func ParseDockerTimestamp(s string) (time.Time, error) {
// (`foo`), tag references (`foo:bar`), and manifest digest references
// (`foo@sha256:xyz`).
func matchImageTagOrSHA(inspected dockertypes.ImageInspect, image string) bool {
glog.Errorf("ANDY matchImageTagOrSHA, image=%s", image)
// The image string follows the grammar specified here
// https://github.com/docker/distribution/blob/master/reference/reference.go#L4
named, err := dockerref.ParseNormalizedNamed(image)
@ helpers.go:62 @ func matchImageTagOrSHA(inspected dockertypes.ImageInspect, image string) bool {
// An image name (without the tag/digest) can be [hostname '/'] component ['/' component]*
// Because either the RepoTag or the name *may* contain the
// hostname or not, we only check for the suffix match.
if strings.HasSuffix(image, tag) || strings.HasSuffix(tag, image) {
glog.Errorf("ANDY image=%s, tag=%s", image, tag)
t, _ := dockerref.ParseNormalizedNamed(tag)
t2 := t.(dockerref.Tagged)
normalizedTag := t2.String()
glog.Errorf("ANDY image=%s, normalizedTag=%s", image, normalizedTag)
if strings.HasSuffix(image, normalizedTag) || strings.HasSuffix(normalizedTag, image) {
glog.Errorf("ANDY matched")
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment