config

package
v0.4.0-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

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) DoRequest

func (c *Config) DoRequest(req *http.Request) (*http.Response, error)

DoRequest send request to server.

func (*Config) ValidateAndSetup

func (c *Config) ValidateAndSetup() error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL