instance

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInstanceResource

func NewInstanceResource() resource.Resource

NewInstanceResource returns a new instance resource.

func NewInstanceSnapshotResource

func NewInstanceSnapshotResource() resource.Resource

NewInstanceSnapshotResource returns a new instance snapshot resource.

func ToProfileList

func ToProfileList(ctx context.Context, profileList types.List) ([]string, diag.Diagnostics)

ToProfileList converts profiles of type types.List into []string.

If profiles are null, use "default" profile. If profiles lengeth is 0, no profiles are applied.

func ToProfileListType

func ToProfileListType(ctx context.Context, profiles []string) (types.List, diag.Diagnostics)

ToProfileListType converts []string into profiles of type types.List.

Types

type InstanceModel

type InstanceModel struct {
	Name           types.String `tfsdk:"name"`
	Description    types.String `tfsdk:"description"`
	Type           types.String `tfsdk:"type"`
	Image          types.String `tfsdk:"image"`
	Ephemeral      types.Bool   `tfsdk:"ephemeral"`
	Running        types.Bool   `tfsdk:"running"`
	WaitForNetwork types.Bool   `tfsdk:"wait_for_network"`
	Profiles       types.List   `tfsdk:"profiles"`
	Devices        types.Set    `tfsdk:"device"`
	Files          types.Set    `tfsdk:"file"`
	Config         types.Map    `tfsdk:"config"`
	Project        types.String `tfsdk:"project"`
	Remote         types.String `tfsdk:"remote"`
	Target         types.String `tfsdk:"target"`
	SourceInstance types.Object `tfsdk:"source_instance"`

	// Computed.
	IPv4   types.String `tfsdk:"ipv4_address"`
	IPv6   types.String `tfsdk:"ipv6_address"`
	MAC    types.String `tfsdk:"mac_address"`
	Status types.String `tfsdk:"status"`
}

func (InstanceModel) ComputedKeys

func (_ InstanceModel) ComputedKeys() []string

ComputedKeys returns list of computed config keys.

type InstanceResource

type InstanceResource struct {
	// contains filtered or unexported fields
}

InstanceResource represent Incus instance resource.

func (*InstanceResource) Configure

func (InstanceResource) Create

func (InstanceResource) Delete

func (*InstanceResource) ImportState

func (InstanceResource) Metadata

func (*InstanceResource) ModifyPlan

func (InstanceResource) Read

func (InstanceResource) Schema

func (InstanceResource) SyncState

func (r InstanceResource) SyncState(ctx context.Context, tfState *tfsdk.State, server incus.InstanceServer, m InstanceModel) diag.Diagnostics

SyncState fetches the server's current state for an instance and updates the provided model. It then applies this updated model as the new state in Terraform.

func (InstanceResource) Update

Update updates the instance in the following order: - Ensure instance state (stopped/running) - Update configuration (config, devices, profiles) - Upload files - Run exec commands

func (InstanceResource) ValidateConfig

type InstanceSnapshotModel

type InstanceSnapshotModel struct {
	Name     types.String `tfsdk:"name"`
	Instance types.String `tfsdk:"instance"`
	Stateful types.Bool   `tfsdk:"stateful"`
	Project  types.String `tfsdk:"project"`
	Remote   types.String `tfsdk:"remote"`

	// Computed.
	CreatedAt types.Int64 `tfsdk:"created_at"`
}

type InstanceSnapshotResource

type InstanceSnapshotResource struct {
	// contains filtered or unexported fields
}

InstanceSnapshotResource represent Incus instance snapshot resource.

func (*InstanceSnapshotResource) Configure

func (InstanceSnapshotResource) Create

func (InstanceSnapshotResource) Delete

func (InstanceSnapshotResource) Metadata

func (InstanceSnapshotResource) Read

func (InstanceSnapshotResource) Schema

func (InstanceSnapshotResource) SyncState

func (r InstanceSnapshotResource) SyncState(ctx context.Context, tfState *tfsdk.State, server incus.InstanceServer, m InstanceSnapshotModel) diag.Diagnostics

SyncState fetches the server's current state for an instance snapshot and updates the provided model. It then applies this updated model as the new state in Terraform.

func (InstanceSnapshotResource) Update

type SourceInstanceModel added in v0.1.3

type SourceInstanceModel struct {
	Project  types.String `tfsdk:"project"`
	Name     types.String `tfsdk:"name"`
	Snapshot types.String `tfsdk:"snapshot"`
}

Jump to

Keyboard shortcuts

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