Documentation
¶
Index ¶
- type ConnectionConfig
- type DiffAction
- type Inventory
- type Provider
- type ProviderRegistry
- type Resource
- type ResourceDiff
- type ResourceState
- type Target
- func (t *Target) AddLabel(key, value string)
- func (t *Target) Address() string
- func (t *Target) GetKeyFile() string
- func (t *Target) GetPassword() string
- func (t *Target) GetPort() int
- func (t *Target) GetUser() string
- func (t *Target) HasLabel(key, value string) bool
- func (t *Target) RemoveLabel(key string)
- func (t *Target) Validate() error
- type TargetGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionConfig ¶
type ConnectionConfig struct {
Type string `yaml:"type" json:"type"` // ssh, winrm, local
User string `yaml:"user,omitempty" json:"user,omitempty"`
KeyFile string `yaml:"key_file,omitempty" json:"key_file,omitempty"`
Password string `yaml:"password,omitempty" json:"password,omitempty"`
Port int `yaml:"port,omitempty" json:"port,omitempty"`
Timeout int `yaml:"timeout,omitempty" json:"timeout,omitempty"` // seconds
}
ConnectionConfig represents connection configuration for a target
type DiffAction ¶
type DiffAction string
DiffAction represents the type of change needed
const ( ActionCreate DiffAction = "create" ActionUpdate DiffAction = "update" ActionDelete DiffAction = "delete" ActionNoop DiffAction = "noop" )
type Inventory ¶
type Inventory struct {
Targets []Target `yaml:"targets,omitempty" json:"targets,omitempty"`
Groups []TargetGroup `yaml:"groups,omitempty" json:"groups,omitempty"`
// Dynamic inventory configuration
Dynamic map[string]interface{} `yaml:"dynamic,omitempty" json:"dynamic,omitempty"`
}
Inventory represents the complete inventory configuration
type Provider ¶
type Provider interface {
// Type returns the resource type this provider handles
Type() string
// Validate validates the resource configuration
Validate(resource *Resource) error
// Read reads the current state of the resource
Read(ctx context.Context, resource *Resource) (map[string]interface{}, error)
// Diff compares desired vs current state and returns the differences
Diff(ctx context.Context, resource *Resource, current map[string]interface{}) (*ResourceDiff, error)
// Apply applies the changes to bring the resource to desired state
Apply(ctx context.Context, resource *Resource, diff *ResourceDiff) error
}
Provider defines the interface that all resource providers must implement
type ProviderRegistry ¶
type ProviderRegistry struct {
// contains filtered or unexported fields
}
ProviderRegistry manages available providers
func NewProviderRegistry ¶
func NewProviderRegistry() *ProviderRegistry
NewProviderRegistry creates a new provider registry
func (*ProviderRegistry) Get ¶
func (pr *ProviderRegistry) Get(resourceType string) (Provider, error)
Get retrieves a provider for the given resource type
func (*ProviderRegistry) Register ¶
func (pr *ProviderRegistry) Register(provider Provider) error
Register registers a provider for a resource type
func (*ProviderRegistry) Types ¶
func (pr *ProviderRegistry) Types() []string
Types returns all registered provider types
type Resource ¶
type Resource struct {
Type string `yaml:"type" json:"type"`
Name string `yaml:"name" json:"name"`
State ResourceState `yaml:"state,omitempty" json:"state,omitempty"`
Properties map[string]interface{} `yaml:",inline" json:",inline"`
DependsOn []string `yaml:"depends_on,omitempty" json:"depends_on,omitempty"`
Notify []string `yaml:"notify,omitempty" json:"notify,omitempty"`
OnlyIf string `yaml:"only_if,omitempty" json:"only_if,omitempty"`
NotIf string `yaml:"not_if,omitempty" json:"not_if,omitempty"`
}
Resource represents a unit of infrastructure state
func (*Resource) ResourceID ¶
ResourceID returns a unique identifier for the resource
type ResourceDiff ¶
type ResourceDiff struct {
ResourceID string `json:"resource_id"`
Action DiffAction `json:"action"`
Changes map[string]interface{} `json:"changes,omitempty"`
Reason string `json:"reason,omitempty"`
}
ResourceDiff represents the difference between current and desired state
type ResourceState ¶
type ResourceState string
ResourceState represents the desired state of a resource
const ( StatePresent ResourceState = "present" StateAbsent ResourceState = "absent" StateRunning ResourceState = "running" StateStopped ResourceState = "stopped" )
type Target ¶
type Target struct {
// Host is the hostname or IP address
Host string `yaml:"host" json:"host"`
// Port is the SSH port (default: 22)
Port int `yaml:"port,omitempty" json:"port,omitempty"`
// User is the SSH username
User string `yaml:"user,omitempty" json:"user,omitempty"`
// KeyFile is the path to the SSH private key
KeyFile string `yaml:"key_file,omitempty" json:"key_file,omitempty"`
// Password is the SSH password (not recommended)
Password string `yaml:"password,omitempty" json:"password,omitempty"`
// Labels are key-value pairs for target selection
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
// Facts are discovered properties about the target
Facts map[string]interface{} `yaml:"facts,omitempty" json:"facts,omitempty"`
// Connection configuration
Connection *ConnectionConfig `yaml:"connection,omitempty" json:"connection,omitempty"`
}
Target represents a target host for configuration management
func (*Target) GetKeyFile ¶
GetKeyFile returns the effective SSH key file for the target
func (*Target) GetPassword ¶
GetPassword returns the effective password for the target
func (*Target) RemoveLabel ¶
RemoveLabel removes a label from the target
type TargetGroup ¶
type TargetGroup struct {
Name string `yaml:"name" json:"name"`
Selector string `yaml:"selector,omitempty" json:"selector,omitempty"`
Hosts []string `yaml:"hosts,omitempty" json:"hosts,omitempty"`
Connection *ConnectionConfig `yaml:"connection,omitempty" json:"connection,omitempty"`
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
}
TargetGroup represents a group of targets