app

package
v1.76.10 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package app assembles the GitHub controller from its configuration: the policy's GitHub table, the console it reads with its own ServiceAccount token, the report it writes, and the credentials mounted beside it.

A package rather than the body of main, for the reason the service's equivalents are: this is where the decisions a deployment can get wrong are made, and main() cannot be tested.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MintServer added in v1.76.0

func MintServer(apps githubtokens.AppStore, web *http.Client) *modcall.Server

MintServer is the `github` module's server with the mint over apps: it answers `mint_installation` to the issuer's class only (githubtokens.Register allows no other) and has no other method.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App is an assembled controller.

func New

func New(ctx context.Context, cfg Config, log *slog.Logger) (*App, error)

New assembles the controller.

func (*App) Close

func (a *App) Close() error

Close closes the audit emitter, which delivers what its queue holds within its timeout and drops the rest, saying so. Nothing survives the process.

func (*App) Pass added in v1.58.0

func (a *App) Pass(ctx context.Context, target string, unsafeLocal bool) (ran bool, err error)

Pass is App.Tick that says whether the pass ran: false, with no error, when another runner holds the target's lease and the pass is left to it. It is what a Lambda invocation runs (the cmd/sluis-<module> mains), which reports a contended invocation as such and not as a success.

func (*App) Paused added in v1.75.0

func (a *App) Paused(ctx context.Context) bool

Paused says the module is under maintenance, so a pass that did not run was skipped for that and not for another runner's lease.

func (*App) Readiness added in v1.63.0

func (a *App) Readiness() health.Dependency

Readiness is the controller's answer to "did it start": closed until App.RunLoop begins. The one process adds it to the readiness it serves.

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run passes until the context is done, or the audit installation refuses the catalogue after the start, which ends the process the way a refusal at the start would have. It is the controller as a process of its own (`sluis controller`, deprecated): it serves its own probes, which in the one process are the service's.

func (*App) RunLoop added in v1.63.0

func (a *App) RunLoop(ctx context.Context, ready func(context.Context)) error

RunLoop is the controller's loop alone, for the one process that serves the probes. It opens readiness, waits for ready (when not nil) before the first pass, then passes until the context is done, or the audit installation refuses the catalogue after the start, which ends it with that error.

func (*App) Tick

func (a *App) Tick(ctx context.Context, target string, unsafeLocal bool) error

Tick runs one target's tick once, under its lease, and returns: an organisation's login, or controller.LinksTarget. It is what `sluis tick github` runs, and the shape of a function that lives for one invocation. A target another runner holds is left to it.

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is what a deployment decides. It is built from the configuration file, which is what the chart renders.

func FromConfig

FromConfig builds the settings from a configuration already read. What a schema cannot say is checked here, before anything starts.

func FromService added in v1.63.0

func FromService(s *config.Sluis, p *config.PolicyDocument) (Config, error)

FromService builds the settings of the GitHub controller that the one service document runs (`controllers.github`), from the document and the policy it names. The controller shares the process's release, policy, ports, adapters, audit installation and log level, and, with the `ssm` secrets source, its secrets settings (root, layout, KMS key, region, endpoint, grace).

func Load

func Load(file string) (Config, error)

Load reads the configuration file, holds it to its schema, and builds the settings from it.

The file is either the controller's own document (`sluis controller github`, deprecated) or the one service document, whose `controllers.github` section is this controller: a deployment that still runs the controller apart reads the document the process it was folded into reads.

func (Config) ConsoleURL added in v1.63.0

func (c Config) ConsoleURL() string

ConsoleURL is the console's API the controller reads.

func (Config) Declares added in v1.76.0

func (c Config) Declares(target string) bool

Declares says the policy names the target: an organisation it binds, or the links target. A function asks before it assembles the controller, so a run-now of somebody else's target costs no store.

func (Config) LogLevel

func (c Config) LogLevel() slog.Level

LogLevel is the level the process should log at.

func (Config) Serve added in v1.76.0

func (c Config) Serve() *config.ModuleServe

Serve is where the module answers the issuer's calls on Kubernetes (`github.serve`); nil when the document sets none.

func (Config) Verify added in v1.76.0

func (c Config) Verify(ctx context.Context, log *slog.Logger) error

Verify builds what a pass and the mint build: the policy, the storage ports, the secrets, the trigger and the audit trail's sink. A setting the document lacks is refused as New would refuse it. It reaches nothing that mutates (adaptercheck).

type Minter added in v1.76.0

type Minter struct {
	// contains filtered or unexported fields
}

Minter is the GitHub module's installation-token mint and nothing else: the App keys of the catalogue, read from the secrets store, and the `github` module's `mint_installation` method over them (docs/decisions/0071). It runs no controller pass and holds no console client, no leases and no audit trail: the issuer decides the grant and audits the request, and this only signs.

func NewMinter added in v1.76.0

func NewMinter(ctx context.Context, cfg Config, log *slog.Logger) (*Minter, error)

NewMinter assembles the mint from the settings Load built. Opening reads no secret: an App's key is read when a request names it.

func (*Minter) Close added in v1.76.0

func (m *Minter) Close()

Close closes the ports.

func (*Minter) RPC added in v1.76.0

func (m *Minter) RPC() *modcall.Server

RPC is the module's server: it answers `mint_installation` to the issuer's class and refuses every other caller.

func (*Minter) ServeConsole added in v1.76.0

func (m *Minter) ServeConsole(ctx context.Context, cfg Config, log *slog.Logger) error

ServeConsole makes the module also answer the console's GitHub operations (docs/decisions/0071, v1.76 D-v176-1 b) on the server the mint is on: the console class reaches them and no other. The organisations' records, their keys, the audit trail and the module's own tick are this function's; who the caller is and which directories exist are the console's word in the call.

Jump to

Keyboard shortcuts

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