shared

package
v0.0.0-...-294dc8c Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AuthHeader = "authorization"

AuthHeader is the name of the header that contains the basic authoriztation password.

Variables

This section is empty.

Functions

func AuthSecret

func AuthSecret(pwFile string, devEnv string) ([]byte, error)

AuthSecret returns a secret using the secret file as given in environment variable. In case of development it uses the development password.

func CreateFile

func CreateFile(dir string, force bool, name string, content []byte) error

CreateFile creates a file in the given directory with the given content. Use a truthy value for force to override an existing file.

func InputOrFileOrStdin

func InputOrFileOrStdin(input, filename string) ([]byte, error)

InputOrFileOrStdin takes either a command line input or a filename (which can be "-" so we read from stdin) and returns the content.

func ReadFromFileOrStdin

func ReadFromFileOrStdin(filename string) ([]byte, error)

ReadFromFileOrStdin reads the given file. If the filename is "-" it reads from stdin instead.

Types

type BasicAuth

type BasicAuth struct {
	Password []byte
}

BasicAuth contains the password used in basic authorization process. The password will be encoded in base64. The struct implements https://pkg.go.dev/google.golang.org/grpc@v1.38.0/credentials#PerRPCCredentials

func (BasicAuth) EncPassword

func (a BasicAuth) EncPassword() string

EncPassword returns the password encoded in base 64.

func (BasicAuth) GetRequestMetadata

func (a BasicAuth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata gets the current request metadata. See https://pkg.go.dev/google.golang.org/grpc@v1.38.0/credentials#PerRPCCredentials

func (BasicAuth) RequireTransportSecurity

func (a BasicAuth) RequireTransportSecurity() bool

RequireTransportSecurity indicates whether the credentials requires transport security. See https://pkg.go.dev/google.golang.org/grpc@v1.38.0/credentials#PerRPCCredentials

type Logger

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

Logger is a logger that provides logging with respect to the log level.

func NewLogger

func NewLogger(level string) (Logger, error)

NewLogger returns a default logger with respect to the given log level.

func (Logger) Debugf

func (l Logger) Debugf(format string, v ...interface{})

Debugf calls logger.Printf but only in case of log level debug.

func (Logger) Infof

func (l Logger) Infof(format string, v ...interface{})

Infof calls logger.Printf but only in case of log level info or lower.

Jump to

Keyboard shortcuts

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