Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add secrets property to build section #236

Merged
merged 2 commits into from
Apr 11, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions loader/full-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ services:
- foo
- bar
labels: [FOO=BAR]
secrets:
- secret1
- source: secret2
target: my_secret
uid: '103'
gid: '103'
mode: 0440


cap_add:
Expand Down
33 changes: 32 additions & 1 deletion loader/full-struct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
Network: "foo",
CacheFrom: []string{"foo", "bar"},
Labels: map[string]string{"FOO": "BAR"},
Secrets: []types.ServiceSecretConfig{
{
Source: "secret1",
},
{
Source: "secret2",
Target: "my_secret",
UID: "103",
GID: "103",
Mode: uint32Ptr(0440),
},
},
},
CapAdd: []string{"ALL"},
CapDrop: []string{"NET_ADMIN", "SYS_ADMIN"},
Expand Down Expand Up @@ -579,6 +591,13 @@ services:
- bar
network: foo
target: foo
secrets:
- source: secret1
- source: secret2
target: my_secret
uid: "103"
gid: "103"
mode: 288
cap_add:
- ALL
cap_drop:
Expand Down Expand Up @@ -1096,7 +1115,19 @@ func fullExampleJSON(workingDir, homeDir string) string {
"bar"
],
"network": "foo",
"target": "foo"
"target": "foo",
"secrets": [
{
"source": "secret1"
},
{
"source": "secret2",
"target": "my_secret",
"uid": "103",
"gid": "103",
"mode": 288
}
]
},
"cap_add": [
"ALL"
Expand Down
66 changes: 25 additions & 41 deletions schema/compose-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
"target": {"type": "string"},
"shm_size": {"type": ["integer", "string"]},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"isolation": {"type": "string"}
"isolation": {"type": "string"},
"secrets": {"$ref": "#/definitions/service_config_or_secret"}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
Expand Down Expand Up @@ -142,26 +143,7 @@
{"type": "array", "items": {"type": "string"}}
]
},
"configs": {
"type": "array",
"items": {
"oneOf": [
{"type": "string"},
{
"type": "object",
"properties": {
"source": {"type": "string"},
"target": {"type": "string"},
"uid": {"type": "string"},
"gid": {"type": "string"},
"mode": {"type": "number"}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
]
}
},
"configs": {"$ref": "#/definitions/service_config_or_secret"},
"container_name": {"type": "string"},
"cpu_count": {"type": "integer", "minimum": 0},
"cpu_percent": {"type": "integer", "minimum": 0, "maximum": 100},
Expand Down Expand Up @@ -350,26 +332,7 @@
},
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"shm_size": {"type": ["number", "string"]},
"secrets": {
"type": "array",
"items": {
"oneOf": [
{"type": "string"},
{
"type": "object",
"properties": {
"source": {"type": "string"},
"target": {"type": "string"},
"uid": {"type": "string"},
"gid": {"type": "string"},
"mode": {"type": "number"}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
]
}
},
"secrets": {"$ref": "#/definitions/service_config_or_secret"},
"sysctls": {"$ref": "#/definitions/list_or_dict"},
"stdin_open": {"type": "boolean"},
"stop_grace_period": {"type": "string", "format": "duration"},
Expand Down Expand Up @@ -807,6 +770,27 @@
"additionalProperties": false
},

"service_config_or_secret": {
"type": "array",
"items": {
"oneOf": [
{"type": "string"},
{
"type": "object",
"properties": {
"source": {"type": "string"},
"target": {"type": "string"},
"uid": {"type": "string"},
"gid": {"type": "string"},
"mode": {"type": "number"}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
]
}
},

"constraints": {
"service": {
"id": "#/definitions/constraints/service",
Expand Down
1 change: 1 addition & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ type BuildConfig struct {
Isolation string `yaml:",omitempty" json:"isolation,omitempty"`
Network string `yaml:",omitempty" json:"network,omitempty"`
Target string `yaml:",omitempty" json:"target,omitempty"`
Secrets []ServiceSecretConfig `yaml:",omitempty" json:"secrets,omitempty"`

Extensions map[string]interface{} `yaml:",inline" json:"-"`
}
Expand Down