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)
| 59 | // when fetching from GitHub URLs. |
| 60 | // For OCI references, always checks remote for updates but falls back to local cache if offline. |
| 61 | func 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 |