azure

package
v0.7.13 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

internal/bootstrap/azure/admininit.go

internal/bootstrap/azure/bootstrap.go

internal/bootstrap/azure/deploy.go

internal/bootstrap/azure/health.go

internal/bootstrap/azure/image.go

internal/bootstrap/azure/inputs.go

internal/bootstrap/azure/params.go

internal/bootstrap/azure/preflight.go

internal/bootstrap/azure/prompt.go

Package azure implements the `cronfoundry bootstrap azure` interactive installer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminInit

func AdminInit(ctx context.Context, r Runner, binary, dsn, masterKey, orgName string) error

AdminInit shells out to `<binary> admin init --org-name <org>` with CRONFOUNDRY_DATABASE_URL and CRONFOUNDRY_MASTER_KEY set in the env.

func AllowOperatorIP

func AllowOperatorIP(ctx context.Context, r Runner, env, ip string) error

AllowOperatorIP creates a Postgres firewall rule for the operator's IP. The rule name embeds a UTC timestamp so repeated runs don't collide.

func Deploy

func Deploy(ctx context.Context, r Runner, region, templateFile, paramsFile string) error

Deploy invokes `az deployment sub create` and streams output through Runner.

func GeneratePostgresPassword

func GeneratePostgresPassword() (string, error)

GeneratePostgresPassword returns a 24-character alphanumeric password. Postgres ends up in a connection-string URL where @ : / etc. would need encoding, so we keep it simple.

func Preflight

func Preflight(ctx context.Context, r Runner) error

Preflight verifies az is logged in and bicep is installed. Returns a typed error with a remediation hint.

func ProbeImage

func ProbeImage(ctx context.Context, owner, tag string) error

ProbeImage checks ghcr.io/<owner>/cronfoundry:<tag> exists anonymously. On 404 it returns an error suggesting the operator push a v* tag.

func RestartServe

func RestartServe(ctx context.Context, r Runner, env string) error

RestartServe forces a new revision so the migrated schema is picked up. (Failed revisions don't auto-heal after admin init.)

func WaitHealthy

func WaitHealthy(ctx context.Context, fqdn string, timeout time.Duration) error

WaitHealthy polls https://<fqdn>/healthz until 200 OK or timeout.

func WriteParams

func WriteParams(in Inputs, masterKey, paramsPath string) error

WriteParams writes a Bicep deployment parameters file with every required field set, ingressExternal=true, and the PEM contents inlined.

Types

type Bootstrap

type Bootstrap struct {
	Runner       Runner
	Inputs       Inputs
	MasterKey    string
	ParamsPath   string                                    // where to write the Bicep params file
	TemplateFile string                                    // path to deploy/main.bicep
	Binary       string                                    // path to the cronfoundry binary (for admin init)
	DryRun       bool                                      // skip deploy + everything after
	ImageRoot    string                                    // override ghcr.io for testing; defaults to ghcrRoot
	HealthScheme string                                    // "https" by default
	HealthHost   string                                    // test-only: override fqdn used for /healthz polling
	IPDetector   func(ctx context.Context) (string, error) // override for tests; nil → detectPublicIPDefault
	Stdout       io.Writer
}

Bootstrap orchestrates the end-to-end Azure deploy flow.

func (*Bootstrap) Run

func (b *Bootstrap) Run(ctx context.Context) error

Run executes preflight, image probe, params write, deploy, firewall, admin init, restart, and health-wait in order. Honors DryRun.

type ExecRunner

type ExecRunner struct {
	Stdout io.Writer
	Stderr io.Writer
}

ExecRunner is the production Runner, backed by os/exec.

func (*ExecRunner) Run

func (r *ExecRunner) Run(ctx context.Context, name string, args ...string) ([]byte, error)

func (*ExecRunner) RunStreaming

func (r *ExecRunner) RunStreaming(ctx context.Context, name string, args ...string) error

func (*ExecRunner) RunWithEnv

func (r *ExecRunner) RunWithEnv(ctx context.Context, env []string, name string, args ...string) error

type Inputs

type Inputs struct {
	Env               string // resource-name suffix, e.g. "prod"
	Region            string // azure region
	ImageOwner        string // ghcr owner, default "gambtho"
	ImageTag          string // ghcr tag, default "latest"
	GithubAppID       string
	OAuthClientID     string
	OAuthClientSecret string
	PEMContents       string // raw PEM contents (with BEGIN/END headers)
	AdminLogins       string // comma-separated github logins
	PostgresPassword  string
}

Inputs is everything bootstrap needs to deploy.

func Prompt

func Prompt(_ context.Context, stdin io.Reader, stdout io.Writer) (Inputs, error)

Prompt reads bootstrap inputs interactively. Empty input keeps the suggested default.

func (Inputs) Validate

func (in Inputs) Validate() error

Validate checks each field per the Bicep deployment's constraints.

type MockCall

type MockCall struct {
	Name string
	Args []string
}

type MockEnvCall

type MockEnvCall struct {
	Name string
	Args []string
	Env  []string
}

type MockResponse

type MockResponse struct {
	Stdout []byte
	Err    error
}

type MockRunner

type MockRunner struct {
	Responses []MockResponse
	Calls     []MockCall
	EnvCalls  []MockEnvCall
	Stdout    io.Writer
}

MockRunner is a test double recording calls and returning canned responses.

func (*MockRunner) Run

func (m *MockRunner) Run(_ context.Context, name string, args ...string) ([]byte, error)

func (*MockRunner) RunStreaming

func (m *MockRunner) RunStreaming(ctx context.Context, name string, args ...string) error

func (*MockRunner) RunWithEnv

func (m *MockRunner) RunWithEnv(_ context.Context, env []string, name string, args ...string) error

type Runner

type Runner interface {
	Run(ctx context.Context, name string, args ...string) ([]byte, error)
	RunStreaming(ctx context.Context, name string, args ...string) error
	RunWithEnv(ctx context.Context, env []string, name string, args ...string) error
}

Runner abstracts shell-outs so tests can stub them.

Jump to

Keyboard shortcuts

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