Skip to content
Open
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 @@ -137,6 +137,7 @@ func Service(
Labels: addStackLabel(namespace, service.Labels),
Dir: service.WorkingDir,
User: service.User,
Groups: service.GroupAdd,
Mounts: mounts,
StopGracePeriod: composetypes.ConvertDurationPtr(service.StopGracePeriod),
StopSignal: service.StopSignal,
Expand Down
9 changes: 9 additions & 0 deletions cli/compose/convert/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -716,3 +716,12 @@ func TestConvertServiceCapAddAndCapDrop(t *testing.T) {
})
}
}

func TestConvertServiceGroupAdd(t *testing.T) {
result, err := Service(Namespace{name: "foo"}, composetypes.ServiceConfig{
Image: "busybox",
GroupAdd: []string{"mail", "15000"},
}, nil, nil, nil, nil)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(result.TaskTemplate.ContainerSpec.Groups, []string{"mail", "15000"}))
}
14 changes: 14 additions & 0 deletions cli/compose/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,20 @@ func TestInvalidResource(t *testing.T) {
assert.Check(t, is.ErrorContains(err, "additional property 'impossible' is not allowed"))
}

func TestLoadGroupAdd(t *testing.T) {
config, err := loadYAML(`
version: "3.8"
services:
foo:
image: busybox
group_add:
- mail
- 15000
`)
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(config.Services[0].GroupAdd, types.StringOrNumberList{"mail", "15000"}))
}

func TestInvalidExternalAndDriverCombination(t *testing.T) {
_, err := loadYAML(`
version: "3"
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.10.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.11.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.12.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.13.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.3.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.4.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.5.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.6.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
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 @@ -155,6 +155,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.8.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
1 change: 1 addition & 0 deletions cli/compose/schema/data/config_schema_v3.9.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@

"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"group_add": {"type": "array", "items": {"type": ["string", "number"]}, "uniqueItems": true},
"healthcheck": {"$ref": "#/definitions/healthcheck"},
"hostname": {"type": "string"},
"image": {"type": "string"},
Expand Down
14 changes: 14 additions & 0 deletions cli/compose/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@ func TestValidatePorts(t *testing.T) {
}
}

func TestValidateGroupAdd(t *testing.T) {
config := dict{
"version": "3.8",
"services": dict{
"foo": dict{
"image": "busybox",
"group_add": []any{"mail", 15000, "1000"},
},
},
}
assert.NilError(t, Validate(config, "3.8"))
assert.NilError(t, Validate(config, "3"))
}

func TestValidateUndefinedTopLevelOption(t *testing.T) {
config := dict{
"version": "3.0",
Expand Down
1 change: 1 addition & 0 deletions cli/compose/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ type ServiceConfig struct {
Expose StringOrNumberList `yaml:",omitempty" json:"expose,omitempty"`
ExternalLinks []string `mapstructure:"external_links" yaml:"external_links,omitempty" json:"external_links,omitempty"`
ExtraHosts HostsList `mapstructure:"extra_hosts" yaml:"extra_hosts,omitempty" json:"extra_hosts,omitempty"`
GroupAdd StringOrNumberList `mapstructure:"group_add" yaml:"group_add,omitempty" json:"group_add,omitempty"`
Hostname string `yaml:",omitempty" json:"hostname,omitempty"`
HealthCheck *HealthCheckConfig `yaml:",omitempty" json:"healthcheck,omitempty"`
Image string `yaml:",omitempty" json:"image,omitempty"`
Expand Down
Loading