Skip to content

Commit 81db601

Browse files
committed
Update Compose schema to the latest version
The Compose schema itself has not changed but some new descriptions have been added so we should update our copy here to provide users with the latest documentation. Signed-off-by: Remy Suen <[email protected]>
1 parent a4f2ecc commit 81db601

File tree

5 files changed

+70
-41
lines changed

5 files changed

+70
-41
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to the Docker Language Server will be documented in this fil
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- updated Compose schema to the latest version ([#117](https://github.com/docker/docker-language-server/issues/117))
10+
711
### Fixed
812

913
- Compose

internal/compose/completion_test.go

+23-8
Original file line numberDiff line numberDiff line change
@@ -549,23 +549,38 @@ configs:
549549
character: 0,
550550
list: &protocol.CompletionList{
551551
Items: []protocol.CompletionItem{
552-
{Label: "configs"},
553552
{
554-
Documentation: "compose sub-projects to be included.",
553+
Label: "configs",
554+
Documentation: "Configurations for services in the project",
555+
},
556+
{
555557
Label: "include",
558+
Documentation: "compose sub-projects to be included.",
556559
},
557560
{
558-
Documentation: "define the Compose project name, until user defines one explicitly.",
559561
Label: "name",
562+
Documentation: "define the Compose project name, until user defines one explicitly.",
563+
},
564+
{
565+
Label: "networks",
566+
Documentation: "Networks that are shared among multiple services",
567+
},
568+
{
569+
Label: "secrets",
570+
Documentation: "Secrets that are shared among multiple services",
571+
},
572+
{
573+
Label: "services",
574+
Documentation: "The services in your project",
560575
},
561-
{Label: "networks"},
562-
{Label: "secrets"},
563-
{Label: "services"},
564576
{
565-
Documentation: "declared for backward compatibility, ignored.",
566577
Label: "version",
578+
Documentation: "declared for backward compatibility, ignored.",
579+
},
580+
{
581+
Label: "volumes",
582+
Documentation: "Named volumes that are shared among multiple services",
567583
},
568-
{Label: "volumes"},
569584
},
570585
},
571586
},

internal/compose/compose-spec.json

+39-28
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"$ref": "#/definitions/service"
3232
}
3333
},
34-
"additionalProperties": false
34+
"additionalProperties": false,
35+
"description": "The services in your project"
3536
},
3637

3738
"networks": {
@@ -40,7 +41,8 @@
4041
"^[a-zA-Z0-9._-]+$": {
4142
"$ref": "#/definitions/network"
4243
}
43-
}
44+
},
45+
"description": "Networks that are shared among multiple services"
4446
},
4547

4648
"volumes": {
@@ -50,7 +52,8 @@
5052
"$ref": "#/definitions/volume"
5153
}
5254
},
53-
"additionalProperties": false
55+
"additionalProperties": false,
56+
"description": "Named volumes that are shared among multiple services"
5457
},
5558

5659
"secrets": {
@@ -60,7 +63,8 @@
6063
"$ref": "#/definitions/secret"
6164
}
6265
},
63-
"additionalProperties": false
66+
"additionalProperties": false,
67+
"description": "Secrets that are shared among multiple services"
6468
},
6569

6670
"configs": {
@@ -70,7 +74,8 @@
7074
"$ref": "#/definitions/config"
7175
}
7276
},
73-
"additionalProperties": false
77+
"additionalProperties": false,
78+
"description": "Configurations for services in the project"
7479
}
7580
},
7681

@@ -93,11 +98,11 @@
9398
{
9499
"type": "object",
95100
"properties": {
96-
"context": {"type": "string"},
97-
"dockerfile": {"type": "string"},
101+
"context": {"type": "string", "description": "The context used for building the image"},
102+
"dockerfile": {"type": "string", "description": "The Dockerfile used for building the image"},
98103
"dockerfile_inline": {"type": "string"},
99104
"entitlements": {"type": "array", "items": {"type": "string"}},
100-
"args": {"$ref": "#/definitions/list_or_dict"},
105+
"args": {"$ref": "#/definitions/list_or_dict", "description": "Arguments used during the image build process"},
101106
"ssh": {"$ref": "#/definitions/list_or_dict"},
102107
"labels": {"$ref": "#/definitions/list_or_dict"},
103108
"cache_from": {"type": "array", "items": {"type": "string"}},
@@ -152,9 +157,9 @@
152157
"cap_drop": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
153158
"cgroup": {"type": "string", "enum": ["host", "private"]},
154159
"cgroup_parent": {"type": "string"},
155-
"command": {"$ref": "#/definitions/command"},
160+
"command": {"$ref": "#/definitions/command", "description": "The command that will be run in the container"},
156161
"configs": {"$ref": "#/definitions/service_config_or_secret"},
157-
"container_name": {"type": "string"},
162+
"container_name": {"type": "string", "description": "The name that will be given to the container"},
158163
"cpu_count": {"oneOf": [
159164
{"type": "string"},
160165
{"type": "integer", "minimum": 0}
@@ -206,7 +211,8 @@
206211
}
207212
}
208213
}
209-
]
214+
],
215+
"description": "Other services that this service depends on, which will be started before this one"
210216
},
211217
"device_cgroup_rules": {"$ref": "#/definitions/list_of_strings"},
212218
"devices": {
@@ -232,17 +238,18 @@
232238
"dns_opt": {"type": "array","items": {"type": "string"}, "uniqueItems": true},
233239
"dns_search": {"$ref": "#/definitions/string_or_list"},
234240
"domainname": {"type": "string"},
235-
"entrypoint": {"$ref": "#/definitions/command"},
236-
"env_file": {"$ref": "#/definitions/env_file"},
241+
"entrypoint": {"$ref": "#/definitions/command", "description": "The entrypoint to the application in the container"},
242+
"env_file": {"$ref": "#/definitions/env_file", "description": "Files containing environment variables that will be included"},
237243
"label_file": {"$ref": "#/definitions/label_file"},
238-
"environment": {"$ref": "#/definitions/list_or_dict"},
244+
"environment": {"$ref": "#/definitions/list_or_dict", "description": "Environment variables that will be included"},
239245

240246
"expose": {
241247
"type": "array",
242248
"items": {
243249
"type": ["string", "number"]
244250
},
245-
"uniqueItems": true
251+
"uniqueItems": true,
252+
"description": "Ports exposed to the other services but not to the host machine"
246253
},
247254
"extends": {
248255
"oneOf": [
@@ -283,13 +290,13 @@
283290
},
284291
"uniqueItems": true
285292
},
286-
"healthcheck": {"$ref": "#/definitions/healthcheck"},
293+
"healthcheck": {"$ref": "#/definitions/healthcheck", "description": "A command for checking if the container is healthy"},
287294
"hostname": {"type": "string"},
288-
"image": {"type": "string"},
295+
"image": {"type": "string", "description": "The image that will be pulled for the service. If `build` is specified, the built image will be given this tag."},
289296
"init": {"type": ["boolean", "string"]},
290297
"ipc": {"type": "string"},
291298
"isolation": {"type": "string"},
292-
"labels": {"$ref": "#/definitions/list_or_dict"},
299+
"labels": {"$ref": "#/definitions/list_or_dict", "description": "Labels that will be given to the container"},
293300
"links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
294301
"logging": {
295302
"type": "object",
@@ -303,7 +310,8 @@
303310
}
304311
},
305312
"additionalProperties": false,
306-
"patternProperties": {"^x-": {}}
313+
"patternProperties": {"^x-": {}},
314+
"description": "Settings for logging for this service"
307315
},
308316
"mac_address": {"type": "string"},
309317
"mem_limit": {"type": ["number", "string"]},
@@ -346,7 +354,8 @@
346354
},
347355
"additionalProperties": false
348356
}
349-
]
357+
],
358+
"description": "The service will be included in these networks, allowing it to reach other containers on the same network"
350359
},
351360
"oom_kill_disable": {"type": ["boolean", "string"]},
352361
"oom_score_adj": {"oneOf": [
@@ -378,12 +387,13 @@
378387
}
379388
]
380389
},
381-
"uniqueItems": true
390+
"uniqueItems": true,
391+
"description": "Ports that will be exposed to the host"
382392
},
383393
"post_start": {"type": "array", "items": {"$ref": "#/definitions/service_hook"}},
384394
"pre_stop": {"type": "array", "items": {"$ref": "#/definitions/service_hook"}},
385395
"privileged": {"type": ["boolean", "string"]},
386-
"profiles": {"$ref": "#/definitions/list_of_strings"},
396+
"profiles": {"$ref": "#/definitions/list_of_strings", "description": "Profiles that this service is a part of. When the profile is started, this service will be started."},
387397
"pull_policy": {"type": "string",
388398
"pattern": "always|never|build|if_not_present|missing|refresh|daily|weekly|every_([0-9]+[wdhms])+"
389399
},
@@ -398,7 +408,7 @@
398408
},
399409
"security_opt": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
400410
"shm_size": {"type": ["number", "string"]},
401-
"secrets": {"$ref": "#/definitions/service_config_or_secret"},
411+
"secrets": {"$ref": "#/definitions/service_config_or_secret", "description": "Secrets the service will have access to"},
402412
"sysctls": {"$ref": "#/definitions/list_or_dict"},
403413
"stdin_open": {"type": ["boolean", "string"]},
404414
"stop_grace_period": {"type": "string"},
@@ -407,7 +417,7 @@
407417
"tmpfs": {"$ref": "#/definitions/string_or_list"},
408418
"tty": {"type": ["boolean", "string"]},
409419
"ulimits": {"$ref": "#/definitions/ulimits"},
410-
"user": {"type": "string"},
420+
"user": {"type": "string", "description": "The username under which the app in the container will be started"},
411421
"uts": {"type": "string"},
412422
"userns_mode": {"type": "string"},
413423
"volumes": {
@@ -475,14 +485,15 @@
475485
}
476486
]
477487
},
478-
"uniqueItems": true
488+
"uniqueItems": true,
489+
"description": "Named volumes and paths on the host mapped to paths in the container"
479490
},
480491
"volumes_from": {
481492
"type": "array",
482493
"items": {"type": "string"},
483494
"uniqueItems": true
484495
},
485-
"working_dir": {"type": "string"}
496+
"working_dir": {"type": "string", "description": "The working directory in which the entrypoint or command will be run"}
486497
},
487498
"patternProperties": {"^x-": {}},
488499
"additionalProperties": false
@@ -710,7 +721,7 @@
710721
"type": ["object", "null"],
711722
"properties": {
712723
"name": {"type": "string"},
713-
"driver": {"type": "string"},
724+
"driver": {"type": "string", "description": "The driver used for this network"},
714725
"driver_opts": {
715726
"type": "object",
716727
"patternProperties": {
@@ -773,7 +784,7 @@
773784
"type": ["object", "null"],
774785
"properties": {
775786
"name": {"type": "string"},
776-
"driver": {"type": "string"},
787+
"driver": {"type": "string", "description": "The driver used for this volume"},
777788
"driver_opts": {
778789
"type": "object",
779790
"patternProperties": {

internal/compose/hover.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ func Hover(ctx context.Context, params *protocol.HoverParams, doc document.Compo
2020
lines := strings.Split(string(doc.Input()), "\n")
2121
character := int(params.Position.Character) + 1
2222
topLevel, _, _ := NodeStructure(line, root.Content[0].Content)
23-
return hoverLookup(composeSchema, topLevel, character, len(lines[params.Position.Line])+1), nil
23+
return hoverLookup(composeSchema, topLevel, line, character, len(lines[params.Position.Line])+1), nil
2424
}
2525
return nil, nil
2626
}
2727

28-
func hoverLookup(schema *jsonschema.Schema, nodes []*yaml.Node, column, lineLength int) *protocol.Hover {
28+
func hoverLookup(schema *jsonschema.Schema, nodes []*yaml.Node, line, column, lineLength int) *protocol.Hover {
2929
for _, node := range nodes {
3030
if schema.Ref != nil {
3131
schema = schema.Ref
@@ -70,7 +70,7 @@ func hoverLookup(schema *jsonschema.Schema, nodes []*yaml.Node, column, lineLeng
7070
}
7171
}
7272

73-
if node.Column+len(node.Value) >= column && property.Description != "" {
73+
if node.Line == line && node.Column+len(node.Value) >= column && property.Description != "" {
7474
return &protocol.Hover{
7575
Contents: protocol.MarkupContent{
7676
Kind: protocol.MarkupKindPlainText,

internal/compose/hover_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,7 @@ services:
289289
require.Nil(t, result.Range)
290290
markupContent, ok := result.Contents.(protocol.MarkupContent)
291291
require.True(t, ok)
292-
require.Equal(t, tc.result.Contents.(protocol.MarkupContent).Kind, markupContent.Kind)
293-
require.Equal(t, tc.result.Contents.(protocol.MarkupContent).Value, markupContent.Value)
292+
require.Equal(t, tc.result.Contents, markupContent)
294293
}
295294
})
296295
}

0 commit comments

Comments
 (0)