applysetup

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package applysetup defines the container-local installer boundary. Products own configuration changes, conflict handling, runtime activation and atomic audits.

Index

Constants

View Source
const MaxBundleBytes = 128 << 10
View Source
const MaxSecretBytes = 4 << 10
View Source
const ReportSchema = "ky.product-setup-report/1"
View Source
const Schema = "ky.product-setup/1"

Variables

This section is empty.

Functions

func Decode

func Decode(file string, dest any) error

func DecodeRaw

func DecodeRaw(raw []byte, dest any) error

func HTTPS

func HTTPS(s string) bool

func Identifier

func Identifier(s string) bool

func Interval

func Interval(raw string) (time.Duration, error)

func RequestRestart

func RequestRestart(ctx context.Context, socket string) error

func Secret

func Secret(file string) (string, error)

func Stage

func Stage(dataDir, file, id string, canonical []byte, check bool) (string, error)

Stage publishes already validated, canonical, secret-free product metadata. Products decode/validate their own envelope before calling it; this function owns only immutable private-file preparation, never accounts or configuration.

func StartLocal

func StartLocal(ctx context.Context, socket string, apply func(context.Context, []byte, bool) (Report, error), restart func()) (func() error, error)

StartLocal exposes setup only over a private filesystem socket. The product callback validates its own payload and owns all changes. Restart is the product's graceful-stop request; a workload controller restarts it with the committed configuration.

func WriteCapabilities

func WriteCapabilities(out io.Writer, service string, features ...string) error

func WritePreparation

func WritePreparation(out io.Writer, service, id, status string) error

Types

type Backup

type Backup struct {
	Directory string    `json:"directory,omitempty"`
	Keep      int       `json:"keep,omitempty"`
	Interval  string    `json:"interval,omitempty"`
	Recovery  *Recovery `json:"recovery,omitempty"`
}

type Capabilities

type Capabilities struct {
	Schema       string   `json:"schema"`
	Service      string   `json:"service"`
	BundleSchema string   `json:"bundleSchema"`
	Features     []string `json:"features"`
}

type Common

type Common struct {
	Schema   string     `json:"schema"`
	Service  string     `json:"service"`
	SetupID  string     `json:"setupId"`
	SSO      *SSO       `json:"sso,omitempty"`
	Admins   []Identity `json:"admins,omitempty"`
	Everyday []Identity `json:"everyday,omitempty"`
	Backup   *Backup    `json:"backup,omitempty"`
}

func (Common) Validate

func (c Common) Validate(service string, callbackPath string) error

func (Common) ValidatePreparation

func (c Common) ValidatePreparation(service, callback, file string) error

ValidatePreparation checks secret-free metadata before any filesystem mutation. Products still validate their own service, callbacks and extended fields.

type Identity

type Identity struct {
	Issuer   string `json:"issuer"`
	Subject  string `json:"subject"`
	Username string `json:"username"`
	Email    string `json:"email,omitempty"`
}

type Object

type Object struct {
	Kind string `json:"kind"`
	Name string `json:"name"`
	ID   string `json:"id,omitempty"`
}

type Options

type Options struct {
	File                                string
	Check, Capabilities, Restart, Stage bool
}

func Parse

func Parse(args []string) (Options, error)

func ParsePreparation

func ParsePreparation(args []string) (Options, error)

ParsePreparation is an explicit product opt-in. Legacy callers of Parse still refuse --stage instead of accidentally interpreting it as ordinary setup.

type Recovery

type Recovery struct {
	URL             string `json:"url"`
	PairingCodeFile string `json:"pairingCodeFile"`
}

type Refusal

type Refusal struct{ Reason string }

Refusal carries a fixed, public-safe explanation chosen by the product. Never put request values, credentials or a database error into Reason.

func (*Refusal) Error

func (r *Refusal) Error() string

type Report

type Report struct {
	Schema  string   `json:"schema"`
	Service string   `json:"service"`
	SetupID string   `json:"setupId"`
	Created []Object `json:"created"`
	Present []Object `json:"present"`
	Pending []Object `json:"pending"`
}

func CallLocal

func CallLocal(ctx context.Context, socket string, raw []byte, check bool) (Report, error)

func NewReport

func NewReport(c Common) Report

func (Report) Write

func (r Report) Write(out io.Writer) error

type SSO

type SSO struct {
	IssuerURL           string `json:"issuerUrl"`
	ClientID            string `json:"clientId"`
	ClientSecretFile    string `json:"clientSecretFile"`
	RedirectURI         string `json:"redirectUri"`
	DirectorySecretFile string `json:"directorySecretFile,omitempty"`
	SCIMTokenFile       string `json:"scimTokenFile,omitempty"`
}

Jump to

Keyboard shortcuts

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