Skip to content

Conversation

@jphelton
Copy link

@jphelton jphelton commented Nov 22, 2025

resolves #2069

Details

  • Introduces a new method to name.Digest called MaybeTagStr
  • The method returns the tag that was included within a digest if it exists

Example Usage

package main

import (
	"fmt"

	"github.com/google/go-containerregistry/pkg/name"
)

func main() {
	i := "gcr.io/project-id/image:1.0@sha256:deadb33fdeadb33fdeadb33fdeadb33fdeadb33fdeadb33fdeadb33fdeadb33f"
	d, _ := name.NewDigest(i)
	tag, ok := d.MaybeTagStr()
	if ok {
		fmt.Printf("Digest %q has a tag: %q", d, tag)
	} else {
		fmt.Printf("Digest %q does not have a tag.", d)
	}

}

Signed-off-by: jphelton <14790953+jphelton@users.noreply.github.com>
@jphelton jphelton force-pushed the feature/name-digest-maybe-tag branch from f00069d to 9acce9c Compare November 22, 2025 04:38
@jphelton jphelton marked this pull request as ready for review November 23, 2025 16:36
@jphelton jphelton changed the title feat: Add MaybeTag method to Digest type feat: Add MaybeTagStr method to Digest type Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ggcr: Parsing image name with both tag and digest loses tag info

1 participant