Documentation
¶
Overview ¶
Package initwiz provides init wizard state management and types for TerraCi. It contains the StateMap for huh form binding and all init-related type definitions (InitContributor, InitGroupSpec, InitField, etc.).
Index ¶
- type FieldType
- type InitCategory
- type InitContribution
- type InitContributor
- type InitField
- type InitGroupSpec
- type InitOption
- type StateMap
- func (s *StateMap) Binary() string
- func (s *StateMap) Bool(key string) bool
- func (s *StateMap) BoolPtr(key string) *bool
- func (s *StateMap) Get(key string) any
- func (s *StateMap) Provider() string
- func (s *StateMap) Set(key string, val any)
- func (s *StateMap) String(key string) string
- func (s *StateMap) StringPtr(key string) *string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 InitGroupSpec 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() []*InitGroupSpec
BuildInitConfig(state *StateMap) (*InitContribution, error)
}
InitContributor plugins contribute fields and config to the init wizard.
type InitField ¶
type InitField struct {
Key string
Title string
Description string
Type FieldType
Default any
Options []InitOption
Placeholder string
}
InitField describes a single form field in the init wizard.
type InitGroupSpec ¶
type InitGroupSpec struct {
Title string
Category InitCategory
Order int
Fields []InitField
ShowWhen func(*StateMap) bool
}
InitGroupSpec describes a group of form fields contributed by a plugin.
type InitOption ¶
InitOption represents a selectable option for a field.
type StateMap ¶
type StateMap struct {
// contains filtered or unexported fields
}
StateMap is the typed init state backed by a single map[string]any. It exposes typed accessors for plugins (String/Bool) and stable pointers for huh form field binding (StringPtr/BoolPtr).
Lifecycle:
- Core/plugins call Set("key", value) to populate defaults.
- Plugins call StringPtr("key") / BoolPtr("key") to obtain stable pointers for huh fields. The first call upgrades the slot from the plain value to a typed pointer; subsequent Set/Get/String/Bool keep working through that pointer.
- huh forms mutate values through the pointers during the wizard.
- After the form completes, BuildInitConfig reads back via Get/String/Bool.
All accessors flow through the same map, so Set after StringPtr now updates the value backing that pointer (no more silent staleness).
func (*StateMap) Bool ¶
Bool returns the value at key as a bool, or false if missing or of a non-bool type.
func (*StateMap) BoolPtr ¶
BoolPtr returns a stable *bool pointer for huh form binding. If the slot already holds a *bool it is returned unchanged; if it held a plain bool the slot is upgraded to a pointer initialized with that bool.
func (*StateMap) Set ¶
Set stores a value, transparently honoring any *string / *bool slot previously installed by StringPtr / BoolPtr so existing form bindings keep observing the new value.