utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: Apache-2.0 Imports: 17 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.

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 FirstServerFromOpenAPI added in v0.2.0

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

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 gatewayapiv1.PathMatchType) gatewayapiv1.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: - '-' or '@' 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 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 *gatewayapiv1.PathMatchType   `json:"pathMatchType,omitempty"`
	BackendRefs   []gatewayapiv1.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 (k *KuadrantOASPathExtension) GetPathMatchType() gatewayapiv1.PathMatchType

func (*KuadrantOASPathExtension) IsDisabled added in v0.2.0

func (k *KuadrantOASPathExtension) IsDisabled() bool

type KuadrantOASRootExtension added in v0.3.0

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

func NewKuadrantOASRootExtension added in v0.3.0

func NewKuadrantOASRootExtension(doc *openapi3.T) (*KuadrantOASRootExtension, error)

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  []gatewayapiv1.Hostname        `json:"hostnames,omitempty"`
	ParentRefs []gatewayapiv1.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