Documentation
¶
Overview ¶
Package features defines the core feature interface and common functionality
Package features provides the core feature interface and registry
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RegisterUserFeature func(*Registry, *osdetect.Info) RegisterSSHFeature func(*Registry, *osdetect.Info) RegisterSudoFeature func(*Registry, *osdetect.Info) RegisterSecurityFeature func(*Registry, *osdetect.Info) )
Feature registration functions
Functions ¶
func RegisterFeatures ¶
RegisterFeatures registers all features with the registry
Types ¶
type ExecutionContext ¶
type ExecutionContext struct {
// Options contains the parsed command-line options
Options map[string]any
// Logger is the logger instance
Logger *logger.Logger
// DryRun indicates if the feature should only simulate execution
DryRun bool
// Interactive indicates if the feature should prompt for user input
Interactive bool
// Verbose indicates if the feature should output verbose information
Verbose bool
}
ExecutionContext provides context for feature execution
type Feature ¶
type Feature interface {
// Name returns the feature name
Name() string
// Description returns the feature description
Description() string
// Flags returns the command-line flags for the feature
Flags() []Flag
// ShouldActivate determines if the feature should be activated based on options
ShouldActivate(options map[string]any) bool
// ValidateOptions validates the feature options
ValidateOptions(options map[string]any) error
// Execute executes the feature functionality
Execute(ctx *ExecutionContext) error
// Priority returns the feature execution priority (lower numbers run first)
Priority() int
// DetectCurrentState detects and returns the current state of the feature
// The returned map contains state information that can be used for display and decision making
DetectCurrentState(ctx *ExecutionContext) (map[string]any, error)
// DisplayCurrentState displays the current state of the feature to the user
// This is used in interactive mode to show the user the current state before prompting
DisplayCurrentState(ctx *ExecutionContext, state map[string]any)
// ShouldPromptUser determines if the user should be prompted for input based on the current state
// This allows features to skip prompting if the current state already matches the desired state
ShouldPromptUser(ctx *ExecutionContext, state map[string]any) bool
}
Feature defines the interface that all features must implement
func SortFeaturesByPriority ¶
SortFeaturesByPriority sorts features by priority (lower numbers first)
type Flag ¶
type Flag struct {
// Name is the long name of the flag (e.g., "user")
Name string
// Shorthand is the short name of the flag (e.g., "u")
Shorthand string
// Usage is the help text for the flag
Usage string
// Default is the default value for the flag
Default any
// Required indicates if the flag is required
Required bool
}
Flag represents a command-line flag for a feature
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages the registration and retrieval of features
func (*Registry) GetActiveFeatures ¶
GetActiveFeatures returns features that should be activated based on options
func (*Registry) GetFeatures ¶
GetFeatures returns all registered features
Directories
¶
| Path | Synopsis |
|---|---|
|
Package security implements the SSH security configuration feature
|
Package security implements the SSH security configuration feature |
|
Package ssh implements the SSH key management feature
|
Package ssh implements the SSH key management feature |
|
Package sudo implements the sudo configuration feature
|
Package sudo implements the sudo configuration feature |
|
Package user implements the user management feature
|
Package user implements the user management feature |
Click to show internal directories.
Click to hide internal directories.