profiles

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package profiles is the profile library manager tools share: named, reusable edits stored as ConfigHub Invocations, applied to one Unit or to a selector of them.

A profile bundles a function with preset arguments -- a resource tier, a hardening pass, a spread rule, an autoscaling target -- and exposes whatever has to vary as a parameter the caller supplies at apply time. What differs between tools is only which profiles are seeded and what the help text calls them; the Space, the Invocations, the parameter binding, and the three commands are the same each time.

Index

Constants

View Source
const DescriptionAnnotation = "Description"

DescriptionAnnotation is where a profile's human description is kept: a stored Invocation has no description field.

One key for every tool, not one per tool. The library Space is shared -- that is the point of one place to look -- so a per-tool key would mean each tool listing every profile it did not install with a blank description, and nothing about a description is tool-specific enough to earn that.

Variables

This section is empty.

Functions

func Arg

func Arg(fnParam string, value any) api.FunctionArgument

Arg is a function argument with a fixed value.

func ParseParams

func ParseParams(params []string) (map[string]any, error)

ParseParams turns --param name=value flags into the map a stored Invocation is applied with.

func TmplArg

func TmplArg(fnParam, profileParam string) api.FunctionArgument

TmplArg binds a function parameter to a profile parameter through a Go-template ref, so the value is substituted when the profile is applied.

func YQParamArg

func YQParamArg(name string) api.FunctionArgument

YQParamArg binds set-yq's `param` varArg to a profile parameter, so the yq expression can read $params.<name>. set-yq takes its parameters this way rather than as named arguments, so TmplArg does not apply to it.

Types

type FleetEdit

type FleetEdit struct {
	// WhereData scopes the edit to the resource kinds a profile can act on, so a
	// profile never reaches a Unit it has nothing to say about. Required.
	WhereData string
	// Scope names those kinds in the help text, e.g.
	// "HorizontalPodAutoscaler / ScaledObject Units".
	Scope string
	// Example is one worked invocation for the help text, without the command
	// name. Optional.
	Example string
}

FleetEdit is the bulk half: one profile applied to every Unit a selector matches, in one server-side operation.

type Library

type Library struct {
	// Tool is the tool's name, e.g. "cub-manage". It becomes the
	// profiles Space's `app` label.
	Tool string
	// Noun is what this tool calls a profile in help text: "autoscaling
	// profile", "placement profile", or just "profile".
	Noun string
	// Target names what `apply` writes to, with its article: "an HPA Unit",
	// "a workload".
	Target string
	// ParamExample is a worked --param for the apply help, e.g.
	// "--param min=3 --param max=10 for hpa-range". Optional.
	ParamExample string

	// Profiles are what `profile install` seeds.
	Profiles []Spec

	// Preflight verifies the tool's ConfigHub session and returns the client.
	Preflight func(context.Context) (*cubapi.Client, error)
	// InvocationName is how the tool is spelled in help text, e.g.
	// "cub-manage", or "cub manage" when run as a plugin.
	InvocationName func() string

	// FleetEdit configures the bulk command. Leave WhereData empty to omit the
	// command entirely.
	FleetEdit FleetEdit
}

Library is one tool's profile library.

func (Library) Command

func (l Library) Command() *cobra.Command

Command is the `profile` command group: install, list, apply.

func (Library) FleetEditCommand

func (l Library) FleetEditCommand() *cobra.Command

FleetEditCommand is `fleet-edit`: one profile applied to every Unit a selector matches, in one server-side operation -- the bulk analog of `profile apply`.

type Param

type Param struct {
	// Name is the parameter's own name. It has to be an identifier
	// (^[A-Za-z_][A-Za-z0-9_]*$), which is why a profile parameter binding a
	// function's kebab-case argument is named differently from it.
	Name string
	// DataType defaults to "string".
	DataType string
}

Param declares one profile parameter the caller supplies at apply time.

type Spec

type Spec struct {
	Slug        string
	Description string
	Function    string
	Args        []api.FunctionArgument
	Params      []Param
	// WhereResource restricts the profile to the resources it selects, e.g.
	// "ConfigHub.ResourceType = 'apps/v1/Deployment'". A Unit can hold several
	// resources, and a function runs on every one unless told otherwise, so a
	// profile that edits one kind should name it. It is stored with the profile,
	// so it holds however the profile is invoked.
	WhereResource string
}

Spec is one profile: a function, its fixed arguments, and the parameters left for the caller.

Jump to

Keyboard shortcuts

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