Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/compose/convert/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func Service(
ReadOnly: service.ReadOnly,
Privileges: &privileges,
Isolation: container.Isolation(service.Isolation),
Init: service.Init,
},
LogDriver: logDriver,
Resources: resources,
Expand Down
48 changes: 48 additions & 0 deletions cli/compose/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1415,3 +1415,51 @@ networks:
}
assert.DeepEqual(t, config, expected, cmpopts.EquateEmpty())
}

func TestLoadInit(t *testing.T) {
booleanTrue := true
booleanFalse := false

var testcases = []struct {
doc string
yaml string
init *bool
}{
{
doc: "no init defined",
yaml: `
version: '3.7'
services:
foo:
image: alpine`,
},
{
doc: "has true init",
yaml: `
version: '3.7'
services:
foo:
image: alpine
init: true`,
init: &booleanTrue,
},
{
doc: "has false init",
yaml: `
version: '3.7'
services:
foo:
image: alpine
init: false`,
init: &booleanFalse,
},
}
for _, testcase := range testcases {
t.Run(testcase.doc, func(t *testing.T) {
config, err := loadYAML(testcase.yaml)
assert.NilError(t, err)
assert.Check(t, is.Len(config.Services, 1))
assert.Check(t, is.DeepEqual(config.Services[0].Init, testcase.init))
})
}
}
44 changes: 22 additions & 22 deletions cli/compose/schema/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.7.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
"init": {"type": "boolean"},
"ipc": {"type": "string"},
"isolation": {"type": "string"},
"labels": {"$ref": "#/definitions/list_or_dict"},
Expand Down
6 changes: 4 additions & 2 deletions cli/compose/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ type ServiceConfig struct {
Hostname string `yaml:",omitempty"`
HealthCheck *HealthCheckConfig `yaml:",omitempty"`
Image string `yaml:",omitempty"`
Init *bool `yaml:",omitempty"`
Ipc string `yaml:",omitempty"`
Isolation string `mapstructure:"isolation" yaml:"isolation,omitempty"`
Labels Labels `yaml:",omitempty"`
Links []string `yaml:",omitempty"`
Logging *LoggingConfig `yaml:",omitempty"`
Expand All @@ -142,8 +144,8 @@ type ServiceConfig struct {
User string `yaml:",omitempty"`
Volumes []ServiceVolumeConfig `yaml:",omitempty"`
WorkingDir string `mapstructure:"working_dir" yaml:"working_dir,omitempty"`
Isolation string `mapstructure:"isolation" yaml:"isolation,omitempty"`
Extras map[string]interface{} `yaml:",inline"`

Extras map[string]interface{} `yaml:",inline"`
}

// BuildConfig is a type for build
Expand Down