Skip to content

Commit ef73f5a

Browse files
authored
Merge pull request #236 from glours/add-secrets-build
2 parents 4975f3f + c3a57cf commit ef73f5a

File tree

4 files changed

+65
-42
lines changed

4 files changed

+65
-42
lines changed

loader/full-example.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ services:
1515
- foo
1616
- bar
1717
labels: [FOO=BAR]
18+
secrets:
19+
- secret1
20+
- source: secret2
21+
target: my_secret
22+
uid: '103'
23+
gid: '103'
24+
mode: 0440
1825

1926

2027
cap_add:

loader/full-struct_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
5858
Network: "foo",
5959
CacheFrom: []string{"foo", "bar"},
6060
Labels: map[string]string{"FOO": "BAR"},
61+
Secrets: []types.ServiceSecretConfig{
62+
{
63+
Source: "secret1",
64+
},
65+
{
66+
Source: "secret2",
67+
Target: "my_secret",
68+
UID: "103",
69+
GID: "103",
70+
Mode: uint32Ptr(0440),
71+
},
72+
},
6173
},
6274
CapAdd: []string{"ALL"},
6375
CapDrop: []string{"NET_ADMIN", "SYS_ADMIN"},
@@ -579,6 +591,13 @@ services:
579591
- bar
580592
network: foo
581593
target: foo
594+
secrets:
595+
- source: secret1
596+
- source: secret2
597+
target: my_secret
598+
uid: "103"
599+
gid: "103"
600+
mode: 288
582601
cap_add:
583602
- ALL
584603
cap_drop:
@@ -1096,7 +1115,19 @@ func fullExampleJSON(workingDir, homeDir string) string {
10961115
"bar"
10971116
],
10981117
"network": "foo",
1099-
"target": "foo"
1118+
"target": "foo",
1119+
"secrets": [
1120+
{
1121+
"source": "secret1"
1122+
},
1123+
{
1124+
"source": "secret2",
1125+
"target": "my_secret",
1126+
"uid": "103",
1127+
"gid": "103",
1128+
"mode": 288
1129+
}
1130+
]
11001131
},
11011132
"cap_add": [
11021133
"ALL"

schema/compose-spec.json

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
"target": {"type": "string"},
102102
"shm_size": {"type": ["integer", "string"]},
103103
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
104-
"isolation": {"type": "string"}
104+
"isolation": {"type": "string"},
105+
"secrets": {"$ref": "#/definitions/service_config_or_secret"}
105106
},
106107
"additionalProperties": false,
107108
"patternProperties": {"^x-": {}}
@@ -144,26 +145,7 @@
144145
{"type": "array", "items": {"type": "string"}}
145146
]
146147
},
147-
"configs": {
148-
"type": "array",
149-
"items": {
150-
"oneOf": [
151-
{"type": "string"},
152-
{
153-
"type": "object",
154-
"properties": {
155-
"source": {"type": "string"},
156-
"target": {"type": "string"},
157-
"uid": {"type": "string"},
158-
"gid": {"type": "string"},
159-
"mode": {"type": "number"}
160-
},
161-
"additionalProperties": false,
162-
"patternProperties": {"^x-": {}}
163-
}
164-
]
165-
}
166-
},
148+
"configs": {"$ref": "#/definitions/service_config_or_secret"},
167149
"container_name": {"type": "string"},
168150
"cpu_count": {"type": "integer", "minimum": 0},
169151
"cpu_percent": {"type": "integer", "minimum": 0, "maximum": 100},
@@ -352,26 +334,7 @@
352334
},
353335
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
354336
"shm_size": {"type": ["number", "string"]},
355-
"secrets": {
356-
"type": "array",
357-
"items": {
358-
"oneOf": [
359-
{"type": "string"},
360-
{
361-
"type": "object",
362-
"properties": {
363-
"source": {"type": "string"},
364-
"target": {"type": "string"},
365-
"uid": {"type": "string"},
366-
"gid": {"type": "string"},
367-
"mode": {"type": "number"}
368-
},
369-
"additionalProperties": false,
370-
"patternProperties": {"^x-": {}}
371-
}
372-
]
373-
}
374-
},
337+
"secrets": {"$ref": "#/definitions/service_config_or_secret"},
375338
"sysctls": {"$ref": "#/definitions/list_or_dict"},
376339
"stdin_open": {"type": "boolean"},
377340
"stop_grace_period": {"type": "string", "format": "duration"},
@@ -809,6 +772,27 @@
809772
"additionalProperties": false
810773
},
811774

775+
"service_config_or_secret": {
776+
"type": "array",
777+
"items": {
778+
"oneOf": [
779+
{"type": "string"},
780+
{
781+
"type": "object",
782+
"properties": {
783+
"source": {"type": "string"},
784+
"target": {"type": "string"},
785+
"uid": {"type": "string"},
786+
"gid": {"type": "string"},
787+
"mode": {"type": "number"}
788+
},
789+
"additionalProperties": false,
790+
"patternProperties": {"^x-": {}}
791+
}
792+
]
793+
}
794+
},
795+
812796
"constraints": {
813797
"service": {
814798
"id": "#/definitions/constraints/service",

types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ type BuildConfig struct {
304304
Isolation string `yaml:",omitempty" json:"isolation,omitempty"`
305305
Network string `yaml:",omitempty" json:"network,omitempty"`
306306
Target string `yaml:",omitempty" json:"target,omitempty"`
307+
Secrets []ServiceSecretConfig `yaml:",omitempty" json:"secrets,omitempty"`
307308

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

0 commit comments

Comments
 (0)