Documentation ¶
Index ¶
- Variables
- func MaybeWithTimeout(ctx context.Context, timeoutMins int) (context.Context, func(error))
- func NewAuthenticatedTransport(ctx context.Context, f *authcli.Flags) (http.RoundTripper, error)
- func NewAuthenticator(ctx context.Context, f *authcli.Flags) (*auth.Authenticator, error)
- func NewHTTPClient(ctx context.Context, f *authcli.Flags) (*http.Client, error)
- func NewQuietUsageError(flags flag.FlagSet, format string, a ...interface{}) error
- func NewUsageError(flags flag.FlagSet, format string, a ...interface{}) error
- func PrintError(a subcommands.Application, err error)
- type UserErrorReporter
Constants ¶
This section is empty.
Variables ¶
var JSONPBMarshaller = &jsonpb.Marshaler{ EmitDefaults: true, }
JSONPBMarshaller marshals protobufs as JSON.
var JSONPBUnmarshaller = jsonpb.Unmarshaler{ AllowUnknownFields: true, }
JSONPBUnmarshaller unmarshals JSON and creates corresponding protobufs.
Functions ¶
func MaybeWithTimeout ¶
MaybeWithTimeout creates a new context that has a timeout if the provided timeout is positive.
func NewAuthenticatedTransport ¶
NewAuthenticatedTransport creates a new authenticated transport
func NewAuthenticator ¶
NewAuthenticator creates a new authenticator based on flags.
func NewHTTPClient ¶
NewHTTPClient returns an HTTP client with authentication set up.
func NewQuietUsageError ¶
NewQuietUsageError creates a new error that only reports flags usage error details
func NewUsageError ¶
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.