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 (plan_enabled, auto_approve). CategoryPipeline InitCategory = "pipeline" // CategoryFeature groups contain optional feature toggles (cost, policy, summary). CategoryFeature InitCategory = "feature" // CategoryDetail groups contain detail settings for enabled features (policy settings). CategoryDetail InitCategory = "detail" )
type InitContribution ¶
InitContribution holds the config produced by a plugin's init logic.
type InitContributor ¶
type InitContributor interface {
plugin.Plugin
InitGroups() []*InitGroupSpec
BuildInitConfig(state *StateMap) *InitContribution
}
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 maps. It provides both typed accessors and stable pointers for huh form field binding.
Lifecycle:
- Core calls Set("key", "default") to populate initial values.
- Plugins call StringPtr("key") / BoolPtr("key") to get stable pointers for huh fields.
- huh form mutates values through the pointers during user interaction.
- After form completes, BuildInitConfig reads back via Get() / String() / Bool().
Get() resolves with priority: StringPtr store > BoolPtr store > Set store. This ensures pointer-backed values (mutated by forms) take precedence.
func (*StateMap) BoolPtr ¶
BoolPtr returns a stable *bool pointer for huh form binding. If a value was previously Set for the key, it initializes the pointer with that value.
func (*StateMap) Get ¶
Get retrieves a value, preferring pointer-backed values from StringPtr/BoolPtr.