types

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

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

func (r *Resource) ResourceID() string

ResourceID returns a unique identifier for the resource

func (*Resource) Validate

func (r *Resource) Validate() error

Validate checks if the resource configuration is valid

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) AddLabel

func (t *Target) AddLabel(key, value string)

AddLabel adds or updates a label on the target

func (*Target) Address

func (t *Target) Address() string

Address returns the target address in host:port format

func (*Target) GetKeyFile

func (t *Target) GetKeyFile() string

GetKeyFile returns the effective SSH key file for the target

func (*Target) GetPassword

func (t *Target) GetPassword() string

GetPassword returns the effective password for the target

func (*Target) GetPort

func (t *Target) GetPort() int

GetPort returns the effective port for the target

func (*Target) GetUser

func (t *Target) GetUser() string

GetUser returns the effective username for the target

func (*Target) HasLabel

func (t *Target) HasLabel(key, value string) bool

HasLabel checks if the target has a specific label with the given value

func (*Target) RemoveLabel

func (t *Target) RemoveLabel(key string)

RemoveLabel removes a label from the target

func (*Target) Validate

func (t *Target) Validate() error

Validate validates the target configuration

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL