utils

package
v0.0.0-...-0490640 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeDupFilters

func DeDupFilters(filters map[string][]string)

Take out the duplicate entries if they exist.. not need to return the map.. maps are passed by ref. getting the duplicates out of the filters avoids the filtersQuery from becoming less efficient by having duplicate clauses. Duplicates in filter entries also make deep filtering impossible because deep filtering at the moment requires that we have exactly one profile and no controls or one profile and one control. If we have duplicates, it's easy to see why deep filtering would therefore, break.

func DiffArray

func DiffArray(a, b []string) (inANotB []string)

DiffArray - A util func that takes two string arrays (a and b), and returns an array containing elements that are in a but not b

func EscapeLiteralForPG

func EscapeLiteralForPG(value string) string

func EscapeLiteralForPGPatternMatch

func EscapeLiteralForPGPatternMatch(value string) string

func FormatErrorMsg

func FormatErrorMsg(err error, id string) error

Error codes can be found here: https://github.com/grpc-ecosystem/grpc-gateway/blob/master/runtime/errors.go#L15 FormatErrorMsg takes a message and a string id to return a unified error msg across requests

func IsSafeUUID

func IsSafeUUID(uuid string) bool

Ensuring it only has valid UUID characters TODO: unit tests

func IsSqlSafe

func IsSqlSafe(str string) bool

Ensuring str only has the characters we support at the moment TODO: unit tests

func KvMatches

func KvMatches(matchKey string, matchVal string, kv *common.Kv) bool

func ProcessInvalid

func ProcessInvalid(err error, msg string) error

ProcessInvalid returns InvalidError

func ProcessNotFound

func ProcessNotFound(err error, id string) error

ProcessNotFound returns NotFoundError

func ProcessSQLNotFound

func ProcessSQLNotFound(err error, id string, wrap string) error

ProcessSQLNotFound checks for err of type sql.ErrNoRows and returns NotFoundError if true, otherwise wrap original error and return

func ProcessUnauthenticated

func ProcessUnauthenticated(err error, msg string) error

ProcessUnauthenticated returns UnauthenticatedError

func UniqueStringSlice

func UniqueStringSlice(stringSlice []string) []string

Types

type InvalidError

type InvalidError struct {
	Msg string
	// contains filtered or unexported fields
}

InvalidError is the error returned when user has provided invalid arguments

func (*InvalidError) Error

func (e *InvalidError) Error() string

type NotFoundError

type NotFoundError struct {
	Id string
	// contains filtered or unexported fields
}

NotFoundError is the error returned when nothing was found

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type UnauthenticatedError

type UnauthenticatedError struct {
	Msg string
	// contains filtered or unexported fields
}

UnauthenticatedError is the error returned when user is not authenticated with an external service such as aws or azure

func (*UnauthenticatedError) Error

func (e *UnauthenticatedError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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