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

mock

package
v1.20.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 21 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
}

API represents a mocked EC2 API

func NewAPI

func NewAPI(subnets []*ipamTypes.Subnet, vpcs []*ipamTypes.VirtualNetwork, securityGroups []*types.SecurityGroup, routeTables []*ipamTypes.RouteTable) *API

NewAPI returns a new mocked EC2 API

func (*API) AssignENIIPv6Prefix

func (e *API) AssignENIIPv6Prefix(ctx context.Context, eniID string) error

func (*API) AssignENIPrefixes

func (e *API) AssignENIPrefixes(ctx context.Context, eniID string, prefixes int32) error

func (*API) AssignPrivateIpAddresses

func (e *API) AssignPrivateIpAddresses(ctx context.Context, eniID string, addresses int32) ([]string, error)

func (*API) AssociateEIP

func (e *API) AssociateEIP(ctx context.Context, eniID string, eipTags ipamTypes.Tags) (string, error)

func (*API) AttachNetworkInterface

func (e *API) AttachNetworkInterface(ctx context.Context, index int32, instanceID, eniID string) (string, error)

func (*API) CreateNetworkInterface

func (e *API) CreateNetworkInterface(ctx context.Context, toAllocate int32, subnetID, desc string, groups []string, allocatePrefixes, allocateIPv6 bool) (string, *types.ENI, error)

CreateNetworkInterface mocks the interface creation. As with the upstream EC2 API, the number of IP addresses in toAllocate are the number of secondary IPs, a primary IP is always allocated.

func (*API) DeleteNetworkInterface

func (e *API) DeleteNetworkInterface(ctx context.Context, eniID string) error

func (*API) DetachNetworkInterface

func (e *API) DetachNetworkInterface(ctx context.Context, instanceID, eniID string) error

func (*API) GetDetachedNetworkInterfaces

func (e *API) GetDetachedNetworkInterfaces(ctx context.Context, tags ipamTypes.Tags, maxResults int32) ([]string, error)

func (*API) GetInstance

func (e *API) GetInstance(ctx context.Context, vpcs ipamTypes.VirtualNetworkMap, subnets ipamTypes.SubnetMap, instanceID string) (*ipamTypes.Instance, error)

func (*API) GetInstanceTypes

func (e *API) GetInstanceTypes(ctx context.Context) ([]ec2_types.InstanceTypeInfo, error)

func (*API) GetInstances

func (e *API) GetInstances(ctx context.Context, vpcs ipamTypes.VirtualNetworkMap, subnets ipamTypes.SubnetMap) (*ipamTypes.InstanceMap, error)

func (*API) GetRouteTables

func (e *API) GetRouteTables(ctx context.Context, vpcID string) (ipamTypes.RouteTableMap, error)

func (*API) GetSecurityGroups

func (e *API) GetSecurityGroups(ctx context.Context, vpcID string) (types.SecurityGroupMap, error)

func (*API) GetSubnets

func (e *API) GetSubnets(ctx context.Context, vpcID string) (ipamTypes.SubnetMap, error)

func (*API) GetVpcs

func (e *API) GetVpcs(ctx context.Context, vpcID string) (ipamTypes.VirtualNetworkMap, error)

func (*API) ModifyNetworkInterface

func (e *API) ModifyNetworkInterface(ctx context.Context, eniID, attachmentID string, deleteOnTermination bool) error

func (*API) SetDelay

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

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

func (*API) SetLimiter

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

SetLimiter adds a rate limiter to all simulated API calls

func (*API) SetMockError

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

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

func (*API) TagENI

func (e *API) TagENI(ctx context.Context, eniID string, eniTags map[string]string) error

func (*API) UnassignENIPrefixes

func (e *API) UnassignENIPrefixes(ctx context.Context, eniID string, prefixes []string) error

func (*API) UnassignPrivateIpAddresses

func (e *API) UnassignPrivateIpAddresses(ctx context.Context, eniID string, addresses []string) error

func (*API) UpdateENIs

func (e *API) UpdateENIs(enis map[string]ENIMap)

UpdateENIs replaces the ENIs which the mock API will return

func (*API) UpdateInstanceTypes

func (e *API) UpdateInstanceTypes(instanceTypes []ec2_types.InstanceTypeInfo)

func (*API) UpdateRouteTables

func (e *API) UpdateRouteTables(routeTables []*ipamTypes.RouteTable)

UpdateRouteTables replaces the route tables which the mock API will return

func (*API) UpdateSecurityGroups

func (e *API) UpdateSecurityGroups(securityGroups []*types.SecurityGroup)

UpdateSecurityGroups replaces the security groups which the mock API will return

func (*API) UpdateSubnets

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

UpdateSubnets replaces the subents which the mock API will return

type ENIMap

type ENIMap map[string]*types.ENI

ENIMap is a map of ENI interfaces indexed by ENI ID

type Operation

type Operation int

Operation is an EC2 API operation that this mock API supports

const (
	AllOperations Operation = iota
	CreateNetworkInterface
	DeleteNetworkInterface
	AttachNetworkInterface
	ModifyNetworkInterface
	AssignPrivateIpAddresses
	AssignIPv6Addresses
	UnassignPrivateIpAddresses
	TagENI
	AssociateEIP
	MaxOperation
)

Jump to

Keyboard shortcuts

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