Documentation
¶
Overview ¶
Package forge resolves a finding's repository URL to the Forge custom resource whose credentials may act on it, and mints per-operation scoped tokens from that Forge's secret.
It is the single shared seam for forge access: source-controller resolves read scope (clone/tarball), remediation-controller resolves write scope (branch push, pull request). Matching is host equality, then the org allowlist, then the repository regexes; when several Forges match, the more constrained spec wins (orgs set beats unset, then repositories set beats unset) and a remaining tie is ErrAmbiguous — an operator configuration error, never silently resolved.
Index ¶
- Constants
- Variables
- func Host(f *v1alpha1.Forge) string
- func ParseRepoURL(raw string) (host string, repo ghclient.Repo, err error)
- type Resolved
- type Scope
- type Store
- func (s *Store) Client(ctx context.Context, res *Resolved) (*ghclient.Client, error)
- func (s *Store) Resolve(ctx context.Context, namespace, repoURL string) (*Resolved, error)
- func (s *Store) Token(ctx context.Context, res *Resolved, scope Scope) (string, time.Time, error)
- func (s *Store) Validate(ctx context.Context, f *v1alpha1.Forge) error
Constants ¶
const ( SecretKeyToken = ghsecret.KeyToken SecretKeyAppID = ghsecret.KeyAppID SecretKeyPrivateKey = ghsecret.KeyPrivateKey )
Secret keys a Forge credential Secret may carry (shared shape with Integration secrets — see internal/ghsecret).
Variables ¶
var ( // ErrNoMatch: no Forge's filters cover the repository. ErrNoMatch = errors.New("no forge matches repository") // ErrAmbiguous: two or more Forges match with equal specificity. ErrAmbiguous = errors.New("ambiguous forge match") )
Sentinel errors callers branch on (they become Finding condition reasons).
Functions ¶
func Host ¶
Host returns the host a Forge covers: spec.baseURL's host when set (a bare host or a URL are both accepted), else the provider's public host.
func ParseRepoURL ¶
ParseRepoURL splits a repository URL into host and owner/name. It accepts https URLs with or without a .git suffix or trailing path segments and normalizes case (hosts and owners are case-insensitive on every supported forge; the repo name's case is preserved for display but matching is case-insensitive).
Types ¶
type Resolved ¶
type Resolved struct {
// Forge whose credentials cover the repository.
Forge *v1alpha1.Forge
// Repo is the parsed owner/name.
Repo ghclient.Repo
// Host the repository lives on (lowercase, no port).
Host string
}
Resolved is a repository bound to the Forge allowed to act on it.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store resolves Forges and mints their credentials.
func NewStore ¶
NewStore builds a Store reading Forges and Secrets through r. Pass the manager's API reader (not the cache) so Secrets need no list/watch grant.
func (*Store) Client ¶
Client returns an API client authenticated for the resolved repository — the surface for archive downloads, head-SHA resolution, and pull requests.