mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-13 19:33:55 +03:00
cli: validate pro plugin version
GitOrigin-RevId: 2bcb64256b357d07d0f06d8347260c649bfcc132
This commit is contained in:
parent
d8d4626ba3
commit
9e3f5a9f01
@ -48,6 +48,7 @@ $ hasura metadata export -o json
|
||||
- cli: fix applying migrations in a different environment after config v3 update (#6861)
|
||||
- cli: fix bug caused by usage of space character in database name (#6852)
|
||||
- cli: fix issues with generated filepaths in windows (#6813)
|
||||
- cli: add warning for incompatible pro plugin version
|
||||
|
||||
## v2.0.0-alpha.10
|
||||
|
||||
|
31
cli/cli.go
31
cli/cli.go
@ -43,6 +43,7 @@ import (
|
||||
|
||||
"github.com/hasura/graphql-engine/cli/internal/hasura"
|
||||
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/briandowns/spinner"
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/hasura/graphql-engine/cli/internal/metadataobject/actions/types"
|
||||
@ -439,6 +440,10 @@ type ExecutionContext struct {
|
||||
// already this configuration option will disable this step
|
||||
// more details in: https://github.com/hasura/graphql-engine/issues/6861
|
||||
DisableAutoStateMigration bool
|
||||
|
||||
// proPluginVersionValidated is used to avoid validating pro plugin multiple times
|
||||
// while preparing the execution context
|
||||
proPluginVersionValidated bool
|
||||
}
|
||||
|
||||
type Source struct {
|
||||
@ -488,6 +493,11 @@ func (ec *ExecutionContext) Prepare() error {
|
||||
return errors.Wrap(err, "setting up plugins path failed")
|
||||
}
|
||||
|
||||
if !ec.proPluginVersionValidated {
|
||||
ec.validateProPluginVersion()
|
||||
ec.proPluginVersionValidated = true
|
||||
}
|
||||
|
||||
err = ec.setupCodegenAssetsRepo()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "setting up codegen-assets repo failed")
|
||||
@ -539,6 +549,27 @@ func (ec *ExecutionContext) setupPlugins() error {
|
||||
return ec.PluginsConfig.Prepare()
|
||||
}
|
||||
|
||||
func (ec *ExecutionContext) validateProPluginVersion() {
|
||||
installedPlugins, err := ec.PluginsConfig.ListInstalledPlugins()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
proPluginVersion := installedPlugins["pro"]
|
||||
cliVersion := ec.Version.GetCLIVersion()
|
||||
|
||||
proPluginSemVer, _ := semver.NewVersion(proPluginVersion)
|
||||
cliSemVer := ec.Version.CLISemver
|
||||
if proPluginSemVer == nil || cliSemVer == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if cliSemVer.Major() != proPluginSemVer.Major() {
|
||||
ec.Logger.Warnf("[cli: %s] [pro plugin: %s] incompatible version of cli and pro plugin.", cliVersion, proPluginVersion)
|
||||
ec.Logger.Warn("Try running `hasura plugins upgrade pro` or `hasura plugins install pro --version <version>`")
|
||||
}
|
||||
}
|
||||
|
||||
func (ec *ExecutionContext) setupCodegenAssetsRepo() error {
|
||||
base := filepath.Join(ec.GlobalConfigDir, util.ActionsCodegenDirName)
|
||||
base, err := filepath.Abs(base)
|
||||
|
Loading…
Reference in New Issue
Block a user