Skip to content

Commit

Permalink
Allow build --env option to be comma separated list.
Browse files Browse the repository at this point in the history
According to help
(https://buildpacks.io/docs/tools/pack/cli/pack_build/) it should
already be this way.

Signed-off-by: Kuba Skiepko <[email protected]>
  • Loading branch information
kramarz committed Jun 18, 2021
1 parent dc17e64 commit 7acadb6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func buildCommandFlags(cmd *cobra.Command, buildFlags *BuildFlags, cfg config.Co
cmd.Flags().BoolVar(&buildFlags.ClearCache, "clear-cache", false, "Clear image's associated cache before building")
cmd.Flags().StringVarP(&buildFlags.DescriptorPath, "descriptor", "d", "", "Path to the project descriptor file")
cmd.Flags().StringVarP(&buildFlags.DefaultProcessType, "default-process", "D", "", `Set the default process type. (default "web")`)
cmd.Flags().StringArrayVarP(&buildFlags.Env, "env", "e", []string{}, "Build-time environment variable, in the form 'VAR=VALUE' or 'VAR'.\nWhen using latter value-less form, value will be taken from current\n environment at the time this command is executed.\nThis flag may be specified multiple times and will override\n individual values defined by --env-file."+multiValueHelp("env")+"\nNOTE: These are NOT available at image runtime.")
cmd.Flags().StringSliceVarP(&buildFlags.Env, "env", "e", []string{}, "Build-time environment variable, in the form 'VAR=VALUE' or 'VAR'.\nWhen using latter value-less form, value will be taken from current\n environment at the time this command is executed.\nThis flag may be specified multiple times and will override\n individual values defined by --env-file."+multiValueHelp("env")+"\nNOTE: These are NOT available at image runtime.")
cmd.Flags().StringArrayVar(&buildFlags.EnvFiles, "env-file", []string{}, "Build-time environment variables file\nOne variable per line, of the form 'VAR=VALUE' or 'VAR'\nWhen using latter value-less form, value will be taken from current\n environment at the time this command is executed\nNOTE: These are NOT available at image runtime.\"")
cmd.Flags().StringVar(&buildFlags.Network, "network", "", "Connect detect and build containers to network")
cmd.Flags().BoolVar(&buildFlags.Publish, "publish", false, "Publish to registry")
Expand Down
14 changes: 14 additions & 0 deletions internal/commands/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,20 @@ func testBuildCommand(t *testing.T, when spec.G, it spec.S) {
})
})

when("env vars are passed as coma separated flag", func() {
it("sets flag variables", func() {
mockClient.EXPECT().
Build(gomock.Any(), EqBuildOptionsWithEnv(map[string]string{
"KEY1": "VALUE1",
"KEY2": "VALUE2",
})).
Return(nil)

command.SetArgs([]string{"image", "--builder", "my-builder", "--env", "KEY1=VALUE1,KEY2=VALUE2"})
h.AssertNil(t, command.Execute())
})
})

when("env vars are passed as flags", func() {
var (
tmpVar = "tmpVar"
Expand Down

0 comments on commit 7acadb6

Please sign in to comment.