utils

package
v0.0.0-...-6d3ae4b Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsString

func ContainsString(list []string, target string) bool

ContainsString checks whether a list contains a specific string. It returns true if the string is found in the list, otherwise false.

func ConvertRefConfigsV1ToV2

func ConvertRefConfigsV1ToV2(refConfig *dpv1alpha1.RefConfig) *dpv1alpha2.RefConfig

ConvertRefConfigsV1ToV2 converts RefConfig v2 to v1

func FilterByNamespaces

func FilterByNamespaces(namespaces []string) func(object k8client.Object) bool

FilterByNamespaces takes a list of namespaces and returns a filter function which return true if the input object is in the given namespaces list, and returns false otherwise

func GetBackendJWT

func GetBackendJWT(ctx context.Context, client k8client.Client, namespace,
	backendJWTReference string, api *dpv1alpha2.API) *dpv1alpha1.BackendJWT

GetBackendJWT reads BackendJWT when backendJWTReference is given

func GetDefaultHostNameForBackend

func GetDefaultHostNameForBackend(backend gwapiv1b1.HTTPBackendRef,
	defaultNamespace string) string

GetDefaultHostNameForBackend returns the host in <backend.name>.<namespace> format

func GetInterceptorService

func GetInterceptorService(ctx context.Context, client k8client.Client, namespace string,
	interceptorReference *dpv1alpha2.InterceptorReference, api *dpv1alpha2.API) *dpv1alpha1.InterceptorService

GetInterceptorService reads InterceptorService when interceptorReference is given

func GetNamespace

func GetNamespace(namespace *gwapiv1b1.Namespace, defaultNamespace string) string

GetNamespace reads namespace with a default value

func GetOperatorPodNamespace

func GetOperatorPodNamespace() string

GetOperatorPodNamespace returns the namesapce of the operator pod

func GetPtrSlice

func GetPtrSlice[T any](inputSlice []T) []*T

GetPtrSlice returns a slice which is also a slice containing pointers to the elements in the input slice.

func GetResolvedBackend

func GetResolvedBackend(ctx context.Context, client k8client.Client,
	backendNamespacedName types.NamespacedName, api *dpv1alpha2.API) *dpv1alpha1.ResolvedBackend

GetResolvedBackend resolves backend TLS configurations.

func GetResolvedMutualSSL

func GetResolvedMutualSSL(ctx context.Context, client k8client.Client, authentication dpv1alpha2.Authentication, resolvedMutualSSL *dpv1alpha2.MutualSSL) error

GetResolvedMutualSSL resolves mTLS related security configurations.

func GroupPtr

func GroupPtr(name string) *gwapiv1b1.Group

GroupPtr returns pointer to created v1beta1.Group object

func KindPtr

func KindPtr(name string) *gwapiv1b1.Kind

KindPtr returns a pointer to created v1beta1.Kind object

func NamespacedName

func NamespacedName(obj k8client.Object) types.NamespacedName

NamespacedName generates namespaced name for Kubernetes objects

func PathMatchTypePtr

func PathMatchTypePtr(pType gwapiv1b1.PathMatchType) *gwapiv1b1.PathMatchType

PathMatchTypePtr returns a pointer to created v1beta1.PathMatchType object

func ResolveAllmTLSCertificates

func ResolveAllmTLSCertificates(ctx context.Context, mutualSSL *dpv1alpha2.MutualSSLConfig, client k8client.Client, namespace string) ([]string, error)

ResolveAllmTLSCertificates resolves all mTLS certificates

func ResolveAndAddBackendToMapping

func ResolveAndAddBackendToMapping(ctx context.Context, client k8client.Client,
	backendMapping map[string]*dpv1alpha1.ResolvedBackend,
	backendRef dpv1alpha1.BackendReference, interceptorServiceNamespace string, api *dpv1alpha2.API)

ResolveAndAddBackendToMapping resolves backend from reference and adds it to the backendMapping.

func ResolveCertificate

func ResolveCertificate(ctx context.Context, client k8client.Client, namespace string, certificateInline *string,
	configMapRef *dpv1alpha2.RefConfig, secretRef *dpv1alpha2.RefConfig) (string, error)

ResolveCertificate reads the certificate from TLSConfig, first checks the certificateInline field, if no value then load the certificate from secretRef using util function called getSecretValue

func ResolveRef

func ResolveRef(ctx context.Context, client k8client.Client, api *dpv1alpha2.API,
	namespacedName types.NamespacedName, isReplace bool, obj k8client.Object, opts ...k8client.GetOption) error

ResolveRef this function will return k8client object and update owner

func RetrieveAPIList

func RetrieveAPIList(k8sclient k8client.Client) ([]dpv1alpha2.API, error)

RetrieveAPIList retrieves API list from the given kubernetes client

func RetrieveNamespaceListOptions

func RetrieveNamespaceListOptions(namespaces []string) k8client.ListOptions

RetrieveNamespaceListOptions retrieve namespace list options for the given namespaces

func SelectPolicy

func SelectPolicy[T any](policyUpOverride, policyUpDefault, policyDownOverride, policyDownDefault **T) *T

SelectPolicy selects the policy based on the policy override and default values

func StringPtr

func StringPtr(val string) *string

StringPtr returns a pointer to created string

func TieBreaker

func TieBreaker[T metav1.Object](k8sObjects []T) *T

TieBreaker breaks ties when multiple objects are present in a case only single object is expected. tie breaking logic is explained in https://gateway-api.sigs.k8s.io/geps/gep-713/?h=multiple+targetrefs#conflict-resolution

func UpdateCR

func UpdateCR(ctx context.Context, client k8client.Client, child metav1.Object) error

UpdateCR updates the given CR. use to update owner reference of the given CR.

func ValidateAndRetrieveNamespace

func ValidateAndRetrieveNamespace(namespace *gwapiv1.Namespace, defaultNamespace string) (string, error)

ValidateAndRetrieveNamespace checks if the child resource's namespace is the same as the parent resource's namespace

Types

This section is empty.

Jump to

Keyboard shortcuts

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