utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanAddress added in v1.2.0

func CleanAddress(address string) string

CleanAddress removes trailling / from a URL.

func CleanKongVersion added in v0.7.1

func CleanKongVersion(version string) (string, error)

CleanKongVersion takes a version of Kong and returns back a string in the form of `/major.minor` version. There are various dashes and dots and other descriptors in Kong version strings, which has often created confusion in code and incorrect parsing, and hence this function does not return the patch version (on which shouldn't rely on anyways).

func Empty

func Empty(s *string) bool

Empty checks if a string referenced by s or s itself is empty.

func GetKongClient

func GetKongClient(opt KongClientConfig) (*kong.Client, error)

GetKongClient returns a Kong client

func MergeTags added in v0.3.0

func MergeTags(obj interface{}, tags []string) error

MergeTags merges Tags in the object with tags.

func MustMergeTags added in v0.6.0

func MustMergeTags(obj interface{}, tags []string)

MustMergeTags is same as MergeTags but panics if there is an error.

func MustRemoveTags added in v0.6.0

func MustRemoveTags(obj interface{}, tags []string)

MustRemoveTags is same as RemoveTags but panics if there is an error.

func RemoveTags added in v0.3.0

func RemoveTags(obj interface{}, tags []string) error

RemoveTags removes tags from the Tags in obj.

func UUID

func UUID() string

UUID will generate a random v14 unique identifier based upon random numbers

Types

type Defaulter added in v0.3.0

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

Defaulter registers types and fills in struct fields with default values.

func GetKongDefaulter added in v0.3.0

func GetKongDefaulter() (*Defaulter, error)

GetKongDefaulter returns a defaulter which can set default values for Kong entities.

func (*Defaulter) MustSet added in v0.6.0

func (d *Defaulter) MustSet(arg interface{})

MustSet is like Set but panics if there is an error.

func (*Defaulter) Register added in v0.3.0

func (d *Defaulter) Register(def interface{}) error

Register registers a type and it's default value. The default value is passed in and the type is inferred from the default value.

func (*Defaulter) Set added in v0.3.0

func (d *Defaulter) Set(arg interface{}) error

Set fills in default values in a struct of a registered type.

type ErrArray

type ErrArray struct {
	Errors []error
}

ErrArray holds an array of errors.

func (ErrArray) Error

func (e ErrArray) Error() string

Error returns a pretty string of errors present.

type HeaderRoundTripper

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

HeaderRoundTripper injects Headers into requests made via RT.

func (*HeaderRoundTripper) RoundTrip

func (t *HeaderRoundTripper) RoundTrip(req *http.Request) (*http.Response,
	error)

RoundTrip satisfies the RoundTripper interface.

type KongClientConfig

type KongClientConfig struct {
	Address   string
	Workspace string

	TLSServerName string

	TLSCACert string

	TLSSkipVerify bool
	Debug         bool

	SkipWorkspaceCrud bool

	Headers []string
}

KongClientConfig holds config details to use to talk to a Kong server.

type KongRawState

type KongRawState struct {
	Services []*kong.Service
	Routes   []*kong.Route

	Plugins []*kong.Plugin

	Upstreams []*kong.Upstream
	Targets   []*kong.Target

	Certificates   []*kong.Certificate
	SNIs           []*kong.SNI
	CACertificates []*kong.CACertificate

	Consumers      []*kong.Consumer
	CustomEntities []*custom.Entity

	KeyAuths    []*kong.KeyAuth
	HMACAuths   []*kong.HMACAuth
	JWTAuths    []*kong.JWTAuth
	BasicAuths  []*kong.BasicAuth
	ACLGroups   []*kong.ACLGroup
	Oauth2Creds []*kong.Oauth2Credential
	MTLSAuths   []*kong.MTLSAuth
}

KongRawState contains all of Kong Data

Jump to

Keyboard shortcuts

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