config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupportedConfigFileFormat is returned when the config file format
	// is not supported by the provider.
	ErrUnsupportedConfigFileFormat = errors.New("unsupported config file format, only yaml, json and toml are supported")
)

Functions

This section is empty.

Types

type BluelinkSignatureV1Config

type BluelinkSignatureV1Config struct {
	KeyPair       BluelinkSignatureV1KeyPair `json:"keyPair"`
	CustomHeaders []string                   `json:"customHeaders"`
}

BluelinkSignatureV1Config is the configuration for the Bluelink Signature v1 authentication.

type BluelinkSignatureV1KeyPair

type BluelinkSignatureV1KeyPair struct {
	KeyID     string `json:"keyId"`
	SecretKey string `json:"secretKey"`
}

BluelinkSignatureV1KeyPair is the key pair for the Bluelink Signature v1 authentication.

type EngineAuthConfig

type EngineAuthConfig struct {
	Method              string                     `json:"method"`
	APIKey              string                     `json:"apiKey"`
	OAuth2              *OAuth2Config              `json:"oauth2"`
	BluelinkSignatureV1 *BluelinkSignatureV1Config `json:"bluelinkSignatureV1"`
}

EngineAuthConfig is the configuration for the deploy engine authentication.

func LoadEngineAuthConfig

func LoadEngineAuthConfig(confProvider *Provider) (*EngineAuthConfig, error)

LoadEngineAuthConfig loads the engine authentication configuration from an auth config file.

type OAuth2Config

type OAuth2Config struct {
	// ClientID is used as a part of the client credentials grant type
	// to obtain an access token from the OAuth2 or OIDC provider.
	ClientID string `json:"clientId"`
	// ClientSecret is used as a part of the client credentials grant type
	// to obtain an access token from the OAuth2 or OIDC provider.
	ClientSecret string `json:"clientSecret"`
	// ProviderBaseURL is the base URL of the OAuth2 or OIDC provider.
	// This is the URL from which the client will use to obtain
	// the discovery document for the provider at either `/.well-known/openid-configuration`
	// or `/.well-known/oauth-authorization-server`.
	// When TokenEndpoint is set, this value is ignored.
	ProviderBaseURL string `json:"providerBaseURL"`
	// TokenEndpoint is the fully qualified URL of the token endpoint to use to obtain
	// an access token from the OAuth2 or OIDC provider.
	// When this value is left empty, the client will attempt to obtain the discovery document
	// from the ProviderBaseURL and use the token endpoint from that document.
	TokenEndpoint string `json:"tokenEndpoint"`
}

OAuth2Config is the configuration for the OAuth2 authentication.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is a simple config provider for the CLI that can fall back to a config file or environment variables. This is an alternative approach to using the viper library that was a pain to integrate with cobra in providing config file and env var defaults across multiple levels of subcommands.

The precendence of config values is as follows: 1. Flags 2. Environment variables 3. Config file 4. Flag defaults 5. Config provider defaults

Provider only supports strings, booleans, integers and floats as configuration values. Complex types such as arrays, structs and maps are not supported.

YAML, JSON and TOML are supported as config file formats.

func NewProvider

func NewProvider() *Provider

NewProvider creates a new Provider of configuration values for the CLI.

func (*Provider) BindEnvVar

func (p *Provider) BindEnvVar(configName string, envVarName string)

func (*Provider) BindPFlag

func (p *Provider) BindPFlag(configName string, flag *pflag.Flag)

func (*Provider) GetBool

func (p *Provider) GetBool(configName string) (bool, bool)

func (*Provider) GetFloat32

func (p *Provider) GetFloat32(configName string) (float32, bool)

func (*Provider) GetFloat64

func (p *Provider) GetFloat64(configName string) (float64, bool)

func (*Provider) GetInt32

func (p *Provider) GetInt32(configName string) (int32, bool)

func (*Provider) GetInt64

func (p *Provider) GetInt64(configName string) (int64, bool)

func (*Provider) GetString

func (p *Provider) GetString(configName string) (string, bool)

GetString returns the value of a configuration value as a string. It also returns a boolean indicating whether the value was set by the user or if it's a default value. `true` means the value is a default value.

func (*Provider) GetUint32

func (p *Provider) GetUint32(configName string) (uint32, bool)

func (*Provider) GetUint64

func (p *Provider) GetUint64(configName string) (uint64, bool)

func (*Provider) LoadConfigFile

func (p *Provider) LoadConfigFile(configFilePath string) error

func (*Provider) SetDefault

func (p *Provider) SetDefault(configName, value string)

Jump to

Keyboard shortcuts

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