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
17 changes: 17 additions & 0 deletions loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3760,3 +3760,20 @@ services:
assert.Equal(t, len(p.Services["test"].Secrets), 1)
assert.Equal(t, *p.Services["test"].Secrets[0].Mode, types.FileMode(0o440))
}

func TestExternalService(t *testing.T) {
p, err := loadYAML(`
name: external-service
services:
test:
external:
type: foo
options:
bar: zot
`)
assert.NilError(t, err)
assert.DeepEqual(t, p.Services["test"].External, &types.ExternalServiceConfig{
Type: "foo",
Options: map[string]string{"bar": "zot"},
})
}
2 changes: 1 addition & 1 deletion loader/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
// checkConsistency validate a compose model is consistent
func checkConsistency(project *types.Project) error { //nolint:gocyclo
for name, s := range project.Services {
if s.Build == nil && s.Image == "" {
if s.Build == nil && s.Image == "" && s.External == nil {
return fmt.Errorf("service %q has neither an image nor a build context specified: %w", s.Name, errdefs.ErrInvalid)
}

Expand Down
15 changes: 14 additions & 1 deletion schema/compose-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,20 @@
}
]
},
"external": {
"type": "object",
"properties": {
"type": {"type": "string"},
"options": {
"type": "object",
"patternProperties": {
"^.+$": {"type": ["string", "number", "null"]}
}
}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
},
"external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"extra_hosts": {"$ref": "#/definitions/extra_hosts"},
"gpus": {"$ref": "#/definitions/gpus"},
Expand All @@ -279,7 +293,6 @@
"links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"logging": {
"type": "object",

"properties": {
"driver": {"type": "string"},
"options": {
Expand Down
Loading