MCPcopy Create free account
hub / github.com/docker/docker-language-server / scanForLinks

Function scanForLinks

internal/compose/documentLink.go:240–333  ·  view source on GitHub ↗
(folderAbsolutePath string, wslDollarSign bool, n *ast.MappingValueNode)

Source from the content-addressed store, hash-verified

238}
239
240func scanForLinks(folderAbsolutePath string, wslDollarSign bool, n *ast.MappingValueNode) []protocol.DocumentLink {
241 if s, ok := resolveAnchor(n.Key).(*ast.StringNode); ok {
242 links := []protocol.DocumentLink{}
243 switch s.Value {
244 case "include":
245 if sequence, ok := resolveAnchor(n.Value).(*ast.SequenceNode); ok {
246 for _, token := range includedPaths(sequence.Values) {
247 link := createLink(folderAbsolutePath, wslDollarSign, token)
248 if link != nil {
249 links = append(links, *link)
250 }
251 }
252 }
253 case "services":
254 if mappingNode, ok := resolveAnchor(n.Value).(*ast.MappingNode); ok {
255 for _, node := range mappingNode.Values {
256 if serviceAttributes, ok := resolveAnchor(node.Value).(*ast.MappingNode); ok {
257 for _, serviceAttribute := range serviceAttributes.Values {
258 link := createImageLink(serviceAttribute)
259 if link != nil {
260 links = append(links, *link)
261 }
262
263 link = createdNestedLink(folderAbsolutePath, wslDollarSign, serviceAttribute, "build", "dockerfile")
264 if link != nil {
265 links = append(links, *link)
266 }
267
268 link = createdNestedLink(folderAbsolutePath, wslDollarSign, serviceAttribute, "credential_spec", "file")
269 if link != nil {
270 links = append(links, *link)
271 }
272
273 link = createdNestedLink(folderAbsolutePath, wslDollarSign, serviceAttribute, "extends", "file")
274 if link != nil {
275 links = append(links, *link)
276 }
277
278 envFileLinks := createFileLinks(folderAbsolutePath, wslDollarSign, serviceAttribute, "env_file")
279 links = append(links, envFileLinks...)
280
281 labelFileLinks := createFileLinks(folderAbsolutePath, wslDollarSign, serviceAttribute, "label_file")
282 links = append(links, labelFileLinks...)
283
284 volumeFileLinks := createVolumeFileLinks(folderAbsolutePath, wslDollarSign, serviceAttribute)
285 links = append(links, volumeFileLinks...)
286 }
287 }
288 }
289 }
290 case "configs":
291 if mappingNode, ok := resolveAnchor(n.Value).(*ast.MappingNode); ok {
292 for _, node := range mappingNode.Values {
293 if configAttributes, ok := resolveAnchor(node.Value).(*ast.MappingNode); ok {
294 for _, configAttribute := range configAttributes.Values {
295 link := createObjectFileLink(folderAbsolutePath, wslDollarSign, configAttribute)
296 if link != nil {
297 links = append(links, *link)

Callers 1

DocumentLinkFunction · 0.85

Calls 9

resolveAnchorFunction · 0.85
includedPathsFunction · 0.85
createLinkFunction · 0.85
createImageLinkFunction · 0.85
createdNestedLinkFunction · 0.85
createFileLinksFunction · 0.85
createVolumeFileLinksFunction · 0.85
createObjectFileLinkFunction · 0.85
createModelLinkFunction · 0.85

Tested by

no test coverage detected