graphql-engine/cli/version/feature_flags.go
nizar-m f83a8e591f rename access-key to admin-secret (close #1347) (#1540)
Rename the admin secret key header used to access GraphQL engine from X-Hasura-Access-Key to X-Hasura-Admin-Secret.

Server CLI and console all support the older flag but marks it as deprecated.
2019-02-14 15:07:47 +05:30

30 lines
837 B
Go

package version
import (
"github.com/Masterminds/semver"
"github.com/pkg/errors"
)
// ServerFeatureFlags indicates what features are supported by this
// version of server.
type ServerFeatureFlags struct {
HasAccessKey bool
}
const adminSecretVersion = "v1.0.0-alpha38"
// GetServerFeatureFlags returns the feature flags for server.
func (v *Version) GetServerFeatureFlags() (*ServerFeatureFlags, error) {
flags := &ServerFeatureFlags{}
// create a constraint to check if the current server version has admin secret
adminSecretConstraint, err := semver.NewConstraint("< " + adminSecretVersion)
if err != nil {
return nil, errors.Wrap(err, "building admin secret constraint failed")
}
// check the current version with the constraint
flags.HasAccessKey = adminSecretConstraint.Check(v.ServerSemver)
return flags, nil
}