Documentation ¶
Index ¶
- Variables
- type CommonConfig
- type Config
- type ServerContext
- func (c *ServerContext) ContextExisted(name string) bool
- func (c *ServerContext) Inject(cmd *cobra.Command) error
- func (c *ServerContext) InjectFields() []string
- func (c *ServerContext) InjectURI(uri, name string) string
- func (c *ServerContext) Merge(ns ServerContext, flags *pflag.FlagSet) ServerContext
- func (c *ServerContext) OpenAPIURL() (*url.URL, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var InjectFields = []string{"project", "environment"}
Functions ¶
This section is empty.
Types ¶
type CommonConfig ¶
type CommonConfig struct { Debug bool `json:"debug,omitempty" yaml:"debug,omitempty"` Format string `json:"format,omitempty" yaml:"format,omitempty"` }
CommonConfig indicate the common CLI command config.
type Config ¶
type Config struct { CommonConfig `json:",inline" yaml:",inline" mapstructure:",squash"` ServerContext `json:",inline" yaml:",inline" mapstructure:",squash"` }
Config include the common config and server context config.
func (*Config) ValidateAndSetup ¶
ValidateAndSetup validate and setup the context.
type ServerContext ¶
type ServerContext struct { // Server config. Server string `json:"server" survey:"server"` Token string `json:"token" survey:"token"` Insecure bool `json:"insecure" survey:"insecure"` // Project name. Project string `json:"project,omitempty" survey:"project"` // Environment name. Environment string `json:"environment,omitempty" survey:"environment"` }
ServerContext contains the server config.
func (*ServerContext) ContextExisted ¶
func (c *ServerContext) ContextExisted(name string) bool
ContextExisted check whether the value already existed in the context.
func (*ServerContext) Inject ¶
func (c *ServerContext) Inject(cmd *cobra.Command) error
Inject update the flags base on the context.
func (*ServerContext) InjectFields ¶
func (c *ServerContext) InjectFields() []string
InjectFields config the fields need to inject.
func (*ServerContext) InjectURI ¶
func (c *ServerContext) InjectURI(uri, name string) string
InjectURI update the uri base on the context.
func (*ServerContext) Merge ¶
func (c *ServerContext) Merge(ns ServerContext, flags *pflag.FlagSet) ServerContext
Merge generate new server context base on old context, new context and flags.
func (*ServerContext) OpenAPIURL ¶
func (c *ServerContext) OpenAPIURL() (*url.URL, error)
OpenAPIURL generate OpenAPI url.
Click to show internal directories.
Click to hide internal directories.