holos

package
v0.97.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultProvisionerNamespace = "secrets"

Variables

This section is empty.

Functions

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

Jump to

Keyboard shortcuts

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