Bläddra i källkod

make image repo uri separate for pack caching

Alexander Belanger 4 år sedan
förälder
incheckning
e4222a9b6a
3 ändrade filer med 17 tillägg och 1 borttagningar
  1. 15 0
      cli/cmd/deploy.go
  2. 1 1
      cli/cmd/deploy/build.go
  3. 1 0
      cli/cmd/deploy/shared.go

+ 15 - 0
cli/cmd/deploy.go

@@ -211,6 +211,7 @@ var stream bool
 var buildFlagsEnv []string
 var forcePush bool
 var useCache bool
+var cacheImage string
 
 func init() {
 	buildFlagsEnv = []string{}
@@ -233,6 +234,13 @@ func init() {
 		"Whether to use cache (currently in beta)",
 	)
 
+	updateCmd.PersistentFlags().StringVar(
+		&cacheImage,
+		"cache-image",
+		"",
+		"Image repo URI to use for the cache image",
+	)
+
 	updateCmd.PersistentFlags().StringVar(
 		&namespace,
 		"namespace",
@@ -461,6 +469,7 @@ func updateGetAgent(client *api.Client) (*deploy.DeployAgent, error) {
 			Method:          buildMethod,
 			AdditionalEnv:   additionalEnv,
 			UseCache:        useCache,
+			CacheImageRepo:  cacheImage,
 		},
 		Local: source != "github",
 	})
@@ -556,6 +565,12 @@ func updateBuildWithAgent(updateAgent *deploy.DeployAgent) error {
 }
 
 func updatePushWithAgent(updateAgent *deploy.DeployAgent) error {
+	if useCache && cacheImage != "" {
+		color.New(color.FgGreen).Println("Skipping image push for", app, "as use-cache is set")
+
+		return nil
+	}
+
 	// push the deployment
 	color.New(color.FgGreen).Println("Pushing new image for", app)
 

+ 1 - 1
cli/cmd/deploy/build.go

@@ -83,7 +83,7 @@ func (b *BuildAgent) BuildPack(dockerAgent *docker.Agent, dst, tag, prevTag stri
 	}
 
 	// call builder
-	return packAgent.Build(opts, buildConfig, dockerAgent, fmt.Sprintf("%s:%s", b.imageRepo, "pack-cache"))
+	return packAgent.Build(opts, buildConfig, dockerAgent, fmt.Sprintf("%s:%s", b.CacheImageRepo, "pack-cache"))
 }
 
 // ResolveDockerPaths returns a path to the dockerfile that is either relative or absolute, and a path

+ 1 - 0
cli/cmd/deploy/shared.go

@@ -20,6 +20,7 @@ type SharedOpts struct {
 	AdditionalEnv   map[string]string
 	EnvGroups       []types.EnvGroupMeta
 	UseCache        bool
+	CacheImageRepo  string
 }
 
 func coalesceEnvGroups(