Documentation
¶
Overview ¶
Package mac provides a Terraform attribute type for MAC addresses that suppresses spurious plan-vs-apply diffs from cosmetic representation differences. See MAC.StringSemanticEquals for the normalization it applies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Type = macType{}
Type is the singleton attribute type for MAC addresses. Pass it as `CustomType:` on string attributes whose value is a MAC emitted by a Hyper-V cmdlet or supplied by an operator.
Functions ¶
func Normalize ¶
Normalize folds the two cosmetic differences (separator presence / case) that Hyper-V treats as identical. Strips colons and hyphens, then uppercases. Used by StringSemanticEquals for the framework's plan-vs-apply comparison; also exported so resource code that needs to compare MACs outside the framework's call path (e.g. NIC-update diff logic) gets the same canonical form.
Types ¶
type MAC ¶
type MAC struct {
basetypes.StringValue
}
MAC is the attribute-value implementation. Embeds StringValue so the .ValueString() / .IsNull() / .IsUnknown() accessors continue to work unchanged after a schema's CustomType is set to mac.Type.
func NewMACNull ¶
func NewMACNull() MAC
NewMACNull constructs a null MAC. Convenient for collapsing empty optional-attribute reads to schema-null on the wire.
func NewMACValue ¶
NewMACValue constructs a known, non-null MAC. Convenient when hydrating a model from a typed-client struct on Read.
func (MAC) Equal ¶
Equal compares two MAC values for raw equality (byte-for-byte). The framework calls this for known-after-apply tracking and other plan- machinery checks where strict equality is what's wanted. Semantic equality is the separate StringSemanticEquals method.
func (MAC) StringSemanticEquals ¶
func (m MAC) StringSemanticEquals(_ context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics)
StringSemanticEquals normalizes both sides (colons/hyphens stripped, uppercased) before comparing, so Set-VMNetworkAdapter's AA:BB:CC:DD:EE:01 and Get-VMNetworkAdapter's echoed AABBCCDDEE01 compare equal and the framework suppresses the diff. The framework only calls this when both sides are known and non-null; null/unknown handling happens before this method runs.