utils

package
v1.3.13 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanOpaVersion

func CleanOpaVersion(version string) (string, error)

CleanOpaVersion takes a version of Opa and returns back a string in the form of `/major.minor` version. There are various dashes and dots and other descriptors in Opa 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 GetOpaClient

func GetOpaClient(opt OpaClientConfig) (*opa.Client, error)

GetOpaClient returns a Opa opa

func UUID

func UUID() string

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

Types

type Defaulter

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

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

func GetOpaDefaulter

func GetOpaDefaulter() (*Defaulter, error)

GetOpaDefaulter returns a defaulter which can set default values for Opa entities.

func (*Defaulter) MustSet

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

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

func (*Defaulter) Register

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

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 OpaClientConfig

type OpaClientConfig struct {
	Address string

	Headers []string

	TLSSkipVerify bool
	TLSServerName string

	TLSCACert string

	Debug bool
}

OpaClientConfig holds config details to use to talk to a Opa server.

type OpaRawState

type OpaRawState struct {
	Policies []*opa.Policy
}

OpaRawState contains all of Opa Data

type OpaTransformer

type OpaTransformer struct {
}

OpaTransformer default types

func (OpaTransformer) Transformer

func (t OpaTransformer) Transformer(typ reflect.Type) func(dst, src reflect.Value) error

Transformer reflect types

Jump to

Keyboard shortcuts

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