Skip to content

Commit

Permalink
add support for bumping AR registries
Browse files Browse the repository at this point in the history
  • Loading branch information
upodroid committed Jun 6, 2023
1 parent 71151e3 commit 6408779
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions experiment/image-bumper/bumper/bumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

var (
imageRegexp = regexp.MustCompile(`\b((?:[a-z0-9]+\.)?gcr\.io)/([a-z][a-z0-9-]{5,29}/[a-zA-Z0-9][a-zA-Z0-9_./-]+):([a-zA-Z0-9_.-]+)\b`)
imageRegexp = regexp.MustCompile(`\b((?:[a-z0-9]+\.)?gcr\.io|(?:[a-z0-9]+\-)?docker\.pkg\.dev)/([a-z][a-z0-9-]{5,29}/[a-zA-Z0-9][a-zA-Z0-9_./-]+):([a-zA-Z0-9_.-]+)\b`)
tagRegexp = regexp.MustCompile(`(v?\d{8}-(?:v\d(?:[.-]\d+)*-g)?[0-9a-f]{6,10}|latest)(-.+)?`)
)

Expand Down Expand Up @@ -68,11 +68,11 @@ var commitRegexp = regexp.MustCompile(`^g?([\da-f]+)|(.+?)??(?:-(\d+)-g([\da-f]+

// DeconstructCommit separates a git describe commit into its parts.

//
// Examples:
// v0.0.30-14-gdeadbeef => (v0.0.30 14 deadbeef)
// v0.0.30 => (v0.0.30 0 "")
// deadbeef => ("", 0, deadbeef)
//
// v0.0.30-14-gdeadbeef => (v0.0.30 14 deadbeef)
// v0.0.30 => (v0.0.30 0 "")
// deadbeef => ("", 0, deadbeef)
//
// See man git describe.
func DeconstructCommit(commit string) (string, int, string) {
Expand Down
8 changes: 8 additions & 0 deletions experiment/image-bumper/bumper/bumper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,14 @@ func TestUpdateAllTags(t *testing.T) {
"eu.gcr.io/k8s-testimages/some-image:v20190404-12345678": "v20190405-123456789",
},
},
{
name: "AR subdomains are supported",
content: `{"images": ["us-docker.pkg.dev/k8s-testimages/some-image:v20190404-12345678"]}`,
expectedResult: `{"images": ["us-docker.pkg.dev/k8s-testimages/some-image:v20190405-123456789"]}`,
newTags: map[string]string{
"us-docker.pkg.dev/k8s-testimages/some-image:v20190404-12345678": "v20190405-123456789",
},
},
{
name: "images not matching the filter regex are not updated",
content: `{"images": ["gcr.io/k8s-prow/prow-thing:v20190404-12345678", "gcr.io/k8s-testimages/some-image:v20190404-12345678"]}`,
Expand Down

0 comments on commit 6408779

Please sign in to comment.