utils

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnsupportedInstanceTypeReason       = "Unsupported"
	InsufficientCidrBlocksReason        = "InsufficientCidrBlocks"
	CNINodeCreatedReason                = "CNINodeCreation"
	NodeTrunkInitiatedReason            = "NodeTrunkInitiated"
	NodeTrunkFailedInitializationReason = "NodeTrunkFailedInit"
	EniConfigNameNotFoundReason         = "EniConfigNameNotFound"
	VersionNotice                       = "ControllerVersionNotice"
	BranchENICoolDownUpdateReason       = "BranchENICoolDownPeriodUpdated"
)
View Source
const (
	PartitionIndex = 1
	AccountIndex   = 4
)

Variables

View Source
var (
	ErrNotFound                   = errors.New("resource was not found")
	ErrInsufficientCidrBlocks     = errors.New("InsufficientCidrBlocks: The specified subnet does not have enough free cidr blocks to satisfy the request")
	ErrMsgProviderAndPoolNotFound = "cannot find the instance provider and pool from the cache"
	NotRetryErrors                = []string{InsufficientCidrBlocksReason}
)

Functions

func CeilDivision added in v1.1.8

func CeilDivision(x, y int) int

CeilDivision returns the ceiling result of numerator x divided by denominator y. y should be non-zero

func CopyMap added in v1.1.0

func CopyMap(original map[string]string) map[string]string

func DeconstructIPsFromPrefix added in v1.1.8

func DeconstructIPsFromPrefix(prefix string) ([]string, error)

DeconstructIPsFromPrefix deconstructs a IPv4 prefix into a list of /32 IPv4 addresses

func Difference added in v1.1.0

func Difference[T comparable](a, b []T) (diff []T)

Difference returns a-b, elements present in a and not in b

func GetKeyValSlice added in v1.1.0

func GetKeyValSlice(m map[string]string) (key []string, val []string)

func GetSourceAcctAndArn added in v1.3.1

func GetSourceAcctAndArn(roleARN, region, clusterName string) (string, string, error)

GetSourceAcctAndArn constructs source acct and arn and return them for use

func IntPower added in v1.1.8

func IntPower(n, m int) int

IntPower calculates n to the mth power. m should be a non-negative power to have an int return value

func IsNitroInstance added in v1.1.8

func IsNitroInstance(instanceType string) (bool, error)

func MaxOf added in v1.1.5

func MaxOf[T constraints.Ordered](vars ...T) T

func Maximum added in v1.1.5

func Maximum[T constraints.Ordered](a, b T) T

func MinOf added in v1.1.5

func MinOf[T constraints.Ordered](vars ...T) T

func Minimum added in v1.1.5

func Minimum[T constraints.Ordered](a, b T) T

func NewRateLimitedClient

func NewRateLimitedClient(qps int, burst int) (*http.Client, error)

NewRateLimitedClient returns a new HTTP client with rate limiter.

func RemoveDuplicatedSg

func RemoveDuplicatedSg(list []string) []string

RemoveDuplicatedSg removes duplicated items from a string slice. It returns a no duplicates string slice.

func SendBroadcastNodeEvent added in v1.3.4

func SendBroadcastNodeEvent(client k8s.K8sWrapper, reason, msg, eventType string, logger logr.Logger)

func SendNodeEventWithNodeName added in v1.1.8

func SendNodeEventWithNodeName(client k8s.K8sWrapper, nodeName, reason, msg, eventType string, logger logr.Logger)

func SendNodeEventWithNodeObject added in v1.1.8

func SendNodeEventWithNodeObject(client k8s.K8sWrapper, node *v1.Node, reason, msg, eventType string, logger logr.Logger)

func ShouldRetryOnError added in v1.1.8

func ShouldRetryOnError(err error) bool

ShouldRetryOnError returns true if the error is retryable, else returns false

Types

type SecurityGroupForPods added in v1.1.0

type SecurityGroupForPods struct {
	Client client.Client
	Log    logr.Logger
}

func (*SecurityGroupForPods) GetMatchingSecurityGroupForPods added in v1.1.0

func (s *SecurityGroupForPods) GetMatchingSecurityGroupForPods(pod *corev1.Pod) ([]string, error)

GetMatchingSecurityGroupForPods returns the list of security groups that should be associated with the Pod by matching against all the SecurityGroupPolicy

type SecurityGroupForPodsAPI added in v1.1.0

type SecurityGroupForPodsAPI interface {
	GetMatchingSecurityGroupForPods(pod *corev1.Pod) ([]string, error)
}

func NewSecurityGroupForPodsAPI added in v1.1.0

func NewSecurityGroupForPodsAPI(client client.Client, log logr.Logger) SecurityGroupForPodsAPI

NewSecurityGroupForPodsAPI returns the SecurityGroupForPod APIs for common operations on objects Using Security Group Policy

Jump to

Keyboard shortcuts

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