function

package
v1.0.52172 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package function resolves published CircleCI functions.

Index

Constants

View Source
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

View Source
var ErrNotPinned = errors.New("function not declared")

ErrNotPinned is returned when an alias has no entry in the functions: block.

Functions

func AddPin

func AddPin(configPath, alias string, ref Reference) error

AddPin adds alias → ref to the functions: block, creating the block when the config has none. It fails if alias is already declared.

func AliasFor

func AliasFor(functionPath string) string

AliasFor is the default alias for a function path: its last segment.

func CheckAdd

func CheckAdd(configPath, alias string) error

CheckAdd reports whether AddPin could add alias, without writing anything.

func Conflicts

func Conflicts(configPath, alias string) (string, error)

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 ExpandName

func ExpandName(arg string) (string, error)

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

func UpdatePin(configPath, alias string, ref Reference) error

UpdatePin replaces the reference alias is declared as, in place, so the entry keeps its position and any comment attached to it.

func ValidateAlias

func ValidateAlias(alias string) error

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

func ValidatePath(path string) error

ValidatePath reports whether path is a function path the config accepts.

func ValidateVersion

func ValidateVersion(version string) error

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.

func Flags

func Flags(content map[string]any) []Flag

Flags reads the arguments a function accepts. A descriptor is served exactly as published and its shape can differ between versions, so a missing or unexpectedly typed field degrades to a thinner result rather than an error.

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.

func FindPin

func FindPin(configPath, alias string) (Pin, error)

FindPin returns the pin for alias, or ErrNotPinned.

func ListPins

func ListPins(configPath string) ([]Pin, error)

ListPins returns every entry in the functions: block, in config order.

A functions: key that is not a map of declarations yields nothing rather than an error, so a config using the name to hold YAML anchors keeps working.

type Reference

type Reference struct {
	Path    string
	Version string
}

Reference is a pinned function reference as the config records it.

func (Reference) String

func (r Reference) String() string

Jump to

Keyboard shortcuts

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