MCPcopy Index your code
hub / github.com/docker/docker-agent / externalRefBaseName

Function externalRefBaseName

pkg/config/resolve.go:317–337  ·  view source on GitHub ↗

externalRefBaseName extracts a short agent name from an external reference. - OCI: last path segment, tag/digest stripped "agentcatalog/review-pr" → "review-pr" "docker.io/myorg/myagent:v1" → "myagent" - URL: filename without extension "https://example.com/agent.yaml" → "agent"

(ref string)

Source from the content-addressed store, hash-verified

315// - URL: filename without extension
316// "https://example.com/agent.yaml" → "agent"
317func externalRefBaseName(ref string) string {
318 if IsURLReference(ref) {
319 return fileNameWithoutExt(ref)
320 }
321
322 // OCI reference: strip tag or digest, then take last path segment.
323 base := ref
324 if i := strings.LastIndex(base, "@"); i >= 0 {
325 base = base[:i]
326 }
327 if i := strings.LastIndex(base, ":"); i >= 0 {
328 // Only strip if the colon is after the last slash (i.e. it's a tag, not a port).
329 if j := strings.LastIndex(base, "/"); j < i {
330 base = base[:i]
331 }
332 }
333 if i := strings.LastIndex(base, "/"); i >= 0 {
334 base = base[i+1:]
335 }
336 return base
337}

Callers 1

ParseExternalAgentRefFunction · 0.85

Calls 2

IsURLReferenceFunction · 0.85
fileNameWithoutExtFunction · 0.85

Tested by

no test coverage detected