Documentation
¶
Index ¶
Constants ¶
const (
// DefaultErrorExitCode defines the default exit code.
DefaultErrorExitCode = 1
)
Variables ¶
var ErrExit = fmt.Errorf("exit")
ErrExit may be passed to CheckError to instruct it to output nothing but exit with status code 1.
Functions ¶
func BehaviorOnFatal ¶
BehaviorOnFatal allows you to override the default behavior when a fatal error occurs, which is to call os.Exit(code). You can pass 'panic' as a function here if you prefer the panic() over os.Exit(1).
func CheckErr ¶
func CheckErr(err error)
CheckErr prints a user-friendly error to STDERR and exits with a non-zero exit code. Unrecognized errors will be printed with an "error: " prefix.
This method is generic to the command in use and may be used by non-IAM commands.
func DefaultBehaviorOnFatal ¶
func DefaultBehaviorOnFatal()
DefaultBehaviorOnFatal allows you to undo any previous override. Useful in tests.
func MultipleErrors ¶
MultipleErrors returns a newline delimited string containing the prefix and referenced errors in standard form.
func StandardErrorMessage ¶
StandardErrorMessage translates common errors into a human-readable message, or returns false if the error is not one of the recognized types. It may also log extended information to log.
This method is generic to the command in use and may be used by non-IAM commands.
Types ¶
type Factory ¶
type Factory interface {
HTTPClient() *http.Client
// AdminClient returns a HivemindAdminService gRPC client connected to the given address.
// The caller is responsible for closing the returned connection.
AdminClient(addr string) (pb.HivemindAdminServiceClient, *grpc.ClientConn, error)
// HivemindAddr returns the configured Hivemind gRPC address.
HivemindAddr() string
}
Factory provides abstractions that allow the echoctl command to be extended across multiple types of resources and different API sets.
func NewDefaultFactory ¶
NewDefaultFactory creates a Factory. The hivemindAddr pointer should point to the global flag variable that holds the Hivemind address.