mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 18:42:30 +03:00
8edd3f03a5
Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com> GitOrigin-RevId: 6ad93a11830868a05a1c02333d482a2978b704c2
45 lines
946 B
Go
45 lines
946 B
Go
package version
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/hasura/graphql-engine/cli"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type V3MetadataV2ConfigVersion struct {
|
|
*VersionConfig
|
|
}
|
|
|
|
func (a *V3MetadataV2ConfigVersion) Build(metadata *yaml.MapSlice) error {
|
|
item := yaml.MapItem{
|
|
Key: "version",
|
|
// Force version 2
|
|
Value: 2,
|
|
}
|
|
*metadata = append(*metadata, item)
|
|
return nil
|
|
}
|
|
|
|
func NewV3MetadataVersion(ec *cli.ExecutionContext, baseDir string) *V3MetadataV2ConfigVersion {
|
|
ec.Version.GetServerFeatureFlags()
|
|
return &V3MetadataV2ConfigVersion{
|
|
&VersionConfig{
|
|
MetadataDir: baseDir,
|
|
},
|
|
}
|
|
}
|
|
func (a *V3MetadataV2ConfigVersion) Export(_ yaml.MapSlice) (map[string][]byte, error) {
|
|
v := Version{
|
|
// during a v3 metadata export forcefully write metadata v2
|
|
Version: 2,
|
|
}
|
|
data, err := yaml.Marshal(v)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return map[string][]byte{
|
|
filepath.ToSlash(filepath.Join(a.MetadataDir, fileName)): data,
|
|
}, nil
|
|
}
|