model

package
v0.0.19-0...-9bec282 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HealthCheckNagiosFormat HealthCheckFormat = "nagios"
	HealthCheckGossFormat   HealthCheckFormat = "goss"

	HealthCheckOK       HealthCheckStatus = 0
	HealthCheckWarning  HealthCheckStatus = 1
	HealthCheckCritical HealthCheckStatus = 2
	HealthCheckUnknown  HealthCheckStatus = 3
)
View Source
const (
	// EnsurePresent indicates a resource should be present on the system
	EnsurePresent string = "present"
	// EnsureAbsent indicates a resource should be removed from the system
	EnsureAbsent string = "absent"
)
View Source
const (
	ResourceEnsureApiRequestProtocol  = "io.choria.ccm.v1.resource.ensure.request"
	ResourceEnsureApiResponseProtocol = "io.choria.ccm.v1.resource.ensure.response"
)
View Source
const (
	// ResourceStatusArchiveProtocol is the protocol identifier for archive resource state
	ResourceStatusArchiveProtocol = "io.choria.ccm.v1.resource.archive.state"

	// ArchiveTypeName is the type name for archive resources
	ArchiveTypeName = "archive"
)
View Source
const (
	// ResourceStatusExecProtocol is the protocol identifier for exec resource state
	ResourceStatusExecProtocol = "io.choria.ccm.v1.resource.exec.state"

	// ExecTypeName is the type name for exec resources
	ExecTypeName = "exec"
)
View Source
const (
	// ResourceStatusFileProtocol is the protocol identifier for file resource state
	ResourceStatusFileProtocol = "io.choria.ccm.v1.resource.file.state"

	// FileTypeName is the type name for file resources
	FileTypeName = "file"

	FileEnsureDirectory = "directory"
)
View Source
const (
	// ResourceStatusPackageProtocol is the protocol identifier for package resource state
	ResourceStatusPackageProtocol = "io.choria.ccm.v1.resource.package.state"

	// PackageTypeName is the type name for package resources
	PackageTypeName = "package"

	PackageEnsureLatest = "latest"
)
View Source
const (
	// ResourceStatusScaffoldProtocol is the protocol identifier for scaffold resource state
	ResourceStatusScaffoldProtocol = "io.choria.ccm.v1.resource.scaffold.state"

	// ScaffoldTypeName is the type name for scaffold resources
	ScaffoldTypeName = "scaffold"
)
View Source
const (
	ServiceEnsureRunning = "running"
	ServiceEnsureStopped = "stopped"
	// ResourceStatusServiceProtocol is the protocol identifier for service resource state
	ResourceStatusServiceProtocol = "io.choria.ccm.v1.resource.service.state"

	// ServiceTypeName is the type name for service resources
	ServiceTypeName = "service"
)
View Source
const SessionStartEventProtocol = "io.choria.ccm.v1.session.start"
View Source
const TransactionEventProtocol = "io.choria.ccm.v1.transaction.event"

Variables

View Source
var (
	ErrResourceInvalid        = errors.New("invalid resource")
	ErrResourceNameRequired   = errors.New("name is required")
	ErrResourceEnsureRequired = errors.New("ensure is required")
	ErrInvalidRequires        = errors.New("invalid require properties")
	ErrProviderNotFound       = errors.New("provider not found")
	ErrProviderNotManageable  = errors.New("provider is not manageable")
	ErrNoSuitableProvider     = errors.New("no suitable provider found")
	ErrDuplicateProvider      = errors.New("provider already exists")
	ErrUnknownType            = errors.New("unknown resource type")
	ErrDesiredStateFailed     = errors.New("failed to reach desired state")
	ErrInvalidEnsureValue     = errors.New("invalid ensure value")
	ErrInvalidState           = errors.New("invalid state encountered")
)
View Source
var PackageGlobalLock = sync.Mutex{}

PackageGlobalLock is used to ensure only one package resource is running at a time even when multiple managers are applying multiple manifests. This avoids issues with concurrent access to databases etc

View Source
var ServiceGlobalLock = sync.Mutex{}

ServiceGlobalLock is used to ensure only one service resource is running at a time even when multiple managers are applying multiple manifests.

Functions

func MarshalResourceEnsureApiResponse added in v0.0.16

func MarshalResourceEnsureApiResponse(encoding RequestEncoding, event *TransactionEvent, err error) ([]byte, error)

Types

type Apply

type Apply interface {
	Resources() []map[string]ResourceProperties
	Data() map[string]any
	FailOnError() bool
	Execute(ctx context.Context, mgr Manager, healthCheckOnly bool, userLog Logger) (SessionStore, error)
	Source() string
	String() string
	PreMessage() string
	PostMessage() string
}

type ArchiveMetadata added in v0.0.15

type ArchiveMetadata struct {
	Name          string    `json:"name" yaml:"name"`
	Checksum      string    `json:"checksum,omitempty" yaml:"checksum,omitempty"`
	ArchiveExists bool      `json:"archive_exists,omitempty" yaml:"archive_exists,omitempty"`
	CreatesExists bool      `json:"creates_exists,omitempty" yaml:"creates_exists,omitempty"`
	Owner         string    `json:"owner" yaml:"owner"`
	Group         string    `json:"group" yaml:"group"`
	MTime         time.Time `json:"mtime,omitempty" yaml:"mtime,omitempty"`
	Size          int64     `json:"size,omitempty" yaml:"size,omitempty"`
	Provider      string    `json:"provider,omitempty" yaml:"provider,omitempty"`
}

ArchiveMetadata contains detailed metadata about an archive

type ArchiveResourceProperties added in v0.0.15

type ArchiveResourceProperties struct {
	CommonResourceProperties `yaml:",inline"`
	Url                      string            `json:"url" yaml:"url"`                                           // URL specifies the URL to download the archive from
	Headers                  map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`               // Headers specify any HTTP headers to include in the request
	Username                 string            `json:"username,omitempty" yaml:"username,omitempty"`             // Username specifies the username to use for basic auth
	Password                 string            `json:"password,omitempty" yaml:"password,omitempty"`             // Password specifies the password to use for basic auth
	Checksum                 string            `json:"checksum,omitempty" yaml:"checksum,omitempty"`             // Checksum specifies the expected sha256 checksum of the archive
	ExtractParent            string            `json:"extract_parent,omitempty" yaml:"extract_parent,omitempty"` // ExtractParent specifies the parent directory to extract the archive into
	Cleanup                  bool              `json:"cleanup,omitempty" yaml:"cleanup,omitempty"`               // Cleanup specifies whether to remove the archive file after extraction
	Creates                  string            `json:"creates,omitempty" yaml:"creates,omitempty"`               // Creates specifies a file that the archive creates; if this file exists, the archive will not be extracted on future runs
	Owner                    string            `json:"owner" yaml:"owner"`                                       // Owner specifies the user that should own the file
	Group                    string            `json:"group" yaml:"group"`                                       // Group specifies the group that should own the file
}

ArchiveResourceProperties defines the properties for a archive resource

func (*ArchiveResourceProperties) CommonProperties added in v0.0.15

func (p *ArchiveResourceProperties) CommonProperties() *CommonResourceProperties

func (*ArchiveResourceProperties) ResolveTemplates added in v0.0.15

func (p *ArchiveResourceProperties) ResolveTemplates(env *templates.Env) error

ResolveTemplates resolves template expressions in the package resource properties

func (*ArchiveResourceProperties) ToYamlManifest added in v0.0.15

func (p *ArchiveResourceProperties) ToYamlManifest() (yaml.RawMessage, error)

ToYamlManifest returns the package resource properties as a yaml document

func (*ArchiveResourceProperties) Validate added in v0.0.15

func (p *ArchiveResourceProperties) Validate() error

Validate validates the package resource properties

type ArchiveState added in v0.0.15

type ArchiveState struct {
	CommonResourceState

	Metadata *ArchiveMetadata `json:"metadata,omitempty"`
}

ArchiveState represents the current state of an archive on the system

func (*ArchiveState) CommonState added in v0.0.15

func (f *ArchiveState) CommonState() *CommonResourceState

type CommandRunner

type CommandRunner interface {
	Execute(ctx context.Context, cmd string, args ...string) (stdout []byte, stderr []byte, exitCode int, err error)
	ExecuteWithOptions(ctx context.Context, opts ExtendedExecOptions) ([]byte, []byte, int, error)
}

type CommonHealthCheck added in v0.0.2

type CommonHealthCheck struct {
	Command       string            `json:"command,omitempty" yaml:"command,omitempty"`       // Command is the shell command to execute for nagios-format health checks
	GossRules     yaml.RawMessage   `json:"goss_rules,omitempty" yaml:"goss_rules,omitempty"` // GossRules contains YAML rules for goss-format health checks
	Name          string            `json:"name,omitempty" yaml:"name,omitempty"`             // Name is the human-readable identifier for this health check
	Timeout       string            `json:"timeout,omitempty" yaml:"timeout,omitempty"`       // Timeout is the maximum duration to wait for health check completion (parsed into ParsedTimeout)
	Tries         int               `json:"tries,omitempty" yaml:"tries,omitempty"`           // Tries is the number of retry attempts before marking the health check as failed
	TrySleep      string            `json:"try_sleep,omitempty" yaml:"try_sleep,omitempty"`   // TrySleep is the duration to wait between retry attempts (parsed into ParseTrySleep)
	Format        HealthCheckFormat `json:"format,omitempty" yaml:"format,omitempty"`         // Format specifies the health check output format (nagios or goss)
	ParsedTimeout time.Duration     `json:"-" yaml:"-"`                                       // ParsedTimeout is the parsed duration from the Timeout field
	ParseTrySleep time.Duration     `json:"-" yaml:"-"`                                       // ParseTrySleep is the parsed duration from the TrySleep field
	TypeName      string            `json:"-" yaml:"-"`                                       // TypeName is the resource type this health check belongs to (e.g., "service", "package")
	ResourceName  string            `json:"-" yaml:"-"`                                       // ResourceName is the specific resource instance this health check belongs to
}

CommonHealthCheck defines the configuration for resource health checks

func (*CommonHealthCheck) UnmarshalJSON added in v0.0.2

func (c *CommonHealthCheck) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler to parse Timeout string into ParsedTimeout duration

func (*CommonHealthCheck) UnmarshalYAML added in v0.0.2

func (c *CommonHealthCheck) UnmarshalYAML(data []byte) error

UnmarshalYAML implements yaml.BytesUnmarshaler to parse Timeout string into ParsedTimeout duration

type CommonResourceControl added in v0.0.12

type CommonResourceControl struct {
	ManageIf     string `json:"if,omitempty" yaml:"if,omitempty"`
	ManageUnless string `json:"unless,omitempty" yaml:"unless,omitempty"`
}

type CommonResourceProperties

type CommonResourceProperties struct {
	Type         string                 `json:"-" yaml:"-"`
	Name         string                 `json:"name" yaml:"name"`
	Alias        string                 `json:"alias,omitempty" yaml:"alias,omitempty"`
	Ensure       string                 `json:"ensure,omitempty" yaml:"ensure,omitempty"`
	Provider     string                 `json:"provider,omitempty" yaml:"provider,omitempty"`
	HealthChecks []CommonHealthCheck    `json:"health_checks,omitempty" yaml:"health_checks,omitempty"`
	Require      []string               `json:"require,omitempty" yaml:"require,omitempty"`
	Control      *CommonResourceControl `json:"control,omitempty" yaml:"control,omitempty"`
	SkipValidate bool                   `json:"-" yaml:"-"`
}

CommonResourceProperties contains properties shared by all resource types

func (*CommonResourceProperties) ResolveTemplates

func (p *CommonResourceProperties) ResolveTemplates(env *templates.Env) error

ResolveTemplates resolves template expressions in common resource properties

func (*CommonResourceProperties) Validate

func (p *CommonResourceProperties) Validate() error

Validate validates common resource properties

type CommonResourceState

type CommonResourceState struct {
	TimeStamp    time.Time          `json:"timestamp" yaml:"timestamp"`
	Protocol     string             `json:"protocol" yaml:"protocol"`
	ResourceType string             `json:"type" yaml:"type"`
	Name         string             `json:"name" yaml:"name"`
	Ensure       string             `json:"ensure" yaml:"ensure"`
	Changed      bool               `json:"changed" yaml:"changed"`
	Refreshed    bool               `json:"refreshed" yaml:"refreshed"`
	Stable       bool               `json:"stable" yaml:"stable"`
	Noop         bool               `json:"noop" yaml:"noop"`
	NoopMessage  string             `json:"noop_message,omitempty" yaml:"noop_message,omitempty"`
	HealthCheck  *HealthCheckResult `json:"health_check,omitempty" yaml:"health_check,omitempty"`
}

CommonResourceState contains state information shared by all resource types

func NewCommonResourceState

func NewCommonResourceState(protocol string, resourceType string, name string, ensure string) CommonResourceState

NewCommonResourceState creates a new common resource state with the given properties

type ExecMetadata added in v0.0.6

type ExecMetadata struct {
	Name     string         `json:"name" yaml:"name"`
	Provider string         `json:"provider,omitempty" yaml:"provider,omitempty"`
	Runtime  time.Duration  `json:"runtime,omitempty" yaml:"runtime,omitempty"`
	Extended map[string]any `json:"extended,omitempty" yaml:"extended,omitempty"`
}

ExecMetadata contains detailed metadata about an execution

type ExecResourceProperties added in v0.0.6

type ExecResourceProperties struct {
	CommonResourceProperties `yaml:",inline"`
	Command                  string   `json:"command" yaml:"command"`                             // Command specifies the command to run, when not set will use the name property
	Cwd                      string   `json:"cwd,omitempty" yaml:"cwd,omitempty"`                 // Cwd specifies the working directory from which to run the command
	Environment              []string `json:"environment,omitempty" yaml:"environment,omitempty"` // Environment specifies additional environment variables to set when running the command
	Path                     string   `json:"path,omitempty" yaml:"path,omitempty"`               // Path specifies the search path for executable commands, as an array of directories or a colon-separated list
	Returns                  []int    `json:"returns,omitempty" yaml:"returns,omitempty"`         // Returns specify the expected exit codes indicating success; defaults to 0 if not specified
	Timeout                  string   `json:"timeout,omitempty" yaml:"timeout,omitempty"`         // Timeout specifies the maximum time the command is allowed to run; if exceeded the command will be terminated, the timeout is a duration like 10s
	Creates                  string   `json:"creates,omitempty" yaml:"creates,omitempty"`         // Creates specifies a file that the command creates; if this file exists the command will not run
	RefreshOnly              bool     `json:"refreshonly,omitempty" yaml:"refreshonly,omitempty"` // RefreshOnly determines whether the command should only run when notified by a subscribed resource
	Subscribe                []string `json:"subscribe,omitempty" yaml:"subscribe,omitempty"`     // Subscribe specifies resources to subscribe to for refresh notifications in the format "type#name"
	LogOutput                bool     `json:"logoutput,omitempty" yaml:"logoutput,omitempty"`     // LogOutput determines whether to log the command's output

	ParsedTimeout time.Duration `json:"-" yaml:"-"` // ParsedTimeout is the parsed duration representation of Timeout, should not be set by callers
}

ExecResourceProperties defines the properties for an exec resource

func (*ExecResourceProperties) CommonProperties added in v0.0.6

func (p *ExecResourceProperties) CommonProperties() *CommonResourceProperties

func (*ExecResourceProperties) ResolveTemplates added in v0.0.6

func (p *ExecResourceProperties) ResolveTemplates(env *templates.Env) error

ResolveTemplates resolves template expressions in the package resource properties

func (*ExecResourceProperties) ToYamlManifest added in v0.0.6

func (p *ExecResourceProperties) ToYamlManifest() (yaml.RawMessage, error)

ToYamlManifest returns the package resource properties as a yaml document

func (*ExecResourceProperties) Validate added in v0.0.6

func (p *ExecResourceProperties) Validate() error

Validate validates the package resource properties

type ExecState added in v0.0.6

type ExecState struct {
	CommonResourceState

	ExitCode         *int `json:"exitcode,omitempty" yaml:"exitcode"`
	CreatesSatisfied bool `json:"creates_satisfied,omitempty" yaml:"creates_satisfied"`
}

ExecState represents the current state of an execution

func (*ExecState) CommonState added in v0.0.6

func (f *ExecState) CommonState() *CommonResourceState

type ExtendedExecOptions added in v0.0.6

type ExtendedExecOptions struct {
	Command     string
	Args        []string
	Cwd         string
	Environment []string
	Path        string
	Timeout     time.Duration
}

type FileMetadata added in v0.0.3

type FileMetadata struct {
	Name     string         `json:"name" yaml:"name"`
	Checksum string         `json:"checksum,omitempty" yaml:"checksum,omitempty"`
	Owner    string         `json:"owner" yaml:"owner"`
	Group    string         `json:"group" yaml:"group"`
	Mode     string         `json:"mode" yaml:"mode"`
	Provider string         `json:"provider,omitempty" yaml:"provider,omitempty"`
	MTime    time.Time      `json:"mtime,omitempty" yaml:"mtime,omitempty"`
	Size     int64          `json:"size,omitempty" yaml:"size,omitempty"`
	Extended map[string]any `json:"extended,omitempty" yaml:"extended,omitempty"`
}

FileMetadata contains detailed metadata about a file

type FileResourceProperties added in v0.0.3

type FileResourceProperties struct {
	CommonResourceProperties `yaml:",inline"`
	Contents                 string `json:"content,omitempty" yaml:"content,omitempty"` // Contents specifies the desired file contents as a string; mutually exclusive with Source
	Source                   string `json:"source,omitempty" yaml:"source,omitempty"`   // Source specifies a local file path to use as the source for the file contents; mutually exclusive with Contents
	Owner                    string `json:"owner" yaml:"owner"`                         // Owner specifies the user that should own the file
	Group                    string `json:"group" yaml:"group"`                         // Group specifies the group that should own the file
	Mode                     string `json:"mode" yaml:"mode"`                           // Mode specifies the file permissions in octal notation (e.g., "0644")
}

FileResourceProperties defines the properties for a file resource

func (*FileResourceProperties) CommonProperties added in v0.0.5

func (p *FileResourceProperties) CommonProperties() *CommonResourceProperties

func (*FileResourceProperties) ResolveTemplates added in v0.0.3

func (p *FileResourceProperties) ResolveTemplates(env *templates.Env) error

ResolveTemplates resolves template expressions in the package resource properties

func (*FileResourceProperties) ToYamlManifest added in v0.0.3

func (p *FileResourceProperties) ToYamlManifest() (yaml.RawMessage, error)

ToYamlManifest returns the file resource properties as a yaml document

func (*FileResourceProperties) Validate added in v0.0.3

func (p *FileResourceProperties) Validate() error

Validate validates the package resource properties

type FileState added in v0.0.3

type FileState struct {
	CommonResourceState

	Metadata *FileMetadata `json:"metadata,omitempty"`
}

FileState represents the current state of a file on the system

func (*FileState) CommonState added in v0.0.5

func (f *FileState) CommonState() *CommonResourceState

type HealthCheckFormat added in v0.0.2

type HealthCheckFormat string

type HealthCheckResult added in v0.0.2

type HealthCheckResult struct {
	Status HealthCheckStatus `json:"status" yaml:"status"`
	Tries  int               `json:"tries" yaml:"tries"`
	Output string
}

HealthCheckResult represents the outcome of a health check execution

type HealthCheckStatus added in v0.0.2

type HealthCheckStatus int

func (HealthCheckStatus) String added in v0.0.2

func (s HealthCheckStatus) String() string

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
	With(args ...any) Logger
}

type Manager

type Manager interface {
	Close() error
	FactsRaw(ctx context.Context) (json.RawMessage, error)
	Facts(ctx context.Context) (map[string]any, error)
	MergeFacts(ctx context.Context, facts map[string]any) (map[string]any, error)
	SetFacts(facts map[string]any)
	SystemFacts(ctx context.Context) (map[string]any, error)
	Data() map[string]any
	SetData(data map[string]any) map[string]any
	SetExternalData(data map[string]any)
	Logger(args ...any) (Logger, error)
	UserLogger() Logger
	NewRunner() (CommandRunner, error)
	RecordEvent(event *TransactionEvent) error
	ShouldRefresh(resourceType string, resourceName string) (bool, error)
	IsResourceFailed(resourceType string, resourceName string) (bool, error)
	TemplateEnvironment(ctx context.Context) (*templates.Env, error)
	SetWorkingDirectory(dir string)
	WorkingDirectory() string
	StartSession(Apply) (SessionStore, error)
	ResourceInfo(ctx context.Context, typeName, name string) (any, error)
	SessionSummary() (*SessionSummary, error)
	NoopMode() bool
	JetStream() (jetstream.JetStream, error)
}

type NatsConnProvider added in v0.0.9

type NatsConnProvider interface {
	Connect(natsContext string, opts ...nats.Option) (*nats.Conn, error)
}

type PackageMetadata

type PackageMetadata struct {
	Name        string         `json:"name" yaml:"name"`
	Version     string         `json:"version" yaml:"version"`
	Arch        string         `json:"arch,omitempty" yaml:"arch,omitempty"`
	License     string         `json:"license,omitempty" yaml:"license,omitempty"`
	URL         string         `json:"url,omitempty" yaml:"url,omitempty"`
	Summary     string         `json:"summary,omitempty" yaml:"summary,omitempty"`
	Description string         `json:"description,omitempty" yaml:"description,omitempty"`
	Provider    string         `json:"provider,omitempty" yaml:"provider,omitempty"`
	Extended    map[string]any `json:"extended,omitempty" yaml:"extended,omitempty"`
}

PackageMetadata contains detailed metadata about a package

type PackageResourceProperties

type PackageResourceProperties struct {
	CommonResourceProperties `yaml:",inline"`
}

PackageResourceProperties defines the properties for a package resource

func (*PackageResourceProperties) CommonProperties added in v0.0.5

func (p *PackageResourceProperties) CommonProperties() *CommonResourceProperties

func (*PackageResourceProperties) ResolveTemplates

func (p *PackageResourceProperties) ResolveTemplates(env *templates.Env) error

ResolveTemplates resolves template expressions in the package resource properties

func (*PackageResourceProperties) ToYamlManifest

func (p *PackageResourceProperties) ToYamlManifest() (yaml.RawMessage, error)

ToYamlManifest returns the package resource properties as a yaml document

func (*PackageResourceProperties) Validate

func (p *PackageResourceProperties) Validate() error

Validate validates the package resource properties

type PackageState

type PackageState struct {
	CommonResourceState

	Metadata *PackageMetadata `json:"metadata,omitempty"`
}

PackageState represents the current state of a package on the system

func (*PackageState) CommonState added in v0.0.5

func (f *PackageState) CommonState() *CommonResourceState

type Provider

type Provider interface {
	Name() string
}

Provider is an interface for a resource provider

type ProviderFactory

type ProviderFactory interface {
	IsManageable(map[string]any, ResourceProperties) (usable bool, priority int, err error)
	TypeName() string
	Name() string
	New(Logger, CommandRunner) (Provider, error)
}

type RequestEncoding added in v0.0.16

type RequestEncoding int
var JsonRequestEncoding RequestEncoding = 1
var UnknownRequestEncoding RequestEncoding = 0
var YamlRequestEncoding RequestEncoding = 2

func (RequestEncoding) String added in v0.0.16

func (e RequestEncoding) String() string

type Resource

type Resource interface {
	Type() string
	Name() string
	Provider() string
	Properties() ResourceProperties
	Apply(context.Context) (*TransactionEvent, error)
	Info(context.Context) (any, error)
	Healthcheck(ctx context.Context) (*TransactionEvent, error)
}

Resource represents a system resource that can be managed

type ResourceEnsureApiRequest added in v0.0.16

type ResourceEnsureApiRequest struct {
	Protocol   string          `json:"protocol" yaml:"protocol"`
	Type       string          `json:"type" yaml:"type"`
	Properties yaml.RawMessage `json:"properties" yaml:"properties"`
	Encoding   RequestEncoding `json:"-" yaml:"-"`
}

func UnmarshalResourceEnsureApiRequest added in v0.0.16

func UnmarshalResourceEnsureApiRequest(req []byte) (*ResourceEnsureApiRequest, error)

UnmarshalResourceEnsureApiRequest unmarshals a resource ensure request, the input request can be YAML or JSON

type ResourceEnsureApiResponse added in v0.0.16

type ResourceEnsureApiResponse struct {
	Protocol string            `json:"protocol" yaml:"protocol"`
	Error    string            `json:"error,omitempty" yaml:"error,omitempty"`
	State    *TransactionEvent `json:"state,omitempty" yaml:"state,omitempty"`
}

type ResourceProperties

type ResourceProperties interface {
	CommonProperties() *CommonResourceProperties
	Validate() error
	ResolveTemplates(*templates.Env) error
	ToYamlManifest() (yaml.RawMessage, error)
}

ResourceProperties defines the interface for resource property validation and template resolution

func NewArchiveResourcePropertiesFromYaml added in v0.0.15

func NewArchiveResourcePropertiesFromYaml(raw yaml.RawMessage) ([]ResourceProperties, error)

NewArchiveResourcePropertiesFromYaml creates a new archive resource properties object from a yaml document, does not validate or expand templates

func NewExecResourcePropertiesFromYaml added in v0.0.6

func NewExecResourcePropertiesFromYaml(raw yaml.RawMessage) ([]ResourceProperties, error)

NewExecResourcePropertiesFromYaml creates a new exec resource properties object from a yaml document, does not validate or expand templates

func NewFileResourcePropertiesFromYaml added in v0.0.3

func NewFileResourcePropertiesFromYaml(raw yaml.RawMessage) ([]ResourceProperties, error)

NewFileResourcePropertiesFromYaml creates a new file resource properties object from a yaml document, does not validate or expand templates

func NewPackageResourcePropertiesFromYaml

func NewPackageResourcePropertiesFromYaml(raw yaml.RawMessage) ([]ResourceProperties, error)

NewPackageResourcePropertiesFromYaml creates a new package resource properties object from a yaml document, does not validate or expand templates

func NewResourcePropertiesFromYaml

func NewResourcePropertiesFromYaml(typeName string, rawProperties yaml.RawMessage, env *templates.Env) ([]ResourceProperties, error)

NewResourcePropertiesFromYaml creates a new resource properties object from a yaml document, it validates the properties and expands any templates

func NewScaffoldResourcePropertiesFromYaml added in v0.0.18

func NewScaffoldResourcePropertiesFromYaml(raw yaml.RawMessage) ([]ResourceProperties, error)

NewScaffoldResourcePropertiesFromYaml creates a new scaffold resource properties object from a yaml document, does not validate or expand templates

func NewServiceResourcePropertiesFromYaml added in v0.0.2

func NewServiceResourcePropertiesFromYaml(raw yaml.RawMessage) ([]ResourceProperties, error)

NewServiceResourcePropertiesFromYaml creates a new service resource properties object from a yaml document, does not validate or expand templates

func NewValidatedResourcePropertiesFromYaml added in v0.0.5

func NewValidatedResourcePropertiesFromYaml(typeName string, rawProperties yaml.RawMessage, env *templates.Env) ([]ResourceProperties, error)

NewValidatedResourcePropertiesFromYaml creates and validates a new resource properties object from a yaml document, it validates the properties and expands any templates

type ResourceState added in v0.0.5

type ResourceState interface {
	CommonState() *CommonResourceState
}

type ScaffoldMetadata added in v0.0.18

type ScaffoldMetadata struct {
	Name         string                 `json:"name" yaml:"name"`
	Provider     string                 `json:"provider,omitempty" yaml:"provider,omitempty"`
	TargetExists bool                   `json:"target_exists,omitempty" yaml:"target_exists,omitempty"`
	Changed      []string               `json:"changed,omitempty" yaml:"changed,omitempty"`
	Purged       []string               `json:"purged,omitempty" yaml:"purged,omitempty"`
	Stable       []string               `json:"stable,omitempty" yaml:"stable,omitempty"`
	Engine       ScaffoldResourceEngine `json:"engine,omitempty" yaml:"engine,omitempty"`
}

ScaffoldMetadata contains detailed metadata about a scaffold

type ScaffoldResourceEngine added in v0.0.18

type ScaffoldResourceEngine string
const (
	ScaffoldEngineGo  ScaffoldResourceEngine = "go"
	ScaffoldEngineJet ScaffoldResourceEngine = "jet"
)

type ScaffoldResourceProperties added in v0.0.18

type ScaffoldResourceProperties struct {
	CommonResourceProperties `yaml:",inline"`
	Source                   string                 `json:"source" yaml:"source"`
	SkipEmpty                bool                   `json:"skip_empty,omitempty" yaml:"skip_empty,omitempty"`
	LeftDelimiter            string                 `json:"left_delimiter,omitempty" yaml:"left_delimiter,omitempty"`
	RightDelimiter           string                 `json:"right_delimiter,omitempty" yaml:"right_delimiter,omitempty"`
	Engine                   ScaffoldResourceEngine `json:"engine,omitempty" yaml:"engine,omitempty"`
	Purge                    bool                   `json:"purge,omitempty" yaml:"purge,omitempty"`
	Post                     []map[string]string    `json:"post,omitempty" yaml:"post,omitempty"`
}

ScaffoldResourceProperties defines the properties for a scaffold resource

func (*ScaffoldResourceProperties) CommonProperties added in v0.0.18

func (*ScaffoldResourceProperties) ResolveTemplates added in v0.0.18

func (p *ScaffoldResourceProperties) ResolveTemplates(env *templates.Env) error

ResolveTemplates resolves template expressions in the package resource properties

func (*ScaffoldResourceProperties) ToYamlManifest added in v0.0.18

func (p *ScaffoldResourceProperties) ToYamlManifest() (yaml.RawMessage, error)

ToYamlManifest returns the file resource properties as a yaml document

func (*ScaffoldResourceProperties) Validate added in v0.0.18

func (p *ScaffoldResourceProperties) Validate() error

Validate validates the package resource properties

type ScaffoldState added in v0.0.18

type ScaffoldState struct {
	CommonResourceState

	Metadata *ScaffoldMetadata `json:"metadata,omitempty"`
}

ScaffoldState represents the current state of a scaffold on the system

func (*ScaffoldState) CommonState added in v0.0.18

func (f *ScaffoldState) CommonState() *CommonResourceState

type ServiceMetadata added in v0.0.2

type ServiceMetadata struct {
	Name     string `json:"name" yaml:"name"`
	Provider string `json:"provider,omitempty" yaml:"provider,omitempty"`
	Enabled  bool   `json:"enabled" yaml:"enabled"`
	Running  bool   `json:"running" yaml:"running"`
}

ServiceMetadata contains detailed metadata about a service

type ServiceResourceProperties added in v0.0.2

type ServiceResourceProperties struct {
	CommonResourceProperties `yaml:",inline"`
	Enable                   *bool    `json:"enable,omitempty" yaml:"enable,omitempty"`       // Enable indicates the service should be enabled on boot
	Subscribe                []string `json:"subscribe,omitempty" yaml:"subscribe,omitempty"` // Subscribe lists resource statusses to subscribe to in format type#name
}

ServiceResourceProperties defines the properties for a service resource

func (*ServiceResourceProperties) CommonProperties added in v0.0.5

func (p *ServiceResourceProperties) CommonProperties() *CommonResourceProperties

func (*ServiceResourceProperties) ResolveTemplates added in v0.0.2

func (p *ServiceResourceProperties) ResolveTemplates(env *templates.Env) error

ResolveTemplates resolves template expressions in the package resource properties

func (*ServiceResourceProperties) ToYamlManifest added in v0.0.2

func (p *ServiceResourceProperties) ToYamlManifest() (yaml.RawMessage, error)

ToYamlManifest returns the service resource properties as a yaml document

func (*ServiceResourceProperties) Validate added in v0.0.2

func (p *ServiceResourceProperties) Validate() error

Validate validates the package resource properties

type ServiceState added in v0.0.2

type ServiceState struct {
	CommonResourceState

	Metadata *ServiceMetadata `json:"metadata,omitempty"`
}

ServiceState represents the current state of a service on the system

func (*ServiceState) CommonState added in v0.0.5

func (f *ServiceState) CommonState() *CommonResourceState

type SessionEvent added in v0.0.2

type SessionEvent interface {
	SessionEventID() string
	String() string
}

type SessionStartEvent added in v0.0.2

type SessionStartEvent struct {
	Protocol  string    `json:"protocol" yaml:"protocol"`
	EventID   string    `json:"event_id" yaml:"event_id"`
	TimeStamp time.Time `json:"timestamp" yaml:"timestamp"`
}

func NewSessionStartEvent added in v0.0.2

func NewSessionStartEvent() *SessionStartEvent

func (*SessionStartEvent) SessionEventID added in v0.0.2

func (t *SessionStartEvent) SessionEventID() string

func (*SessionStartEvent) String added in v0.0.2

func (t *SessionStartEvent) String() string

type SessionStore

type SessionStore interface {
	StartSession(Apply) error
	StopSession(destroy bool) (*SessionSummary, error)
	RecordEvent(SessionEvent) error
	EventsForResource(resourceType string, resourceName string) ([]TransactionEvent, error)
	AllEvents() ([]SessionEvent, error)
}

type SessionSummary added in v0.0.2

type SessionSummary struct {
	StartTime                time.Time     `json:"start_time" yaml:"start_time"`
	EndTime                  time.Time     `json:"end_time" yaml:"end_time"`
	TotalDuration            time.Duration `json:"total_duration" yaml:"total_duration"`
	TotalResources           int           `json:"total_resources" yaml:"total_resources"`
	UniqueResources          int           `json:"unique_resources" yaml:"unique_resources"`
	ChangedResources         int           `json:"changed_resources" yaml:"changed_resources"`
	FailedResources          int           `json:"failed_resources" yaml:"failed_resources"`
	SkippedResources         int           `json:"skipped_resources" yaml:"skipped_resources"`
	StableResources          int           `json:"stable_resources" yaml:"stable_resources"`
	RefreshedCount           int           `json:"refreshed_count" yaml:"refreshed_count"`
	RequirementsUnMetCount   int           `json:"requirements_unmet_count" yaml:"requirements_unmet_count"`
	HealthCheckedCount       int           `json:"health_checked_count" yaml:"health_checked_count"`
	HealthCheckOKCount       int           `json:"health_check_ok_count" yaml:"health_check_ok_count"`
	HealthCheckWarningCount  int           `json:"health_check_warning_count" yaml:"health_check_warning_count"`
	HealthCheckCriticalCount int           `json:"health_check_critical_count" yaml:"health_check_critical_count"`
	HealthCheckUnknownCount  int           `json:"health_check_unknown_count" yaml:"health_check_unknown_count"`
	TotalErrors              int           `json:"total_errors" yaml:"total_errors"`
}

SessionSummary provides a statistical summary of a configuration management session

func BuildSessionSummary added in v0.0.2

func BuildSessionSummary(events []SessionEvent) *SessionSummary

BuildSessionSummary creates a summary report from all events in a session

func (*SessionSummary) RenderText added in v0.0.12

func (s *SessionSummary) RenderText(w io.Writer)

func (*SessionSummary) String added in v0.0.2

func (s *SessionSummary) String() string

String returns a human-readable summary of the session

type TransactionEvent

type TransactionEvent struct {
	Protocol        string               `json:"protocol" yaml:"protocol"`
	EventID         string               `json:"event_id" yaml:"event_id"`
	TimeStamp       time.Time            `json:"timestamp" yaml:"timestamp"`
	ResourceType    string               `json:"type" yaml:"type"`
	Provider        string               `json:"provider" yaml:"provider"`
	Name            string               `json:"name" yaml:"name"`
	Alias           string               `json:"alias,omitempty" yaml:"alias,omitempty"`
	RequestedEnsure string               `json:"requested_ensure" yaml:"requested_ensure"` // RequestedEnsure is the requested ensure value in the initial properties
	FinalEnsure     string               `json:"final_ensure" yaml:"final_ensure"`         // FinalEnsure is the actual `ensure` value after the session
	Duration        time.Duration        `json:"duration" yaml:"duration"`
	Properties      any                  `json:"properties" yaml:"properties"`
	Status          any                  `json:"status" yaml:"status"`
	NoopMessage     string               `json:"noop_message,omitempty" yaml:"noop_message,omitempty"`
	HealthChecks    []*HealthCheckResult `json:"health_check,omitempty" yaml:"health_check,omitempty"`
	HealthCheckOnly bool                 `json:"health_check_only,omitempty" yaml:"health_check_only,omitempty"`

	Errors            []string `json:"error" yaml:"error"`
	Changed           bool     `json:"changed" yaml:"changed"`
	Refreshed         bool     `json:"refreshed" yaml:"refreshed"` // Refreshed indicates the resource was restarted/reloaded via subscribe
	Failed            bool     `json:"failed" yaml:"failed"`
	Skipped           bool     `json:"skipped" yaml:"skipped"`
	Noop              bool     `json:"noop" yaml:"noop"`
	UnmetRequirements []string `json:"unmet_requirements" yaml:"unmet_requirements"`
}

TransactionEvent represents a single event for a resource session

func NewTransactionEvent

func NewTransactionEvent(typeName string, name string, alias string) *TransactionEvent

func (*TransactionEvent) LogStatus

func (t *TransactionEvent) LogStatus(log Logger)

func (*TransactionEvent) SessionEventID added in v0.0.2

func (t *TransactionEvent) SessionEventID() string

func (*TransactionEvent) String

func (t *TransactionEvent) String() string

Directories

Path Synopsis
Package modelmocks is a generated GoMock package.
Package modelmocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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