setup

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package setup owns safe first-run initialization for a local Starport instance.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPathsRequired reports incomplete managed paths.
	ErrPathsRequired = errors.New("setup paths are required")
	// ErrAlreadyInitialized reports existing configuration or identity storage.
	ErrAlreadyInitialized = errors.New("starport is already initialized")
	// ErrPartialState reports an incomplete managed configuration directory.
	ErrPartialState = errors.New("starport setup state is incomplete")
	// ErrProviderRequired reports an absent provider selection.
	ErrProviderRequired = errors.New("setup provider is required")
	// ErrUnsupportedProvider reports a provider absent from the current catalog.
	ErrUnsupportedProvider = errors.New("setup provider is not in the current Starmap catalog")
	// ErrProviderCredentialRequired reports incomplete catalog-declared material.
	ErrProviderCredentialRequired = errors.New("required provider credential is not configured")
	// ErrRollbackRefused reports state that does not match an initialization result.
	ErrRollbackRefused = errors.New("setup rollback refused")
)

Functions

func InitializeIdentity

func InitializeIdentity(
	ctx context.Context,
	store storage.KVStore,
	name string,
) (identity.IssueResult, error)

InitializeIdentity creates the first named identity in configured storage. It refuses a repository that already contains an identity.

func ReleaseIdentity

func ReleaseIdentity(ctx context.Context, store storage.KVStore, id string) error

ReleaseIdentity removes an unpublished initial identity and its setup claim.

Types

type Option added in v1.0.2

type Option func(*Service)

Option configures catalog and environment setup boundaries.

func WithEnvironmentLookup added in v1.0.2

func WithEnvironmentLookup(lookup func(string) (string, bool)) Option

WithEnvironmentLookup replaces process environment access.

func WithProviderLookup added in v1.0.2

func WithProviderLookup(lookup ProviderLookup) Option

WithProviderLookup replaces the current Starmap provider lookup.

type ProviderLookup added in v1.0.2

type ProviderLookup func(context.Context, catalogs.ProviderID) (catalogs.Provider, bool, error)

ProviderLookup returns one exact provider from the setup catalog.

type Request

type Request struct {
	Provider     catalogs.ProviderID
	IdentityName string
}

Request contains the explicit choices for local initialization.

type Result

type Result struct {
	Provider     catalogs.ProviderID
	IdentityName string
	ConfigFile   string
	DataDir      string
	APIKey       string
	// contains filtered or unexported fields
}

Result contains initialized paths and the one-time gateway credential.

type Service

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

Service initializes one local configuration and identity store.

func New

func New(paths config.Paths, options ...Option) *Service

New returns a local setup service for the supplied managed paths.

func (*Service) Initialize

func (s *Service) Initialize(ctx context.Context, request Request) (Result, error)

Initialize creates local configuration and one named gateway identity. It never replaces an existing configuration file or identity store.

func (*Service) Rollback

func (s *Service) Rollback(ctx context.Context, result Result) error

Rollback removes local state when the initialization result could not be returned.

type State

type State string

State describes the durable local setup state.

const (
	// StateAbsent means the managed configuration directory does not exist.
	StateAbsent State = "absent"
	// StatePartial means the directory exists without both required artifacts.
	StatePartial State = "partial"
	// StateReady means the configuration file and identity store both exist.
	StateReady State = "ready"
)

func Inspect

func Inspect(paths config.Paths) (State, error)

Inspect reads the managed local setup state without changing it.

Jump to

Keyboard shortcuts

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