helpers

package
v0.0.0-...-ea6ac85 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckGardenerCRD

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

func CreateApiRule

func CreateApiRule(resourceMgr *resource.Manager, k8sClient dynamic.Interface, retryOpts []retry.Option, apiRuleResource unstructured.Unstructured) error

CreateApiRule creates APIRule and waits for its status This function works for both v1beta1 and v2alpha1 versions of APIRule.

func CreateApiRuleV2Alpha1

func CreateApiRuleV2Alpha1(resourceMgr *resource.Manager, k8sClient dynamic.Interface, retryOpts []retry.Option, apiRuleResource unstructured.Unstructured) error

func CreateApiRuleV2Alpha1ExpectError

func CreateApiRuleV2Alpha1ExpectError(resourceMgr *resource.Manager, k8sClient dynamic.Interface, retryOpts []retry.Option, apiRuleResource unstructured.Unstructured, errorMessage string) 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 GetLoadBalancerIngress

func GetLoadBalancerIngress(k8sClient dynamic.Interface, svcName string, svcNamespace string) (map[string]interface{}, 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(resourceMgr *resource.Manager, k8sClient dynamic.Interface, retryOpts []retry.Option, apiRuleResource unstructured.Unstructured) error

func WaitForDeployment

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

func WaitForRateLimit

func WaitForRateLimit(resourceMgr *resource.Manager, k8sClient dynamic.Interface, namespace string, rateLimitName 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 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) CallEndpointWithRequestRetry

func (h *RetryableHttpClient) CallEndpointWithRequestRetry(req *http.Request, 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)

func (*RetryableHttpClient) HttpClient

func (h *RetryableHttpClient) HttpClient() *http.Client

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