Documentation
¶
Overview ¶
Package vswitch implements the hyperv_virtual_switch data source -- read-only access to an existing switch by name. Mirrors the resource's read shape but writes no state.
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_virtual_switch.
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 switch via Get-VMSwitch and writes the typed shape into state. ErrNotFound surfaces as an attribute-anchored diagnostic so the operator sees which `name` value didn't resolve. ErrUnavailable surfaces with transient phrasing so a vmms blip during a plan doesn't read like "the switch is gone".
func (*DataSource) Schema ¶
func (d *DataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse)
Schema declares the data source's read shape: name is the lookup key (Required); everything else is read-only Computed pulled from Get-VMSwitch.
net_adapter_names is intentionally absent -- the resource preserves it as user intent, but Get-VMSwitch doesn't return the originally-supplied adapter-name list (only NetAdapterInterfaceDescription, which is the teamed adapter's friendly description). Exposing only what the cmdlet actually returns avoids a phantom field that we can't reliably populate.
type Model ¶
type Model struct {
Name types.String `tfsdk:"name"`
ID types.String `tfsdk:"id"`
SwitchType types.String `tfsdk:"switch_type"`
AllowManagementOS types.Bool `tfsdk:"allow_management_os"`
Notes types.String `tfsdk:"notes"`
NetAdapterInterfaceDescription types.String `tfsdk:"net_adapter_interface_description"`
}
Model is the tfsdk-bound state struct.