Parcourir la source

Inserting the image info into values on resource update now too (#3013)

Feroze Mohideen il y a 3 ans
Parent
commit
02dccea8f3
3 fichiers modifiés avec 19 ajouts et 1 suppressions
  1. 16 1
      cli/cmd/apply.go
  2. 1 0
      cli/cmd/stack/release.go
  3. 2 0
      internal/integrations/preview/utils.go

+ 16 - 1
cli/cmd/apply.go

@@ -636,8 +636,23 @@ func (d *DeployDriver) updateApplication(resource *switchboardModels.Resource, c
 		}
 	}
 
-	err = updateAgent.UpdateImageAndValues(appConf.Values)
+	if appConf.InjectBuild {
+		// use the built image in the values if it is set
+		// if it contains a $, then the query did not resolve
+		if appConf.Build.Image != "" && !strings.Contains(appConf.Build.Image, "$") {
+			imageSpl := strings.Split(appConf.Build.Image, ":")
+			if len(imageSpl) == 2 {
+				appConf.Values["image"] = map[string]interface{}{
+					"repository": imageSpl[0],
+					"tag":        imageSpl[1],
+				}
+			} else {
+				return nil, fmt.Errorf("could not parse image info %s", appConf.Build.Image)
+			}
+		}
+	}
 
+	err = updateAgent.UpdateImageAndValues(appConf.Values)
 	if err != nil {
 		return nil, err
 	}

+ 1 - 0
cli/cmd/stack/release.go

@@ -29,6 +29,7 @@ func createReleaseResource(client *api.Client, release *App, stackName, buildRes
 	config.Build.Image = fmt.Sprintf("{ .%s.image }", buildResourceName)
 	config.Build.Env = CopyEnv(env)
 	config.WaitForJob = true
+	config.InjectBuild = true
 
 	helm_values := make(map[string]interface{})
 	if release != nil && release.Config != nil {

+ 2 - 0
internal/integrations/preview/utils.go

@@ -71,6 +71,8 @@ type BuildDriverConfig struct {
 type ApplicationConfig struct {
 	WaitForJob bool
 
+	InjectBuild bool
+
 	// If set to true, this does not run an update, it only creates the initial application and job,
 	// skipping subsequent updates
 	OnlyCreate bool