Documentation
¶
Overview ¶
Package function holds helpers shared across the builtin function implementations: GitLab client construction and the ErrNotFound sentinel (for gitlab_project.* Functions), the VersionedFile/CommitAction commit-IO types and files-input reader (for the manifest.* Functions), and JSONL output writing (for all).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when the project, ref, or file cannot be resolved. Callers should match with errors.Is.
Functions ¶
func ClusterConfig ¶
func ClusterConfig(newRoundTripper apifunc.K8sRoundTripperFactory, agentID string) (*rest.Config, error)
ClusterConfig builds a rest.Config for the cluster behind agentID, with the injected K8sRoundTripperFactory as its transport — the shared agent_id↔cluster routing seam the cluster-touching Functions build their clients on.
agent_id arrives as a string (Starlark has no int64) and is parsed only here. A nil factory errors rather than panicking, so a module built without one fails gracefully if invoked.
func NewGitlabClient ¶
NewGitlabClient builds a GitLab API client for the given host. With a non-empty token, requests authenticate via the Private-Token header. With an empty token, the client uses the upstream Unauthenticated source — fine for public reads, will fail for any write.
func WriteOutputs ¶
WriteOutputs writes a JSONL output file in the format step-runner expects: one `{"name": "...", "value": ...}` line per output.
Values are typed as any so a Function can emit structured outputs (a struct or array) that serialize as raw JSON — step-runner then parses them into a structpb struct/list value rather than a quoted string. A string value still serializes as a JSON string, so scalar-only callers pass strings unchanged.
Types ¶
type CommitAction ¶ added in v0.3.0
type CommitAction struct {
Action string `json:"action"`
Path string `json:"path"`
Content string `json:"content"`
LastCommitID string `json:"last_commit_id"`
}
CommitAction is a single file change, shaped exactly as gitlab_project.commit's actions input expects. The manifest.* Functions emit one per file they touched, so their output can be handed straight to commit.
type VersionedFile ¶ added in v0.3.0
VersionedFile is one manifest file read from the repo: its content and the optimistic-concurrency token to thread back into the resulting commit action. It mirrors an element of gitlab_project.read_files's output, and is the files input the manifest.* Functions edit.
func GetFiles ¶
func GetFiles(builtinCtx runner.BuiltinContext, inputSpec map[string]*proto.Spec_Content_Input) ([]VersionedFile, error)
GetFiles reads a "files" array input off the BuiltinContext and maps each element's path, content, and last_commit_id fields onto a VersionedFile. Missing fields decode to the empty string (structpb getters are nil-safe), leaving the caller's own validation to reject them — the only structural error worth flagging here is an element that isn't an object.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package argopromote implements the argo.promote builtin function: advance an Argo Rollout past one canary pause point, idempotently.
|
Package argopromote implements the argo.promote builtin function: advance an Argo Rollout past one canary pause point, idempotently. |
|
Package argosync implements the argo.sync builtin function: set an Argo CD Application's spec.source.targetRevision and trigger a sync.
|
Package argosync implements the argo.sync builtin function: set an Argo CD Application's spec.source.targetRevision and trigger a sync. |
|
Package commit implements the gitlab_project.commit builtin function: create a commit with one or more file changes on a branch in a GitLab project.
|
Package commit implements the gitlab_project.commit builtin function: create a commit with one or more file changes on a branch in a GitLab project. |
|
Package functiontest holds test helpers shared by the builtin gitlab_project.* function tests: an httptest-backed GitLab client and a JSONL output-file parser.
|
Package functiontest holds test helpers shared by the builtin gitlab_project.* function tests: an httptest-backed GitLab client and a JSONL output-file parser. |
|
Package k8sget implements the k8s.get builtin function: a generic, idempotent read of a single Kubernetes object, identified by api_version, kind, (optional) namespace, and name.
|
Package k8sget implements the k8s.get builtin function: a generic, idempotent read of a single Kubernetes object, identified by api_version, kind, (optional) namespace, and name. |
|
Package manifest is the shared machinery the manifest.* CD Functions use to mutate Kubernetes GitOps manifests by editing a structured YAML document model, never by splicing strings into manifest text.
|
Package manifest is the shared machinery the manifest.* CD Functions use to mutate Kubernetes GitOps manifests by editing a structured YAML document model, never by splicing strings into manifest text. |
|
Package pinimages implements the manifest.pin_images builtin function: pin service artifact images into their Kubernetes workload manifests by editing a structured document model, never by splicing strings into manifest text.
|
Package pinimages implements the manifest.pin_images builtin function: pin service artifact images into their Kubernetes workload manifests by editing a structured document model, never by splicing strings into manifest text. |
|
Package readfile implements the gitlab_project.read_files builtin function: read one or more files from a GitLab project at a Git ref.
|
Package readfile implements the gitlab_project.read_files builtin function: read one or more files from a GitLab project at a Git ref. |
|
Package setrollingstrategy implements the manifest.set_rolling_strategy builtin function: set a service's Argo Rollout to a rolling update strategy by editing a structured document model, never by splicing strings into manifest text.
|
Package setrollingstrategy implements the manifest.set_rolling_strategy builtin function: set a service's Argo Rollout to a rolling update strategy by editing a structured document model, never by splicing strings into manifest text. |