Skip to content

Commit

Permalink
fix(build): fix invalid image digest when cache repo used
Browse files Browse the repository at this point in the history
There was an issue where users would receive a value in the format `<cache-repo-address>@<digest>` instead of `<digest>`.

Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
  • Loading branch information
alexey-igrychev committed Jul 4, 2024
1 parent 6eea7f2 commit aac0cfe
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/image/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Info struct {
Name string `json:"name"`
Repository string `json:"repository"`
Tag string `json:"tag"`

// FIXME remove RepoDigest from Info and use Digest everywhere instead cause it's more clear and repo part is not needed.
// repo@sha256:digest
RepoDigest string `json:"repoDigest"`

Expand All @@ -33,7 +35,16 @@ type Info struct {
}

func (info *Info) GetDigest() string {
return strings.TrimPrefix(info.RepoDigest, fmt.Sprintf("%s@", info.Repository))
if info.RepoDigest == "" {
return ""
}

parts := strings.Split(info.RepoDigest, "@")
if len(parts) != 2 {
panic(fmt.Sprintf("bad repo digest %q", info.RepoDigest))
}

return parts[1]
}

func (info *Info) SetCreatedAtUnix(seconds int64) {
Expand Down

0 comments on commit aac0cfe

Please sign in to comment.