orgsettings

package
v1.88.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT 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 orgsettings reconciles one GitHub organisation's Actions variables, Actions secrets and code security configurations with the typed document the organisation keeps in its own account (ADR 0080).

The package reads the document through a [Reader], checks it against the owner's ceiling with policy/tenant, and compares it with what GitHub holds. In `report` mode it says what differs and changes nothing. In `enforce` mode it applies the difference. It removes only a name it wrote itself and recorded in status.Managed, and it never holds a secret's value beyond the one call that seals it: values are not logged, not stored and not recorded in the audit trail.

Index

Constants

View Source
const (
	ModeReport  = orgconfig.ModeReport
	ModeEnforce = orgconfig.ModeEnforce
)

The modes.

Variables

This section is empty.

Functions

func Pass

func Pass(ctx context.Context, in PassInput) status.Settings

Pass reads the organisation's document and, when it holds to its checks, reconciles GitHub with it. A document that cannot be read or fails a check is not applied: GitHub keeps what the last good document made it, and the report says why. The result never holds a value.

Types

type AWSReader

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

AWSReader reads each organisation's document and secrets with the role the installation names for it. The controller's own credentials (a Lambda role, Pod Identity, the environment) are used only to assume that role.

func NewAWSReader

func NewAWSReader(ctx context.Context, configs map[string]orgconfig.Config) (*AWSReader, error)

NewAWSReader connects with the platform's credentials. It calls nothing: a role is assumed when an organisation's document is first read.

func NewAWSReaderWith

func NewAWSReaderWith(configs map[string]orgconfig.Config, assume stscreds.AssumeRoleAPIClient, client ParametersFor) *AWSReader

NewAWSReaderWith is NewAWSReader with the clients given, for a test.

func (*AWSReader) For

func (r *AWSReader) For(org string) (Source, bool)

For is the source of one organisation, or false when the installation names no reading for it.

type Desired

type Desired struct {
	Variables map[string]tenant.OrgVariable
	Secrets   map[string]tenant.OrgSecret
	Configs   map[string]tenant.SecurityConfiguration
	// Platform are the variables the installation sets, which the controller
	// writes whatever GitHub already holds under the name.
	Platform map[string]bool
}

Desired is what the organisation should hold: the platform's variables and the document's, merged and checked. Variable and secret names are keyed as GitHub keeps them, folded to upper case (tenant.FoldName).

type Input

type Input struct {
	Mode    Mode
	Target  Target
	Desired Desired
	// Ceiling says which names the platform owns: the controller never
	// removes one the installation does not set.
	Ceiling tenant.OrgCeiling
	// Previous is the record of what the controller wrote last time.
	Previous status.Managed
	Secrets  Secrets
}

Input is one pass over one organisation.

type Mode

type Mode = orgconfig.Mode

Mode is what the controller does with a difference.

type ParametersAPI

type ParametersAPI interface {
	GetParameter(ctx context.Context, in *awsssm.GetParameterInput, opts ...func(*awsssm.Options)) (*awsssm.GetParameterOutput, error)
}

ParametersAPI is the part of the SSM client a read calls.

type ParametersFor

type ParametersFor func(creds aws.CredentialsProvider, region string) ParametersAPI

ParametersFor builds the parameter-store client of one organisation's account, from the credentials of the role assumed there.

type PassInput

type PassInput struct {
	Org      string
	Settings orgconfig.Config
	// Source is nil when the organisation has no way to read its document;
	// the pass then reports it unreadable.
	Source Source
	Target Target
	// Previous is the last pass's record, or nil for the first.
	Previous *status.Settings
	Now      time.Time
	// Enabled is whether the controller acts in this organisation
	// (`controllers.github.enabledOrgs`). A disabled organisation is read as
	// `report` whatever its mode says: that list is the kill switch.
	Enabled bool
}

PassInput is one pass over one organisation's settings.

type Result

type Result struct {
	Changes []status.SettingChange
	Managed status.Managed
}

Result is what a pass found or did, and the record to keep.

func Reconcile

func Reconcile(ctx context.Context, in Input) (Result, error)

Reconcile compares the desired settings with GitHub's and, in enforce mode, applies the difference. An error means GitHub could not be read, so nothing was changed; a change that GitHub refuses is a row of the result and the pass goes on.

A name GitHub holds that the controller did not write is the organisation's and not the controller's: it is reported as a conflict and never written, adopted or removed, except for the installation's own variables. A pass that would remove most of what the controller wrote removes none of it.

type Secrets

type Secrets interface {
	// Version is the parameter's version, read without decrypting it.
	Version(ctx context.Context, parameter string) (int64, error)
	// Value is the parameter's decrypted value and its version.
	Value(ctx context.Context, parameter string) (string, int64, error)
}

Secrets reads the values the document's secrets refer to, from the organisation's own parameter store.

type Source

type Source interface {
	// Document is the organisation's typed document, read now.
	Document(ctx context.Context) ([]byte, error)
	Secrets
}

Source is where one organisation's document and secrets are read from.

type Target

type Target struct {
	Org   githubapp.Org
	Token string
}

Target is one organisation, with the installation token to act with.

Directories

Path Synopsis
Package settingstest is an organisation's own account in memory: the document and the SecureString parameters the controller reads with the role it assumes.
Package settingstest is an organisation's own account in memory: the document and the SecureString parameters the controller reads with the role it assumes.

Jump to

Keyboard shortcuts

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