Documentation
¶
Overview ¶
Package initwiz provides init wizard state management and types for TerraCi.
Index ¶
- Variables
- type BoolFieldOptions
- type FieldType
- type InitCategory
- type InitContribution
- type InitContributor
- type InitField
- func (f InitField) ApplyDefault(state *StateMap)
- func (f InitField) BoolKey() StateKey[bool]
- func (f InitField) Clone() InitField
- func (f InitField) Description() string
- func (f InitField) Key() string
- func (f InitField) Options() []InitOption
- func (f InitField) Placeholder() string
- func (f InitField) StringKey() StateKey[string]
- func (f InitField) Title() string
- func (f InitField) Type() FieldType
- type InitGroup
- type InitGroupOptions
- type InitOption
- type SelectFieldOptions
- type StateKey
- type StateMap
- type StateValue
- type StringFieldOptions
Constants ¶
This section is empty.
Variables ¶
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
BoolFieldOptions describes a boolean confirmation field.
type FieldType ¶
type FieldType string
FieldType identifies the kind of form field in the init wizard.
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
ApplyDefault writes the field's default value when the key is not present.
func (InitField) Description ¶
Description returns the field description.
func (InitField) Options ¶
func (f InitField) Options() []InitOption
Options returns defensive select options.
func (InitField) Placeholder ¶
Placeholder returns the string input placeholder.
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.
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 ¶
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
Bind returns a stable typed pointer for TUI form binding.
func (StateKey[T]) Get ¶ added in v0.10.7
Get returns the typed state value, or the zero value when unset.
func (StateKey[T]) Lookup ¶ added in v0.10.7
Lookup returns the typed state value and whether it was set.
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.
type StateValue ¶ added in v0.10.7
StateValue is the set of supported init wizard state value types.