Documentation
¶
Overview ¶
Package resource holds what the commands managing schedules, services, profiles, templates and runs share: writing a document to a file or stdout, reading one back, and applying files with the new id written into them.
Index ¶
- Constants
- func ApplyFiles(paths []string, recursive bool, what string, ...) error
- func Body(value any) io.Reader
- func Confirmed(yes bool, question string) (bool, error)
- func CreatedOrUpdated(created bool) string
- func DecodeEach[T any](raw []json.RawMessage, into *[]T) error
- func DecodeListed(resp *http.Response, err error, field string, typed any) ([]json.RawMessage, error)
- func List(items []json.RawMessage, explicitType string, table func() error) error
- func Machine(explicitType string) bool
- func Optional(values []string) *[]string
- func Output(doc *output.Document, file, explicitType string) error
- func OutputValue(value *jsyaml.Map, file, explicitType string) error
- func PrintJSONValue(raw []byte, explicitType string) error
- func Read(file, what string) (*output.Document, output.Datatype, error)
- func Strip(doc *output.Document, fields ...string) *output.Document
- func Time(flag, value string) (*time.Time, error)
- func UUID(id string) (openapi_types.UUID, bool)
- func Variables(pairs []string, file string, replace bool) (*jsyaml.Map, error)
- func VariablesOutcome(replace bool) string
- type Applied
Constants ¶
const ListTypeHelp = `Print the platform's items as "json" or "yaml" instead of a table.`
ListTypeHelp describes the -t flag of listings.
Variables ¶
This section is empty.
Functions ¶
func ApplyFiles ¶
func ApplyFiles(paths []string, recursive bool, what string, upsert func(file string, doc *output.Document) (Applied, error)) error
ApplyFiles upserts every file. A file without an id gets the new one written into it, first, so the next apply updates what this one created instead of creating another.
func Confirmed ¶
Confirmed asks before something that cannot be undone, unless --yes was given. Without a terminal, as in a pipeline, it goes ahead, as `experiment run` does.
func CreatedOrUpdated ¶
func DecodeEach ¶
func DecodeEach[T any](raw []json.RawMessage, into *[]T) error
DecodeEach decodes raw items into typed ones, for the table.
func DecodeListed ¶
func DecodeListed(resp *http.Response, err error, field string, typed any) ([]json.RawMessage, error)
DecodeListed reads a listing response once: into typed, for the table, and as the raw items under field ("" for a response that is the array itself), for -t and --jq.
func List ¶
func List(items []json.RawMessage, explicitType string, table func() error) error
List prints items, the platform's objects as it sent them, as JSON or YAML, or hands over to table when a person is reading.
func Machine ¶
Machine reports whether a listing prints its items rather than a table: with -t, or when --jq filters them.
func Output ¶
Output writes to the file when one is given and to stdout otherwise, as JSON indented by two, or YAML.
func OutputValue ¶
OutputValue is Output for a value that is not an object, such as a map of variables.
func PrintJSONValue ¶
PrintJSONValue prints any JSON value as -t and --jq ask: through the jq expression, or as YAML, or as indented JSON.
func Strip ¶
Strip removes fields the platform reports but does not accept back, so that a file written by `get` can be applied again unchanged.
func UUID ¶
func UUID(id string) (openapi_types.UUID, bool)
UUID parses an id; a malformed one cannot name anything, so callers report it as not found.
func Variables ¶
Variables merges KEY=VALUE arguments, always strings, over a file's variables, which may be lists or select expressions. Nothing given is only allowed when replacing, where it removes every variable.