Browse code

Export BuildArgs

Signed-off-by: Priya Wadhwa <priyawadhwa@google.com>

Priya Wadhwa authored on 2018/05/08 02:49:13
Showing 7 changed files
... ...
@@ -21,8 +21,8 @@ var builtinAllowedBuildArgs = map[string]bool{
21 21
 	"no_proxy":    true,
22 22
 }
23 23
 
24
-// buildArgs manages arguments used by the builder
25
-type buildArgs struct {
24
+// BuildArgs manages arguments used by the builder
25
+type BuildArgs struct {
26 26
 	// args that are allowed for expansion/substitution and passing to commands in 'run'.
27 27
 	allowedBuildArgs map[string]*string
28 28
 	// args defined before the first `FROM` in a Dockerfile
... ...
@@ -33,8 +33,9 @@ type buildArgs struct {
33 33
 	argsFromOptions map[string]*string
34 34
 }
35 35
 
36
-func newBuildArgs(argsFromOptions map[string]*string) *buildArgs {
37
-	return &buildArgs{
36
+// NewBuildArgs creates a new BuildArgs type
37
+func NewBuildArgs(argsFromOptions map[string]*string) *BuildArgs {
38
+	return &BuildArgs{
38 39
 		allowedBuildArgs: make(map[string]*string),
39 40
 		allowedMetaArgs:  make(map[string]*string),
40 41
 		referencedArgs:   make(map[string]struct{}),
... ...
@@ -42,8 +43,9 @@ func newBuildArgs(argsFromOptions map[string]*string) *buildArgs {
42 42
 	}
43 43
 }
44 44
 
45
-func (b *buildArgs) Clone() *buildArgs {
46
-	result := newBuildArgs(b.argsFromOptions)
45
+// Clone returns a copy of the BuildArgs type
46
+func (b *BuildArgs) Clone() *BuildArgs {
47
+	result := NewBuildArgs(b.argsFromOptions)
47 48
 	for k, v := range b.allowedBuildArgs {
48 49
 		result.allowedBuildArgs[k] = v
49 50
 	}
... ...
@@ -56,7 +58,9 @@ func (b *buildArgs) Clone() *buildArgs {
56 56
 	return result
57 57
 }
58 58
 
59
-func (b *buildArgs) MergeReferencedArgs(other *buildArgs) {
59
+// MergeReferencedArgs merges referenced args from another BuildArgs
60
+// object into the current one
61
+func (b *BuildArgs) MergeReferencedArgs(other *BuildArgs) {
60 62
 	for k := range other.referencedArgs {
61 63
 		b.referencedArgs[k] = struct{}{}
62 64
 	}
... ...
@@ -64,7 +68,7 @@ func (b *buildArgs) MergeReferencedArgs(other *buildArgs) {
64 64
 
65 65
 // WarnOnUnusedBuildArgs checks if there are any leftover build-args that were
66 66
 // passed but not consumed during build. Print a warning, if there are any.
67
-func (b *buildArgs) WarnOnUnusedBuildArgs(out io.Writer) {
67
+func (b *BuildArgs) WarnOnUnusedBuildArgs(out io.Writer) {
68 68
 	leftoverArgs := []string{}
69 69
 	for arg := range b.argsFromOptions {
70 70
 		_, isReferenced := b.referencedArgs[arg]
... ...
@@ -80,17 +84,17 @@ func (b *buildArgs) WarnOnUnusedBuildArgs(out io.Writer) {
80 80
 
81 81
 // ResetAllowed clears the list of args that are allowed to be used by a
82 82
 // directive
83
-func (b *buildArgs) ResetAllowed() {
83
+func (b *BuildArgs) ResetAllowed() {
84 84
 	b.allowedBuildArgs = make(map[string]*string)
85 85
 }
86 86
 
87 87
 // AddMetaArg adds a new meta arg that can be used by FROM directives
88
-func (b *buildArgs) AddMetaArg(key string, value *string) {
88
+func (b *BuildArgs) AddMetaArg(key string, value *string) {
89 89
 	b.allowedMetaArgs[key] = value
90 90
 }
91 91
 
92 92
 // AddArg adds a new arg that can be used by directives
93
-func (b *buildArgs) AddArg(key string, value *string) {
93
+func (b *BuildArgs) AddArg(key string, value *string) {
94 94
 	b.allowedBuildArgs[key] = value
95 95
 	b.referencedArgs[key] = struct{}{}
96 96
 }
... ...
@@ -98,23 +102,23 @@ func (b *buildArgs) AddArg(key string, value *string) {
98 98
 // IsReferencedOrNotBuiltin checks if the key is a built-in arg, or if it has been
99 99
 // referenced by the Dockerfile. Returns true if the arg is not a builtin or
100 100
 // if the builtin has been referenced in the Dockerfile.
101
-func (b *buildArgs) IsReferencedOrNotBuiltin(key string) bool {
101
+func (b *BuildArgs) IsReferencedOrNotBuiltin(key string) bool {
102 102
 	_, isBuiltin := builtinAllowedBuildArgs[key]
103 103
 	_, isAllowed := b.allowedBuildArgs[key]
104 104
 	return isAllowed || !isBuiltin
105 105
 }
106 106
 
107 107
 // GetAllAllowed returns a mapping with all the allowed args
108
-func (b *buildArgs) GetAllAllowed() map[string]string {
108
+func (b *BuildArgs) GetAllAllowed() map[string]string {
109 109
 	return b.getAllFromMapping(b.allowedBuildArgs)
110 110
 }
111 111
 
112 112
 // GetAllMeta returns a mapping with all the meta meta args
113
-func (b *buildArgs) GetAllMeta() map[string]string {
113
+func (b *BuildArgs) GetAllMeta() map[string]string {
114 114
 	return b.getAllFromMapping(b.allowedMetaArgs)
115 115
 }
116 116
 
117
-func (b *buildArgs) getAllFromMapping(source map[string]*string) map[string]string {
117
+func (b *BuildArgs) getAllFromMapping(source map[string]*string) map[string]string {
118 118
 	m := make(map[string]string)
119 119
 
120 120
 	keys := keysFromMaps(source, builtinAllowedBuildArgs)
... ...
@@ -128,7 +132,7 @@ func (b *buildArgs) getAllFromMapping(source map[string]*string) map[string]stri
128 128
 }
129 129
 
130 130
 // FilterAllowed returns all allowed args without the filtered args
131
-func (b *buildArgs) FilterAllowed(filter []string) []string {
131
+func (b *BuildArgs) FilterAllowed(filter []string) []string {
132 132
 	envs := []string{}
133 133
 	configEnv := opts.ConvertKVStringsToMap(filter)
134 134
 
... ...
@@ -140,7 +144,7 @@ func (b *buildArgs) FilterAllowed(filter []string) []string {
140 140
 	return envs
141 141
 }
142 142
 
143
-func (b *buildArgs) getBuildArg(key string, mapping map[string]*string) (string, bool) {
143
+func (b *BuildArgs) getBuildArg(key string, mapping map[string]*string) (string, bool) {
144 144
 	defaultValue, exists := mapping[key]
145 145
 	// Return override from options if one is defined
146 146
 	if v, ok := b.argsFromOptions[key]; ok && v != nil {
... ...
@@ -14,7 +14,7 @@ func strPtr(source string) *string {
14 14
 }
15 15
 
16 16
 func TestGetAllAllowed(t *testing.T) {
17
-	buildArgs := newBuildArgs(map[string]*string{
17
+	buildArgs := NewBuildArgs(map[string]*string{
18 18
 		"ArgNotUsedInDockerfile":              strPtr("fromopt1"),
19 19
 		"ArgOverriddenByOptions":              strPtr("fromopt2"),
20 20
 		"ArgNoDefaultInDockerfileFromOptions": strPtr("fromopt3"),
... ...
@@ -45,7 +45,7 @@ func TestGetAllAllowed(t *testing.T) {
45 45
 }
46 46
 
47 47
 func TestGetAllMeta(t *testing.T) {
48
-	buildArgs := newBuildArgs(map[string]*string{
48
+	buildArgs := NewBuildArgs(map[string]*string{
49 49
 		"ArgNotUsedInDockerfile":        strPtr("fromopt1"),
50 50
 		"ArgOverriddenByOptions":        strPtr("fromopt2"),
51 51
 		"ArgNoDefaultInMetaFromOptions": strPtr("fromopt3"),
... ...
@@ -67,7 +67,7 @@ func TestGetAllMeta(t *testing.T) {
67 67
 }
68 68
 
69 69
 func TestWarnOnUnusedBuildArgs(t *testing.T) {
70
-	buildArgs := newBuildArgs(map[string]*string{
70
+	buildArgs := NewBuildArgs(map[string]*string{
71 71
 		"ThisArgIsUsed":    strPtr("fromopt1"),
72 72
 		"ThisArgIsNotUsed": strPtr("fromopt2"),
73 73
 		"HTTPS_PROXY":      strPtr("referenced builtin"),
... ...
@@ -86,7 +86,7 @@ func TestWarnOnUnusedBuildArgs(t *testing.T) {
86 86
 }
87 87
 
88 88
 func TestIsUnreferencedBuiltin(t *testing.T) {
89
-	buildArgs := newBuildArgs(map[string]*string{
89
+	buildArgs := NewBuildArgs(map[string]*string{
90 90
 		"ThisArgIsUsed":    strPtr("fromopt1"),
91 91
 		"ThisArgIsNotUsed": strPtr("fromopt2"),
92 92
 		"HTTPS_PROXY":      strPtr("referenced builtin"),
... ...
@@ -250,7 +250,7 @@ func emitImageID(aux *streamformatter.AuxFormatter, state *dispatchState) error
250 250
 	return aux.Emit(types.BuildResult{ID: state.imageID})
251 251
 }
252 252
 
253
-func processMetaArg(meta instructions.ArgCommand, shlex *shell.Lex, args *buildArgs) error {
253
+func processMetaArg(meta instructions.ArgCommand, shlex *shell.Lex, args *BuildArgs) error {
254 254
 	// shell.Lex currently only support the concatenated string format
255 255
 	envs := convertMapToEnvList(args.GetAllAllowed())
256 256
 	if err := meta.Expand(func(word string) (string, error) {
... ...
@@ -271,7 +271,7 @@ func printCommand(out io.Writer, currentCommandIndex int, totalCommands int, cmd
271 271
 
272 272
 func (b *Builder) dispatchDockerfileWithCancellation(parseResult []instructions.Stage, metaArgs []instructions.ArgCommand, escapeToken rune, source builder.Source) (*dispatchState, error) {
273 273
 	dispatchRequest := dispatchRequest{}
274
-	buildArgs := newBuildArgs(b.options.BuildArgs)
274
+	buildArgs := NewBuildArgs(b.options.BuildArgs)
275 275
 	totalCommands := len(metaArgs) + len(parseResult)
276 276
 	currentCommandIndex := 1
277 277
 	for _, stage := range parseResult {
... ...
@@ -388,7 +388,7 @@ func BuildFromConfig(config *container.Config, changes []string, os string) (*co
388 388
 		commands = append(commands, cmd)
389 389
 	}
390 390
 
391
-	dispatchRequest := newDispatchRequest(b, dockerfile.EscapeToken, nil, newBuildArgs(b.options.BuildArgs), newStagesBuildResults())
391
+	dispatchRequest := newDispatchRequest(b, dockerfile.EscapeToken, nil, NewBuildArgs(b.options.BuildArgs), newStagesBuildResults())
392 392
 	// We make mutations to the configuration, ensure we have a copy
393 393
 	dispatchRequest.state.runConfig = copyRunConfig(config)
394 394
 	dispatchRequest.state.imageID = config.Image
... ...
@@ -399,7 +399,7 @@ func dispatchRun(d dispatchRequest, c *instructions.RunCommand) error {
399 399
 // remove any unreferenced built-in args from the environment variables.
400 400
 // These args are transparent so resulting image should be the same regardless
401 401
 // of the value.
402
-func prependEnvOnCmd(buildArgs *buildArgs, buildArgVars []string, cmd strslice.StrSlice) strslice.StrSlice {
402
+func prependEnvOnCmd(buildArgs *BuildArgs, buildArgVars []string, cmd strslice.StrSlice) strslice.StrSlice {
403 403
 	var tmpBuildEnv []string
404 404
 	for _, env := range buildArgVars {
405 405
 		key := strings.SplitN(env, "=", 2)[0]
... ...
@@ -41,7 +41,7 @@ func newBuilderWithMockBackend() *Builder {
41 41
 
42 42
 func TestEnv2Variables(t *testing.T) {
43 43
 	b := newBuilderWithMockBackend()
44
-	sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
44
+	sb := newDispatchRequest(b, '\\', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
45 45
 	envCommand := &instructions.EnvCommand{
46 46
 		Env: instructions.KeyValuePairs{
47 47
 			instructions.KeyValuePair{Key: "var1", Value: "val1"},
... ...
@@ -60,7 +60,7 @@ func TestEnv2Variables(t *testing.T) {
60 60
 
61 61
 func TestEnvValueWithExistingRunConfigEnv(t *testing.T) {
62 62
 	b := newBuilderWithMockBackend()
63
-	sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
63
+	sb := newDispatchRequest(b, '\\', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
64 64
 	sb.state.runConfig.Env = []string{"var1=old", "var2=fromenv"}
65 65
 	envCommand := &instructions.EnvCommand{
66 66
 		Env: instructions.KeyValuePairs{
... ...
@@ -79,7 +79,7 @@ func TestEnvValueWithExistingRunConfigEnv(t *testing.T) {
79 79
 func TestMaintainer(t *testing.T) {
80 80
 	maintainerEntry := "Some Maintainer <maintainer@example.com>"
81 81
 	b := newBuilderWithMockBackend()
82
-	sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
82
+	sb := newDispatchRequest(b, '\\', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
83 83
 	cmd := &instructions.MaintainerCommand{Maintainer: maintainerEntry}
84 84
 	err := dispatch(sb, cmd)
85 85
 	assert.NilError(t, err)
... ...
@@ -91,7 +91,7 @@ func TestLabel(t *testing.T) {
91 91
 	labelValue := "value"
92 92
 
93 93
 	b := newBuilderWithMockBackend()
94
-	sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
94
+	sb := newDispatchRequest(b, '\\', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
95 95
 	cmd := &instructions.LabelCommand{
96 96
 		Labels: instructions.KeyValuePairs{
97 97
 			instructions.KeyValuePair{Key: labelName, Value: labelValue},
... ...
@@ -106,7 +106,7 @@ func TestLabel(t *testing.T) {
106 106
 
107 107
 func TestFromScratch(t *testing.T) {
108 108
 	b := newBuilderWithMockBackend()
109
-	sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
109
+	sb := newDispatchRequest(b, '\\', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
110 110
 	cmd := &instructions.Stage{
111 111
 		BaseName: "scratch",
112 112
 	}
... ...
@@ -133,7 +133,7 @@ func TestFromWithArg(t *testing.T) {
133 133
 	}
134 134
 	b := newBuilderWithMockBackend()
135 135
 	b.docker.(*MockBackend).getImageFunc = getImage
136
-	args := newBuildArgs(make(map[string]*string))
136
+	args := NewBuildArgs(make(map[string]*string))
137 137
 
138 138
 	val := "sometag"
139 139
 	metaArg := instructions.ArgCommand{
... ...
@@ -165,7 +165,7 @@ func TestFromWithUndefinedArg(t *testing.T) {
165 165
 	}
166 166
 	b := newBuilderWithMockBackend()
167 167
 	b.docker.(*MockBackend).getImageFunc = getImage
168
-	sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
168
+	sb := newDispatchRequest(b, '\\', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
169 169
 
170 170
 	b.options.BuildArgs = map[string]*string{"THETAG": &tag}
171 171
 
... ...
@@ -182,8 +182,8 @@ func TestFromMultiStageWithNamedStage(t *testing.T) {
182 182
 	firstFrom := &instructions.Stage{BaseName: "someimg", Name: "base"}
183 183
 	secondFrom := &instructions.Stage{BaseName: "base"}
184 184
 	previousResults := newStagesBuildResults()
185
-	firstSB := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), previousResults)
186
-	secondSB := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), previousResults)
185
+	firstSB := newDispatchRequest(b, '\\', nil, NewBuildArgs(make(map[string]*string)), previousResults)
186
+	secondSB := newDispatchRequest(b, '\\', nil, NewBuildArgs(make(map[string]*string)), previousResults)
187 187
 	err := initializeStage(firstSB, firstFrom)
188 188
 	assert.NilError(t, err)
189 189
 	assert.Check(t, firstSB.state.hasFromImage())
... ...
@@ -196,7 +196,7 @@ func TestFromMultiStageWithNamedStage(t *testing.T) {
196 196
 
197 197
 func TestOnbuild(t *testing.T) {
198 198
 	b := newBuilderWithMockBackend()
199
-	sb := newDispatchRequest(b, '\\', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
199
+	sb := newDispatchRequest(b, '\\', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
200 200
 	cmd := &instructions.OnbuildCommand{
201 201
 		Expression: "ADD . /app/src",
202 202
 	}
... ...
@@ -207,7 +207,7 @@ func TestOnbuild(t *testing.T) {
207 207
 
208 208
 func TestWorkdir(t *testing.T) {
209 209
 	b := newBuilderWithMockBackend()
210
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
210
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
211 211
 	sb.state.baseImage = &mockImage{}
212 212
 	workingDir := "/app"
213 213
 	if runtime.GOOS == "windows" {
... ...
@@ -224,7 +224,7 @@ func TestWorkdir(t *testing.T) {
224 224
 
225 225
 func TestCmd(t *testing.T) {
226 226
 	b := newBuilderWithMockBackend()
227
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
227
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
228 228
 	sb.state.baseImage = &mockImage{}
229 229
 	command := "./executable"
230 230
 
... ...
@@ -250,7 +250,7 @@ func TestCmd(t *testing.T) {
250 250
 
251 251
 func TestHealthcheckNone(t *testing.T) {
252 252
 	b := newBuilderWithMockBackend()
253
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
253
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
254 254
 	cmd := &instructions.HealthCheckCommand{
255 255
 		Health: &container.HealthConfig{
256 256
 			Test: []string{"NONE"},
... ...
@@ -266,7 +266,7 @@ func TestHealthcheckNone(t *testing.T) {
266 266
 func TestHealthcheckCmd(t *testing.T) {
267 267
 
268 268
 	b := newBuilderWithMockBackend()
269
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
269
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
270 270
 	expectedTest := []string{"CMD-SHELL", "curl -f http://localhost/ || exit 1"}
271 271
 	cmd := &instructions.HealthCheckCommand{
272 272
 		Health: &container.HealthConfig{
... ...
@@ -282,7 +282,7 @@ func TestHealthcheckCmd(t *testing.T) {
282 282
 
283 283
 func TestEntrypoint(t *testing.T) {
284 284
 	b := newBuilderWithMockBackend()
285
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
285
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
286 286
 	sb.state.baseImage = &mockImage{}
287 287
 	entrypointCmd := "/usr/sbin/nginx"
288 288
 
... ...
@@ -307,7 +307,7 @@ func TestEntrypoint(t *testing.T) {
307 307
 
308 308
 func TestExpose(t *testing.T) {
309 309
 	b := newBuilderWithMockBackend()
310
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
310
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
311 311
 
312 312
 	exposedPort := "80"
313 313
 	cmd := &instructions.ExposeCommand{
... ...
@@ -326,7 +326,7 @@ func TestExpose(t *testing.T) {
326 326
 
327 327
 func TestUser(t *testing.T) {
328 328
 	b := newBuilderWithMockBackend()
329
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
329
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
330 330
 
331 331
 	cmd := &instructions.UserCommand{
332 332
 		User: "test",
... ...
@@ -338,7 +338,7 @@ func TestUser(t *testing.T) {
338 338
 
339 339
 func TestVolume(t *testing.T) {
340 340
 	b := newBuilderWithMockBackend()
341
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
341
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
342 342
 
343 343
 	exposedVolume := "/foo"
344 344
 
... ...
@@ -358,7 +358,7 @@ func TestStopSignal(t *testing.T) {
358 358
 		return
359 359
 	}
360 360
 	b := newBuilderWithMockBackend()
361
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
361
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
362 362
 	sb.state.baseImage = &mockImage{}
363 363
 	signal := "SIGKILL"
364 364
 
... ...
@@ -372,7 +372,7 @@ func TestStopSignal(t *testing.T) {
372 372
 
373 373
 func TestArg(t *testing.T) {
374 374
 	b := newBuilderWithMockBackend()
375
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
375
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
376 376
 
377 377
 	argName := "foo"
378 378
 	argVal := "bar"
... ...
@@ -386,7 +386,7 @@ func TestArg(t *testing.T) {
386 386
 
387 387
 func TestShell(t *testing.T) {
388 388
 	b := newBuilderWithMockBackend()
389
-	sb := newDispatchRequest(b, '`', nil, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
389
+	sb := newDispatchRequest(b, '`', nil, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
390 390
 
391 391
 	shellCmd := "powershell"
392 392
 	cmd := &instructions.ShellCommand{Shell: strslice.StrSlice{shellCmd}}
... ...
@@ -399,7 +399,7 @@ func TestShell(t *testing.T) {
399 399
 }
400 400
 
401 401
 func TestPrependEnvOnCmd(t *testing.T) {
402
-	buildArgs := newBuildArgs(nil)
402
+	buildArgs := NewBuildArgs(nil)
403 403
 	buildArgs.AddArg("NO_PROXY", nil)
404 404
 
405 405
 	args := []string{"sorted=nope", "args=not", "http_proxy=foo", "NO_PROXY=YA"}
... ...
@@ -412,7 +412,7 @@ func TestPrependEnvOnCmd(t *testing.T) {
412 412
 
413 413
 func TestRunWithBuildArgs(t *testing.T) {
414 414
 	b := newBuilderWithMockBackend()
415
-	args := newBuildArgs(make(map[string]*string))
415
+	args := NewBuildArgs(make(map[string]*string))
416 416
 	args.argsFromOptions["HTTP_PROXY"] = strPtr("FOO")
417 417
 	b.disableCommit = false
418 418
 	sb := newDispatchRequest(b, '`', nil, args, newStagesBuildResults())
... ...
@@ -111,11 +111,11 @@ type dispatchState struct {
111 111
 	imageID         string
112 112
 	baseImage       builder.Image
113 113
 	stageName       string
114
-	buildArgs       *buildArgs
114
+	buildArgs       *BuildArgs
115 115
 	operatingSystem string
116 116
 }
117 117
 
118
-func newDispatchState(baseArgs *buildArgs) *dispatchState {
118
+func newDispatchState(baseArgs *BuildArgs) *dispatchState {
119 119
 	args := baseArgs.Clone()
120 120
 	args.ResetAllowed()
121 121
 	return &dispatchState{runConfig: &container.Config{}, buildArgs: args}
... ...
@@ -193,7 +193,7 @@ type dispatchRequest struct {
193 193
 	stages  *stagesBuildResults
194 194
 }
195 195
 
196
-func newDispatchRequest(builder *Builder, escapeToken rune, source builder.Source, buildArgs *buildArgs, stages *stagesBuildResults) dispatchRequest {
196
+func newDispatchRequest(builder *Builder, escapeToken rune, source builder.Source, buildArgs *BuildArgs, stages *stagesBuildResults) dispatchRequest {
197 197
 	return dispatchRequest{
198 198
 		state:   newDispatchState(buildArgs),
199 199
 		shlex:   shell.NewLex(escapeToken),
... ...
@@ -137,7 +137,7 @@ func executeTestCase(t *testing.T, testCase dispatchTestCase) {
137 137
 	}()
138 138
 
139 139
 	b := newBuilderWithMockBackend()
140
-	sb := newDispatchRequest(b, '`', context, newBuildArgs(make(map[string]*string)), newStagesBuildResults())
140
+	sb := newDispatchRequest(b, '`', context, NewBuildArgs(make(map[string]*string)), newStagesBuildResults())
141 141
 	err = dispatch(sb, testCase.cmd)
142 142
 	testutil.ErrorContains(t, err, testCase.expectedError)
143 143
 }