graphql-engine/cli/commands/metadata_inconsistency_drop.go
Aravind K P 33d6025a20 cli: refactor metadata object interface
https://github.com/hasura/graphql-engine-mono/pull/1618

GitOrigin-RevId: f4559de4852f247de35604be3808f05fe5ed341a
2021-07-23 09:50:36 +00:00

41 lines
1.1 KiB
Go

package commands
import (
"github.com/hasura/graphql-engine/cli/v2"
"github.com/hasura/graphql-engine/cli/v2/internal/projectmetadata"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func newMetadataInconsistencyDropCmd(ec *cli.ExecutionContext) *cobra.Command {
opts := &metadataInconsistencyDropOptions{
EC: ec,
}
metadataInconsistencyDropCmd := &cobra.Command{
Use: "drop",
Short: "Drop inconsistent objects from the metadata",
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
opts.EC.Spin("Dropping inconsistent metadata...")
err := opts.run()
opts.EC.Spinner.Stop()
if err != nil {
return errors.Wrap(err, "failed to drop inconsistent metadata")
}
opts.EC.Logger.Info("all inconsistent objects removed from metadata")
return nil
},
}
return metadataInconsistencyDropCmd
}
type metadataInconsistencyDropOptions struct {
EC *cli.ExecutionContext
}
func (o *metadataInconsistencyDropOptions) run() error {
return projectmetadata.NewHandlerFromEC(o.EC).DropInconsistentMetadata()
}