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 one shared path to 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). 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) ContentsPermission(ctx context.Context, res *Resolved) (string, error)
- func (s *Store) ProxyURL(ctx context.Context, res *Resolved) (string, 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. Integration secrets use the same shape (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 http(s) URLs with or without a .git suffix or trailing path segments. The host is lowercased; owner and name keep their case. The org filter compares owners case-insensitively, but repository regexes match the name as given.
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, used for archive downloads, head-SHA resolution, and pull requests.
func (*Store) ContentsPermission ¶ added in v0.15.0
ContentsPermission reports the contents permission the resolved Forge's credential holds on the repository: "write", "read" or "none" for a GitHub App installation (none when the App is not installed on it), and "unknown" for a PAT, whose scopes patchy cannot see.
func (*Store) ProxyURL ¶ added in v0.11.2
ProxyURL returns the resolved Forge's effective proxy URL (the spec proxy with the Secret's basic-auth credentials attached) for callers building their own client, such as the write-path pusher. "" means no spec proxy, so the environment applies.