MCPcopy Create free account
hub / github.com/celer-pkg/celer / findTool

Method findTool

buildtools/build_tools.go:264–286  ·  view source on GitHub ↗

findTool find matched tool with name and version.

(ctx context.Context, nameVersion string)

Source from the content-addressed store, hash-verified

262
263// findTool find matched tool with name and version.
264func (b BuildTools) findTool(ctx context.Context, nameVersion string) (*BuildTool, error) {
265 toolName, toolVersion := b.parseNameVersion(nameVersion)
266
267 for index, tool := range b.BuildTools {
268 if tool.Name != toolName {
269 continue
270 }
271
272 if toolVersion == "" {
273 if !tool.Default { // No version specified - must use default.
274 return nil, fmt.Errorf("%s is found, but no version specified", toolName)
275 }
276 } else if tool.Version != toolVersion {
277 continue
278 }
279
280 // Matched tool found.
281 b.BuildTools[index].ctx = ctx
282 return &b.BuildTools[index], nil
283 }
284
285 return nil, fmt.Errorf("tool %s is not found", nameVersion)
286}
287
288func (b BuildTools) contains(name string) bool {
289 toolName, _ := b.parseNameVersion(name)

Callers 3

CheckToolsFunction · 0.95
FindBuildToolFunction · 0.95

Calls 1

parseNameVersionMethod · 0.95

Tested by

no test coverage detected