util

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRateLimit indicates hitting linode API rate limits
	ErrRateLimit = errors.New("rate-limit exceeded")
)

Functions

func GetInstanceID added in v0.6.1

func GetInstanceID(providerID *string) (int, error)

GetInstanceID determines the instance ID from the ProviderID

func IgnoreLinodeAPIError

func IgnoreLinodeAPIError(err error, code int) error

IgnoreLinodeAPIError returns the error except matches to status code

func IsRetryableError added in v0.6.0

func IsRetryableError(err error) bool

IsRetryableError determines if the error is retryable, meaning a controller that encounters this error should requeue reconciliation to try again later

func Pointer

func Pointer[T any](t T) *T

Pointer returns the pointer of any type

func UnwrapError added in v0.2.1

func UnwrapError(err error) error

UnwrapError safely unwraps an error until it can't be unwrapped.

Types

type Filter

type Filter struct {
	ID                *int              // Filter on the resource's ID (most specific).
	Label             string            // Filter on the resource's label.
	Tags              []string          // Filter resources by their tags (least specific).
	AdditionalFilters map[string]string // Filter resources by additional parameters
}

Filter holds the fields used for filtering results from the Linode API.

The fields within Filter are prioritized so that only the most-specific field is present when Filter is marshaled to JSON.

func (Filter) MarshalJSON

func (f Filter) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON-encoded representation of a Filter. The resulting encoded value will have exactly 1 (one) field present. See Filter for details on the value precedence.

func (Filter) String

func (f Filter) String() (string, error)

String returns the string representation of the encoded value from Filter.MarshalJSON.

type PostRequestCounter added in v0.6.4

type PostRequestCounter struct {
	Mu           sync.RWMutex
	ReqRemaining int
	RefreshTime  int
}

PostRequestCounter keeps track of rate limits for POST to /linode/instances

func GetPostReqCounter added in v0.6.4

func GetPostReqCounter(tokenHash string) *PostRequestCounter

GetPostReqCounter returns pointer to PostRequestCounter for a given token hash

func (*PostRequestCounter) ApiResponseRatelimitCounter added in v0.6.4

func (c *PostRequestCounter) ApiResponseRatelimitCounter(resp *resty.Response) error

ApiResponseRatelimitCounter updates ReqRemaining and RefreshTime when a POST call is made to /linode/instances

func (*PostRequestCounter) IsPOSTLimitReached added in v0.6.4

func (c *PostRequestCounter) IsPOSTLimitReached() bool

IsPOSTLimitReached checks whether POST limits have been reached.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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