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

Function lookupPackage

pkg/toolinstall/resolver.go:182–202  ·  view source on GitHub ↗

lookupPackage resolves the aqua package for a command. If versionRef is provided (e.g. "owner/repo@v1.0"), it parses the reference and looks up by name. Otherwise, it searches by command name. Returns the package, the explicit version (if any), and any error.

(ctx context.Context, registry *Registry, command, versionRef string)

Source from the content-addressed store, hash-verified

180// and looks up by name. Otherwise, it searches by command name.
181// Returns the package, the explicit version (if any), and any error.
182func lookupPackage(ctx context.Context, registry *Registry, command, versionRef string) (*Package, string, error) {
183 if versionRef == "" {
184 pkg, err := registry.LookupByCommand(ctx, command)
185 if err != nil {
186 return nil, "", fmt.Errorf("looking up command %q in aqua registry: %w", command, err)
187 }
188 return pkg, "", nil
189 }
190
191 owner, repo, version, err := parseAquaRef(versionRef)
192 if err != nil {
193 return nil, "", fmt.Errorf("parsing aqua reference: %w", err)
194 }
195
196 pkg, err := registry.LookupByName(ctx, owner+"/"+repo)
197 if err != nil {
198 return nil, "", fmt.Errorf("looking up aqua package %s/%s: %w", owner, repo, err)
199 }
200
201 return pkg, version, nil
202}
203
204// resolveVersion determines the latest version for a package.
205func resolveVersion(ctx context.Context, registry *Registry, pkg *Package) (string, error) {

Callers 2

ResolveHostsFunction · 0.85
doInstallFunction · 0.85

Calls 3

parseAquaRefFunction · 0.85
LookupByCommandMethod · 0.80
LookupByNameMethod · 0.80

Tested by

no test coverage detected