Skip to content

Commit 7bd0f24

Browse files
authored
Merge pull request #391 from laurazard/fix-dockerfile-inline
schema: add `mapstructure` struct tag to `dockerfile_inline`
2 parents e4d5895 + 565417c commit 7bd0f24

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

loader/full-example.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
name: full_example_project_name
22
services:
3-
foo:
43

4+
bar:
5+
build:
6+
dockerfile_inline: |
7+
FROM alpine
8+
RUN echo "hello" > /world.txt
9+
10+
foo:
511
build:
612
context: ./dir
713
dockerfile: Dockerfile

loader/full-struct_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,14 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
432432
},
433433
WorkingDir: "/code",
434434
},
435+
{
436+
Name: "bar",
437+
Build: &types.BuildConfig{
438+
DockerfileInline: "FROM alpine\nRUN echo \"hello\" > /world.txt\n",
439+
},
440+
Environment: types.MappingWithEquals{},
441+
Scale: 1,
442+
},
435443
}
436444
}
437445

@@ -585,6 +593,11 @@ func secrets(workingDir string) map[string]types.SecretConfig {
585593
func fullExampleYAML(workingDir, homeDir string) string {
586594
return fmt.Sprintf(`name: full_example_project_name
587595
services:
596+
bar:
597+
build:
598+
dockerfile_inline: |
599+
FROM alpine
600+
RUN echo "hello" > /world.txt
588601
foo:
589602
build:
590603
context: ./dir
@@ -1124,6 +1137,13 @@ func fullExampleJSON(workingDir, homeDir string) string {
11241137
}
11251138
},
11261139
"services": {
1140+
"bar": {
1141+
"build": {
1142+
"dockerfile_inline": "FROM alpine\nRUN echo \"hello\" \u003e /world.txt\n"
1143+
},
1144+
"command": null,
1145+
"entrypoint": null
1146+
},
11271147
"foo": {
11281148
"build": {
11291149
"context": "./dir",

loader/loader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ func TestFullExample(t *testing.T) {
10081008
expectedConfig := fullExampleProject(workingDir, homeDir)
10091009

10101010
assert.Check(t, is.DeepEqual(expectedConfig.Name, config.Name))
1011-
assert.Check(t, is.DeepEqual(expectedConfig.Services, config.Services))
1011+
assert.Check(t, is.DeepEqual(serviceSort(expectedConfig.Services), serviceSort(config.Services)))
10121012
assert.Check(t, is.DeepEqual(expectedConfig.Networks, config.Networks))
10131013
assert.Check(t, is.DeepEqual(expectedConfig.Volumes, config.Volumes))
10141014
assert.Check(t, is.DeepEqual(expectedConfig.Secrets, config.Secrets))

types/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func (s set) toSlice() []string {
296296
type BuildConfig struct {
297297
Context string `yaml:",omitempty" json:"context,omitempty"`
298298
Dockerfile string `yaml:",omitempty" json:"dockerfile,omitempty"`
299-
DockerfileInline string `yaml:"dockerfile_inline,omitempty" json:"dockerfile_inline,omitempty"`
299+
DockerfileInline string `mapstructure:"dockerfile_inline,omitempty" yaml:"dockerfile_inline,omitempty" json:"dockerfile_inline,omitempty"`
300300
Args MappingWithEquals `yaml:",omitempty" json:"args,omitempty"`
301301
SSH SSHConfig `yaml:"ssh,omitempty" json:"ssh,omitempty"`
302302
Labels Labels `yaml:",omitempty" json:"labels,omitempty"`

0 commit comments

Comments
 (0)