Skip to content

Commit

Permalink
Update Image Tag to v9.99.9-dev only for ghcr/kanisterio images (#1623)
Browse files Browse the repository at this point in the history
* Modify UpdateImageTags function to only update image from blueprint if it has ghcr/kanisterio prefix

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Modify UpdateImageTags function to only update image from blueprint if it has ghcr/kanisterio prefix

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>

* Update validateImageTags to verify if only image having prefix `ghcr.io/kanisterio` have tags updated
Minor Refactor

* Minor refactor, Add Comments

Signed-off-by: Akanksha Kumari <akankshakumari393@gmail.com>
  • Loading branch information
akankshakumari393 authored Sep 8, 2022
1 parent 4a0614a commit ea16889
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 7 additions & 2 deletions pkg/app/bp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import (

const (
blueprintsRepo = "./blueprints"
// imagePrefix specifies the prefix an image is going to have if it's being consumed from
// kanister's ghcr registry
imagePrefix = "ghcr.io/kanisterio"
)

// Blueprint implements Blueprint() to return Blueprint specs for the app
Expand Down Expand Up @@ -87,8 +90,10 @@ func updateImageTags(bp *crv1alpha1.Blueprint) {
continue
}

// ghcr.io/kanisterio/tools:v0.xx.x => ghcr.io/kanisterio/tools:v9.99.9-dev
phase.Args["image"] = fmt.Sprintf("%s:v9.99.9-dev", strings.Split(imageStr, ":")[0])
if strings.HasPrefix(imageStr, imagePrefix) {
// ghcr.io/kanisterio/tools:v0.xx.x => ghcr.io/kanisterio/tools:v9.99.9-dev
phase.Args["image"] = fmt.Sprintf("%s:v9.99.9-dev", strings.Split(imageStr, ":")[0])
}

// Change imagePullPolicy to Always using podOverride config
phase.Args["podOverride"] = crv1alpha1.JSONMap{
Expand Down
10 changes: 6 additions & 4 deletions pkg/app/bp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (bs *BlueprintSuite) TestUpdateImageTags(c *C) {
Name: "test-kube-task",
Args: map[string]interface{}{
"namespace": "{{ .Deployment.Namespace }}",
"image": "ghcr.io/image:v0.50.0",
"image": "ghcr.io/kanisterio/image:v0.50.0",
"command": []string{"echo", "hello"},
},
},
Expand Down Expand Up @@ -104,7 +104,7 @@ func (bs *BlueprintSuite) TestUpdateImageTags(c *C) {
Name: "test-kube-task",
Args: map[string]interface{}{
"namespace": "{{ .Deployment.Namespace }}",
"image": "ghcr.io/image:v0.50.0",
"image": "ghcr.io/kanisterio/image:v0.50.0",
"command": []string{"echo", "hello"},
},
},
Expand Down Expand Up @@ -153,9 +153,11 @@ func validateImageTags(c *C, bp *crv1alpha1.Blueprint) {
if !ok {
continue
}
// Verify if the tag is "v9.99.9-dev"
// Verify if image with prefix "ghcr.io/kanisterio" is tagged "v9.99.9-dev"
c.Log(fmt.Sprintf("phase:%s, image:%s", phase.Name, image.(string)))
c.Assert(strings.Split(image.(string), ":")[1], Equals, "v9.99.9-dev")
if strings.HasPrefix(image.(string), imagePrefix) {
c.Assert(strings.Split(image.(string), ":")[1], Equals, "v9.99.9-dev")
}
c.Assert(phase.Args["podOverride"], DeepEquals, podOverride)
}
}
Expand Down

0 comments on commit ea16889

Please sign in to comment.