Переглянути джерело

include build env only for build

Mohammed Nafees 4 роки тому
батько
коміт
d90bbaad84
3 змінених файлів з 34 додано та 12 видалено
  1. 18 2
      cli/cmd/apply.go
  2. 6 3
      cli/cmd/deploy.go
  3. 10 7
      cli/cmd/deploy/deploy.go

+ 18 - 2
cli/cmd/apply.go

@@ -527,8 +527,9 @@ func (d *Driver) updateApplication(resource *models.Resource, client *api.Client
 	// if the build method is registry, we do not trigger a build
 	if appConf.Build.Method != "registry" {
 		buildEnv, err := updateAgent.GetBuildEnv(&deploy.GetBuildEnvOpts{
-			UseNewConfig: true,
-			NewConfig:    appConf.Values,
+			UseNewConfig:    true,
+			NewConfig:       appConf.Values,
+			IncludeBuildEnv: true,
 		})
 
 		if err != nil {
@@ -565,6 +566,21 @@ func (d *Driver) updateApplication(resource *models.Resource, client *api.Client
 		}
 	}
 
+	buildEnv, err := updateAgent.GetBuildEnv(&deploy.GetBuildEnvOpts{
+		UseNewConfig: true,
+		NewConfig:    appConf.Values,
+	})
+
+	if err != nil {
+		return nil, err
+	}
+
+	err = updateAgent.SetBuildEnv(buildEnv)
+
+	if err != nil {
+		return nil, err
+	}
+
 	err = updateAgent.UpdateImageAndValues(appConf.Values)
 
 	if err != nil {

+ 6 - 3
cli/cmd/deploy.go

@@ -497,8 +497,9 @@ func updateBuildWithAgent(updateAgent *deploy.DeployAgent) error {
 	}
 
 	buildEnv, err := updateAgent.GetBuildEnv(&deploy.GetBuildEnvOpts{
-		UseNewConfig: true,
-		NewConfig:    valuesObj,
+		UseNewConfig:    true,
+		NewConfig:       valuesObj,
+		IncludeBuildEnv: true,
 	})
 
 	if err != nil {
@@ -638,7 +639,9 @@ func updateUpgradeWithAgent(updateAgent *deploy.DeployAgent) error {
 		return err
 	}
 
-	env, err := updateAgent.GetBuildEnv(&deploy.GetBuildEnvOpts{UseNewConfig: false})
+	env, err := updateAgent.GetBuildEnv(&deploy.GetBuildEnvOpts{
+		UseNewConfig: false,
+	})
 
 	if err == nil && len(env) > 0 {
 		valuesObj = templaterUtils.CoalesceValues(valuesObj, map[string]interface{}{

+ 10 - 7
cli/cmd/deploy/deploy.go

@@ -146,8 +146,9 @@ func NewDeployAgent(client *client.Client, app string, opts *DeployOpts) (*Deplo
 }
 
 type GetBuildEnvOpts struct {
-	UseNewConfig bool
-	NewConfig    map[string]interface{}
+	UseNewConfig    bool
+	NewConfig       map[string]interface{}
+	IncludeBuildEnv bool
 }
 
 // GetBuildEnv retrieves the build env from the release config and returns it
@@ -166,12 +167,14 @@ func (d *DeployAgent) GetBuildEnv(opts *GetBuildEnvOpts) (map[string]string, err
 		return nil, err
 	}
 
-	buildEnv, err := GetNestedMap(conf, "container", "env", "build")
+	if opts.IncludeBuildEnv {
+		buildEnv, err := GetNestedMap(conf, "container", "env", "build")
 
-	if err == nil {
-		for key, val := range buildEnv {
-			if valStr, ok := val.(string); ok {
-				env[key] = valStr
+		if err == nil {
+			for key, val := range buildEnv {
+				if valStr, ok := val.(string); ok {
+					env[key] = valStr
+				}
 			}
 		}
 	}