Documentation
¶
Overview ¶
Package scaffold provides profile scaffolding functionality for the init command. It generates starter profiles and system configurations based on user-selected plugins.
Index ¶
- Constants
- Variables
- func DefaultConfigPath() string
- func EnsureConfigDir(configPath string) error
- func ExpandConfigPath(path string) (string, error)
- func ValidPluginNames() map[string]bool
- func ValidateProfileName(name string) error
- type CapabilityGrant
- type ConfigGenerator
- type GeneratedProfile
- type InitOptions
- type PluginExample
- type PluginInfo
- type ProfileGenerator
Constants ¶
const DefaultOutputPath = "./reglet-profile.yaml"
DefaultOutputPath is the default output path for generated profiles.
Variables ¶
var AvailablePlugins = []PluginInfo{
{Name: "file", Description: "Validate file existence, permissions, and content"},
{Name: "http", Description: "Check HTTP endpoints and responses"},
{Name: "dns", Description: "Verify DNS records and resolution"},
{Name: "tcp", Description: "Test TCP port connectivity"},
{Name: "command", Description: "Execute shell commands and validate output"},
{Name: "smtp", Description: "Validate SMTP server configuration"},
}
AvailablePlugins returns the list of plugins that can be selected during init.
Functions ¶
func DefaultConfigPath ¶
func DefaultConfigPath() string
DefaultConfigPath returns the default system config path. This is always ~/.reglet/config.yaml.
func EnsureConfigDir ¶
EnsureConfigDir creates the config directory if it doesn't exist.
func ExpandConfigPath ¶
ExpandConfigPath expands ~ in the config path to the user's home directory.
func ValidPluginNames ¶
ValidPluginNames returns a set of valid plugin names for validation.
func ValidateProfileName ¶
ValidateProfileName is a validation function for use with huh.Input. Returns an error if the name is invalid, nil otherwise.
Types ¶
type CapabilityGrant ¶
type CapabilityGrant struct {
Kind string // fs, network, exec, env
Pattern string // e.g., "read:/etc/hostname", "outbound:80,443"
}
CapabilityGrant represents a single capability grant for config generation.
func GetCapabilitiesForPlugins ¶
func GetCapabilitiesForPlugins(plugins []string) []CapabilityGrant
GetCapabilitiesForPlugins returns all capability grants needed for the given plugins. This aggregates capabilities from all plugin examples.
type ConfigGenerator ¶
type ConfigGenerator struct{}
ConfigGenerator generates system configuration YAML content.
func NewConfigGenerator ¶
func NewConfigGenerator() *ConfigGenerator
NewConfigGenerator creates a new ConfigGenerator.
type GeneratedProfile ¶
type GeneratedProfile struct {
// ProfilePath is the target output path for the profile
ProfilePath string
// ConfigPath is the target output path for the config (empty if not generated)
ConfigPath string
// ProfileContent is the raw YAML content of the generated profile
ProfileContent []byte
// ConfigContent is the raw YAML content of the config (nil if not generated)
ConfigContent []byte
}
GeneratedProfile holds the result of profile generation.
type InitOptions ¶
type InitOptions struct {
// ProfileName is the name for the generated profile (required)
ProfileName string
// OutputPath is where to write the generated profile (default: ./reglet-profile.yaml)
OutputPath string
// Plugins is the list of selected plugins to include (required, 1-6 items)
Plugins []string
// WithConfig indicates whether to generate ~/.reglet/config.yaml
WithConfig bool
// Force allows overwriting existing files without prompting
Force bool
}
InitOptions holds the configuration collected from the wizard or CLI flags. This value object encapsulates all user inputs needed for profile generation.
func (*InitOptions) Validate ¶
func (o *InitOptions) Validate() error
Validate checks that all required fields are present and valid. Returns an error describing the first validation failure, or nil if valid.
type PluginExample ¶
type PluginExample struct {
// PluginName is the plugin identifier (file, http, etc.)
PluginName string
// ControlID is the unique identifier for the example control
ControlID string
// ControlName is the human-readable name for the control
ControlName string
// Description explains what the example demonstrates
Description string
// ConfigYAML is the plugin-specific configuration as a YAML fragment
// This is embedded directly in the generated profile
ConfigYAML string
// ExpectExpressions are the example expect expressions
ExpectExpressions []string
// Capabilities lists the required capability grants for this example
Capabilities []CapabilityGrant
}
PluginExample represents a template for a single plugin's example control. Each plugin type has one example demonstrating its basic usage.
func GetPluginExample ¶
func GetPluginExample(pluginName string) *PluginExample
GetPluginExample returns the example configuration for a specific plugin. Returns nil if the plugin is not found.
func GetPluginExamples ¶
func GetPluginExamples(plugins []string) []PluginExample
GetPluginExamples returns examples for the specified plugins. Unknown plugins are silently skipped.
type PluginInfo ¶
type PluginInfo struct {
Name string // Plugin identifier
Description string // User-facing description for selection UI
}
PluginInfo provides metadata about available plugins.
type ProfileGenerator ¶
type ProfileGenerator struct{}
ProfileGenerator generates profile YAML content from InitOptions.
func NewProfileGenerator ¶
func NewProfileGenerator() *ProfileGenerator
NewProfileGenerator creates a new ProfileGenerator.
func (*ProfileGenerator) Generate ¶
func (g *ProfileGenerator) Generate(opts *InitOptions) (*GeneratedProfile, error)
Generate creates profile content from the provided options. Returns an error if options are invalid or template execution fails.