holos

package
v0.106.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const BuildPlanRequest string = "BuildPlanRequest"

BuildPlanRequest represents the kind value of a BuildPlanRequest

View Source
const BuildPlanResponse string = "BuildPlanResponse"

BuildPlanResponse represents the kind value of a BuildPlanResponse

View Source
const DefaultProvisionerNamespace = "secrets"
View Source
const TagMapHelp = "set the value of a cue @tag field in the form key=value or simply key"
View Source
const TypeMetaFile string = "typemeta.yaml"

TypeMetaFile represents the file holos uses to discriminate the api version of a component BuildPlan.

View Source
const WriteToDefault string = "deploy"

WriteToDefault represents the default value of the --write-to flag which is the base directory where holos render component writes rendered configuration into.

View Source
const WriteToEnvVar string = "HOLOS_WRITE_TO"

WriteToEnvVar represents the environment variable used to look up the default value of the --write-to flag.

Variables

This section is empty.

Functions

func IsSelected added in v0.100.0

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

IsSelected returns true if any one selector selects 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 BuildContext added in v0.104.2

type BuildContext struct {
	// TempDir represents the temporary directory managed and owned by the holos
	// render component command for the execution of one BuildPlan.  Multiple
	// tasks in the build plan share this temporary directory and therefore should
	// avoid reading and writing into the same sub-directories as one another.
	TempDir string `json:"tempDir" yaml:"tempDir"`
}

BuildContext represents build context values provided by the holos render component command. These values are expected to be randomly generated and late binding, meaning they cannot be known ahead of time in a static configuration. As such, CUE configuration may refer to the values here which will be populated by holos when the final build plan is exported from CUE.

type BuildOpts added in v0.100.0

type BuildOpts struct {
	Store       artifact.Store
	Concurrency int
	Stderr      io.Writer
	WriteTo     string
	// Path represents the component path relative to the platform module root.
	Path string
	// Tags represents user managed tags including a component name, labels, and
	// annotations.
	Tags []string
	// contains filtered or unexported fields
}

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(root, leaf, writeTo, tempDir string) BuildOpts

NewBuildOpts returns a BuildOpts configured to build the component at leaf from the platform module at root writing rendered manifests into the deploy directory.

func (*BuildOpts) AbsLeaf added in v0.104.2

func (b *BuildOpts) AbsLeaf() string

AbsLeaf returns the absolute cleaned component path.

func (*BuildOpts) AbsWriteTo added in v0.104.2

func (b *BuildOpts) AbsWriteTo() string

AbsWriteTo returns the absolute path to the write to directory, usually the deploy sub directory of the platform module root.

func (*BuildOpts) Leaf added in v0.104.2

func (b *BuildOpts) Leaf() string

Leaf returns the cleaned component path relative to the platform root. For example "components/podinfo"

func (*BuildOpts) Root added in v0.104.2

func (b *BuildOpts) Root() string

Root returns the platform root directory containing the cue module.

func (*BuildOpts) TempDir added in v0.104.2

func (b *BuildOpts) TempDir() string

TempDir returns the temporary directory managed by holos and injected into cue using a BuildContext so artifacts can refer to the same path in the configuration.

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 Component added in v0.100.0

type Component interface {
	// Describe represents a description of the component for user feedback.
	Describe() string
	// Path represents the component path relative to the platform root.
	Path() string
	// Tags represents the Component name, labels, annotations injected into cue
	// for BuildPlan export.
	Tags() ([]string, error)
}

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

type Config

type Config struct {
	// 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) Finalize

func (c *Config) Finalize() error

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

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) 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. The format argument specifies "yaml" or "json" format output.

type Exporter added in v0.104.2

type Exporter interface {
	Export(Encoder) error
}

Exporter is the interface used to export Platform, Component, and BuildPlan resources. Useful for the show subcommand.

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 Logger

func Logger(logger *slog.Logger) Option

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(encoding string, w io.Writer) (OrderedEncoder, error)

NewSequentialEncoder returns a yaml or json encoder that writes to w. The encoding argument may be "json" or "yaml".

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 Selectors added in v0.102.4

type Selectors []Selector

func (*Selectors) Set added in v0.102.4

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

Set implements the flag.Value interface.

func (*Selectors) String added in v0.102.4

func (s *Selectors) String() string

String implements the flag.Value interface.

func (*Selectors) Type added in v0.102.4

func (s *Selectors) Type() string

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

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 {
	APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
	Kind       string `json:"kind,omitempty" yaml:"kind,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