mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
f83a8e591f
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.
30 lines
837 B
Go
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
|
|
}
|