mock

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func NewAPI

func NewAPI(subnets []*ipamTypes.Subnet) *API

func (*API) AssignPrivateIpAddressesVM

func (a *API) AssignPrivateIpAddressesVM(ctx context.Context, subnetID, interfaceName string, addresses int) error

func (*API) AssignPrivateIpAddressesVMSS

func (a *API) AssignPrivateIpAddressesVMSS(ctx context.Context, vmName, vmssName, subnetID, interfaceName string, addresses int) error

func (*API) AssignPublicIPAddressesVM added in v1.19.0

func (a *API) AssignPublicIPAddressesVM(ctx context.Context, instanceID string, publicIpTags ipamTypes.Tags) (netip.Addr, error)

func (*API) AssignPublicIPAddressesVMSS added in v1.19.0

func (a *API) AssignPublicIPAddressesVMSS(ctx context.Context, instanceID, vmssName string, publicIpTags ipamTypes.Tags) (netip.Addr, error)

func (*API) GetSubnetsByIDs added in v1.20.0

func (a *API) GetSubnetsByIDs(ctx context.Context, nodeSubnetIDs []string) (ipamTypes.SubnetMap, error)

func (*API) ListAllNetworkInterfaces added in v1.20.0

func (a *API) ListAllNetworkInterfaces(ctx context.Context) ([]*armnetwork.Interface, error)

ListAllNetworkInterfaces returns a dummy slice since mock doesn't use real network interfaces The mock API uses instances directly rather than armnetwork.Interface objects

func (*API) ListVMNetworkInterfaces added in v1.20.0

func (a *API) ListVMNetworkInterfaces(ctx context.Context, instanceID string) ([]*armnetwork.Interface, error)

ListVMNetworkInterfaces returns a single sentinel armnetwork.Interface whose ID carries the requested instanceID, so ParseInterfacesIntoInstance can recover which instance to return without making another API call.

func (*API) ParseInterfacesIntoInstance added in v1.20.0

func (a *API) ParseInterfacesIntoInstance(networkInterfaces []*armnetwork.Interface, subnets ipamTypes.SubnetMap) *ipamTypes.Instance

ParseInterfacesIntoInstance recovers the instanceID from the sentinel produced by ListVMNetworkInterfaces and returns the mock's instance.

func (*API) ParseInterfacesIntoInstanceMap added in v1.20.0

func (a *API) ParseInterfacesIntoInstanceMap(networkInterfaces []*armnetwork.Interface, subnets ipamTypes.SubnetMap) *ipamTypes.InstanceMap

ParseInterfacesIntoInstanceMap ignores the input and returns the mock's instances The mock API doesn't use real armnetwork.Interface objects

func (*API) SetDelay

func (a *API) SetDelay(op Operation, delay time.Duration)

SetDelay specifies the delay which should be simulated for an individual Azure API operation

func (*API) SetLimiter

func (a *API) SetLimiter(limit float64, burst int)

SetLimiter adds a rate limiter to all simulated API calls

func (*API) SetMockError

func (a *API) SetMockError(op Operation, err error)

SetMockError modifies the mock API to return an error for a particular operation

func (*API) UpdateInstances

func (a *API) UpdateInstances(instances *ipamTypes.InstanceMap)

func (*API) UpdateSubnets

func (a *API) UpdateSubnets(subnets []*ipamTypes.Subnet)

type Operation

type Operation int

Operation is an Azure API operation that this mock API supports

const (
	AllOperations Operation = iota
	ListVMNetworkInterfaces
	ListAllNetworkInterfaces
	GetSubnetsByIDs
	AssignPrivateIpAddressesVMSS
	MaxOperation
)

Jump to

Keyboard shortcuts

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