Documentation
¶
Overview ¶
Package managerkit holds what manager tools -- command-line tools that each manage one concern across a fleet, such as namespaces, scheduling or autoscaling -- agree on. Its subpackages are the shared parts of such a tool: guardrails installs a policy pack, profiles a library of reusable edits, and write reports what a mutating command did.
Reading a fleet is github.com/confighub/sdk/core/cubapi (SnapshotLoader, MemoizedClient), and the generic command-line surface is github.com/confighub/sdk/cliutil (QueryFlags and its Space-label shorthands, the output and table helpers). What is here is a convention of manager tools rather than a ConfigHub primitive.
Index ¶
Constants ¶
const ( OutputJSON = "json" OutputTable = "table" )
Output formats. JSON is the default so that the tools compose; a table is for a human reading one answer.
A command does not compare against these: Render decides, and a command only renders its table when Render declines. They are here because the flag's default is one of them.
const CommonSpace = "common"
CommonSpace is the Space manager tools put whatever an organization keeps in common: the guardrail Triggers, the profile library, the Attributes a validating function reads.
One Space rather than one per tool. A Space selects guardrails with one WhereTrigger naming one policy Space and the groups it has opted into, so per-tool policy Spaces could not be combined in it. Profiles have no such constraint, but an operator should still have one place to look rather than one per tool they happen to have installed.
Every command that writes here takes a flag to put it elsewhere.
Variables ¶
This section is empty.
Functions ¶
func AddOutputFlag ¶
AddOutputFlag registers the -o/--output flag every command in a manager tool has.
The default is JSON rather than a table, which is the opposite of what a person at a terminal usually wants. Manager tools are meant to be read by an agent as often as by a person, and an agent that has to parse a table is an agent that will eventually parse it wrong.
func BindComponentResolver ¶ added in v0.10.3
func BindComponentResolver(cmd *cobra.Command, q *cliutil.QueryFlags, preflight func(context.Context) (*cubapi.Client, error))
BindComponentResolver lets --component on q name a Component by slug as well as by ID. QueryFlags cannot look a slug up on its own, having no client, so this resolves it with the client preflight returns when the command runs.
func ProgressWriter ¶
ProgressWriter is where a command writes the lines it prints while it works: stdout under a table, which is text throughout, and stderr under every format Render writes, whose stdout has to hold the value alone for it to parse.
func Render ¶
Render writes v in the format output names, reporting whether it did.
It handles every format that is a projection of the value itself: json, yaml, and the jq and yq expressions, which walk what the JSON is built from. It returns false for a table, which only the command can render -- a table's columns are a decision about what matters, not something derivable from the value.
So the calling convention is: ask Render first, and render the table only if it declined.
if done, err := managerkit.Render(out, output, report); done || err != nil {
return err
}
printTable(cmd, report)
return nil
name, wide and custom-columns are refused. cliutil parses them and can render them over an entity with named columns, but these commands report their own models rather than entities, and no command here has named columns for one.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package configmaps defines the configmaps pack: the Mutation Triggers that keep the hashes that roll a workload when a ConfigMap it uses changes, and that bound how many immutable ConfigMaps render-configmap leaves behind.
|
Package configmaps defines the configmaps pack: the Mutation Triggers that keep the hashes that roll a workload when a ConfigMap it uses changes, and that bound how many immutable ConfigMaps render-configmap leaves behind. |
|
Package guardrails installs and inspects a tool's policy pack: a group of validating Triggers defined once in a policy Space and selected by the WhereTrigger of each Space, and Target, that opts into the group.
|
Package guardrails installs and inspects a tool's policy pack: a group of validating Triggers defined once in a policy Space and selected by the WhereTrigger of each Space, and Target, that opts into the group. |
|
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.
|
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. |
|
Package write is the surface the mutating commands of manager tools share: naming the Unit to write to, saying whether this is a dry run, and reporting what a function invocation did -- including, path by path, what it changed or on a dry run would change, so a reader can judge a change before committing it.
|
Package write is the surface the mutating commands of manager tools share: naming the Unit to write to, saying whether this is a dry run, and reporting what a function invocation did -- including, path by path, what it changed or on a dry run would change, so a reader can judge a change before committing it. |