mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
3136ffad1b
> ### 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
67 lines
2.6 KiB
Go
67 lines
2.6 KiB
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/scripts"
|
|
"github.com/hasura/graphql-engine/cli/v2/util"
|
|
"github.com/spf13/afero"
|
|
|
|
"github.com/hasura/graphql-engine/cli/v2"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func newUpdateMultipleSources(ec *cli.ExecutionContext) *cobra.Command {
|
|
v := viper.New()
|
|
var opts scripts.UpdateProjectV3Opts
|
|
cmd := &cobra.Command{
|
|
Use: "update-project-v3",
|
|
Short: "Update the Hasura project from config v2 to v3",
|
|
Long: `
|
|
Convenience script used to upgrade your CLI project to use config v3.
|
|
Note that this process is completely independent from your Hasura Graphql Engine server update process`,
|
|
SilenceUsage: true,
|
|
PreRunE: func(cmd *cobra.Command, args []string) error {
|
|
ec.Viper = v
|
|
err := ec.Prepare()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return ec.Validate()
|
|
},
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
if opts.Force && len(opts.TargetDatabase) == 0 {
|
|
return fmt.Errorf("--database-name is required when --force is set")
|
|
}
|
|
opts.Fs = afero.NewOsFs()
|
|
opts.ProjectDirectory = ec.ExecutionDirectory
|
|
opts.MigrationsAbsDirectoryPath = ec.MigrationDir
|
|
opts.SeedsAbsDirectoryPath = ec.SeedsDirectory
|
|
opts.Logger = ec.Logger
|
|
opts.EC = ec
|
|
return scripts.UpdateProjectV3(opts)
|
|
},
|
|
}
|
|
|
|
f := cmd.Flags()
|
|
f.StringVar(&opts.TargetDatabase, "database-name", "", "database name for which the current migrations / seeds belong to")
|
|
f.BoolVar(&opts.Force, "force", false, "do not ask for confirmation")
|
|
f.BoolVar(&opts.MoveStateOnly, "move-state-only", false, "do only a state migration from old hdb_catalog.* table to catalog state and skip others")
|
|
|
|
f.String("endpoint", "", "http(s) endpoint for Hasura GraphQL engine")
|
|
f.String("admin-secret", "", "admin secret for Hasura GraphQL engine")
|
|
f.String("access-key", "", "access key for Hasura GraphQL engine")
|
|
f.MarkDeprecated("access-key", "use --admin-secret instead")
|
|
f.Bool("insecure-skip-tls-verify", false, "skip TLS verification and disable cert checking (default: false)")
|
|
f.String("certificate-authority", "", "path to a cert file for the certificate authority")
|
|
|
|
// need to create a new viper because https://github.com/spf13/viper/issues/233
|
|
util.BindPFlag(v, "endpoint", f.Lookup("endpoint"))
|
|
util.BindPFlag(v, "admin_secret", f.Lookup("admin-secret"))
|
|
util.BindPFlag(v, "access_key", f.Lookup("access-key"))
|
|
util.BindPFlag(v, "insecure_skip_tls_verify", f.Lookup("insecure-skip-tls-verify"))
|
|
util.BindPFlag(v, "certificate_authority", f.Lookup("certificate-authority"))
|
|
return cmd
|
|
}
|