Documentation
¶
Overview ¶
Package dryrun asks the cluster whether it would accept a GitOps change from the caller, before the change goes to Git. Every object the GitOps controller would apply is server-side applied, and every object it would prune is deleted, both with DryRunAll and the caller's client: RBAC and admission decide for the caller's identity exactly as for a real write, and nothing is persisted. The change must be committed with the same identity, or the check proves nothing about the commit.
The package reads no GitOps controller object, so it holds for Flux, Argo CD or any other controller.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRefused = errors.New("the cluster refuses the change")
ErrRefused is the cluster refusing at least one object of a change for the caller's identity: RBAC (Forbidden) or admission (Forbidden or Invalid). The error Check returns also wraps each refusal, so apierrors.IsForbidden and apierrors.IsInvalid hold for the first one.
Functions ¶
func Check ¶
func Check(ctx context.Context, client dynamic.Interface, mapper meta.RESTMapper, fieldManager string, change manifest.Change) error
Check dry-runs change with client, the caller's client, mapping each object's kind with mapper. fieldManager names the server-side apply.
It returns nil when the cluster accepts every object, and an error wrapping ErrRefused that names each refused object otherwise. A namespace that does not exist yet is an error: admission cannot validate its objects until the namespace exists. An object to prune that is already gone passes. A namespaced object without a namespace, a kind the mapper does not know and a request that fails are errors without ErrRefused: the cluster did not answer for the caller.
Applied objects pass through manifest.Desired, as do the files rendered for Git. File removals are checked as deletions only when change.Prune is true.
Types ¶
This section is empty.