initwiz

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package initwiz provides init wizard state management and types for TerraCi.

Index

Constants

This section is empty.

Variables

View Source
var (
	ProviderKey       = MustStateKey[string]("provider")
	BinaryKey         = MustStateKey[string]("binary")
	PatternKey        = MustStateKey[string]("pattern")
	SummaryEnabledKey = MustStateKey[bool]("summary.enabled")
)

Canonical init wizard state keys owned by TerraCi core.

Functions

This section is empty.

Types

type BoolFieldOptions added in v0.10.7

type BoolFieldOptions struct {
	Key         StateKey[bool]
	Title       string
	Description string
	Default     bool
}

BoolFieldOptions describes a boolean confirmation field.

type FieldType

type FieldType string

FieldType identifies the kind of form field in the init wizard.

const (
	FieldString FieldType = "string"
	FieldBool   FieldType = "bool"
	FieldSelect FieldType = "select"
)

type InitCategory

type InitCategory string

InitCategory determines how an InitGroup is rendered in the wizard.

const (
	// CategoryProvider groups contain CI-specific infrastructure settings (image, runner).
	CategoryProvider InitCategory = "provider"
	// CategoryPipeline groups contain pipeline behavior settings.
	CategoryPipeline InitCategory = "pipeline"
	// CategoryFeature groups contain optional feature toggles.
	CategoryFeature InitCategory = "feature"
	// CategoryDetail groups contain detail settings for enabled features.
	CategoryDetail InitCategory = "detail"
)

type InitContribution

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

InitContribution holds a validated extension config produced by a plugin's init logic.

func NewInitContribution added in v0.10.5

func NewInitContribution(pluginKey string, typedConfig any) (*InitContribution, error)

NewInitContribution builds a validated init contribution from typed config.

func (*InitContribution) DecodeConfig added in v0.10.5

func (c *InitContribution) DecodeConfig(target any) error

DecodeConfig decodes the contribution config into target.

func (*InitContribution) ExtensionValue added in v0.10.5

func (c *InitContribution) ExtensionValue() config.ExtensionValue

ExtensionValue returns a defensive copy of the encoded extension config.

func (*InitContribution) PluginKey

func (c *InitContribution) PluginKey() string

PluginKey returns the extension config key.

type InitContributor

type InitContributor interface {
	plugin.Plugin
	InitGroups() ([]InitGroup, error)
	BuildInitConfig(state *StateMap) (*InitContribution, error)
}

InitContributor plugins contribute fields and config to the init wizard.

type InitField

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

InitField describes a single form field in the init wizard.

func NewBoolField added in v0.10.7

func NewBoolField(opts BoolFieldOptions) (InitField, error)

NewBoolField constructs a boolean confirmation field.

func NewSelectField added in v0.10.7

func NewSelectField(opts SelectFieldOptions) (InitField, error)

NewSelectField constructs a string select field.

func NewStringField added in v0.10.7

func NewStringField(opts StringFieldOptions) (InitField, error)

NewStringField constructs a string input field.

func (InitField) ApplyDefault added in v0.10.7

func (f InitField) ApplyDefault(state *StateMap)

ApplyDefault writes the field's default value when the key is not present.

func (InitField) BoolKey added in v0.10.7

func (f InitField) BoolKey() StateKey[bool]

BoolKey returns the typed bool key for bool fields.

func (InitField) Clone added in v0.10.7

func (f InitField) Clone() InitField

Clone returns a defensive field copy.

func (InitField) Description

func (f InitField) Description() string

Description returns the field description.

func (InitField) Key

func (f InitField) Key() string

Key returns the raw state key name for display and deterministic de-duping.

func (InitField) Options

func (f InitField) Options() []InitOption

Options returns defensive select options.

func (InitField) Placeholder

func (f InitField) Placeholder() string

Placeholder returns the string input placeholder.

func (InitField) StringKey added in v0.10.7

func (f InitField) StringKey() StateKey[string]

StringKey returns the typed string key for string and select fields.

func (InitField) Title

func (f InitField) Title() string

Title returns the field title.

func (InitField) Type

func (f InitField) Type() FieldType

Type returns the field type.

type InitGroup added in v0.10.7

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

InitGroup is a validated init wizard field group.

func NewInitGroup added in v0.10.7

func NewInitGroup(opts InitGroupOptions) (InitGroup, error)

NewInitGroup constructs a validated init wizard field group.

func (InitGroup) Category added in v0.10.7

func (g InitGroup) Category() InitCategory

Category returns the group rendering category.

func (InitGroup) Clone added in v0.10.7

func (g InitGroup) Clone() InitGroup

Clone returns a defensive group copy.

func (InitGroup) Fields added in v0.10.7

func (g InitGroup) Fields() []InitField

Fields returns defensive field copies.

func (InitGroup) Order added in v0.10.7

func (g InitGroup) Order() int

Order returns the group ordering weight.

func (InitGroup) Title added in v0.10.7

func (g InitGroup) Title() string

Title returns the group title.

func (InitGroup) Visible added in v0.10.7

func (g InitGroup) Visible(state *StateMap) bool

Visible reports whether the group should be shown for the current state.

type InitGroupOptions added in v0.10.7

type InitGroupOptions struct {
	Title    string
	Category InitCategory
	Order    int
	Fields   []InitField
	ShowWhen func(*StateMap) bool
}

InitGroupOptions describes a group of form fields contributed by a plugin.

type InitOption

type InitOption struct {
	Label string
	Value string
}

InitOption represents a selectable option for a field.

type SelectFieldOptions added in v0.10.7

type SelectFieldOptions struct {
	Key         StateKey[string]
	Title       string
	Description string
	Default     string
	Options     []InitOption
}

SelectFieldOptions describes a string select field.

type StateKey added in v0.10.7

type StateKey[T StateValue] struct {
	// contains filtered or unexported fields
}

StateKey is a typed key into StateMap.

func MustStateKey added in v0.10.7

func MustStateKey[T StateValue](name string) StateKey[T]

MustStateKey constructs a typed state key and panics for invalid programmer input. Plugin packages should define their init wizard keys once at package scope with this helper.

func NewStateKey added in v0.10.7

func NewStateKey[T StateValue](name string) (StateKey[T], error)

NewStateKey constructs a validated typed state key.

func (StateKey[T]) Bind added in v0.10.7

func (k StateKey[T]) Bind(state *StateMap) *T

Bind returns a stable typed pointer for TUI form binding.

func (StateKey[T]) Get added in v0.10.7

func (k StateKey[T]) Get(state *StateMap) T

Get returns the typed state value, or the zero value when unset.

func (StateKey[T]) Lookup added in v0.10.7

func (k StateKey[T]) Lookup(state *StateMap) (T, bool)

Lookup returns the typed state value and whether it was set.

func (StateKey[T]) Name added in v0.10.7

func (k StateKey[T]) Name() string

Name returns the raw key name used in form rendering and diagnostics.

func (StateKey[T]) Set added in v0.10.7

func (k StateKey[T]) Set(state *StateMap, value T)

Set stores a typed state value. If a UI binding already exists for this key, the binding target is updated in place.

type StateMap

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

StateMap is mutable wizard state backed by typed StateKey slots. It remains mutable because TUI form bindings need stable pointers, but plugin code reads and writes only through StateKey values.

func NewStateMap

func NewStateMap() *StateMap

NewStateMap creates an empty StateMap.

type StateValue added in v0.10.7

type StateValue interface {
	~string | ~bool
}

StateValue is the set of supported init wizard state value types.

type StringFieldOptions added in v0.10.7

type StringFieldOptions struct {
	Key         StateKey[string]
	Title       string
	Description string
	Default     string
	Placeholder string
}

StringFieldOptions describes a string input field.

Jump to

Keyboard shortcuts

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