ghapp

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const TokenValidity = time.Hour

TokenValidity is the duration for which a token is valid. Always exactly 1 hour.

Variables

View Source
var (
	ConfigPath = "/config"
	ConfigName = "gtm"
)
View Source
var ErrNoStartupConfig = errors.New("no startup GitHub App configuration loaded; set spec.appRef")

ErrNoStartupConfig is returned by Registry.Startup when the operator was started without a usable GitHub App config and a Token/ClusterToken without an explicit appRef attempts to reconcile.

View Source
var StartupKey = Key{}

StartupKey is the reserved key for the operator's startup-config client.

Functions

This section is empty.

Types

type FactoryFunc added in v1.5.0

type FactoryFunc func(ctx context.Context, cfg ghait.Config) (ghait.GHAIT, error)

FactoryFunc constructs a ghait.GHAIT client from a ghait.Config. It is a variable on the Registry so tests can inject a fake without touching network or KMS providers.

type Key added in v1.5.0

type Key struct {
	Namespace string
	Name      string
}

Key identifies an App in the registry. The zero value is reserved for the startup-config singleton (see Registry.Startup).

type OperatorConfig

type OperatorConfig struct {
	AppID          int64  `mapstructure:"app_id"`
	InstallationID int64  `mapstructure:"installation_id"`
	Provider       string `mapstructure:"provider"`
	Key            string `mapstructure:"key"`
	ValidateKey    bool   `mapstructure:"validate_key"`
}

func LoadConfig

func LoadConfig(ctx context.Context) (*OperatorConfig, error)

func (*OperatorConfig) GetAppID

func (c *OperatorConfig) GetAppID() int64

func (*OperatorConfig) GetInstallationID

func (c *OperatorConfig) GetInstallationID() int64

func (*OperatorConfig) GetKey

func (c *OperatorConfig) GetKey() string

func (*OperatorConfig) GetProvider

func (c *OperatorConfig) GetProvider() string

func (*OperatorConfig) GetValidateKey added in v1.4.0

func (c *OperatorConfig) GetValidateKey() bool

type Option added in v1.5.0

type Option func(*Registry)

Option configures a Registry at construction time.

func WithFactory added in v1.5.0

func WithFactory(f FactoryFunc) Option

WithFactory replaces the default client factory. Intended for tests.

type Registry added in v1.5.0

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

Registry caches ghait.GHAIT clients keyed by App identity. The startup config lives under StartupKey; each App CR gets its own entry keyed by {namespace, name} and invalidated on generation change.

func NewRegistry added in v1.5.0

func NewRegistry(operatorNS string, startupCfg *OperatorConfig, opts ...Option) *Registry

NewRegistry builds a Registry. Pass a nil startupCfg to require that every Token/ClusterToken sets spec.appRef explicitly.

func (*Registry) ForApp added in v1.5.0

func (r *Registry) ForApp(ctx context.Context, key Key, version string, cfg ghait.Config) (ghait.GHAIT, error)

ForApp returns a cached client for the given App, building it when the cached entry's version differs from the supplied one. The version is an opaque string the caller derives from all inputs that affect client identity (typically the App's spec generation, plus any referenced Secret's ResourceVersion when the App is Secret-backed).

func (*Registry) Invalidate added in v1.5.0

func (r *Registry) Invalidate(key Key)

Invalidate drops the cache entry for key. Safe to call for unknown keys.

func (*Registry) Lookup added in v1.5.0

func (r *Registry) Lookup(key Key) (ghait.GHAIT, bool)

Lookup returns the cached client for key, if any. Unlike Registry.ForApp it never builds a new client — callers use this on the hot path (Token/ClusterToken reconcile) where the App reconciler is the authority for keeping the entry current. A miss means the App reconciler has not yet populated (or has invalidated) the entry; the caller should requeue and let the App watch re-trigger.

func (*Registry) OperatorNamespace added in v1.5.0

func (r *Registry) OperatorNamespace() string

OperatorNamespace returns the operator's own namespace, used to default an unset ClusterToken.spec.appRef.namespace.

func (*Registry) Startup added in v1.5.0

func (r *Registry) Startup(ctx context.Context) (ghait.GHAIT, error)

Startup returns the cached startup-config client, building it on first use. Returns ErrNoStartupConfig if no startup config was loaded.

Jump to

Keyboard shortcuts

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