Explorar el Código

confirm that image info is valid before applying (#3319)

Feroze Mohideen hace 2 años
padre
commit
5dd5bd8309

+ 7 - 0
api/server/handlers/porter_app/create.go

@@ -147,6 +147,13 @@ func (c *CreatePorterAppHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
 		}
 		cloneEnvGroup(c, w, r, k8sAgent, request.EnvGroups, namespace)
 	}
+
+	if imageInfo.Repository == "" || imageInfo.Tag == "" {
+		err = telemetry.Error(ctx, span, nil, "incomplete image info provided: must provide both repository and tag")
+		c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusBadRequest))
+		return
+	}
+
 	chart, values, preDeployJobValues, err := parse(
 		ParseConf{
 			PorterYaml:                porterYaml,

+ 5 - 7
api/server/handlers/porter_app/parse.go

@@ -273,13 +273,11 @@ func buildUmbrellaChartValues(
 		}
 	}
 
-	if imageInfo.Repository != "" && imageInfo.Tag != "" {
-		values["global"] = map[string]interface{}{
-			"image": map[string]interface{}{
-				"repository": imageInfo.Repository,
-				"tag":        imageInfo.Tag,
-			},
-		}
+	values["global"] = map[string]interface{}{
+		"image": map[string]interface{}{
+			"repository": imageInfo.Repository,
+			"tag":        imageInfo.Tag,
+		},
 	}
 
 	return values, nil