Skip to content

Commit

Permalink
feat: support sha256 format image
Browse files Browse the repository at this point in the history
convert source image such as `repo:tag@sha256xxxxxx` or `repo@sha256xxxxxx`.

Signed-off-by: Yadong Ding <[email protected]>
  • Loading branch information
Desiki-high committed Jan 12, 2024
1 parent b82ccee commit 7645aaf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/adapter/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package adapter

import (
"fmt"
"regexp"
"strings"

"github.com/containerd/containerd/reference/docker"
Expand All @@ -34,7 +35,8 @@ const (
// Source: 192.168.1.1/nginx:latest
// Target: 192.168.1.1/nginx:latest-suffix
func addSuffix(ref, suffix string) (string, error) {
named, err := docker.ParseDockerRef(ref)
re := regexp.MustCompile(`@sha256.*`)
named, err := docker.ParseDockerRef(re.ReplaceAllString(ref, ""))
if err != nil {
return "", errors.Wrap(err, "invalid source image reference")
}
Expand All @@ -50,7 +52,8 @@ func addSuffix(ref, suffix string) (string, error) {
// Source:192.168.1.1/nginx:latest
// Target:192.168.1.1/nginx:tag
func setReferenceTag(ref, tag string) (string, error) {
named, err := docker.ParseDockerRef(ref)
re := regexp.MustCompile(`@sha256.*`)
named, err := docker.ParseDockerRef(re.ReplaceAllString(ref, ""))
if err != nil {
return "", errors.Wrap(err, "invalid source image reference")
}
Expand Down

0 comments on commit 7645aaf

Please sign in to comment.