rename metadata reset to metadta clear (close #1851) (#1893)

The word "reset" is little ambiguous (reset to scratch or reset to last known consistent state). metadata reset clears the all the metadata to mimic a freshly installed hasura instance. This actually invokes the clear_metadata API in the backend and hence should also be called metadata clear for perfect clarity.

All references to metadata reset should be changed to metadata clear.
This commit is contained in:
Aravind Shankar 2019-03-29 10:44:56 +05:30 committed by Shahidh K Muhammed
parent 7bfcc764db
commit ca7d8b3df5
5 changed files with 30 additions and 24 deletions

View File

@ -20,7 +20,7 @@ func NewMetadataCmd(ec *cli.ExecutionContext) *cobra.Command {
}
metadataCmd.AddCommand(
newMetadataExportCmd(ec),
newMetadataResetCmd(ec),
newMetadataClearCmd(ec),
newMetadataReloadCmd(ec),
newMetadataApplyCmd(ec),
)
@ -54,10 +54,10 @@ func executeMetadata(cmd string, t *migrate.Migrate, ec *cli.ExecutionContext) e
if err != nil {
return errors.Wrap(err, "cannot save metadata")
}
case "reset":
case "clear":
err := t.ResetMetadata()
if err != nil {
return errors.Wrap(err, "cannot reset Metadata")
return errors.Wrap(err, "cannot clear Metadata")
}
case "reload":
err := t.ReloadMetadata()

View File

@ -7,24 +7,28 @@ import (
"github.com/spf13/viper"
)
func newMetadataResetCmd(ec *cli.ExecutionContext) *cobra.Command {
func newMetadataClearCmd(ec *cli.ExecutionContext) *cobra.Command {
v := viper.New()
opts := &metadataResetOptions{
opts := &metadataClearOptions{
EC: ec,
actionType: "reset",
actionType: "clear",
}
metadataResetCmd := &cobra.Command{
Use: "reset",
Short: "Reset or clean Hasura GraphQL Engine metadata on the database",
Example: ` # Clean all the metadata information from database:
hasura metadata reset`,
Use: "clear",
Aliases: []string{"reset"},
Short: "Clear Hasura GraphQL Engine metadata on the database",
Example: ` # Clear all the metadata information from database:
hasura metadata clear`,
SilenceUsage: true,
PreRunE: func(cmd *cobra.Command, args []string) error {
ec.Viper = v
return ec.Validate()
},
RunE: func(cmd *cobra.Command, args []string) error {
if cmd.CalledAs() == "reset" {
opts.EC.Logger.Warn("metadata reset command is deprecated, use metadata clear instead")
}
return opts.run()
},
}
@ -43,20 +47,20 @@ func newMetadataResetCmd(ec *cli.ExecutionContext) *cobra.Command {
return metadataResetCmd
}
type metadataResetOptions struct {
type metadataClearOptions struct {
EC *cli.ExecutionContext
actionType string
}
func (o *metadataResetOptions) run() error {
func (o *metadataClearOptions) run() error {
migrateDrv, err := newMigrate(o.EC.MigrationDir, o.EC.ServerConfig.ParsedEndpoint, o.EC.ServerConfig.AdminSecret, o.EC.Logger, o.EC.Version)
if err != nil {
return err
}
err = executeMetadata(o.actionType, migrateDrv, o.EC)
if err != nil {
return errors.Wrap(err, "Cannot reset metadata")
return errors.Wrap(err, "Cannot clear metadata")
}
return nil
}

View File

@ -14,7 +14,7 @@ import (
func testMetadataReset(t *testing.T, metadataFile string, endpoint *url.URL) {
logger, _ := test.NewNullLogger()
opts := &metadataResetOptions{
opts := &metadataClearOptions{
EC: &cli.ExecutionContext{
Logger: logger,
Spinner: spinner.New(spinner.CharSets[7], 100*time.Millisecond),
@ -25,7 +25,7 @@ func testMetadataReset(t *testing.T, metadataFile string, endpoint *url.URL) {
ParsedEndpoint: endpoint,
},
},
actionType: "reset",
actionType: "clear",
}
opts.EC.Version = version.New()

View File

@ -32,8 +32,8 @@ SEE ALSO
* :ref:`hasura <hasura>` - Hasura GraphQL Engine command line tool
* :ref:`hasura metadata apply <hasura_metadata_apply>` - Apply Hasura metadata on a database
* :ref:`hasura metadata clear <hasura_metadata_clear>` - Clear Hasura GraphQL Engine metadata on the database
* :ref:`hasura metadata export <hasura_metadata_export>` - Export Hasura GraphQL Engine metadata from the database
* :ref:`hasura metadata reload <hasura_metadata_reload>` - Reload Hasura GraphQL Engine metadata on the database
* :ref:`hasura metadata reset <hasura_metadata_reset>` - Reset or clean Hasura GraphQL Engine metadata on the database
*Auto generated by spf13/cobra*

View File

@ -1,27 +1,29 @@
.. _hasura_metadata_reset:
.. _hasura_metadata_clear:
Hasura CLI: hasura metadata reset
Hasura CLI: hasura metadata clear
---------------------------------
Reset or clean Hasura GraphQL Engine metadata on the database
Clear Hasura GraphQL Engine metadata on the database
Synopsis
~~~~~~~~
Reset or clean Hasura GraphQL Engine metadata on the database
Clear Hasura GraphQL Engine metadata on the database
::
hasura metadata reset [flags]
hasura metadata clear [flags]
Alias: reset
Examples
~~~~~~~~
::
# Clean all the metadata information from database:
hasura metadata reset
# Clear all the metadata information from database:
hasura metadata clear
Options
~~~~~~~
@ -30,7 +32,7 @@ Options
--admin-secret string admin secret for Hasura GraphQL Engine
--endpoint string http(s) endpoint for Hasura GraphQL Engine
-h, --help help for reset
-h, --help help for clear
Options inherited from parent commands
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~