Forráskód Böngészése

handle case where update called on hello-porter images

Alexander Belanger 4 éve
szülő
commit
6de918d386
2 módosított fájl, 30 hozzáadás és 2 törlés
  1. 28 0
      cli/cmd/deploy/deploy.go
  2. 2 2
      go.mod

+ 28 - 0
cli/cmd/deploy/deploy.go

@@ -279,10 +279,38 @@ func (d *DeployAgent) UpdateImageAndValues(overrideValues map[string]interface{}
 	// overwrite the tag based on a new image
 	currImageSection := mergedValues["image"].(map[string]interface{})
 
+	// if the current image section is hello-porter, the image must be overriden
+	if currImageSection["repository"] == "public.ecr.aws/o1j4x7p4/hello-porter" ||
+		currImageSection["repository"] == "public.ecr.aws/o1j4x7p4/hello-porter-job" {
+		newImage, err := d.getReleaseImage()
+
+		if err != nil {
+			return fmt.Errorf("could not overwrite hello-porter image: %s", err.Error())
+		}
+
+		currImageSection["repository"] = newImage
+
+		// set to latest just to be safe -- this will be overriden if "d.tag" is set in
+		// the agent
+		currImageSection["tag"] = "latest"
+	}
+
 	if d.tag != "" && currImageSection["tag"] != d.tag {
 		currImageSection["tag"] = d.tag
 	}
 
+	// if opts.Kind == "web" || opts.Kind == "worker" {
+	// 	mergedValues["image"] = map[string]interface{}{
+	// 		"repository": "public.ecr.aws/o1j4x7p4/hello-porter",
+	// 		"tag":        "latest",
+	// 	}
+	// } else if opts.Kind == "job" {
+	// 	mergedValues["image"] = map[string]interface{}{
+	// 		"repository": "public.ecr.aws/o1j4x7p4/hello-porter-job",
+	// 		"tag":        "latest",
+	// 	}
+	// }
+
 	bytes, err := json.Marshal(mergedValues)
 
 	if err != nil {

+ 2 - 2
go.mod

@@ -7,7 +7,7 @@ require (
 	github.com/AlecAivazis/survey/v2 v2.2.9
 	github.com/DATA-DOG/go-sqlmock v1.5.0
 	github.com/aws/aws-sdk-go v1.35.4
-	github.com/bradleyfalzon/ghinstallation v1.1.1 // indirect
+	github.com/bradleyfalzon/ghinstallation v1.1.1
 	github.com/buildpacks/pack v0.19.0
 	github.com/cli/cli v1.11.0
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
@@ -28,7 +28,7 @@ require (
 	github.com/google/go-github/v29 v29.0.3 // indirect
 	github.com/google/go-github/v33 v33.0.0
 	github.com/google/go-querystring v1.1.0 // indirect
-  github.com/gorilla/mux v1.8.0 // indirect
+	github.com/gorilla/mux v1.8.0 // indirect
 	github.com/gorilla/schema v1.2.0
 	github.com/gorilla/securecookie v1.1.1
 	github.com/gorilla/sessions v1.2.1