Documentation
¶
Index ¶
- Constants
- Variables
- func CLIPrompt(reason string, defaultResponse bool) (bool, error)
- func ErrToString(e error) string
- func GetUserEmail(ctx context.Context, flags *authcli.Flags) (string, error)
- func MapToStruct(m map[string]interface{}) (*structpb.Struct, error)
- func OffsetTimestamp(minutes int64) *timestamppb.Timestamp
- func ToKeyvalSlice(keyvals map[string]string) []string
- func WriteCrosfleetUIPromptStderr(args []string)
- type CLIPrinter
- func (p *CLIPrinter) Register(fl *flag.FlagSet)
- func (p *CLIPrinter) RegisterFromSubcmdArgs(args []string)
- func (p *CLIPrinter) WriteJSONStdout(output proto.Message)
- func (p *CLIPrinter) WriteTextStderr(output string, outputArgs ...interface{})
- func (p *CLIPrinter) WriteTextStdout(output string, outputArgs ...interface{})
- type EnvFlags
Constants ¶
const CrosfleetToolTag = "crosfleet-tool"
Tag to add to Buildbucket builds to indicate which crosfleet subcommand was used to launch the build.
Variables ¶
var CmpOpts = cmpopts.IgnoreUnexported( buildbucketpb.Build{}, buildbucketpb.RequestedDimension{}, buildbucketpb.StringPair{}, chromiumos.BuildTarget{}, duration.Duration{}, test_platform.Request{}, test_platform.Request_TestPlan{}, test_platform.Request_Params{}, test_platform.Request_Params_HardwareAttributes{}, test_platform.Request_Params_SoftwareAttributes{}, test_platform.Request_Params_SoftwareDependency{}, test_platform.Request_Params_FreeformAttributes{}, test_platform.Request_Params_Scheduling{}, test_platform.Request_Params_Decorations{}, test_platform.Request_Params_Retry{}, test_platform.Request_Params_Metadata{}, test_platform.Request_Params_Time{}, test_platform.ServiceVersion{}, structpb.ListValue{}, structpb.Struct{}, structpb.Value{})
CmpOpts enables comparisons of the listed protos with unexported fields.
var JSONPBUnmarshaler = jsonpb.Unmarshaler{AllowUnknownFields: true}
JSONPBUnmarshaler unmarshals JSON into proto messages.
Functions ¶
func ErrToString ¶
ErrToString enables safe conversions of errors to strings. Returns an empty string for nil errors.
func GetUserEmail ¶
GetUserEmail parses the given auth flags and returns the email of the authenticated crosfleet user.
func MapToStruct ¶
MapToStruct constructs a Struct from the given map[string]interface{}. The map keys must be valid UTF-8. The map values can be any of Go's basic types (bool, string, number type, byte, or rune), a proto message (in the form protoreflect.ProtoMessage), or a nested map[string]interface{} that fulfils the same requirements recursively.
NOTE: This function is just a modified version of structpb.NewStruct(), with added logic to handle the case where the map value is a proto message. This is necessary because Buildbucket request interfaces are almost always implemented as proto messages at some level.
func OffsetTimestamp ¶
func OffsetTimestamp(minutes int64) *timestamppb.Timestamp
OffsetTimestamp returns a timestamp offset from the current time by the given number of minutes.
func ToKeyvalSlice ¶
ToKeyvalSlice converts a key-val map to a slice of "key:val" strings.
func WriteCrosfleetUIPromptStderr ¶
func WriteCrosfleetUIPromptStderr(args []string)
WriteCrosfleetUIPromptStderr writes a prompt to Stderr for users to visit the go/my-crosfleet PLX dashboard to track their crosfleet-launched tasks, as long as the CLI args do NOT include the -json flag. If -json WAS included, the function does nothing.
NOTE: Parsing the -json flag here must happen separately from the normal CLIPrinter functions, since unlike those functions, this is run at the level of the outer "run"/"dut" commands, which don't have native access to the -json flag passed to their subcommands (e.g. "run test" or "dut lease").
Types ¶
type CLIPrinter ¶
type CLIPrinter struct {
// contains filtered or unexported fields
}
CLIPrinter handles all command line output.
func (*CLIPrinter) Register ¶
func (p *CLIPrinter) Register(fl *flag.FlagSet)
Register parses the -json flag.
func (*CLIPrinter) RegisterFromSubcmdArgs ¶
func (p *CLIPrinter) RegisterFromSubcmdArgs(args []string)
RegisterFromSubcmdArgs parses the -json flag directly from a list of args intended for a subcommand. This function is used to read the -json flag at the outer command level, e.g. dutcmd and runcmd.
func (*CLIPrinter) WriteJSONStdout ¶
func (p *CLIPrinter) WriteJSONStdout(output proto.Message)
WriteJSONStdout writes the given proto message as JSON (followed by a line break) to Stdout, as long as the CLI command WAS passed the -json flag. If -json was NOT passed, the function does nothing.
func (*CLIPrinter) WriteTextStderr ¶
func (p *CLIPrinter) WriteTextStderr(output string, outputArgs ...interface{})
WriteTextStderr writes the given human-readable output string (followed by a line break) to Stderr, as long as the CLI command was NOT passed the -json flag. If -json WAS passed, the function does nothing.
func (*CLIPrinter) WriteTextStdout ¶
func (p *CLIPrinter) WriteTextStdout(output string, outputArgs ...interface{})
WriteTextStdout writes the given human-readable output string (followed by a line break) to Stdout, as long as the CLI command was NOT passed the -json flag. If -json WAS passed, the function does nothing.