scripts

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package scripts embeds the PowerShell scripts the provider runs against the host. The typed Hyper-V client (internal/hyperv) reads from these embedded filesystems and concatenates common/preamble.ps1 to the top of each resource script per the §5 contract.

Directory layout (one subdir per resource family):

common/preamble.ps1     — concatenated to every script (§5)
vswitch/get.ps1         — Get-VMSwitch wrapper        (M1)
vswitch/new.ps1         — New-VMSwitch wrapper        (M1)
vswitch/set.ps1         — Set-VMSwitch wrapper        (M1)
vswitch/remove.ps1      — Remove-VMSwitch wrapper     (M1)
... etc.

Index

Constants

This section is empty.

Variables

View Source
var Common embed.FS

Common holds preamble and shared helpers — exposed because the typed client prepends preamble.ps1 to every resource-script body before sending it through the connection layer.

View Source
var ImageFile embed.FS

ImageFile holds the verb scripts for hyperv_image_file (M4). No "set" verb -- every image_file schema field is RequiresReplace, so Update is a Go-side no-op with no PS round-trip.

View Source
var VHD embed.FS

VHD holds the verb scripts for hyperv_vhd (M4). The "set" verb only resizes -- every other attribute is RequiresReplace at the schema layer.

VM holds the verb scripts for hyperv_vm. Beyond the four base verbs (get/new/set/remove) there are per-attachment add/remove scripts:

  • add-hard-disk-drive / remove-hard-disk-drive (M4)
  • add-network-adapter / remove-network-adapter (next M4 commit)
  • add-dvd-drive / remove-dvd-drive (next M4 commit)

The attachment scripts deliberately don't get fold into set.ps1 -- each attach/detach is a separate cmdlet on the host (Add-VMHardDiskDrive, Add-VMNetworkAdapter, etc.) and the Go-side reconciliation in Update is much cleaner when each cmdlet has its own script with its own per-cmdlet error mapping than when set.ps1 has to disambiguate which of N internal failures fired.

View Source
var Vswitch embed.FS

Vswitch holds the four verb scripts for hyperv_virtual_switch. The typed client reads each by path and concatenates the preamble before invoking. Pester *.Tests.ps1 and the _test_helpers.ps1 stub file are deliberately excluded from the embed glob — production Go has no use for them.

Functions

func ImageFileScript

func ImageFileScript(verb string) ([]byte, error)

ImageFileScript returns the contents of image_file/<verb>.ps1 (verb in {get, new, remove}).

func Preamble

func Preamble() ([]byte, error)

Preamble returns the contents of common/preamble.ps1. Convenience wrapper so callers don't have to repeat the path string.

func VHDScript

func VHDScript(verb string) ([]byte, error)

VHDScript returns the contents of vhd/<verb>.ps1 (verb in {get, new, set, remove}).

func VMReadResult

func VMReadResult() ([]byte, error)

VMReadResult returns vm/read-result.ps1, the canonical Read-HypervVMResult function shared by the four VM read-emitting scripts (get/new/set/set-state). The Go-side hyperv.Client prepends its body to those scripts at runtime, replacing what used to be four inline copies of the same function.

func VMScript

func VMScript(verb string) ([]byte, error)

VMScript returns the contents of vm/<verb>.ps1.

`verb` is the file name without extension. For multi-word verbs use the hyphenated form ("add-hard-disk-drive"). The base verbs are get/new/set/remove; attachment verbs add the specific cmdlet name.

func VswitchScript

func VswitchScript(verb string) ([]byte, error)

VswitchScript returns the contents of vswitch/<verb>.ps1 (verb in {get, new, set, remove}). Centralizes the path joining so callers don't repeat the "vswitch/" prefix and a typo'd verb fails loudly at startup (via embed_test.go) rather than at first apply.

Types

This section is empty.

Jump to

Keyboard shortcuts

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