Skip to content

Commit f0a7498

Browse files
authored
Merge pull request #451 from docker/ignore-bind-mounts
Prevent bind mounts from being interpreted as volume object references
2 parents 9c4d28a + 473b9b2 commit f0a7498

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
All notable changes to the Docker Language Server will be documented in this file.
44

5+
## [Unreleased]
6+
7+
### Fixed
8+
9+
- Compose
10+
- textDocument/documentHighlight
11+
- prevent file and folder bind mounts from returning results as they are not valid volume object references ([#450](https://github.com/docker/docker-language-server/issues/450))
12+
- textDocument/prepareRename
13+
- prevent file and folder bind mounts from returning results as they are not valid volume object references ([#450](https://github.com/docker/docker-language-server/issues/450))
14+
- textDocument/rename
15+
- prevent file and folder bind mounts from returning results as they are not valid volume object references ([#450](https://github.com/docker/docker-language-server/issues/450))
16+
517
## [0.17.0] - 2025-08-21
618

719
### Added

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.25.0
55
require (
66
github.com/bep/debounce v1.2.1
77
github.com/bugsnag/bugsnag-go v2.5.1+incompatible
8+
github.com/compose-spec/compose-go/v2 v2.8.1
89
github.com/docker/buildx v0.26.1
910
github.com/dromara/carbon/v2 v2.6.11
1011
github.com/go-git/go-git/v5 v5.14.0
@@ -47,7 +48,6 @@ require (
4748
github.com/bugsnag/panicwrap v1.3.4 // indirect
4849
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
4950
github.com/cloudflare/circl v1.6.0 // indirect
50-
github.com/compose-spec/compose-go/v2 v2.7.2-0.20250703132301-891fce532a51 // indirect
5151
github.com/containerd/console v1.0.5 // indirect
5252
github.com/containerd/containerd/api v1.9.0 // indirect
5353
github.com/containerd/containerd/v2 v2.1.3 // indirect
@@ -149,6 +149,7 @@ require (
149149
go.opentelemetry.io/otel/sdk/metric v1.35.0 // indirect
150150
go.opentelemetry.io/otel/trace v1.35.0 // indirect
151151
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
152+
go.yaml.in/yaml/v3 v3.0.4 // indirect
152153
golang.org/x/crypto v0.37.0 // indirect
153154
golang.org/x/mod v0.24.0 // indirect
154155
golang.org/x/net v0.39.0 // indirect

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ github.com/cloudflare/circl v1.6.0 h1:cr5JKic4HI+LkINy2lg3W2jF8sHCVTBncJr5gIIq7q
6969
github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
7070
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE=
7171
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb/go.mod h1:ZjrT6AXHbDs86ZSdt/osfBi5qfexBrKUdONk989Wnk4=
72-
github.com/compose-spec/compose-go/v2 v2.7.2-0.20250703132301-891fce532a51 h1:AjI75N9METifYMZK7eNt8XIgY9Sryv+1w3XDA7X2vZQ=
73-
github.com/compose-spec/compose-go/v2 v2.7.2-0.20250703132301-891fce532a51/go.mod h1:Zow/3eYNOnl2T4qLGZEizf8d/ht1qfy09G7WGOSzGOY=
72+
github.com/compose-spec/compose-go/v2 v2.8.1 h1:27O4dzyhiS/UEUKp1zHOHCBWD1WbxGsYGMNNaSejTk4=
73+
github.com/compose-spec/compose-go/v2 v2.8.1/go.mod h1:veko/VB7URrg/tKz3vmIAQDaz+CGiXH8vZsW79NmAww=
7474
github.com/containerd/cgroups/v3 v3.0.5 h1:44na7Ud+VwyE7LIoJ8JTNQOa549a8543BmzaJHo6Bzo=
7575
github.com/containerd/cgroups/v3 v3.0.5/go.mod h1:SA5DLYnXO8pTGYiAHXz94qvLQTKfVM5GEVisn4jpins=
7676
github.com/containerd/console v1.0.5 h1:R0ymNeydRqH2DmakFNdmjR2k0t7UPuiOV/N/27/qqsc=
@@ -392,6 +392,8 @@ go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU
392392
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
393393
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
394394
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
395+
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
396+
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
395397
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
396398
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
397399
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=

internal/compose/documentHighlight.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package compose
33
import (
44
"strings"
55

6+
"github.com/compose-spec/compose-go/v2/format"
7+
"github.com/compose-spec/compose-go/v2/types"
68
"github.com/docker/docker-language-server/internal/pkg/document"
79
"github.com/docker/docker-language-server/internal/tliron/glsp/protocol"
810
"github.com/goccy/go-yaml/ast"
@@ -100,7 +102,11 @@ func volumeReferences(servicesNode *ast.MappingNode) []*token.Token {
100102
}
101103
}
102104
} else {
103-
tokens = append(tokens, volumeToken(volumeNode.GetToken()))
105+
token := volumeNode.GetToken()
106+
volumeConfig, err := format.ParseVolume(token.Value)
107+
if err == nil && volumeConfig.Type == types.VolumeTypeVolume {
108+
tokens = append(tokens, volumeToken(token))
109+
}
104110
}
105111
}
106112
} else if mappingNode, ok := volumesValue.(*ast.MappingNode); ok {

internal/compose/documentHighlight_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,6 +2796,23 @@ services:
27962796
End: protocol.Position{Line: 4, Character: 14},
27972797
},
27982798
},
2799+
{
2800+
name: "read highlight on a volume's string array item with a bind mount",
2801+
content: `
2802+
services:
2803+
test:
2804+
volumes:
2805+
- ./folder:/mount/path`,
2806+
line: 4,
2807+
character: 14,
2808+
locations: func(u protocol.DocumentUri) any { return nil },
2809+
links: func(u protocol.DocumentUri) any { return nil },
2810+
ranges: nil,
2811+
renameEdits: func(u protocol.DocumentUri) *protocol.WorkspaceEdit {
2812+
return nil
2813+
},
2814+
prepareRename: nil,
2815+
},
27992816
{
28002817
name: "read highlight on an undefined volume array item's mount path",
28012818
content: `

0 commit comments

Comments
 (0)