mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 18:42:30 +03:00
a398d3b190
GITHUB_PR_NUMBER: 6111 GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6111 Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com> GitOrigin-RevId: 1f6517acfacb58c566bb5e48f74ea0dfa5c6f063
30 lines
597 B
Go
30 lines
597 B
Go
package v3
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/Masterminds/semver"
|
|
)
|
|
|
|
const (
|
|
metadataDirPrefixV3 = "v3/metadata"
|
|
)
|
|
|
|
func getMetadataDir(serverVersion *semver.Version) string {
|
|
var version string
|
|
if serverVersion == nil {
|
|
version = "latest"
|
|
} else {
|
|
currDir, _ := os.Getwd()
|
|
versionDir := fmt.Sprintf("v%d.%d", serverVersion.Major(), serverVersion.Minor())
|
|
if _, err := os.Stat(filepath.Join(currDir, metadataDirPrefixV3, versionDir)); err != nil {
|
|
version = "latest"
|
|
} else {
|
|
version = versionDir
|
|
}
|
|
}
|
|
return filepath.Join(metadataDirPrefixV3, version)
|
|
}
|