Documentation
¶
Overview ¶
Package function resolves published CircleCI functions.
Index ¶
- Constants
- Variables
- func AddPin(configPath, alias string, ref Reference) error
- func AliasFor(functionPath string) string
- func CheckAdd(configPath, alias string) error
- func Conflicts(configPath, alias string) (string, error)
- func ExampleStep(content map[string]any, alias string) string
- func ExpandName(arg string) (string, error)
- func UpdatePin(configPath, alias string, ref Reference) error
- func ValidateAlias(alias string) error
- func ValidatePath(path string) error
- func ValidateVersion(version string) error
- type Flag
- type Pin
- type Reference
Constants ¶
const DefaultOrg = "github.com/circleci-functions"
DefaultOrg is the path CircleCI publishes its own functions under. A bare function name is resolved against it.
Variables ¶
var ErrNotPinned = errors.New("function not declared")
ErrNotPinned is returned when an alias has no entry in the functions: block.
Functions ¶
func AddPin ¶
AddPin adds alias → ref to the functions: block, creating the block when the config has none. It fails if alias is already declared.
func Conflicts ¶
Conflicts reports what else in the config already claims alias: "orb", "command", or "" when nothing does.
Built-in step names are not checked. They are not in the file being read, and a copy of that list here would drift from the one config validation enforces, so a clash with a built-in stays its job to report.
func ExampleStep ¶ added in v1.3.0
ExampleStep returns the step from a descriptor's example config, keyed by alias instead of the function's own name. An example is rendered when the function is released, so one that is missing or shaped unexpectedly yields "" rather than an error.
func ExpandName ¶
ExpandName resolves a user-supplied function name to the identifier the API lists it under. A bare name expands against DefaultOrg; anything carrying a path is validated and used verbatim.
func UpdatePin ¶
UpdatePin replaces the reference alias is declared as, in place, so the entry keeps its position and any comment attached to it.
func ValidateAlias ¶
ValidateAlias reports whether alias can key an entry in the functions: block. A '/' is rejected because the config reads it as naming one of the function's commands.
func ValidatePath ¶
ValidatePath reports whether path is a function path the config accepts.
func ValidateVersion ¶
ValidateVersion reports whether version is a version the config accepts.
Types ¶
type Flag ¶
type Flag struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Default string `json:"default,omitempty"`
Description string `json:"description,omitempty"`
}
Flag is one argument a function accepts, read out of a published descriptor.
type Pin ¶
type Pin struct {
Alias string `json:"alias"`
Function string `json:"function"`
Version string `json:"version"`
}
Pin is one entry in the functions: block. Alias is the key, and the name a step uses to invoke the function.