Documentation
¶
Overview ¶
Package whatchanged produces the "what changed" delta between two GitOps revisions: a path-scoped unified diff (the actual landed change). It is the differentiating core of RunLore's investigation spine.
Index ¶
- func WithCloneCache(ctx context.Context) (context.Context, func())
- type Differ
- func (d *Differ) ForChange(ctx context.Context, c providers.Change) (providers.Diff, error)
- func (d *Differ) Local(ctx context.Context, path, fromRev, toRev, scope string) (providers.Diff, error)
- func (d *Differ) Remote(ctx context.Context, url, fromRev, toRev, scope string) (providers.Diff, error)
- func (d *Differ) RemoteFromParent(ctx context.Context, url, rev, scope string) (providers.Diff, error)
- func (d *Differ) RemoteLastPathChange(ctx context.Context, url, atRev, scope string) (providers.Diff, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCloneCache ¶
WithCloneCache returns a derived context carrying a clone cache, plus a cleanup func that removes every clone the cache created. Wrap a batch of diffs that may hit the same repo (the what_changed tool's change loop) so each source repo is cloned at most once; call the returned func when the batch is done.
Types ¶
type Differ ¶
type Differ struct {
// TokenSource mints a GitHub App installation token for HTTPS clone auth in
// Remote/RemoteFromParent. It is called once per clone so a short-lived
// (~1h) installation token stays fresh across a long-running agent. nil
// disables auth (e.g. public or local repos).
TokenSource func(context.Context) (string, error)
}
Differ computes path-scoped diffs between Git revisions.
func (*Differ) ForChange ¶
ForChange resolves the diff for a detected Change by cloning its source repo and scoping to the workload's path. With both revisions it diffs FromRev..ToRev; with only ToRev it diffs the change introduced by ToRev (against its parent). ctx bounds the clone + patch so a caller deadline (per-investigation timeout) aborts a hung remote.
When the forward range holds no change to the resource's path it falls back to the newest commit that actually touched the path. This matters on a Flux health-check failure: Flux applies the manifest (advancing lastAppliedRevision to the breaking commit) and only then fails the health gate, so the change is at/behind the applied revision — diffing forward from it misses it entirely (RunLore #239).
func (*Differ) Local ¶
func (d *Differ) Local(ctx context.Context, path, fromRev, toRev, scope string) (providers.Diff, error)
Local diffs two revisions in an already-cloned repository at path. ctx bounds the (potentially expensive) patch computation so a caller deadline is honored.
func (*Differ) Remote ¶
func (d *Differ) Remote(ctx context.Context, url, fromRev, toRev, scope string) (providers.Diff, error)
Remote clones url to disk (auth via the installation token when set) and diffs two revisions. The source may be a remote HTTPS URL or a local path. ctx bounds the clone + patch.
func (*Differ) RemoteFromParent ¶
func (d *Differ) RemoteFromParent(ctx context.Context, url, rev, scope string) (providers.Diff, error)
RemoteFromParent clones url and returns the path-scoped diff of the change introduced by rev (rev against its first parent). A root commit (no parent) yields an empty diff. ctx bounds the clone + patch.
NOTE (perf): does a full (disk) clone per call. When the GitOpsProvider drives this across many changes, add a per-repo clone cache here (see dev/plans note).
func (*Differ) RemoteLastPathChange ¶ added in v0.6.1
func (d *Differ) RemoteLastPathChange(ctx context.Context, url, atRev, scope string) (providers.Diff, error)
RemoteLastPathChange clones url and returns the path-scoped diff of the newest commit reachable from atRev that actually modified scope, against its first parent. It is ForChange's fallback when the forward range holds no change to scope (see RunLore #239). Returns an empty diff when scope is empty, no ancestor of atRev touches scope, or the touching commit is a root commit (no parent).