Documentation
¶
Overview ¶
Package cli and it's sub packages implements the command line tool for Hasura GraphQL Engine. The CLI operates on a directory, denoted by "ExecutionDirectory" in the "ExecutionContext" struct.
The ExecutionContext is passed to all the subcommands so that a singleton context is available for the execution. Logger and Spinner comes from the same context.
Index ¶
Constants ¶
const ( // Name of the global configuration directory GlobalConfigDirName = ".hasura" // Name of the global configuration file GlobalConfigFileName = "config.json" // Name of the file to store last update check time LastUpdateCheckFileName = "last_update_check_at" )
Other constants used in the package
const (
StrTelemetryNotice = `` /* 214-byte string literal not displayed */
)
String constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecutionContext ¶
type ExecutionContext struct { // CMDName is the name of CMD (os.Args[0]). To be filled in later to // correctly render example strings etc. CMDName string // ID is a unique ID for this Execution ID string // ServerUUID is the unique ID for the server this execution is contacting. ServerUUID string // Spinner is the global spinner object used to show progress across the cli. Spinner *spinner.Spinner // Logger is the global logger object to print logs. Logger *logrus.Logger // ExecutionDirectory is the directory in which command is being executed. ExecutionDirectory string // MigrationDir is the name of directory where migrations are stored. MigrationDir string // ConfigFile is the file where endpoint etc. are stored. ConfigFile string // MetadataFile (optional) is a yaml|json file where Hasura metadata is stored. MetadataFile []string // ServerConfig is the configuration object storing the endpoint and admin secret // information after reading from config file or env var. ServerConfig *ServerConfig // GlobalConfigDir is the ~/.hasura-graphql directory to store configuration // globally. GlobalConfigDir string // GlobalConfigFile is the file inside GlobalConfigDir where values are // stored. GlobalConfigFile string // GlobalConfig holds all the configuration options. GlobalConfig *GlobalConfig // IsStableRelease indicates if the CLI release is stable or not. IsStableRelease bool // Version indicates the version object Version *version.Version // Viper indicates the viper object for the execution Viper *viper.Viper // LogLevel indicates the logrus default logging level LogLevel string // Telemetry collects the telemetry data throughout the execution Telemetry *telemetry.Data // LastUpdateCheckFile is the file where the timestamp of last update check is stored LastUpdateCheckFile string // SkipUpdateCheck will skip the auto update check if set to true SkipUpdateCheck bool }
ExecutionContext contains various contextual information required by the cli at various points of it's execution. Values are filled in by the initializers and passed on to each command. Commands can also fill in values to be used further down the line.
func NewExecutionContext ¶
func NewExecutionContext() *ExecutionContext
NewExecutionContext returns a new instance of execution context
func (*ExecutionContext) GetMetadataFilePath ¶
func (ec *ExecutionContext) GetMetadataFilePath(format string) (string, error)
GetMetadataPath returns the file path based on the format.
func (*ExecutionContext) Prepare ¶
func (ec *ExecutionContext) Prepare() error
Prepare as the name suggests, prepares the ExecutionContext ec by initializing most of the variables to sensible defaults, if it is not already set.
func (*ExecutionContext) Spin ¶
func (ec *ExecutionContext) Spin(message string)
Spin stops any existing spinner and starts a new one with the given message.
func (*ExecutionContext) Validate ¶
func (ec *ExecutionContext) Validate() error
Validate prepares the ExecutionContext ec and then validates the ExecutionDirectory to see if all the required files and directories are in place.
type GlobalConfig ¶
type GlobalConfig struct { // UUID used for telemetry, generated on first run. UUID string `json:"uuid"` // Indicate if telemetry is enabled or not EnableTelemetry bool `json:"enable_telemetry"` // Indicates whether update notifications should be shown or not ShowUpdateNotification bool `json:"show_update_notification"` }
GlobalConfig is the configuration object stored in the GlobalConfigFile.
type ServerConfig ¶
type ServerConfig struct { // Endpoint for the GraphQL Engine Endpoint string // AdminSecret (optional) required to query the endpoint AdminSecret string ParsedEndpoint *url.URL }
ServerConfig has the config values required to contact the server.
func (ServerConfig) MarshalJSON ¶
func (s ServerConfig) MarshalJSON() ([]byte, error)
MarshalJSON converts s to JSON
func (*ServerConfig) ParseEndpoint ¶
func (s *ServerConfig) ParseEndpoint() error
ParseEndpoint ensures the endpoint is valid.
func (ServerConfig) UnmarshalJSON ¶
func (s ServerConfig) UnmarshalJSON(b []byte) error
UnmarshalJSON converts b to struct s
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
hasura
command
Package main is the entrypoint for the command line executable.
|
Package main is the entrypoint for the command line executable. |
Package commands contains the definition for all the commands present in Hasura CLI.
|
Package commands contains the definition for all the commands present in Hasura CLI. |
Package migrate implements migrations on Hasura GraphQL Engine.
|
Package migrate implements migrations on Hasura GraphQL Engine. |
Package util contains utility functions used by various commands.
|
Package util contains utility functions used by various commands. |
Package version implements server, cli and console version handling.
|
Package version implements server, cli and console version handling. |