utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 27 Imported by: 1

Documentation

Overview

Copyright 2021 Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 Red Hat, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	// NonWordCharRegexp not word characters (== [^0-9A-Za-z_])
	NonWordCharRegexp = regexp.MustCompile(`\W`)
	// TemplateRegexp used to render openapi server URLs
	TemplateRegexp = regexp.MustCompile(`{([\w]+)}`)
	// LastSlashRegexp matches the last slash
	LastSlashRegexp = regexp.MustCompile(`/$`)
)

Functions

func BasePathFromOpenAPI added in v0.2.0

func BasePathFromOpenAPI(obj *openapi3.T) (string, error)

func CheckDeploymentAvailable

func CheckDeploymentAvailable(ctx context.Context, k8sClient client.Client, key types.NamespacedName) (bool, error)

func CreateOnlyK8SObject

func CreateOnlyK8SObject(k8sClient client.Client, obj runtime.Object) error

func CreateOrUpdateK8SObject

func CreateOrUpdateK8SObject(k8sClient client.Client, obj runtime.Object) error

func DeleteK8SObject

func DeleteK8SObject(k8sClient client.Client, obj runtime.Object) error

func FirstServerFromOpenAPI added in v0.2.0

func FirstServerFromOpenAPI(obj *openapi3.T) *openapi3.Server

func IsDeploymentAvailable

func IsDeploymentAvailable(dc *appsv1.Deployment) bool

IsDeploymentAvailable returns true when the provided Deployment has the "Available" condition set to true

func MergeMaps added in v0.2.0

func MergeMaps[K comparable, V any](MyMap1 map[K]V, MyMap2 map[K]V) map[K]V

func OpenAPIMatcherFromOASOperations added in v0.2.0

func OpenAPIMatcherFromOASOperations(basePath, path string, pathItem *openapi3.PathItem, verb string, op *openapi3.Operation, pathMatchType gatewayapiv1beta1.PathMatchType) gatewayapiv1beta1.HTTPRouteMatch

func OpenAPIOperationName added in v0.2.0

func OpenAPIOperationName(path, opVerb string, op *openapi3.Operation) string

func ParseURL

func ParseURL(str string) (*url.URL, bool)

ParseURL returns true when valid HTTP[S] url is found

func ReadExternalResource

func ReadExternalResource(resource string) ([]byte, error)

ReadExternalResource reads data streams from external resources. Currently implemented: - '@' for STDIN - URLs (HTTP[S]) - Files

func ReadURL

func ReadURL(location *url.URL) ([]byte, error)

func RenderOpenAPIServerURL added in v0.2.0

func RenderOpenAPIServerURL(server *openapi3.Server) (*url.URL, error)

func RenderOpenAPIServerURLStr added in v0.2.0

func RenderOpenAPIServerURLStr(server *openapi3.Server) (string, error)

func SetupScheme

func SetupScheme() error

Types

type KuadrantOASInfoExtension added in v0.2.0

type KuadrantOASInfoExtension struct {
	Route *RouteObject `json:"route,omitempty"`
}

func NewKuadrantOASInfoExtension added in v0.2.0

func NewKuadrantOASInfoExtension(info *openapi3.Info) (*KuadrantOASInfoExtension, error)

type KuadrantOASOperationExtension added in v0.2.0

type KuadrantOASOperationExtension KuadrantOASPathExtension

func NewKuadrantOASOperationExtension added in v0.2.0

func NewKuadrantOASOperationExtension(operation *openapi3.Operation) (*KuadrantOASOperationExtension, error)

type KuadrantOASPathExtension added in v0.2.0

type KuadrantOASPathExtension struct {
	Disable       *bool                              `json:"disable,omitempty"`
	PathMatchType *gatewayapiv1beta1.PathMatchType   `json:"pathMatchType,omitempty"`
	BackendRefs   []gatewayapiv1beta1.HTTPBackendRef `json:"backendRefs,omitempty"`
	RateLimit     *KuadrantRateLimitExtension        `json:"rate_limit,omitempty"`
}

func NewKuadrantOASPathExtension added in v0.2.0

func NewKuadrantOASPathExtension(pathItem *openapi3.PathItem) (*KuadrantOASPathExtension, error)

func (*KuadrantOASPathExtension) GetPathMatchType added in v0.2.0

func (*KuadrantOASPathExtension) IsDisabled added in v0.2.0

func (k *KuadrantOASPathExtension) IsDisabled() bool

type KuadrantRateLimitExtension added in v0.2.0

type KuadrantRateLimitExtension struct {
	When []kuadrantapiv1beta2.WhenCondition `json:"when,omitempty"`

	Counters []kuadrantapiv1beta2.ContextSelector `json:"counters,omitempty"`

	Rates []kuadrantapiv1beta2.Rate `json:"rates,omitempty"`
}

type RouteObject added in v0.2.0

type RouteObject struct {
	Name       *string                             `json:"name,omitempty"`
	Namespace  *string                             `json:"namespace,omitempty"`
	Hostnames  []gatewayapiv1beta1.Hostname        `json:"hostnames,omitempty"`
	ParentRefs []gatewayapiv1beta1.ParentReference `json:"parentRefs,omitempty"`
	Labels     map[string]string                   `json:"labels,omitempty"`
}

Jump to

Keyboard shortcuts

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