| 333 | } |
| 334 | |
| 335 | func DocumentLink(ctx context.Context, documentURI protocol.URI, doc document.ComposeDocument) ([]protocol.DocumentLink, error) { |
| 336 | d, err := doc.DocumentPath() |
| 337 | if err != nil { |
| 338 | return nil, err |
| 339 | } |
| 340 | |
| 341 | file := doc.File() |
| 342 | if file == nil || len(file.Docs) == 0 { |
| 343 | return nil, nil |
| 344 | } |
| 345 | |
| 346 | links := []protocol.DocumentLink{} |
| 347 | for _, documentNode := range file.Docs { |
| 348 | if mappingNode, ok := documentNode.Body.(*ast.MappingNode); ok { |
| 349 | for _, node := range mappingNode.Values { |
| 350 | links = append(links, scanForLinks(d.Folder, d.WSLDollarSignHost, node)...) |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | return links, nil |
| 355 | } |
| 356 | |
| 357 | func extractNonDockerHubImageLink(nodeValue, prefix, uriPrefix string, startIndex uint) (string, string) { |
| 358 | if len(nodeValue) <= len(prefix)+1 { |