githubapps

package
v0.54.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

type App struct {
	ID       int64
	Slug     string
	HTMLURL  string
	ClientID string
}

App is what may be shown of a created App.

func (App) InstallURL added in v0.47.0

func (a App) InstallURL() string

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.

func DocTables

func DocTables() []DocTable

DocTables are the documented sets: the agents App, the factory App with the merger folded in and every merger option on, the factory App alone, and a separate merger App with every option on.

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.

func (Flow) Run added in v0.47.0

func (f Flow) Run(ctx context.Context, ms ...AppManifest) ([]App, error)

Run creates the Apps ms describes, in order, and returns what may be shown of them.

type HookAttributes added in v0.47.0

type HookAttributes struct {
	Active bool   `json:"active"`
	URL    string `json:"url"`
}

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).

const (
	// AgentsApp mints the runs' and the publisher's tokens.
	AgentsApp Kind = "agents"
	// FactoryApp handles issues, labels, statuses and merges, with the merger folded in.
	FactoryApp Kind = "factory"
)

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) Format added in v0.47.0

func (Secret) Format(f fmt.State, _ rune)

Format writes [redacted] whatever the verb.

func (Secret) GoString added in v0.47.0

func (Secret) GoString() string

GoString is [redacted], for %#v.

func (Secret) LogValue added in v0.47.0

func (Secret) LogValue() slog.Value

LogValue is [redacted].

func (Secret) MarshalJSON added in v0.47.0

func (Secret) MarshalJSON() ([]byte, error)

MarshalJSON is "[redacted]".

func (Secret) MarshalText added in v0.47.0

func (Secret) MarshalText() ([]byte, error)

MarshalText is [redacted].

func (Secret) Reveal added in v0.47.0

func (s Secret) Reveal() string

Reveal is the value, for the file it is written to.

func (Secret) String added in v0.47.0

func (Secret) String() string

String is [redacted].

func (*Secret) UnmarshalJSON added in v0.47.0

func (s *Secret) UnmarshalJSON(b []byte) error

UnmarshalJSON reads the value from GitHub's answer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL