cmdlib

package
v0.0.0-...-e560ebb Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JSONPBMarshaller = &jsonpb.Marshaler{
	EmitDefaults: true,
}

JSONPBMarshaller marshals protobufs as JSON.

View Source
var JSONPBUnmarshaller = jsonpb.Unmarshaler{
	AllowUnknownFields: true,
}

JSONPBUnmarshaller unmarshals JSON and creates corresponding protobufs.

Functions

func MaybeWithTimeout

func MaybeWithTimeout(ctx context.Context, timeoutMins int) (context.Context, func(error))

MaybeWithTimeout creates a new context that has a timeout if the provided timeout is positive.

func NewAuthenticatedTransport

func NewAuthenticatedTransport(ctx context.Context, f *authcli.Flags) (http.RoundTripper, error)

NewAuthenticatedTransport creates a new authenticated transport

func NewAuthenticator

func NewAuthenticator(ctx context.Context, f *authcli.Flags) (*auth.Authenticator, error)

NewAuthenticator creates a new authenticator based on flags.

func NewHTTPClient

func NewHTTPClient(ctx context.Context, f *authcli.Flags) (*http.Client, error)

NewHTTPClient returns an HTTP client with authentication set up.

func NewQuietUsageError

func NewQuietUsageError(flags flag.FlagSet, format string, a ...interface{}) error

NewQuietUsageError creates a new error that only reports flags usage error details

func NewUsageError

func NewUsageError(flags flag.FlagSet, format string, a ...interface{}) error

NewUsageError creates a new error that also reports flags usage error details.

func PrintError

func PrintError(a subcommands.Application, err error)

PrintError reports errors back to the user.

Detailed error information is printed if err is a UserErrorReporter.

Types

type UserErrorReporter

type UserErrorReporter interface {
	// Report a user-friendly error through w.
	ReportUserError(w io.Writer)
}

UserErrorReporter reports a detailed error message to the user.

PrintError() uses a UserErrorReporter to print multi-line user error details along with the actual error.

Jump to

Keyboard shortcuts

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