catalogueapp

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: 10 Imported by: 0

Documentation

Overview

Package catalogueapp is what creating a catalogue App leaves behind: the App's record, and its key.

One Secret holds every catalogue App, each under its catalogue id. An installed App is three keys — `<id>.github_app_id`, `<id>.github_app_installation_id`, `<id>.github_app_private_key` — beside its record, `<id>.record.json`, so a deployment can copy one App anywhere (into a secret manager with an External Secrets PushSecret, for one) by naming keys, without reshaping a document, and a restore of the Secret alone brings every App back.

An App created and not yet installed keeps its key under another name, `<id>.pending_private_key`, so the three keys never exist without an installation: a copy made in between never hands anybody an App that cannot mint a token.

The service reads the key to ask GitHub what the App and its installation hold now, and to uninstall it on Disconnect. A token exchange reads it by id, with the installation beside it.

Index

Constants

View Source
const (
	AppIDProperty          = "github_app_id"
	InstallationIDProperty = "github_app_installation_id"
	PrivateKeyProperty     = "github_app_private_key"
	RecordProperty         = "record.json"
	// PendingKeyProperty holds the key of an App not installed yet.
	PendingKeyProperty = "pending_private_key"
	// WebhookSecretProperty holds the secret GitHub signs the App's webhook
	// deliveries with, for an App whose catalogue entry declares a webhook.
	// It is kept whether or not the App is installed, and a rewrite of the
	// App's other keys leaves it alone.
	WebhookSecretProperty = "webhook_secret"
)

The property names of one App.

View Source
const Version = 1

Version is the record version this build writes and reads.

Variables

View Source
var ErrVersion = errors.New("catalogueapp: unsupported record version")

ErrVersion is a record of a version this build does not read.

Functions

func Encode

func Encode(r Record, privateKey string) (map[string][]byte, error)

Encode writes one App: its record, and its three properties once it is installed, or its pending key until then. Keys lists every key an App can have, so a writer removes those first.

func Key

func Key(id, property string) string

Key is the key one property of one App is kept under: `renovate.github_app_id`.

func Keys

func Keys(id string) []string

Keys are every key one App can be kept under.

func OfRecordKey

func OfRecordKey(key string) (string, bool)

OfRecordKey reads the id back out of a record key.

func PrivateKeyOf

func PrivateKeyOf(data map[string][]byte, id string) (string, bool)

PrivateKeyOf reads one App's key from the Secret's data, installed or pending.

func RecordKey

func RecordKey(id string) string

RecordKey is the key one App's record is kept under.

func SecretName

func SecretName(release string) string

SecretName is the object holding every catalogue App.

func WebhookSecretOf added in v1.74.0

func WebhookSecretOf(data map[string][]byte, id string) (string, bool)

WebhookSecretOf reads one App's webhook secret from the Secret's data.

Types

type Record

type Record struct {
	Version int    `json:"version"`
	ID      string `json:"id"`
	Org     string `json:"org"`
	AppID   int64  `json:"app_id"`
	AppSlug string `json:"app_slug"`
	// Purpose is always `catalogue`: Encode sets it. A record written before
	// it existed has none and is read as a catalogue App's all the same.
	Purpose appid.Purpose `json:"purpose,omitempty"`
	// Labels are the App's own, for a reader that selects Apps by them.
	Labels map[string]string `json:"labels,omitempty"`
	// InstallationID is zero between Create and Install.
	InstallationID int64     `json:"installation_id,omitempty"`
	HTMLURL        string    `json:"html_url,omitempty"`
	ConnectedAt    time.Time `json:"connected_at"`
	ConnectedBy    string    `json:"connected_by"`
	// WebhookURL is where GitHub was last told to deliver this App's events.
	// For a Kargo receiver it is derived from the secret, so it moves when
	// the secret does. Not a secret itself: it is what a drift check reads
	// GitHub's configuration against.
	WebhookURL string `json:"webhook_url,omitempty"`
	// HookRotatedAt is when the webhook's secret was last set on GitHub: the
	// creation, or the latest rotation.
	HookRotatedAt time.Time `json:"hook_rotated_at,omitzero"`
}

Record is one catalogue App, as the console shows it. Never the key.

func DecodeRecord

func DecodeRecord(raw []byte) (Record, error)

DecodeRecord reads a record.

func (Record) Installed

func (r Record) Installed() bool

Installed reports whether a token can be minted for it yet.

type Store added in v1.76.0

type Store interface {
	Put(ctx context.Context, record Record, privateKey string) error
	List(ctx context.Context) ([]Record, error)
	// Get is one App's record and its key, installed or pending.
	Get(ctx context.Context, id string) (Record, string, bool, error)
	Delete(ctx context.Context, id string) error
	// PutWebhookSecret keeps the secret GitHub signs one App's webhook with,
	// beside its key and surviving every later Put of the App. The App must
	// have been Put. Where the App is exported the secret is in its document
	// (`webhook_secret`), which is where a consumer reads it.
	PutWebhookSecret(ctx context.Context, id, secret string) error
	// WebhookSecret reads it back; false is an App with none.
	WebhookSecret(ctx context.Context, id string) (string, bool, error)
}

Store is where catalogue Apps are kept: every App's record and key, by its catalogue id.

Jump to

Keyboard shortcuts

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