Documentation
¶
Index ¶
- func NewInstanceResource() resource.Resource
- func NewInstanceSnapshotResource() resource.Resource
- func ToProfileList(ctx context.Context, profileList types.List) ([]string, diag.Diagnostics)
- func ToProfileListType(ctx context.Context, profiles []string) (types.List, diag.Diagnostics)
- type InstanceModel
- type InstanceResource
- func (r *InstanceResource) Configure(_ context.Context, req resource.ConfigureRequest, ...)
- func (r InstanceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r InstanceResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r *InstanceResource) ImportState(ctx context.Context, req resource.ImportStateRequest, ...)
- func (r InstanceResource) Metadata(_ context.Context, req resource.MetadataRequest, ...)
- func (r *InstanceResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, ...)
- func (r InstanceResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r InstanceResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r InstanceResource) SyncState(ctx context.Context, tfState *tfsdk.State, server incus.InstanceServer, ...) diag.Diagnostics
- func (r InstanceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- func (r InstanceResource) ValidateConfig(ctx context.Context, req resource.ValidateConfigRequest, ...)
- type InstanceSnapshotModel
- type InstanceSnapshotResource
- func (r *InstanceSnapshotResource) Configure(_ context.Context, req resource.ConfigureRequest, ...)
- func (r InstanceSnapshotResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r InstanceSnapshotResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r InstanceSnapshotResource) Metadata(_ context.Context, req resource.MetadataRequest, ...)
- func (r InstanceSnapshotResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r InstanceSnapshotResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r InstanceSnapshotResource) SyncState(ctx context.Context, tfState *tfsdk.State, server incus.InstanceServer, ...) diag.Diagnostics
- func (r InstanceSnapshotResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- type SourceInstanceModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewInstanceResource ¶
NewInstanceResource returns a new instance resource.
func NewInstanceSnapshotResource ¶
NewInstanceSnapshotResource returns a new instance snapshot resource.
func ToProfileList ¶
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 ¶
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 (r *InstanceResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
func (InstanceResource) Create ¶
func (r InstanceResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
func (InstanceResource) Delete ¶
func (r InstanceResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
func (*InstanceResource) ImportState ¶
func (r *InstanceResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse)
func (InstanceResource) Metadata ¶
func (r InstanceResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
func (*InstanceResource) ModifyPlan ¶
func (r *InstanceResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse)
func (InstanceResource) Read ¶
func (r InstanceResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
func (InstanceResource) Schema ¶
func (r InstanceResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
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 ¶
func (r InstanceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
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 ¶
func (r InstanceResource) ValidateConfig(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse)
type InstanceSnapshotModel ¶
type InstanceSnapshotResource ¶
type InstanceSnapshotResource struct {
// contains filtered or unexported fields
}
InstanceSnapshotResource represent Incus instance snapshot resource.
func (*InstanceSnapshotResource) Configure ¶
func (r *InstanceSnapshotResource) Configure(_ context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
func (InstanceSnapshotResource) Create ¶
func (r InstanceSnapshotResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
func (InstanceSnapshotResource) Delete ¶
func (r InstanceSnapshotResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
func (InstanceSnapshotResource) Metadata ¶
func (r InstanceSnapshotResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
func (InstanceSnapshotResource) Read ¶
func (r InstanceSnapshotResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
func (InstanceSnapshotResource) Schema ¶
func (r InstanceSnapshotResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse)
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 ¶
func (r InstanceSnapshotResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)