helpers

package
v0.0.0-...-da4e77a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyApiRule

func ApplyApiRule(toExecute RetryableApiRule, onRetry RetryableApiRule, k8sClient dynamic.Interface, retryOpts []retry.Option, resources []unstructured.Unstructured) error

ApplyApiRule tries toExecute function and retries with onRetry if APIRule status is in error status or has no status code. This function works for both v1beta1 and v2alpha1 versions of APIRule.

func ApplyApiRuleV2Alpha1

func ApplyApiRuleV2Alpha1(toExecute RetryableApiRule, onRetry RetryableApiRule, k8sClient dynamic.Interface, retryOpts []retry.Option, resources []unstructured.Unstructured) error

func ApplyApiRuleV2Alpha1ExpectError

func ApplyApiRuleV2Alpha1ExpectError(toExecute RetryableApiRule, onRetry RetryableApiRule, k8sClient dynamic.Interface, retryOpts []retry.Option, resources []unstructured.Unstructured, errorMessage string) error

func CheckGardenerCRD

func CheckGardenerCRD(resourceMgr *resource.Manager, k8sClient dynamic.Interface) error

func GenerateRandomString

func GenerateRandomString(length int) string

func GenerateRandomTestId

func GenerateRandomTestId() string

func GetGardenerDomain

func GetGardenerDomain(resourceMgr *resource.Manager, k8sClient dynamic.Interface) (string, error)

func GetLoadBalancerIp

func GetLoadBalancerIp(loadBalancerIngress map[string]interface{}) (net.IP, error)

GetLoadBalancerIp returns the IP of the load balancer from the load balancer ingress object

func HasAPIRuleStatus

func HasAPIRuleStatus(apiRuleUnstructured *unstructured.Unstructured, status string) (bool, error)

func IsGardenerDetected

func IsGardenerDetected(resourceMgr *resource.Manager, k8sClient dynamic.Interface) bool

func LoadFile

func LoadFile(filePath string) ([]byte, error)

func UpdateApiRule

func UpdateApiRule(resourceManager *resource.Manager, k8sClient dynamic.Interface, retryOpts []retry.Option, resources []unstructured.Unstructured) error

func WaitForDeployment

func WaitForDeployment(resourceMgr *resource.Manager, k8sClient dynamic.Interface, namespace string, deploymentName string, retryOpts []retry.Option) error

Types

type ApiRuleStatusV1beta1

type ApiRuleStatusV1beta1 struct {
	Status struct {
		APIRuleStatus struct {
			Code        string `json:"code"`
			Description string `json:"desc"`
		} `json:"APIRuleStatus"`
	} `json:"status"`
}

func GetAPIRuleStatusV1beta1

func GetAPIRuleStatusV1beta1(apiRuleUnstructured *unstructured.Unstructured) (ApiRuleStatusV1beta1, error)

type ApiRuleStatusV2alpha1

type ApiRuleStatusV2alpha1 struct {
	Status struct {
		State       string `json:"state"`
		Description string `json:"description"`
	} `json:"status"`
}

func GetAPIRuleStatusV2Alpha1

func GetAPIRuleStatusV2Alpha1(apiRuleUnstructured *unstructured.Unstructured) (ApiRuleStatusV2alpha1, error)

type BodyContainsPredicate

type BodyContainsPredicate struct {
	Expected []string
}

BodyContainsPredicate is a struct representing desired HTTP response body containing expected strings

func (*BodyContainsPredicate) Assert

func (s *BodyContainsPredicate) Assert(response http.Response) (bool, string)

Assert asserts that the response body contains the expected string

type HttpResponseAsserter

type HttpResponseAsserter interface {
	// Assert asserts that the response is valid and returns true if it is. It also returns a message with details about the failure.
	Assert(response http.Response) (bool, string)
}

type OIDCConfiguration

type OIDCConfiguration struct {
	Issuer                                string   `json:"issuer"`
	AuthorizationEndpoint                 string   `json:"authorization_endpoint"`
	TokenEndpoint                         string   `json:"token_endpoint"`
	UserinfoEndpoint                      string   `json:"userinfo_endpoint"`
	EndSessionEndpoint                    string   `json:"end_session_endpoint"`
	JwksUri                               string   `json:"jwks_uri"`
	IntrospectionEndpoint                 string   `json:"introspection_endpoint"`
	RevocationEndpoint                    string   `json:"revocation_endpoint"`
	ResponseTypesSupported                []string `json:"response_types_supported"`
	GrantTypesSupported                   []string `json:"grant_types_supported"`
	SubjectTypesSupported                 []string `json:"subject_types_supported"`
	IdTokenSigningAlgValuesSupported      []string `json:"id_token_signing_alg_values_supported"`
	ScopesSupported                       []string `json:"scopes_supported"`
	TokenEndpointAuthMethodsSupported     []string `json:"token_endpoint_auth_methods_supported"`
	ClaimsSupported                       []string `json:"claims_supported"`
	CodeChallengeMethodsSupported         []string `json:"code_challenge_methods_supported"`
	TlsClientCertificateBoundAccessTokens bool     `json:"tls_client_certificate_bound_access_tokens"`
	FrontchannelLogoutSupported           bool     `json:"frontchannel_logout_supported"`
	FrontchannelLogoutSessionSupported    bool     `json:"frontchannel_logout_session_supported"`
}

func GetOIDCConfiguration

func GetOIDCConfiguration(oidcConfigurationEndpoint string) (oidcConfiguration OIDCConfiguration, err error)

type RequestOptions

type RequestOptions struct {
	Audiences []string
	Scopes    []string
}

type RetryableApiRule

type RetryableApiRule func(k8sClient dynamic.Interface, resources ...unstructured.Unstructured) (*unstructured.Unstructured, error)

RetryableApiRule wraps any function that modifies or creates an APIRule

type RetryableHttpClient

type RetryableHttpClient struct {
	// contains filtered or unexported fields
}

func NewClientWithRetry

func NewClientWithRetry(c *http.Client, opts []retry.Option) *RetryableHttpClient

func (*RetryableHttpClient) CallEndpointWithHeadersAndMethod

func (h *RetryableHttpClient) CallEndpointWithHeadersAndMethod(requestHeaders map[string]string, url string, method string, validator HttpResponseAsserter) error

CallEndpointWithHeadersAndMethod calls given url with given method and headers. Returns error if the status code is not in between bounds of status predicate after retrying deadline is reached

func (*RetryableHttpClient) CallEndpointWithHeadersWithRetries

func (h *RetryableHttpClient) CallEndpointWithHeadersWithRetries(requestHeaders map[string]string, url string, validator HttpResponseAsserter) error

CallEndpointWithHeadersWithRetries calls given url with headers and GET method. Returns error if the status code is not in between bounds of status predicate after retrying deadline is reached

func (*RetryableHttpClient) CallEndpointWithRequest

func (h *RetryableHttpClient) CallEndpointWithRequest(req *http.Request, url string, validator HttpResponseAsserter) error

func (*RetryableHttpClient) CallEndpointWithRetries

func (h *RetryableHttpClient) CallEndpointWithRetries(url string, validator HttpResponseAsserter) error

CallEndpointWithRetries returns error if the status code is not in between bounds of status predicate after retrying deadline is reached

func (*RetryableHttpClient) CallEndpointWithRetriesAndGetResponse

func (h *RetryableHttpClient) CallEndpointWithRetriesAndGetResponse(headers map[string]string, body io.Reader, method, url string) (*http.Response, error)

type StatusPredicate

type StatusPredicate struct {
	LowerStatusBound int
	UpperStatusBound int
}

StatusPredicate is a struct representing desired endpoint call response status code, that is between LowerStatusBound and UpperStatusBound

func (*StatusPredicate) Assert

func (s *StatusPredicate) Assert(response http.Response) (bool, string)

Jump to

Keyboard shortcuts

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