Documentation
¶
Overview ¶
Package githubapps is each GitHub App's required permission set, as data (v4 D12): the agents App mints the runs' and the publisher's tokens, the factory App handles issues, labels, statuses and merges, and the merger may be a third App or fold into the factory App. Tokens are minted downscoped from these sets; an installation must grant them. `maku install` (rollout step 7) creates the Apps from them, and the factory checks each installation against them at start.
Index ¶
- Constants
- func Render(p Permissions) string
- type App
- type AppManifest
- type Credentials
- type DocTable
- type Flow
- type HookAttributes
- type Kind
- type ManifestOptions
- type MergerOptions
- type Permissions
- type Secret
- func (Secret) Format(f fmt.State, _ rune)
- func (Secret) GoString() string
- func (Secret) LogValue() slog.Value
- func (Secret) MarshalJSON() ([]byte, error)
- func (Secret) MarshalText() ([]byte, error)
- func (s Secret) Reveal() string
- func (Secret) String() string
- func (s *Secret) UnmarshalJSON(b []byte) error
Constants ¶
const HomepageURL = "https://github.com/Smana/maku"
HomepageURL is the homepage an App created from a manifest points at.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
func Render(p Permissions) string
Render is p as a Markdown table, sorted by permission.
Types ¶
type App ¶ added in v0.47.0
App is what may be shown of a created App.
func (App) InstallURL ¶ added in v0.47.0
InstallURL is where the App is installed on the owner's repositories.
type AppManifest ¶ added in v0.47.0
type AppManifest struct {
CallbackURLs []string `json:"callback_urls,omitempty"`
DefaultEvents []string `json:"default_events"`
DefaultPermissions Permissions `json:"default_permissions"`
HookAttributes HookAttributes `json:"hook_attributes"`
Name string `json:"name"`
Public bool `json:"public"`
RedirectURL string `json:"redirect_url"` // set by the Flow: its loopback callback
RequestOAuthOnInstall *bool `json:"request_oauth_on_install,omitempty"`
URL string `json:"url"`
}
AppManifest is the JSON GitHub's App manifest flow takes. The fields are in alphabetical order, so that its encoding matches a map's: `maku demo app` built its manifest from one.
func Manifest ¶ added in v0.47.0
func Manifest(kind Kind, name string, o ManifestOptions) (AppManifest, error)
Manifest is the manifest that creates the kind's App, named name: its required set, no webhook, not public. The factory App folds the merger in (no third App, D12) and registers the account link's OAuth callback (R5).
type Credentials ¶ added in v0.47.0
type Credentials struct {
App
PEM Secret // the App's private key
ClientSecret Secret // the App's OAuth client secret: the factory App's account link (R5)
}
Credentials are an App and the secrets its conversion returned. The webhook secret is not kept: no App has an active webhook.
type DocTable ¶
type DocTable struct {
Name string
Permissions Permissions
}
DocTable is one permission table docs/github-apps.md carries between its markers.
type Flow ¶ added in v0.47.0
type Flow struct {
Command string // the maku command errors name, such as "demo app" or "install"
GitHub string // the web base the form posts to; empty is https://github.com
API string // the API base; empty is https://api.github.com
Owner string // an organization to own the Apps; empty is the user's account
HC *http.Client // the conversion call; nil is a 30 s client
Out io.Writer // progress lines; never a credential
Open func(ctx context.Context, u string) // opens the browser; nil only prints the URL
Timeout time.Duration // the wait for each App's callback; zero is 5 min
Rand io.Reader // the states; nil is crypto/rand
// Save persists the i-th App's credentials before the browser is told it exists. An error stops the
// flow: the next App is not offered. A rerun after a failure passes only the manifests of the Apps
// not yet saved: the error names those that exist.
Save func(i int, c Credentials) error
}
Flow runs GitHub's App manifest flow for one App or several, one after the other, on one loopback listener. Each App has its own state, checked in constant time and good for one callback. The callback's code is traded for the App's credentials, which go to Save and nowhere else.
type HookAttributes ¶ added in v0.47.0
HookAttributes is the App's webhook; the factory polls, so it is never active (step 6 R2).
type Kind ¶ added in v0.47.0
type Kind string
Kind is which of the two Apps a manifest creates (D12).
type ManifestOptions ¶ added in v0.47.0
type ManifestOptions struct {
Homepage string // the App's homepage; empty is HomepageURL
WebURL string // the factory App: the web hostname, whose /link/github/callback is the OAuth callback (R5)
Merger MergerOptions // the factory App: what the folded merger asks for; Folded is always set
}
ManifestOptions are the answers a manifest is built from.
type MergerOptions ¶
type MergerOptions struct {
Folded bool // the merger signs with the factory App
Reruns bool // merge.checkReruns on any repository: actions write
Labels bool // a live or monitored class: issues write
Status bool // merge.gateStatus on any repository: statuses write
}
MergerOptions says what the merger asks for, as forge.MergerPermissions does, and whether it is folded into the factory App (github.mergerAppIDFile equal to github.appIDFile).
type Permissions ¶
type Permissions = minter.Permissions
Permissions is a permission name to its access, read or write.
func Agents ¶
func Agents() Permissions
Agents is the agents App's required set: every permission the role table may mint, over every role and every enforced combination, the publisher included. It never holds statuses, workflows or administration (the role table's invariants).
func Factory ¶
func Factory(o MergerOptions) Permissions
Factory is the factory App's required set: its own token's scope, and the merger's when the merger is folded into it.
func Merger ¶
func Merger(o MergerOptions) Permissions
Merger is the merger App's required set (R16), whichever App holds it.
type Secret ¶ added in v0.47.0
type Secret string
Secret is a credential GitHub returned once. It prints, encodes and logs as [redacted]; Reveal is how its value reaches the 0600 file it goes to, and nowhere else.
func (Secret) MarshalJSON ¶ added in v0.47.0
MarshalJSON is "[redacted]".
func (Secret) MarshalText ¶ added in v0.47.0
MarshalText is [redacted].
func (*Secret) UnmarshalJSON ¶ added in v0.47.0
UnmarshalJSON reads the value from GitHub's answer.