graphql-engine/cli/commands/metadata_inconsistency_status.go
Kali Vara Purushotham Santhati e3fa6bee0a cli: improve error/log messages
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/2513
Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: bff6e5f6d3553904914eabda02d3406c4b779f3c
2021-10-08 16:10:31 +00:00

38 lines
1.0 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 newMetadataInconsistencyStatusCmd(ec *cli.ExecutionContext) *cobra.Command {
opts := &metadataInconsistencyListOptions{
EC: ec,
}
metadataInconsistencyStatusCmd := &cobra.Command{
Use: "status",
Short: "Check if the metadata is inconsistent or not",
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
opts.EC.Spin("reading metadata status...")
err := opts.read(projectmetadata.NewHandlerFromEC(ec))
opts.EC.Spinner.Stop()
if err != nil {
return errors.Wrap(err, "failed to read metadata status")
}
if opts.isConsistent {
opts.EC.Logger.Println("metadata is consistent")
} else {
return errors.New("metadata is inconsistent, use 'hasura metadata ic list' command to see the inconsistent objects")
}
return nil
},
}
return metadataInconsistencyStatusCmd
}