graphql-engine/cli/internal/metadataobject/version/v3metadata.go
Aravind K P 3136ffad1b cli: update go.mod
>

### Description
Update `go.mod` to allow other packages to import [v2.0.0 versions](https://blog.golang.org/v2-go-modules).

### Changelog

- [x] `CHANGELOG.md` is updated with user-facing content relevant to this PR. If no changelog is required, then add the `no-changelog-required` label.

### Affected components

- [x] CLI

https://github.com/hasura/graphql-engine-mono/pull/1584

GitOrigin-RevId: a5d17ad20289d1cd7217763f56ef3ba6552d69c4
2021-06-16 11:45:07 +00:00

45 lines
949 B
Go

package version
import (
"path/filepath"
"github.com/hasura/graphql-engine/cli/v2"
"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
}