Skip to content

Commit 5282e6c

Browse files
committed
introduce external services
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent b35ee99 commit 5282e6c

File tree

5 files changed

+216
-157
lines changed

5 files changed

+216
-157
lines changed

loader/loader_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -3760,3 +3760,20 @@ services:
37603760
assert.Equal(t, len(p.Services["test"].Secrets), 1)
37613761
assert.Equal(t, *p.Services["test"].Secrets[0].Mode, types.FileMode(0o440))
37623762
}
3763+
3764+
func TestExternalService(t *testing.T) {
3765+
p, err := loadYAML(`
3766+
name: external-service
3767+
services:
3768+
test:
3769+
external:
3770+
type: foo
3771+
options:
3772+
bar: zot
3773+
`)
3774+
assert.NilError(t, err)
3775+
assert.DeepEqual(t, p.Services["test"].External, &types.ExternalServiceConfig{
3776+
Type: "foo",
3777+
Options: map[string]string{"bar": "zot"},
3778+
})
3779+
}

loader/validate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
// checkConsistency validate a compose model is consistent
3030
func checkConsistency(project *types.Project) error { //nolint:gocyclo
3131
for name, s := range project.Services {
32-
if s.Build == nil && s.Image == "" {
32+
if s.Build == nil && s.Image == "" && s.External == nil {
3333
return fmt.Errorf("service %q has neither an image nor a build context specified: %w", s.Name, errdefs.ErrInvalid)
3434
}
3535

schema/compose-spec.json

+14-1
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,20 @@
259259
}
260260
]
261261
},
262+
"external": {
263+
"type": "object",
264+
"properties": {
265+
"type": {"type": "string"},
266+
"options": {
267+
"type": "object",
268+
"patternProperties": {
269+
"^.+$": {"type": ["string", "number", "null"]}
270+
}
271+
}
272+
},
273+
"additionalProperties": false,
274+
"patternProperties": {"^x-": {}}
275+
},
262276
"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
263277
"extra_hosts": {"$ref": "#/definitions/extra_hosts"},
264278
"gpus": {"$ref": "#/definitions/gpus"},
@@ -279,7 +293,6 @@
279293
"links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
280294
"logging": {
281295
"type": "object",
282-
283296
"properties": {
284297
"driver": {"type": "string"},
285298
"options": {

0 commit comments

Comments
 (0)