diff --git a/pkg/app/bp.go b/pkg/app/bp.go index 81e0852532..2dfbabf87a 100644 --- a/pkg/app/bp.go +++ b/pkg/app/bp.go @@ -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 @@ -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{ diff --git a/pkg/app/bp_test.go b/pkg/app/bp_test.go index fa2d3201e8..c96f5c07bc 100644 --- a/pkg/app/bp_test.go +++ b/pkg/app/bp_test.go @@ -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"}, }, }, @@ -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"}, }, }, @@ -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) } }