2019-12-25 11:33:06 +03:00
package commands
import (
2022-11-08 16:52:00 +03:00
"fmt"
2021-06-16 14:44:15 +03:00
"github.com/hasura/graphql-engine/cli/v2"
2022-11-08 16:52:00 +03:00
"github.com/hasura/graphql-engine/cli/v2/internal/errors"
2021-07-23 12:49:44 +03:00
"github.com/hasura/graphql-engine/cli/v2/internal/projectmetadata"
2019-12-25 11:33:06 +03:00
"github.com/spf13/cobra"
)
func newMetadataInconsistencyStatusCmd ( ec * cli . ExecutionContext ) * cobra . Command {
opts := & metadataInconsistencyListOptions {
EC : ec ,
}
metadataInconsistencyStatusCmd := & cobra . Command {
Use : "status" ,
2022-12-30 06:50:48 +03:00
Short : "Check if the Hasura Metadata is inconsistent or not" ,
Long : "At times, when developing, the Hasura Metadata can become inconsistent. This command can be used to check if the Metadata is inconsistent or not." ,
2019-12-25 11:33:06 +03:00
SilenceUsage : true ,
RunE : func ( cmd * cobra . Command , args [ ] string ) error {
2022-11-08 16:52:00 +03:00
op := genOpName ( cmd , "RunE" )
2019-12-25 11:33:06 +03:00
opts . EC . Spin ( "reading metadata status..." )
2021-07-23 12:49:44 +03:00
err := opts . read ( projectmetadata . NewHandlerFromEC ( ec ) )
2019-12-25 11:33:06 +03:00
opts . EC . Spinner . Stop ( )
if err != nil {
2022-11-08 16:52:00 +03:00
return errors . E ( op , fmt . Errorf ( "failed to read metadata status: %w" , err ) )
2019-12-25 11:33:06 +03:00
}
if opts . isConsistent {
opts . EC . Logger . Println ( "metadata is consistent" )
} else {
2022-11-08 16:52:00 +03:00
return errors . E ( op , "metadata is inconsistent, use 'hasura metadata ic list' command to see the inconsistent objects" )
2019-12-25 11:33:06 +03:00
}
return nil
} ,
}
return metadataInconsistencyStatusCmd
}