Просмотр исходного кода

support overriding builder/buildpacks on upgrade

Alexander Belanger 4 лет назад
Родитель
Сommit
493eaefd06
3 измененных файлов с 19 добавлено и 4 удалено
  1. 10 1
      cli/cmd/apply.go
  2. 1 1
      cli/cmd/deploy.go
  3. 8 2
      cli/cmd/deploy/deploy.go

+ 10 - 1
cli/cmd/apply.go

@@ -407,7 +407,16 @@ func (d *Driver) updateApplication(resource *models.Resource, client *api.Client
 		return nil, err
 	}
 
-	err = updateAgent.Build()
+	var buildConfig *types.BuildConfig
+
+	if appConf.Build.Builder != "" {
+		buildConfig = &types.BuildConfig{
+			Builder:    appConf.Build.Builder,
+			Buildpacks: appConf.Build.Buildpacks,
+		}
+	}
+
+	err = updateAgent.Build(buildConfig)
 
 	if err != nil {
 		return nil, err

+ 1 - 1
cli/cmd/deploy.go

@@ -476,7 +476,7 @@ func updateBuildWithAgent(updateAgent *deploy.DeployAgent) error {
 		return err
 	}
 
-	if err := updateAgent.Build(); err != nil {
+	if err := updateAgent.Build(nil); err != nil {
 		if stream {
 			updateAgent.StreamEvent(types.SubEvent{
 				EventID: "build",

+ 8 - 2
cli/cmd/deploy/deploy.go

@@ -216,7 +216,7 @@ func (d *DeployAgent) WriteBuildEnv(fileDest string) error {
 
 // Build uses the deploy agent options to build a new container image from either
 // buildpack or docker.
-func (d *DeployAgent) Build() error {
+func (d *DeployAgent) Build(overrideBuildConfig *types.BuildConfig) error {
 	// if build is not local, fetch remote source
 	var basePath string
 	buildCtx := d.opts.LocalPath
@@ -301,7 +301,13 @@ func (d *DeployAgent) Build() error {
 		)
 	}
 
-	return buildAgent.BuildPack(d.agent, buildCtx, d.tag, currTag, d.release.BuildConfig)
+	buildConfig := d.release.BuildConfig
+
+	if overrideBuildConfig != nil {
+		buildConfig = overrideBuildConfig
+	}
+
+	return buildAgent.BuildPack(d.agent, buildCtx, d.tag, currTag, buildConfig)
 }
 
 // Push pushes a local image to the remote repository linked in the release