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

Method resolveProjectPort

configs/port.go:245–271  ·  view source on GitHub ↗

resolveProjectPort returns the port.toml path for (name@version), searching in priority order: 1. / / / /port.toml (project top-level) 2. / /ports/ / /port.toml (project vendor) 3. / / /<

(project, name, version string)

Source from the content-addressed store, hash-verified

243// - ErrAmbiguousProjectPort if both (1) and (2) exist
244// - ErrPortNotFound if none of the three exists
245func (p Port) resolveProjectPort(project, name, version string) (string, error) {
246 topLevelPort := filepath.Join(dirs.ConfProjectsDir, project, name, version, "port.toml")
247 vendorPort := filepath.Join(dirs.ConfProjectsDir, project, "ports", name, version, "port.toml")
248
249 hasTopLevelPort := fileio.PathExists(topLevelPort)
250 hasVendorPort := fileio.PathExists(vendorPort)
251
252 switch {
253 case hasTopLevelPort && hasVendorPort:
254 return "", fmt.Errorf("%w in booth '%s' and '%s' for '%s' — remove one to disambiguate",
255 errors.ErrAmbiguousPortFound, project+"/", project+"/"+"ports/", name+"@"+version)
256
257 case hasTopLevelPort:
258 return topLevelPort, nil
259
260 case hasVendorPort:
261 return vendorPort, nil
262 }
263
264 // Fall back to the global ports/ collection.
265 publicPort := dirs.GetPortPath(name, version)
266 if fileio.PathExists(publicPort) {
267 return publicPort, nil
268 }
269
270 return "", errors.ErrPortNotFound
271}
272
273func (p Port) checkDepsInstalled() (bool, error) {
274 for _, nameVersion := range p.MatchedConfig.Dependencies {

Callers 1

InitMethod · 0.95

Calls 2

PathExistsFunction · 0.92
GetPortPathFunction · 0.92

Tested by

no test coverage detected