utils

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidURL = "invalid url %s"
	ErrStatusCode = "HTTP %s request failed with status code: %s"
)
View Source
const (
	ErrFailedToSetStatus = "failed to update status"
)

Variables

This section is empty.

Functions

func GetRollbackRetriesLimit

func GetRollbackRetriesLimit(rollbackRetriesLimit *int32) int32

GetRollbackRetriesLimit returns the rollback retries limit.

func IsHTTPError

func IsHTTPError(statusCode int) bool

IsHTTPError checks if an HTTP status code indicates an error.

func IsHTTPSuccess

func IsHTTPSuccess(statusCode int) bool

IsHTTPSuccess checks if an HTTP status code indicates success.

func IsRequestValid

func IsRequestValid(method string, url string) error

IsRequestValid checks if an HTTP request is valid.

func IsUrlValid

func IsUrlValid(input string) bool

func NormalizeWhitespace added in v1.0.5

func NormalizeWhitespace(input string) string

NormalizeWhitespace removes extra whitespace from a string.

func RetriesLimitReached

func RetriesLimitReached(statusFailed int32, rollbackRetriesLimit *int32) bool

RetriesLimitReached determines if the rollback retries limit has been reached.

func RollBackEnabled

func RollBackEnabled(rollbackRetriesLimit *int32) bool

RollBackEnabled determines if the rollback retries limit is enabled.

func SetRequestResourceStatus

func SetRequestResourceStatus(rr RequestResource, statusFuncs ...SetRequestStatusFunc) error

SetRequestResourceStatus sets the status of a resource.

func ShouldRetry

func ShouldRetry(rollbackRetriesLimit *int32, statusFailed int32) bool

ShouldRetry determines if the request should be retried based on the status of the request and the rollback retries limit.

func WaitTimeout

func WaitTimeout(timeout *v1.Duration) time.Duration

WaitTimeout returns the wait timeout duration.

Types

type CacheSetter

type CacheSetter interface {
	SetCache(statusCode int, headers map[string][]string, body string)
}

CacheSetter is an interface that defines the method to set the cache of a resource.

type ErrorSetter

type ErrorSetter interface {
	SetError(err error)
}

ErrorSetter is an interface that defines the method to set the error of a resource.

type LastReconcileTimeSetter added in v1.0.2

type LastReconcileTimeSetter interface {
	SetLastReconcileTime()
}

LastReconcileTimeSetter is an interface that defines the method to set the last reconcile time of a resource.

type RequestDetailsSetter

type RequestDetailsSetter interface {
	SetRequestDetails(url, method, body string, headers map[string][]string)
}

RequestDetailsSetter is an interface that defines the method to set the request details of a resource.

type RequestResource

type RequestResource struct {
	Resource       client.Object
	RequestContext context.Context
	HttpResponse   httpClient.HttpResponse
	HttpRequest    httpClient.HttpRequest
	LocalClient    client.Client
}

RequestResource is a struct that holds the resource, request context, http response, http request, and local client.

func (*RequestResource) ResetFailures

func (rr *RequestResource) ResetFailures() SetRequestStatusFunc

func (*RequestResource) SetBody

func (rr *RequestResource) SetBody() SetRequestStatusFunc

func (*RequestResource) SetCache

func (rr *RequestResource) SetCache() SetRequestStatusFunc

func (*RequestResource) SetError

func (rr *RequestResource) SetError(err error) SetRequestStatusFunc

func (*RequestResource) SetHeaders

func (rr *RequestResource) SetHeaders() SetRequestStatusFunc

func (*RequestResource) SetLastReconcileTime added in v1.0.2

func (rr *RequestResource) SetLastReconcileTime() SetRequestStatusFunc

func (*RequestResource) SetRequestDetails

func (rr *RequestResource) SetRequestDetails() SetRequestStatusFunc

func (*RequestResource) SetStatusCode

func (rr *RequestResource) SetStatusCode() SetRequestStatusFunc

func (*RequestResource) SetSynced

func (rr *RequestResource) SetSynced() SetRequestStatusFunc

type ResetFailures

type ResetFailures interface {
	ResetFailures()
}

ResetFailures is an interface that defines the method to reset the failures of a resource.

type ResponseSetter

type ResponseSetter interface {
	SetStatusCode(statusCode int)
	SetHeaders(headers map[string][]string)
	SetBody(body string)
}

ResponseSetter is an interface that defines the methods to set the status code, headers, and body of a resource.

type SetRequestStatusFunc

type SetRequestStatusFunc func()

SetRequestStatusFunc is a function that sets the status of a resource.

type SyncedSetter

type SyncedSetter interface {
	SetSynced(synced bool)
}

SyncedSetter is an interface that defines the method to set the synced status of a resource.

Jump to

Keyboard shortcuts

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