holos

package
v0.101.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const BuildFeature = feature("BUILD")
View Source
const ClientFeature = feature("CLIENT")
View Source
const DefaultProvisionerNamespace = "secrets"
View Source
const GenerateComponentFeature = feature("GENERATE_COMPONENT")
View Source
const PreflightFeature = feature("PREFLIGHT")
View Source
const SecretsFeature = feature("SECRETS")
View Source
const ServerFeature = feature("SERVER")

Variables

This section is empty.

Functions

func IsSelected added in v0.100.0

func IsSelected(labels Labels, selectors ...Selector) bool

IsSelected returns true if all selectors select the given labels or no selectors are given.

func RoundDuration added in v0.90.0

func RoundDuration(duration time.Duration) string

RoundDuration rounds a duration to the nearest unit based on its length.

Types

type BuildOpts added in v0.100.0

type BuildOpts struct {
	Store       artifact.Store
	Concurrency int
	Stderr      io.Writer
	WriteTo     string
	Path        string
	Tags        []string
}

BuildOpts represents options common across BuildPlan api versions. Use NewBuildOpts to create a new concrete value.

func NewBuildOpts added in v0.100.0

func NewBuildOpts(path string) BuildOpts

type BuildPlan added in v0.100.0

type BuildPlan interface {
	Load(cue.Value) error
	Build(context.Context) error
	Export(idx int, encoder OrderedEncoder) error
}

BuildPlan is the interface to load, build, and export a BuildPlan from a cue value.

type ClientConfig

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

ClientConfig configures the holos rpc client.

func NewClientConfig

func NewClientConfig() *ClientConfig

func (*ClientConfig) FlagSet

func (c *ClientConfig) FlagSet() *flag.FlagSet

func (*ClientConfig) Server

func (c *ClientConfig) Server() string

type ClientContext

type ClientContext struct {
	// OrgID is the organization id of the current context.
	OrgID string `json:"org_id"`
	// UserID is the user id of the current context.
	UserID string `json:"user_id"`
}

ClientContext represents the context the holos api is working in. Used to store and recall values from the filesystem.

func NewClientContext

func NewClientContext(ctx context.Context) *ClientContext

NewClientContext loads a ClientContext from the file system if it exists, otherwise returns a ClientContext with default values.

func (*ClientContext) Exists

func (cc *ClientContext) Exists() bool

Exists returns true if the client context file exists.

func (*ClientContext) Load

func (cc *ClientContext) Load(ctx context.Context) error

func (*ClientContext) Save

func (cc *ClientContext) Save(ctx context.Context) error

type Component added in v0.100.0

type Component interface {
	Describe() string
	Path() string
	Tags() ([]string, error)
	WriteTo() string
	Labels() Labels
}

Component represents the information needed to produce a BuildPlan from a platform component.

type Config

type Config struct {
	ClientConfig *ClientConfig
	ServerConfig *ServerConfig
	// contains filtered or unexported fields
}

Config holds configuration for the whole program, used by main(). The config should be initialized early at a well known location in the program lifecycle then remain immutable.

func New

func New(opts ...Option) *Config

New returns a new top level cli Config.

func (*Config) ClusterFlagSet

func (c *Config) ClusterFlagSet() *flag.FlagSet

ClusterFlagSet returns a *flag.FlagSet wired to c *Config. Useful for commands scoped to one cluster.

func (*Config) ClusterName

func (c *Config) ClusterName() string

ClusterName returns the cluster name configured by flags.

func (*Config) Finalize

func (c *Config) Finalize() error

Finalize validates the config and finalizes the startup lifecycle based on user configuration.

func (*Config) KVFlagSet

func (c *Config) KVFlagSet() *flag.FlagSet

KVFlagSet returns the *flag.FlagSet for kv related commands.

func (*Config) KVKubeconfig

func (c *Config) KVKubeconfig() string

KVKubeconfig returns the provisioner cluster kubeconfig path.

func (*Config) KVNamespace

func (c *Config) KVNamespace() string

KVNamespace returns the configured namespace to operate against in the provisioner cluster.

func (*Config) LogConfig added in v0.100.0

func (c *Config) LogConfig() *logger.Config

func (*Config) LogFlagSet

func (c *Config) LogFlagSet() *flag.FlagSet

LogFlagSet returns the logging *flag.FlagSet for use by the command handler.

func (*Config) Logger

func (c *Config) Logger() *slog.Logger

Logger returns a *slog.Logger configured by the user or the default logger if no logger has been configured by the user.

func (*Config) NewTopLevelLogger

func (c *Config) NewTopLevelLogger() *slog.Logger

NewTopLevelLogger returns a *slog.Logger with a handler that filters source attributes. Useful as a top level error logger in main().

func (*Config) Printf

func (c *Config) Printf(format string, a ...any)

Printf calls fmt.Fprintf with the configured Stdout. Errors are logged.

func (*Config) Println

func (c *Config) Println(a ...any)

Println calls fmt.Fprintln with the configured Stdout. Errors are logged.

func (*Config) ProvisionerClientset

func (c *Config) ProvisionerClientset() (kubernetes.Interface, error)

ProvisionerClientset returns a kubernetes client set for the provisioner cluster.

func (*Config) ServerFlagSet

func (c *Config) ServerFlagSet() *flag.FlagSet

func (*Config) Stderr

func (c *Config) Stderr() io.Writer

Stderr should be used instead of os.Stderr to capture output for tests.

func (*Config) Stdin

func (c *Config) Stdin() io.Reader

Stdin should be used instead of os.Stdin to capture input from tests.

func (*Config) Stdout

func (c *Config) Stdout() io.Writer

Stdout should be used instead of os.Stdout to capture output for tests.

func (*Config) TxtarFlagSet

func (c *Config) TxtarFlagSet() *flag.FlagSet

TxtarFlagSet returns the *flag.FlagSet for txtar related commands.

func (*Config) TxtarIndex

func (c *Config) TxtarIndex() int

TxtarIndex returns the

func (*Config) TxtarQuote added in v0.98.0

func (c *Config) TxtarQuote() bool

func (*Config) Vet

func (c *Config) Vet() error

Vet validates the config.

func (*Config) Write

func (c *Config) Write(p []byte)

Write writes to Stdout. Errors are logged.

func (*Config) WriteFlagSet

func (c *Config) WriteFlagSet() *flag.FlagSet

WriteFlagSet returns a *flag.FlagSet wired to c *Config. Useful for commands that write files.

func (*Config) WriteTo

func (c *Config) WriteTo() string

WriteTo returns the write to path configured by flags.

type Encoder added in v0.100.0

type Encoder interface {
	Encode(any) error
	Close() error
}

Encoder encodes to json or yaml. Concrete values must be safe for concurrent execution. Use NewEncoder to obtain a json or yaml encoder.

func NewEncoder added in v0.100.0

func NewEncoder(format string, w io.Writer) (Encoder, error)

NewEncoder returns a yaml or json encoder that writes to w.

type EnvFlagger added in v0.97.2

type EnvFlagger struct{}

func (*EnvFlagger) Flag added in v0.97.2

func (e *EnvFlagger) Flag(name feature) bool

Flag returns true if feature name is enabled.

type Flagger added in v0.97.2

type Flagger interface {
	Flag(name feature) bool
}

Flagger is the interface to check if an experimental feature is enabled.

type Labels added in v0.100.0

type Labels map[string]string

type Option

type Option func(o *options)

An Option configures a Config using [functional options](https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html).

func ClusterClientset

func ClusterClientset(clientset *kubernetes.Clientset) Option

ClusterClientset sets the kubernetes Clientset, useful for test fake.

func Logger

func Logger(logger *slog.Logger) Option

func ProvisionerClientset

func ProvisionerClientset(clientset kubernetes.Interface) Option

ProvisionerClientset sets the kubernetes Clientset, useful for test fake.

func Stderr

func Stderr(w io.Writer) Option

Stderr redirects standard error to w, useful for test capture.

func Stdin

func Stdin(r io.Reader) Option

Stdin redirects standard input to r, useful for test capture.

func Stdout

func Stdout(w io.Writer) Option

Stdout redirects standard output to w, useful for test capture.

type OrderedEncoder added in v0.100.0

type OrderedEncoder interface {
	Encode(idx int, v any) error
	Close() error
}

OrderedEncoder encodes in sequential order from idx 0. Concrete values must be safe for concurrent execution. Use NewSequentialEncoder to obtain a json or yaml encoder.

func NewSequentialEncoder added in v0.100.0

func NewSequentialEncoder(format string, w io.Writer) (OrderedEncoder, error)

type Platform added in v0.100.0

type Platform interface {
	Load(cue.Value) error
	Select(...Selector) []Component
	Export(Encoder) error
}

Platform is the interface all Platform versions must support.

Concrete values must preserve the relative ordering of components when filtering with Select.

type Selector added in v0.100.0

type Selector struct {
	Positive map[string]string
	Negative map[string]string
}

func (*Selector) IsSelected added in v0.100.0

func (s *Selector) IsSelected(labels Labels) bool

IsSelected returns true when the selector selects the given labels

func (*Selector) Set added in v0.100.0

func (s *Selector) Set(value string) error

func (*Selector) String added in v0.100.0

func (s *Selector) String() string

func (*Selector) Type added in v0.100.0

func (s *Selector) Type() string

type ServerConfig

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

func (*ServerConfig) AuthHeader

func (c *ServerConfig) AuthHeader() string

func (*ServerConfig) DatabaseURI

func (c *ServerConfig) DatabaseURI() string

DatabaseURI represents the database connection uri.

func (*ServerConfig) FlagSet

func (c *ServerConfig) FlagSet() *flag.FlagSet

func (*ServerConfig) ListenAndServe

func (c *ServerConfig) ListenAndServe() bool

ListenAndServe returns true if the server should listen for and serve requests.

func (*ServerConfig) ListenPort

func (c *ServerConfig) ListenPort() int

ListenPort returns the port of the main server.

func (*ServerConfig) MetricsPort

func (c *ServerConfig) MetricsPort() int

MetricsPort returns the port of the prometheus /metrics scrape endpoint configured by a flag.

func (*ServerConfig) OIDCAudiences

func (c *ServerConfig) OIDCAudiences() []string

OIDCAudiences returns the configured allowed id token aud claim values.

func (*ServerConfig) OIDCIssuer

func (c *ServerConfig) OIDCIssuer() string

OIDCIssuer returns the configured oidc issuer url.

type StringSlice

type StringSlice []string

StringSlice represents zero or more flag values.

func (*StringSlice) Set

func (i *StringSlice) Set(value string) error

Set implements the flag.Value interface.

func (*StringSlice) String

func (i *StringSlice) String() string

String implements the flag.Value interface.

func (*StringSlice) Type

func (i *StringSlice) Type() string

Type implements the pflag.Value interface and describes the type.

type TagMap added in v0.100.0

type TagMap map[string]*string

TagMap represents a map of key values for CUE TagMap for flag parsing. The values are pointers to disambiguate between the case where a tag is a boolean ("--inject foo") and the case where a tag has a string zero value ("--inject foo="). Refer to the Tags field of cue/load.Config

func (TagMap) Set added in v0.100.0

func (t TagMap) Set(value string) error

Set sets a value. Only one value per flag is supported. For example --inject=foo=bar --inject=bar=baz. For JSON values, --inject=foo=bar,bar=baz is not supported.

func (TagMap) String added in v0.100.0

func (t TagMap) String() string

func (TagMap) Tags added in v0.100.0

func (t TagMap) Tags() []string

func (TagMap) Type added in v0.100.0

func (t TagMap) Type() string

type TypeMeta added in v0.100.0

type TypeMeta struct {
	Kind       string `json:"kind,omitempty" yaml:"kind,omitempty"`
	APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
}

TypeMeta represents the kind and version of a resource holos needs to process. Useful to discriminate generated resources.

Jump to

Keyboard shortcuts

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