Documentation
¶
Overview ¶
Package vm_state implements the hyperv_vm_state data source: read-only power-state plus IP-address lookup for an existing VM by name, for HCL conditionals and downstream resources that gate on live VM state without managing the VM. Pairs with hyperv_vm.state.{desired, current, shutdown_mode}: the resource manages the transition, this data source reports it.
Index ¶
- func New() datasource.DataSource
- type DataSource
- func (d *DataSource) Configure(_ context.Context, req datasource.ConfigureRequest, ...)
- func (d *DataSource) Metadata(_ context.Context, req datasource.MetadataRequest, ...)
- func (d *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse)
- func (d *DataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse)
- type Model
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DataSource ¶
type DataSource struct {
// contains filtered or unexported fields
}
DataSource implements data.hyperv_vm_state.
func (*DataSource) Configure ¶
func (d *DataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse)
Configure stashes the typed Hyper-V client built by the provider's Configure pass. Skips when ProviderData is nil (validate-time invocation before the provider has resolved its config).
func (*DataSource) Metadata ¶
func (d *DataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse)
Metadata sets the data source's TF type name.
func (*DataSource) Read ¶
func (d *DataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse)
Read fetches the VM via Get-VM and writes the typed state-only view into state. ErrNotFound surfaces as an attribute-anchored diagnostic so the operator sees which `name` didn't resolve; ErrUnavailable surfaces with transient phrasing so a vmms blip doesn't read like "the VM is gone".
func (*DataSource) Schema ¶
func (d *DataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse)
Schema declares name as the lookup key (Required); everything else is read-only Computed pulled from Get-VM. The deliberately narrow surface (current + ip_addresses) reflects the data source's purpose: gate downstream HCL on power state. Callers who need the full VM state (memory, attachments, boot order) should use the hyperv_vm resource's state.