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 ( // ENV_ENDPOINT is the name of env var which indicates the Hasura GraphQL // Engine endpoint URL. ENV_ENDPOINT = "HASURA_GRAPHQL_ENDPOINT" // ENV_ACCESS_KEY is the name of env var that has the access key for GraphQL // Engine endpoint. ENV_ACCESS_KEY = "HASURA_GRAPHQL_ACCESS_KEY" )
Environment variable names recognised by the CLI.
const ( // Name of the global configuration directory GLOBAL_CONFIG_DIR_NAME = ".hasura-graphql" // Name of the global configuration file GLOBAL_CONFIG_FILE_NAME = "config.json" )
Other constants used in the package
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 // 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 file where Hasura metadata is stored. MetadataFile string // Config is the configuration object storing the endpoint and access key // information after reading from config file or env var. Config *HasuraGraphQLConfig // GlobalConfigDir is the ~/.hasura-graphql directory to store configuration // globally. GlobalConfigDir string // GlobalConfigFile is the file inside GlobalConfigDir where values are // stored. GlobalConfigFile string // InstallManifestsRepo is the object referring to the github repo where // installation scripts/manifests for Hasura GraphQL Engine are located. InstallManifestsRepo *util.InstallManifestsRepo // 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 }
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 (*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) RenderTextWithContext ¶
func (ec *ExecutionContext) RenderTextWithContext(in string) (out string)
RenderTextWithContext renders the template text passed as 'in' with the ExecutionContext as the template context and returns 'out'.
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 HasuraGraphQLConfig ¶
type HasuraGraphQLConfig struct { // Endpoint for the GraphQL Engine Endpoint string `json:"endpoint"` // AccessKey (optional) required to query the endpoint AccessKey string `json:"access_key,omitempty"` ParsedEndpoint *url.URL `json:"-"` }
HasuraGraphQLConfig has the config values required to contact the server.
func (*HasuraGraphQLConfig) ParseEndpoint ¶
func (hgc *HasuraGraphQLConfig) ParseEndpoint() error
ParseEndpoint ensures the endpoint is valid.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
hasura
Package main is the entrypoint for the the command line executable.
|
Package main is the entrypoint for the 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. |