config

package
v1.2.113 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultSourceKind = SourceKind("default")
	EnvSourceKind     = SourceKind("env")
	FileSourceKind    = SourceKind("file")
	ArgSourceKind     = SourceKind("arg")
	TokenSourceKind   = SourceKind("service")
	EmptySourceKind   = SourceKind("empty")
)

Functions

func ContextWithEnvironmentGetter

func ContextWithEnvironmentGetter(ctx context.Context, getter EnvironmentGetter) context.Context

Types

type ClientId

type ClientId string

type ClientSecret

type ClientSecret string

type DefaultEnvironmentGetter

type DefaultEnvironmentGetter struct {
	EnvironmentGetter
}

func (DefaultEnvironmentGetter) Abs

func (DefaultEnvironmentGetter) Getenv

func (d DefaultEnvironmentGetter) Getenv(key string) string

func (DefaultEnvironmentGetter) Getwd

func (d DefaultEnvironmentGetter) Getwd() (string, error)

type DirectoryOverrideEnvironmentGetter

type DirectoryOverrideEnvironmentGetter struct {
	EnvironmentGetter
	// contains filtered or unexported fields
}

DirectoryOverrideEnvironmentGetter wraps another EnvironmentGetter but overrides the working directory

func NewDirectoryOverrideEnvironmentGetter

func NewDirectoryOverrideEnvironmentGetter(base EnvironmentGetter, dir string) *DirectoryOverrideEnvironmentGetter

func (*DirectoryOverrideEnvironmentGetter) Abs

func (*DirectoryOverrideEnvironmentGetter) Getenv

func (*DirectoryOverrideEnvironmentGetter) Getwd

type EnvironmentGetter

type EnvironmentGetter interface {
	Getenv(key string) string
	Getwd() (string, error)
	Abs(path string) (string, error)
}

EnvironmentGetter is an interface for getting environment variables and the current working directory. This can help with testing by making otherwise impure functions pure.

func EnvironmentGetterFromContext

func EnvironmentGetterFromContext(ctx context.Context) EnvironmentGetter

type EnvironmentId added in v1.2.97

type EnvironmentId string

type EnvironmentSettings added in v1.2.105

type EnvironmentSettings struct {
	Runtime         *string `json:"runtime,omitempty" yaml:"runtime,omitempty"`
	PlatformVersion *string `json:"platform_version,omitempty" yaml:"platform_version,omitempty"`
	Requirements    *string `json:"requirements,omitempty" yaml:"requirements,omitempty"`
	Dockerfile      *string `json:"dockerfile,omitempty" yaml:"dockerfile,omitempty"`
}

func (*EnvironmentSettings) ToProto added in v1.2.105

type JWT

type JWT struct {
	Token      string    `yaml:"value"`
	ValidUntil time.Time `yaml:"validUntil"`
}

type Manager

type Manager struct {
	ClientId      SourcedConfig[ClientId]
	ClientSecret  SourcedConfig[ClientSecret]
	EnvironmentId SourcedConfig[string]
	Scope         SourcedConfig[string]
	// contains filtered or unexported fields
}

func NewManager

func NewManager(ctx context.Context, inputs *ManagerInputs) (*Manager, error)

func (*Manager) GetAPIServer added in v1.2.104

func (m *Manager) GetAPIServer() SourcedConfig[string]

func (*Manager) GetGRPCQueryServer added in v1.2.104

func (m *Manager) GetGRPCQueryServer() SourcedConfig[string]

func (*Manager) GetJSONQueryServer added in v1.2.104

func (m *Manager) GetJSONQueryServer() SourcedConfig[string]

func (*Manager) SetAPIServer added in v1.2.104

func (m *Manager) SetAPIServer(server SourcedConfig[string])

func (*Manager) SetGRPCQueryServer added in v1.2.104

func (m *Manager) SetGRPCQueryServer(server SourcedConfig[string])

func (*Manager) SetJSONQueryServer added in v1.2.104

func (m *Manager) SetJSONQueryServer(server SourcedConfig[string])

type ManagerInputs added in v1.2.97

type ManagerInputs struct {
	APIServer       string
	GRPCQueryServer string
	JSONQueryServer string
	ClientId        ClientId
	ClientSecret    ClientSecret
	EnvironmentId   string
	Scope           string
	ConfigDir       *string
}

type MapEnvironmentGetter

type MapEnvironmentGetter struct {
	EnvironmentGetter
	Env map[string]string
	Wd  string
}

func NewMockEnvironmentGetter

func NewMockEnvironmentGetter(
	env map[string]string,
	wd string,
) *MapEnvironmentGetter

func (MapEnvironmentGetter) Abs

func (m MapEnvironmentGetter) Abs(path string) (string, error)

func (MapEnvironmentGetter) Getenv

func (m MapEnvironmentGetter) Getenv(key string) string

func (MapEnvironmentGetter) Getwd

func (m MapEnvironmentGetter) Getwd() (string, error)

type ProjectSettings added in v1.2.105

type ProjectSettings struct {
	Project        string                          `json:"project" yaml:"project"`
	Environments   map[string]*EnvironmentSettings `json:"environments" yaml:"environments"`
	LocalDirectory string                          `json:"localDirectory" yaml:"localDirectory,omitempty"`
	ChalkIgnore    *string                         `json:"chalkIgnore,omitempty" yaml:"chalkIgnore,omitempty"`
	Filename       string                          `yaml:"filename,omitempty"`
}

func (*ProjectSettings) ToProto added in v1.2.105

func (settings *ProjectSettings) ToProto() *artifactsv1.ProjectSettings

type ProjectToken

type ProjectToken struct {
	Name              string       `yaml:"name"`
	ClientId          ClientId     `yaml:"clientId"`
	ClientSecret      ClientSecret `yaml:"clientSecret"`
	ValidUntil        string       `yaml:"validUntil"`
	ApiServer         string       `yaml:"apiServer"`
	ActiveEnvironment string       `yaml:"activeEnvironment"`
	JWT               JWT          `yaml:"jwt,omitempty"`
}

func GetProjectAuthConfig

func GetProjectAuthConfig(ctx context.Context, configDir *string) (*ProjectToken, string, error)

type ProjectTokens

type ProjectTokens struct {
	Tokens map[string]*ProjectToken `yaml:"tokens,omitempty"`
}

type SourceKind added in v1.2.97

type SourceKind string

type SourcedConfig

type SourcedConfig[T SourcedValueT] struct {
	Value  T
	Source string
	Kind   SourceKind
}

SourcedConfig represents a configuration value along with information about where it came from

func AddScheme added in v1.2.104

func GetFirstNonEmpty

func GetFirstNonEmpty[T SourcedValueT](configs ...SourcedConfig[T]) SourcedConfig[T]

GetFirstNonEmpty returns the first non-empty SourcedConfig from the provided list using the provided zero-check function

func NewFromArg

func NewFromArg[T SourcedValueT](value T) SourcedConfig[T]

NewFromArg creates a SourcedConfig from a direct argument

func NewFromDefault added in v1.2.97

func NewFromDefault[T SourcedValueT](value T, desc string) SourcedConfig[T]

func NewFromEnvVar

func NewFromEnvVar[T ~string](ctx context.Context, key string) SourcedConfig[T]

func NewFromFile

func NewFromFile[T SourcedValueT](path string, value T) SourcedConfig[T]

NewFromFile creates a SourcedConfig from a config file

func NewFromToken added in v1.2.97

func NewFromToken[T SourcedValueT](value T, description string) SourcedConfig[T]

func (SourcedConfig[T]) WithSource added in v1.2.97

func (c SourcedConfig[T]) WithSource(source string) SourcedConfig[T]

func (SourcedConfig[T]) WithSourceF added in v1.2.97

func (c SourcedConfig[T]) WithSourceF(source string, args ...any) SourcedConfig[T]

func (SourcedConfig[T]) WithValue added in v1.2.97

func (c SourcedConfig[T]) WithValue(value T) SourcedConfig[T]

type SourcedValueT

type SourcedValueT interface {
	~int | ~int64 | ~float32 | ~float64 | ~string
}

Jump to

Keyboard shortcuts

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