Documentation
¶
Index ¶
- Constants
- func Diff(current, desired string) (string, error)
- func DiffResource(currentYAML string, desired *config.Resource) ([]DiffChange, ManagementStatus, error)
- func DiffWithIndent(current, desired, indent string) (string, error)
- func FormatDiffChanges(changes []DiffChange, indent string) string
- func FormatDiffChangesWithWidth(changes []DiffChange, indent string, maxWidth int) string
- func FormatDiffChangesWithWidthAndTrailing(changes []DiffChange, indent string, maxWidth int, hasTrailingLine bool) string
- func HasChanges(current, desired string) (bool, error)
- type Client
- type DiffChange
- type ManagementStatus
- type Result
Constants ¶
const ( ManagementWarningUnmanaged = "unmanaged" ManagementWarningRecreate = "recreate required" )
const DefaultCommandTimeout = 30 * time.Minute
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
Diff generates a human-readable diff between current and desired YAML configurations. Returns an empty string if configurations are identical. Only shows the top-level keys that have changes. Excludes immutable fields and incus-managed config keys (volatile.*).
func DiffResource ¶
func DiffResource(currentYAML string, desired *config.Resource) ([]DiffChange, ManagementStatus, error)
DiffResource computes the preview diff for a resource. Managed resources are diffed against the previously stored incus-apply snapshot. Unmanaged resources fall back to live-state diffing.
func DiffWithIndent ¶
DiffWithIndent computes a diff with a custom indentation prefix. The indent is prepended to each line of the output.
func FormatDiffChanges ¶
func FormatDiffChanges(changes []DiffChange, indent string) string
FormatDiffChanges renders a []DiffChange to a human-readable string with the given indent.
func FormatDiffChangesWithWidth ¶
func FormatDiffChangesWithWidth(changes []DiffChange, indent string, maxWidth int) string
FormatDiffChangesWithWidth renders a []DiffChange to a human-readable string with the given indent and max inline width.
func FormatDiffChangesWithWidthAndTrailing ¶ added in v0.0.6
func FormatDiffChangesWithWidthAndTrailing(changes []DiffChange, indent string, maxWidth int, hasTrailingLine bool) string
FormatDiffChangesWithWidthAndTrailing renders a []DiffChange to a human-readable string with the given indent and max inline width. When hasTrailingLine is true, the final diff entry uses a branch connector because another sibling line will follow.
func HasChanges ¶
HasChanges checks if there are any differences between current and desired config.
Types ¶
type Client ¶
type Client interface {
// Ping verifies connectivity to the Incus daemon.
Ping() error
// Create creates a new resource in Incus.
Create(res *config.Resource) *Result
// Update updates an existing resource in Incus.
Update(res *config.Resource) *Result
// Delete removes a resource from Incus.
Delete(res *config.Resource) *Result
// Exists checks whether the resource already exists in Incus.
Exists(res *config.Resource) (bool, error)
// CurrentConfig retrieves the current YAML configuration of a resource.
CurrentConfig(res *config.Resource) (string, error)
// MergedConfig returns the merged config that would be applied during an update.
MergedConfig(res *config.Resource) (string, error)
// Start starts an instance.
Start(res *config.Resource) *Result
// Stop stops a running instance.
Stop(res *config.Resource) *Result
// Running checks if an instance is currently running.
Running(res *config.Resource) bool
// WaitInstanceAgent waits for a VM instance agent to become available.
WaitInstanceAgent(res *config.Resource) *Result
// WaitCloudInit waits for cloud-init to finish inside the instance.
WaitCloudInit(res *config.Resource) *Result
}
Client is the interface for performing operations on Incus.
type DiffChange ¶
type DiffChange struct {
Path string `json:"path"`
Old any `json:"old,omitempty"`
New any `json:"new,omitempty"`
Action string `json:"action"` // "add", "remove", "modify"
}
DiffChange is an exported representation of a single field change.
func DiffChanges ¶
func DiffChanges(current, desired string) ([]DiffChange, error)
DiffChanges returns structured diff changes between current and desired YAML. Returns nil if configurations are identical.
type ManagementStatus ¶
type ManagementStatus struct {
Managed bool
Snapshot string
Warning string
UnsupportedChanges []DiffChange
}
ManagementStatus reports whether a live resource is managed by incus-apply.