mirror of
https://github.com/gomods/athens
synced 2026-02-03 14:20:31 +00:00
* Added new cataloger interface * Implementing catalog protocol * Propagated to protocol and over * First round of fixes * S3 almost ready, need to be tested * Going on with testing s3 * Better testing with s3 * Simplified catalog tests * Preparing gcp tests to access a gcp instance * Fixing initialization errors * Removed some prints * Gcp ready, to be tested * Gcp working * Aligned bucket mock to catalog method * Switched res payload to json * Added catalog method to all storage instances * Added catalog method to unsupported storages * Fixed with pool test * Restored tests * Fixed gcp constructor * Implemented catalog for fs * Removed trace * E2e tests, fixed fs * Fixed module name return value * Added cataloger method to azure storage * Added docs * Changed pagesize parameter name * Fixed gofmt error * Added json tags to result. Fixed lint warning * Removed extra line * Changed not implemented error to http.KindNotImplemented * Checking for inequality on results * Lower-cased json keys * Added cleaning of path separator * Fixed review comments * Fixed docs
32 lines
827 B
Go
32 lines
827 B
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
// PackageVersionedName return package full name used in storage.
|
|
// E.g athens/@v/v1.0.mod
|
|
func PackageVersionedName(module, version, ext string) string {
|
|
return fmt.Sprintf("%s/@v/%s.%s", module, version, ext)
|
|
}
|
|
|
|
// FmtModVer is a helper function that can take
|
|
// pkg/a/b and v2.3.1 and returns pkg/a/b@v2.3.1
|
|
func FmtModVer(mod, ver string) string {
|
|
return fmt.Sprintf("%s@%s", mod, ver)
|
|
}
|
|
|
|
// ModuleVersionFromPath returns module and version from a
|
|
// storage path
|
|
// E.g athens/@v/v1.0.info -> athens and v.1.0
|
|
func ModuleVersionFromPath(path string) (string, string) {
|
|
segments := strings.Split(path, "/@v/")
|
|
if len(segments) != 2 {
|
|
return "", ""
|
|
}
|
|
version := strings.TrimSuffix(segments[1], filepath.Ext(segments[1]))
|
|
return segments[0], version
|
|
}
|