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

Function ResolveSources

pkg/config/resolve.go:61–80  ·  view source on GitHub ↗

ResolveSources resolves an agent file reference (local file, URL, or OCI image) to sources. If envProvider is non-nil, it will be used to look up GITHUB_TOKEN for authentication when fetching from GitHub URLs. For OCI references, always checks remote for updates but falls back to local cache if offl

(agentsPath string, envProvider environment.Provider)

Source from the content-addressed store, hash-verified

59// when fetching from GitHub URLs.
60// For OCI references, always checks remote for updates but falls back to local cache if offline.
61func ResolveSources(agentsPath string, envProvider environment.Provider) (Sources, error) {
62 resolvedPath, err := resolve(agentsPath)
63 if err != nil {
64 // resolve() only fails for non-OCI, non-URL, non-builtin references
65 // that can't be made absolute. Try OCI as last resort.
66 if IsOCIReference(agentsPath) {
67 return singleSource(reference.OciRefToFilename(agentsPath), NewOCISource(agentsPath)), nil
68 }
69 return nil, err
70 }
71
72 // Only directories need special handling to enumerate YAML files.
73 if dirExists(resolvedPath) {
74 return resolveDirectory(resolvedPath, envProvider)
75 }
76
77 // For all other reference types, delegate to resolveOne.
78 key, source := resolveOne(resolvedPath, envProvider)
79 return singleSource(key, source), nil
80}
81
82// Resolve resolves an agent file reference (local file, URL, or OCI image) to a source.
83// If envProvider is non-nil, it will be used to look up GITHUB_TOKEN for authentication

Calls 8

OciRefToFilenameFunction · 0.92
IsOCIReferenceFunction · 0.85
singleSourceFunction · 0.85
NewOCISourceFunction · 0.85
dirExistsFunction · 0.85
resolveDirectoryFunction · 0.85
resolveOneFunction · 0.85
resolveFunction · 0.70