Documentation ¶
Index ¶
- Constants
- Variables
- func Filter(filters []*ec2.Filter, id, name string, tags []*ec2.Tag) bool
- func FilterDescribeImages(images []*ec2.Image, filters []*ec2.Filter) []*ec2.Image
- func FilterDescribeSecurtyGroups(sgs []*ec2.SecurityGroup, filters []*ec2.Filter) []*ec2.SecurityGroup
- func FilterDescribeSubnets(subnets []*ec2.Subnet, filters []*ec2.Filter) []*ec2.Subnet
- func ImageID() string
- func InstanceID() string
- func InstanceProfileID() string
- func LaunchTemplateID() string
- func LaunchTemplateName() string
- func NewOnDemandPrice(instanceType string, price float64) aws.JSONValue
- func PrivateDNSName() string
- func ProviderID(id string) string
- func RandomProviderID() string
- func RoleID() string
- func SecurityGroupID() string
- func SubnetID() string
- func SubnetsFromFleetRequest(createFleetInput *ec2.CreateFleetInput) []string
- type AtomicError
- type AtomicErrorOption
- type AtomicPtr
- type AtomicPtrSlice
- type CapacityPool
- type CloudProvider
- func (c *CloudProvider) Create(_ context.Context, _ *v1beta1.NodeClaim) (*v1beta1.NodeClaim, error)
- func (c *CloudProvider) Delete(context.Context, *v1beta1.NodeClaim) error
- func (c *CloudProvider) Get(context.Context, string) (*v1beta1.NodeClaim, error)
- func (c *CloudProvider) GetInstanceTypes(_ context.Context, _ *v1beta1.NodePool) ([]*corecloudprovider.InstanceType, error)
- func (c *CloudProvider) IsDrifted(_ context.Context, nodeClaim *v1beta1.NodeClaim) (corecloudprovider.DriftReason, error)
- func (c *CloudProvider) List(context.Context) ([]*v1beta1.NodeClaim, error)
- func (c *CloudProvider) Name() string
- type EC2API
- func (e *EC2API) CreateFleetWithContext(_ context.Context, input *ec2.CreateFleetInput, _ ...request.Option) (*ec2.CreateFleetOutput, error)
- func (e *EC2API) CreateLaunchTemplateWithContext(_ context.Context, input *ec2.CreateLaunchTemplateInput, _ ...request.Option) (*ec2.CreateLaunchTemplateOutput, error)
- func (e *EC2API) CreateTagsWithContext(_ context.Context, input *ec2.CreateTagsInput, _ ...request.Option) (*ec2.CreateTagsOutput, error)
- func (e *EC2API) DeleteLaunchTemplateWithContext(_ context.Context, input *ec2.DeleteLaunchTemplateInput, _ ...request.Option) (*ec2.DeleteLaunchTemplateOutput, error)
- func (e *EC2API) DescribeAvailabilityZonesWithContext(context.Context, *ec2.DescribeAvailabilityZonesInput, ...request.Option) (*ec2.DescribeAvailabilityZonesOutput, error)
- func (e *EC2API) DescribeImagesPagesWithContext(ctx context.Context, input *ec2.DescribeImagesInput, ...) error
- func (e *EC2API) DescribeImagesWithContext(_ context.Context, input *ec2.DescribeImagesInput, _ ...request.Option) (*ec2.DescribeImagesOutput, error)
- func (e *EC2API) DescribeInstanceTypeOfferingsPagesWithContext(ctx context.Context, input *ec2.DescribeInstanceTypeOfferingsInput, ...) error
- func (e *EC2API) DescribeInstanceTypeOfferingsWithContext(_ context.Context, _ *ec2.DescribeInstanceTypeOfferingsInput, ...) (*ec2.DescribeInstanceTypeOfferingsOutput, error)
- func (e *EC2API) DescribeInstanceTypesPagesWithContext(ctx context.Context, input *ec2.DescribeInstanceTypesInput, ...) error
- func (e *EC2API) DescribeInstanceTypesWithContext(_ context.Context, _ *ec2.DescribeInstanceTypesInput, _ ...request.Option) (*ec2.DescribeInstanceTypesOutput, error)
- func (e *EC2API) DescribeInstancesPagesWithContext(ctx context.Context, input *ec2.DescribeInstancesInput, ...) error
- func (e *EC2API) DescribeInstancesWithContext(_ context.Context, input *ec2.DescribeInstancesInput, _ ...request.Option) (*ec2.DescribeInstancesOutput, error)
- func (e *EC2API) DescribeLaunchTemplatesPagesWithContext(ctx context.Context, input *ec2.DescribeLaunchTemplatesInput, ...) error
- func (e *EC2API) DescribeLaunchTemplatesWithContext(_ context.Context, input *ec2.DescribeLaunchTemplatesInput, ...) (*ec2.DescribeLaunchTemplatesOutput, error)
- func (e *EC2API) DescribeSecurityGroupsWithContext(_ context.Context, input *ec2.DescribeSecurityGroupsInput, _ ...request.Option) (*ec2.DescribeSecurityGroupsOutput, error)
- func (e *EC2API) DescribeSpotPriceHistoryPagesWithContext(ctx aws.Context, input *ec2.DescribeSpotPriceHistoryInput, ...) error
- func (e *EC2API) DescribeSpotPriceHistoryWithContext(_ aws.Context, input *ec2.DescribeSpotPriceHistoryInput, _ ...request.Option) (*ec2.DescribeSpotPriceHistoryOutput, error)
- func (e *EC2API) DescribeSubnetsWithContext(_ context.Context, input *ec2.DescribeSubnetsInput, _ ...request.Option) (*ec2.DescribeSubnetsOutput, error)
- func (e *EC2API) Reset()
- func (e *EC2API) TerminateInstancesWithContext(_ context.Context, input *ec2.TerminateInstancesInput, _ ...request.Option) (*ec2.TerminateInstancesOutput, error)
- type EC2Behavior
- type EKSAPI
- type EKSAPIBehavior
- type IAMAPI
- func (s *IAMAPI) AddRoleToInstanceProfileWithContext(_ context.Context, input *iam.AddRoleToInstanceProfileInput, ...) (*iam.AddRoleToInstanceProfileOutput, error)
- func (s *IAMAPI) CreateInstanceProfileWithContext(_ context.Context, input *iam.CreateInstanceProfileInput, _ ...request.Option) (*iam.CreateInstanceProfileOutput, error)
- func (s *IAMAPI) DeleteInstanceProfileWithContext(_ context.Context, input *iam.DeleteInstanceProfileInput, _ ...request.Option) (*iam.DeleteInstanceProfileOutput, error)
- func (s *IAMAPI) GetInstanceProfileWithContext(_ context.Context, input *iam.GetInstanceProfileInput, _ ...request.Option) (*iam.GetInstanceProfileOutput, error)
- func (s *IAMAPI) RemoveRoleFromInstanceProfileWithContext(_ context.Context, input *iam.RemoveRoleFromInstanceProfileInput, ...) (*iam.RemoveRoleFromInstanceProfileOutput, error)
- func (s *IAMAPI) Reset()
- type IAMAPIBehavior
- type MockedFunction
- type PricingAPI
- type PricingBehavior
- type SQSAPI
- func (s *SQSAPI) DeleteMessageWithContext(_ context.Context, input *sqs.DeleteMessageInput, _ ...request.Option) (*sqs.DeleteMessageOutput, error)
- func (s *SQSAPI) GetQueueUrlWithContext(_ context.Context, input *sqs.GetQueueUrlInput, _ ...request.Option) (*sqs.GetQueueUrlOutput, error)
- func (s *SQSAPI) ReceiveMessageWithContext(_ context.Context, input *sqs.ReceiveMessageInput, _ ...request.Option) (*sqs.ReceiveMessageOutput, error)
- func (s *SQSAPI) Reset()
- type SQSBehavior
- type SSMAPI
Constants ¶
const ( DefaultRegion = "us-west-2" DefaultAccount = "123456789" )
Variables ¶
var DefaultSupportedUsageClasses = aws.StringSlice([]string{"on-demand", "spot"})
DefaultSupportedUsageClasses is a var because []*string can't be a const
Functions ¶
func FilterDescribeImages ¶
func FilterDescribeSecurtyGroups ¶
func FilterDescribeSecurtyGroups(sgs []*ec2.SecurityGroup, filters []*ec2.Filter) []*ec2.SecurityGroup
FilterDescribeSecurtyGroups filters the passed in security groups based on the filters passed in. Filters are chained with a logical "AND"
func FilterDescribeSubnets ¶
FilterDescribeSubnets filters the passed in subnets based on the filters passed in. Filters are chained with a logical "AND"
func InstanceID ¶
func InstanceID() string
func InstanceProfileID ¶
func InstanceProfileID() string
func LaunchTemplateID ¶
func LaunchTemplateID() string
func LaunchTemplateName ¶
func LaunchTemplateName() string
func PrivateDNSName ¶
func PrivateDNSName() string
func ProviderID ¶
func RandomProviderID ¶
func RandomProviderID() string
func SecurityGroupID ¶
func SecurityGroupID() string
func SubnetsFromFleetRequest ¶
func SubnetsFromFleetRequest(createFleetInput *ec2.CreateFleetInput) []string
SubnetsFromFleetRequest returns a unique slice of subnetIDs passed as overrides from a CreateFleetInput
Types ¶
type AtomicError ¶
type AtomicError struct {
// contains filtered or unexported fields
}
func (*AtomicError) Get ¶
func (e *AtomicError) Get() error
Get is equivalent to the error being called, so we increase number of calls in this function
func (*AtomicError) IsNil ¶
func (e *AtomicError) IsNil() bool
func (*AtomicError) Reset ¶
func (e *AtomicError) Reset()
func (*AtomicError) Set ¶
func (e *AtomicError) Set(err error, opts ...AtomicErrorOption)
type AtomicErrorOption ¶
type AtomicErrorOption func(atomicError *AtomicError)
func MaxCalls ¶
func MaxCalls(maxCalls int) AtomicErrorOption
type AtomicPtr ¶
type AtomicPtr[T any] struct { // contains filtered or unexported fields }
AtomicPtr is intended for use in mocks to easily expose variables for use in testing. It makes setting and retrieving the values race free by wrapping the pointer itself in a mutex. There is no Get() method, but instead a Clone() method deep copies the object being stored by serializing/de-serializing it from JSON. This pattern shouldn't be followed anywhere else but is an easy way to eliminate races in our tests.
type AtomicPtrSlice ¶
type AtomicPtrSlice[T any] struct { // contains filtered or unexported fields }
AtomicPtrSlice exposes a slice of a pointer type in a race-free manner. The interface is just enough to replace the set.Set usage in our previous tests.
func (*AtomicPtrSlice[T]) Add ¶
func (a *AtomicPtrSlice[T]) Add(input *T)
func (*AtomicPtrSlice[T]) ForEach ¶
func (a *AtomicPtrSlice[T]) ForEach(fn func(*T))
func (*AtomicPtrSlice[T]) Len ¶
func (a *AtomicPtrSlice[T]) Len() int
func (*AtomicPtrSlice[T]) Pop ¶
func (a *AtomicPtrSlice[T]) Pop() *T
func (*AtomicPtrSlice[T]) Reset ¶
func (a *AtomicPtrSlice[T]) Reset()
type CapacityPool ¶
type CloudProvider ¶
type CloudProvider struct { InstanceTypes []*corecloudprovider.InstanceType ValidAMIs []string }
func (*CloudProvider) GetInstanceTypes ¶
func (c *CloudProvider) GetInstanceTypes(_ context.Context, _ *v1beta1.NodePool) ([]*corecloudprovider.InstanceType, error)
func (*CloudProvider) IsDrifted ¶
func (c *CloudProvider) IsDrifted(_ context.Context, nodeClaim *v1beta1.NodeClaim) (corecloudprovider.DriftReason, error)
func (*CloudProvider) Name ¶
func (c *CloudProvider) Name() string
Name returns the CloudProvider implementation name.
type EC2API ¶
type EC2API struct { ec2iface.EC2API EC2Behavior }
func (*EC2API) CreateFleetWithContext ¶
func (e *EC2API) CreateFleetWithContext(_ context.Context, input *ec2.CreateFleetInput, _ ...request.Option) (*ec2.CreateFleetOutput, error)
nolint: gocyclo
func (*EC2API) CreateLaunchTemplateWithContext ¶
func (e *EC2API) CreateLaunchTemplateWithContext(_ context.Context, input *ec2.CreateLaunchTemplateInput, _ ...request.Option) (*ec2.CreateLaunchTemplateOutput, error)
func (*EC2API) CreateTagsWithContext ¶
func (e *EC2API) CreateTagsWithContext(_ context.Context, input *ec2.CreateTagsInput, _ ...request.Option) (*ec2.CreateTagsOutput, error)
func (*EC2API) DeleteLaunchTemplateWithContext ¶
func (e *EC2API) DeleteLaunchTemplateWithContext(_ context.Context, input *ec2.DeleteLaunchTemplateInput, _ ...request.Option) (*ec2.DeleteLaunchTemplateOutput, error)
func (*EC2API) DescribeAvailabilityZonesWithContext ¶
func (e *EC2API) DescribeAvailabilityZonesWithContext(context.Context, *ec2.DescribeAvailabilityZonesInput, ...request.Option) (*ec2.DescribeAvailabilityZonesOutput, error)
func (*EC2API) DescribeImagesPagesWithContext ¶
func (*EC2API) DescribeImagesWithContext ¶
func (e *EC2API) DescribeImagesWithContext(_ context.Context, input *ec2.DescribeImagesInput, _ ...request.Option) (*ec2.DescribeImagesOutput, error)
func (*EC2API) DescribeInstanceTypeOfferingsPagesWithContext ¶
func (*EC2API) DescribeInstanceTypeOfferingsWithContext ¶
func (e *EC2API) DescribeInstanceTypeOfferingsWithContext(_ context.Context, _ *ec2.DescribeInstanceTypeOfferingsInput, _ ...request.Option) (*ec2.DescribeInstanceTypeOfferingsOutput, error)
func (*EC2API) DescribeInstanceTypesPagesWithContext ¶
func (*EC2API) DescribeInstanceTypesWithContext ¶
func (e *EC2API) DescribeInstanceTypesWithContext(_ context.Context, _ *ec2.DescribeInstanceTypesInput, _ ...request.Option) (*ec2.DescribeInstanceTypesOutput, error)
func (*EC2API) DescribeInstancesPagesWithContext ¶
func (*EC2API) DescribeInstancesWithContext ¶
func (e *EC2API) DescribeInstancesWithContext(_ context.Context, input *ec2.DescribeInstancesInput, _ ...request.Option) (*ec2.DescribeInstancesOutput, error)
func (*EC2API) DescribeLaunchTemplatesPagesWithContext ¶
func (*EC2API) DescribeLaunchTemplatesWithContext ¶
func (e *EC2API) DescribeLaunchTemplatesWithContext(_ context.Context, input *ec2.DescribeLaunchTemplatesInput, _ ...request.Option) (*ec2.DescribeLaunchTemplatesOutput, error)
func (*EC2API) DescribeSecurityGroupsWithContext ¶
func (e *EC2API) DescribeSecurityGroupsWithContext(_ context.Context, input *ec2.DescribeSecurityGroupsInput, _ ...request.Option) (*ec2.DescribeSecurityGroupsOutput, error)
func (*EC2API) DescribeSpotPriceHistoryPagesWithContext ¶
func (*EC2API) DescribeSpotPriceHistoryWithContext ¶
func (e *EC2API) DescribeSpotPriceHistoryWithContext(_ aws.Context, input *ec2.DescribeSpotPriceHistoryInput, _ ...request.Option) (*ec2.DescribeSpotPriceHistoryOutput, error)
func (*EC2API) DescribeSubnetsWithContext ¶
func (e *EC2API) DescribeSubnetsWithContext(_ context.Context, input *ec2.DescribeSubnetsInput, _ ...request.Option) (*ec2.DescribeSubnetsOutput, error)
func (*EC2API) Reset ¶
func (e *EC2API) Reset()
Reset must be called between tests otherwise tests will pollute each other.
func (*EC2API) TerminateInstancesWithContext ¶
func (e *EC2API) TerminateInstancesWithContext(_ context.Context, input *ec2.TerminateInstancesInput, _ ...request.Option) (*ec2.TerminateInstancesOutput, error)
type EC2Behavior ¶
type EC2Behavior struct { DescribeImagesOutput AtomicPtr[ec2.DescribeImagesOutput] DescribeLaunchTemplatesOutput AtomicPtr[ec2.DescribeLaunchTemplatesOutput] DescribeSubnetsOutput AtomicPtr[ec2.DescribeSubnetsOutput] DescribeSecurityGroupsOutput AtomicPtr[ec2.DescribeSecurityGroupsOutput] DescribeInstanceTypesOutput AtomicPtr[ec2.DescribeInstanceTypesOutput] DescribeInstanceTypeOfferingsOutput AtomicPtr[ec2.DescribeInstanceTypeOfferingsOutput] DescribeAvailabilityZonesOutput AtomicPtr[ec2.DescribeAvailabilityZonesOutput] DescribeSpotPriceHistoryInput AtomicPtr[ec2.DescribeSpotPriceHistoryInput] DescribeSpotPriceHistoryOutput AtomicPtr[ec2.DescribeSpotPriceHistoryOutput] CreateFleetBehavior MockedFunction[ec2.CreateFleetInput, ec2.CreateFleetOutput] TerminateInstancesBehavior MockedFunction[ec2.TerminateInstancesInput, ec2.TerminateInstancesOutput] DescribeInstancesBehavior MockedFunction[ec2.DescribeInstancesInput, ec2.DescribeInstancesOutput] CreateTagsBehavior MockedFunction[ec2.CreateTagsInput, ec2.CreateTagsOutput] CalledWithCreateLaunchTemplateInput AtomicPtrSlice[ec2.CreateLaunchTemplateInput] CalledWithDescribeImagesInput AtomicPtrSlice[ec2.DescribeImagesInput] Instances sync.Map LaunchTemplates sync.Map InsufficientCapacityPools atomic.Slice[CapacityPool] NextError AtomicError }
EC2Behavior must be reset between tests otherwise tests will pollute each other.
type EKSAPI ¶
type EKSAPI struct { eksiface.EKSAPI EKSAPIBehavior }
func (*EKSAPI) DescribeClusterWithContext ¶
func (s *EKSAPI) DescribeClusterWithContext(_ context.Context, input *eks.DescribeClusterInput, _ ...request.Option) (*eks.DescribeClusterOutput, error)
type EKSAPIBehavior ¶
type EKSAPIBehavior struct {
DescribeClusterBehavior MockedFunction[eks.DescribeClusterInput, eks.DescribeClusterOutput]
}
EKSAPIBehavior must be reset between tests otherwise tests will pollute each other.
type IAMAPI ¶
type IAMAPI struct { sync.Mutex iamiface.IAMAPI IAMAPIBehavior InstanceProfiles map[string]*iam.InstanceProfile }
func (*IAMAPI) AddRoleToInstanceProfileWithContext ¶
func (s *IAMAPI) AddRoleToInstanceProfileWithContext(_ context.Context, input *iam.AddRoleToInstanceProfileInput, _ ...request.Option) (*iam.AddRoleToInstanceProfileOutput, error)
func (*IAMAPI) CreateInstanceProfileWithContext ¶
func (s *IAMAPI) CreateInstanceProfileWithContext(_ context.Context, input *iam.CreateInstanceProfileInput, _ ...request.Option) (*iam.CreateInstanceProfileOutput, error)
func (*IAMAPI) DeleteInstanceProfileWithContext ¶
func (s *IAMAPI) DeleteInstanceProfileWithContext(_ context.Context, input *iam.DeleteInstanceProfileInput, _ ...request.Option) (*iam.DeleteInstanceProfileOutput, error)
func (*IAMAPI) GetInstanceProfileWithContext ¶
func (s *IAMAPI) GetInstanceProfileWithContext(_ context.Context, input *iam.GetInstanceProfileInput, _ ...request.Option) (*iam.GetInstanceProfileOutput, error)
func (*IAMAPI) RemoveRoleFromInstanceProfileWithContext ¶
func (s *IAMAPI) RemoveRoleFromInstanceProfileWithContext(_ context.Context, input *iam.RemoveRoleFromInstanceProfileInput, _ ...request.Option) (*iam.RemoveRoleFromInstanceProfileOutput, error)
type IAMAPIBehavior ¶
type IAMAPIBehavior struct { GetInstanceProfileBehavior MockedFunction[iam.GetInstanceProfileInput, iam.GetInstanceProfileOutput] CreateInstanceProfileBehavior MockedFunction[iam.CreateInstanceProfileInput, iam.CreateInstanceProfileOutput] DeleteInstanceProfileBehavior MockedFunction[iam.DeleteInstanceProfileInput, iam.DeleteInstanceProfileOutput] AddRoleToInstanceProfileBehavior MockedFunction[iam.AddRoleToInstanceProfileInput, iam.AddRoleToInstanceProfileOutput] RemoveRoleFromInstanceProfileBehavior MockedFunction[iam.RemoveRoleFromInstanceProfileInput, iam.RemoveRoleFromInstanceProfileOutput] }
IAMAPIBehavior must be reset between tests otherwise tests will pollute each other.
type MockedFunction ¶
type MockedFunction[I any, O any] struct { Output AtomicPtr[O] // Output to return on call to this function CalledWithInput AtomicPtrSlice[I] // Slice used to keep track of passed input to this function Error AtomicError // Error to return a certain number of times defined by custom error options // contains filtered or unexported fields }
func (*MockedFunction[I, O]) Calls ¶
func (m *MockedFunction[I, O]) Calls() int
func (*MockedFunction[I, O]) FailedCalls ¶
func (m *MockedFunction[I, O]) FailedCalls() int
func (*MockedFunction[I, O]) Invoke ¶
func (m *MockedFunction[I, O]) Invoke(input *I, defaultTransformer func(*I) (*O, error)) (*O, error)
func (*MockedFunction[I, O]) Reset ¶
func (m *MockedFunction[I, O]) Reset()
Reset must be called between tests otherwise tests will pollute each other.
func (*MockedFunction[I, O]) SuccessfulCalls ¶
func (m *MockedFunction[I, O]) SuccessfulCalls() int
type PricingAPI ¶
type PricingAPI struct { pricingiface.PricingAPI PricingBehavior }
func (*PricingAPI) GetProductsPagesWithContext ¶
func (p *PricingAPI) GetProductsPagesWithContext(_ aws.Context, _ *pricing.GetProductsInput, fn func(*pricing.GetProductsOutput, bool) bool, _ ...request.Option) error
func (*PricingAPI) Reset ¶
func (p *PricingAPI) Reset()
type PricingBehavior ¶
type PricingBehavior struct { NextError AtomicError GetProductsOutput AtomicPtr[pricing.GetProductsOutput] }
type SQSAPI ¶
type SQSAPI struct { sqsiface.SQSAPI SQSBehavior }
func (*SQSAPI) DeleteMessageWithContext ¶
func (s *SQSAPI) DeleteMessageWithContext(_ context.Context, input *sqs.DeleteMessageInput, _ ...request.Option) (*sqs.DeleteMessageOutput, error)
func (*SQSAPI) GetQueueUrlWithContext ¶
func (s *SQSAPI) GetQueueUrlWithContext(_ context.Context, input *sqs.GetQueueUrlInput, _ ...request.Option) (*sqs.GetQueueUrlOutput, error)
func (*SQSAPI) ReceiveMessageWithContext ¶
func (s *SQSAPI) ReceiveMessageWithContext(_ context.Context, input *sqs.ReceiveMessageInput, _ ...request.Option) (*sqs.ReceiveMessageOutput, error)
type SQSBehavior ¶
type SQSBehavior struct { GetQueueURLBehavior MockedFunction[sqs.GetQueueUrlInput, sqs.GetQueueUrlOutput] ReceiveMessageBehavior MockedFunction[sqs.ReceiveMessageInput, sqs.ReceiveMessageOutput] DeleteMessageBehavior MockedFunction[sqs.DeleteMessageInput, sqs.DeleteMessageOutput] }
SQSBehavior must be reset between tests otherwise tests will pollute each other.
type SSMAPI ¶
type SSMAPI struct { ssmiface.SSMAPI Parameters map[string]string GetParameterOutput *ssm.GetParameterOutput WantErr error }
func (SSMAPI) GetParameterWithContext ¶
func (a SSMAPI) GetParameterWithContext(_ context.Context, input *ssm.GetParameterInput, _ ...request.Option) (*ssm.GetParameterOutput, error)