Help us shape the future of Go! Take the 2026 Go Developer Survey

mac

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

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

View Source
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

func Normalize(s string) string

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

func NewMACValue(value string) MAC

NewMACValue constructs a known, non-null MAC. Convenient when hydrating a model from a typed-client struct on Read.

func (MAC) Equal

func (m MAC) Equal(o attr.Value) bool

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.

func (MAC) Type

func (m MAC) Type(_ context.Context) attr.Type

Type returns the singleton attribute type.

Jump to

Keyboard shortcuts

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