util

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const TestDataDirectory = "testdata"

TestDataDirectory is the name of the special directory containing test fixtures. It is defined here to avoid an import loop.

Variables

View Source
var (
	AppName   = "cerbos"
	BuildDate = "unknown"
	Commit    = "unknown"
	Version   = "unknown"
)

Functions

func DefaultTLSConfig

func DefaultTLSConfig() *tls.Config

DefaultTLSConfig returns the default TLS configuration.

func GetFreeListenAddr

func GetFreeListenAddr() (string, error)

func GetFreePort

func GetFreePort() (int, error)

func IsSupportedFileType

func IsSupportedFileType(fileName string) bool

IsSupportedFileType returns true if the given file has a supported file extension.

func IsSupportedFileTypeExt added in v0.7.0

func IsSupportedFileTypeExt(fileName string) (string, bool)

IsSupportedFileTypeExt returns true and a file extension if the given file has a supported file extension.

func IsSupportedTestFile added in v0.7.0

func IsSupportedTestFile(fileName string) bool

IsSupportedTestFile return true if the given file is a supported test file name, i.e. "*_test.{yaml,yml,json}".

func LoadFromJSONOrYAML

func LoadFromJSONOrYAML(fsys fs.FS, path string, dest proto.Message) error

LoadFromJSONOrYAML reads a JSON or YAML encoded protobuf from the given path.

func OpenOneOfSupportedFiles added in v0.7.0

func OpenOneOfSupportedFiles(fsys fs.FS, fileName string) (fs.File, error)

OpenOneOfSupportedFiles attempts to open a fileName adding supported extensions.

func ParseListenAddress

func ParseListenAddress(listenAddr string) (network, addr string, err error)

ParseListenAddress parses an address and returns the network type and the address to dial. inspired by https://github.com/ghostunnel/ghostunnel/blob/6e58c75c8762fe371c1134e89dd55033a6d577a4/socket/net.go#L31

func ReadJSONOrYAML

func ReadJSONOrYAML(src io.Reader, dest proto.Message) error

func WriteYAML

func WriteYAML(dest io.Writer, data proto.Message) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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