internal

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthorizationHeader      = "authorization"
	PlaygroundInstanceHeader = "playground-instance"
	UsernameEnvVar           = "CERBOS_USERNAME"
	PasswordEnvVar           = "CERBOS_PASSWORD"
	ServerEnvVar             = "CERBOS_SERVER"
	NetrcFile                = ".netrc"
	NetrcEnvVar              = "NETRC"
	NetrcUserKey             = "login"
	NetrcPassKey             = "password"
)

Variables

View Source
var (
	ErrMultipleYAMLDocs = errors.New("more than one YAML document detected")
)

Functions

func DefaultTLSConfig

func DefaultTLSConfig() *tls.Config

func ExtractMachineName

func ExtractMachineName(target string) (string, error)

ExtractMachineName picks out the machine name from a gRPC target. See https://github.com/grpc/grpc/blob/master/doc/naming.md

func IsValid

func IsValid[T Validatable](obj T) error

func LoadBasicAuthData

func LoadBasicAuthData(env Environment, providedServer, providedUsername, providedPassword string) (server, username, password string, err error)

LoadBasicAuthData loads basic auth credentials and the server address by considering the following options: - User provided values (config or flags) - Environment variables - netrc file.

func ReadJSONOrYAML

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

func ReadPolicy

func ReadPolicy(src io.Reader) (*policyv1.Policy, error)

ReadPolicy reads a policy from the given reader.

func ReadPolicyFromFile

func ReadPolicyFromFile(fsys fs.FS, path string) (*policyv1.Policy, error)

func ReadSchema

func ReadSchema(src io.Reader, id string) (*schemav1.Schema, error)

func ReadSchemaFromFile

func ReadSchemaFromFile(fsys fs.FS, path string) (*schemav1.Schema, error)

func ToStructPB

func ToStructPB(v any) (*structpb.Value, error)

func UserAgent

func UserAgent(impl string) string

func Validate added in v0.2.0

func Validate[T proto.Message](obj T) error

func ValidatePolicy

func ValidatePolicy(p *policyv1.Policy) error

Types

type Environment

type Environment interface {
	Getenv(string) string
	LookupEnv(string) (string, bool)
}

type OSEnvironment

type OSEnvironment struct{}

func (OSEnvironment) Getenv

func (OSEnvironment) Getenv(k string) string

func (OSEnvironment) LookupEnv

func (OSEnvironment) LookupEnv(k string) (string, bool)

type ReqOpt

type ReqOpt struct {
	AuxData     *requestv1.AuxData
	Metadata    metadata.MD
	IncludeMeta bool
}

func (*ReqOpt) Context added in v0.2.2

func (o *ReqOpt) Context(ctx context.Context) context.Context

type Validatable

type Validatable interface {
	Err() error
	Validate() error
}

Jump to

Keyboard shortcuts

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