Documentation
¶
Overview ¶
Package argocd implements providers.GitOpsProvider for Argo CD: it reads Argo CD Applications from the cluster and emits engine-agnostic Changes (diffable via whatchanged.Differ) and failure events — the same contract as the flux package.
Index ¶
- type ApplicationEvent
- type Provider
- func (p *Provider) Changes(ctx context.Context, w providers.TimeWindow, sel providers.Selector) ([]providers.Change, error)
- func (p *Provider) DependencyTree(ctx context.Context, w providers.Workload) (providers.DepNode, error)
- func (p *Provider) Diff(ctx context.Context, c providers.Change) (providers.Diff, error)
- func (p *Provider) ResourceStatus(ctx context.Context, w providers.Workload) (providers.ResourceStatus, error)
- func (p *Provider) WatchFailures(ctx context.Context) (<-chan providers.FailureEvent, error)
- type Reader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplicationEvent ¶
type ApplicationEvent struct {
Application application
}
ApplicationEvent is a single watch event for an Application.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements providers.GitOpsProvider for Argo CD.
func New ¶
func New(reader Reader, differ *whatchanged.Differ) *Provider
New builds an Argo CD provider from a Reader and a Differ.
func (*Provider) Changes ¶
func (p *Provider) Changes(ctx context.Context, w providers.TimeWindow, sel providers.Selector) ([]providers.Change, error)
Changes lists Argo CD Applications and emits a Change per app: its source repo + path, the deployed revision (ToRev), and the previously deployed revision (FromRev, from the rollout history) when available.
Multi-source Applications (spec.sources[]) are supported: the first source + first revision back the Change (see applicationFromUnstructured). An app that still resolves no diffable source is logged at Debug and skipped, so the blind spot is observable rather than silent.
Namespace resolution (B2): an Application lives in the argocd namespace but deploys into spec.destination.namespace, so a query keyed on the workload namespace must match EITHER. When the filter still yields zero and a name is given, we retry name-matched across all namespaces so "no changes" is never a silent false negative — mirroring the flux provider.
TimeWindow (G3): when w is non-zero, each Application emits a Change per source revision that landed IN the window (git-log on the resolved source repo, newest-first, capped at whatchanged.MaxWindowRevisions), so "what changed over the last N hours" surfaces the whole timeline — not just the current synced revision. A zero/unset window falls back to the single current-revision behavior. The enumeration is bounded so a wide window can't explode the output.
func (*Provider) DependencyTree ¶
func (p *Provider) DependencyTree(ctx context.Context, w providers.Workload) (providers.DepNode, error)
DependencyTree returns the Application with its FAILING managed resources (status.resources whose health is not Healthy/Progressing) as children, recursing into child Applications (app-of-apps) — so the root failure behind a degraded app is visible. Best-effort: child read errors don't abort the walk.
func (*Provider) Diff ¶
Diff resolves a Change's diff via the Differ. ctx is threaded into the Differ so a hung clone/patch is cancellable (per-investigation deadline).
func (*Provider) ResourceStatus ¶
func (p *Provider) ResourceStatus(ctx context.Context, w providers.Workload) (providers.ResourceStatus, error)
ResourceStatus reports an Argo CD Application's health + sync status, key source/destination refs, error conditions, and recent Events — the Argo analogue of the Flux inspector's "why is it failing" lens. A missing Application is reported via NotFound (often the cascade root), not an error.
func (*Provider) WatchFailures ¶
WatchFailures watches Argo CD Applications and emits a FailureEvent when an app is health-Degraded OR its last sync operation FAILED (operationState.phase ∈ {Failed, Error}). The sync-operation check catches a failed reconcile that has not (yet) manifested as Degraded health — a signal the health-only check missed. The returned channel closes when the watch ends or ctx is done.
type Reader ¶
type Reader interface {
ListApplications(ctx context.Context) ([]application, error)
WatchApplications(ctx context.Context) (<-chan ApplicationEvent, error)
// GetApplication fetches one Application as unstructured (deep inspection needs
// status.conditions + status.resources, which the minimal `application` omits). A
// NotFound error is returned verbatim so callers can distinguish "missing".
GetApplication(ctx context.Context, namespace, name string) (*unstructured.Unstructured, error)
// ListEvents returns recent Event lines for an involved object.
ListEvents(ctx context.Context, namespace, name, kind string) ([]string, error)
}
Reader is the cluster-read surface the provider depends on. The dynamic client-go implementation lives in dynamic.go; tests use a fake.
func NewDynamicReader ¶
NewDynamicReader builds a Reader backed by a client-go dynamic client.