MCPcopy Create free account
hub / github.com/docker/docker-agent / extractVersionPrefix

Function extractVersionPrefix

pkg/toolinstall/resolver.go:222–240  ·  view source on GitHub ↗

extractVersionPrefix parses an aqua version_filter expression like 'Version startsWith "gopls/"' and returns the prefix string. Returns "" if the filter doesn't match this pattern.

(filter string)

Source from the content-addressed store, hash-verified

220// 'Version startsWith "gopls/"' and returns the prefix string.
221// Returns "" if the filter doesn't match this pattern.
222func extractVersionPrefix(filter string) string {
223 filter = strings.TrimSpace(filter)
224 const marker = "startsWith"
225 _, after, ok := strings.Cut(filter, marker)
226 if !ok {
227 return ""
228 }
229
230 rest := strings.TrimSpace(after)
231 if len(rest) >= 2 && (rest[0] == '"' || rest[0] == '\'') {
232 quote := rest[0]
233 end := strings.IndexByte(rest[1:], quote)
234 if end >= 0 {
235 return rest[1 : end+1]
236 }
237 }
238
239 return ""
240}
241
242// parseAquaRef parses an aqua reference string into owner, repo, and version.
243// Format: "owner/repo" or "owner/repo@version"

Callers 2

TestExtractVersionPrefixFunction · 0.85
resolveVersionFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestExtractVersionPrefixFunction · 0.68