heuristics

package
v0.0.0-...-9febfc8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HwSwarmingBotIDPrefixes = []string{"crossk-", "cros-"}

HwSwarmingBotIDPrefixes includes all possible prefix for bots for DUTs

View Source
var LooksLikeFieldMask = regexp.MustCompile(`\A[a-z][A-Za-z0-9\.]*\z`).MatchString

LooksLikeFieldMask checks whether a given string looks like a field mask.

View Source
var LooksLikeValidPool = regexp.MustCompile(`\A[A-Za-z_][-A-Za-z0-9_]*\z`).MatchString

looksLikeValidPool heuristically checks a string to see if it looks like a valid pool. A heuristically valid pool name contains only a-z, A-Z, 0-9, -, and _ . A pool name cannot begin with - and 0-9 .

Functions

func LooksLikeHeader

func LooksLikeHeader(rec []string) bool

LooksLikeHeader heuristically determines whether a CSV line looks like a CSV header for the MCSV format.

func LooksLikeLabstation

func LooksLikeLabstation(hostname string) bool

LooksLikeLabstation returns whether a hostname or botID appears to be a labstation or not. This function exists so that we always use the same heuristic everywhere when identifying labstations.

func LooksLikeSatlabDevice

func LooksLikeSatlabDevice(hostname string) bool

LooksLikeSatlabDevice returns whether a hostname or botID appears to be a satlab-managed device. This function exists so that we use the same heuristic everywhere when identifying satlab devices.

func LooksLikeSatlabRemoteAccessContainer

func LooksLikeSatlabRemoteAccessContainer() (bool, error)

LooksLikeSatlabRemoteAccessContainer determines whether the container we are running on looks like a satlab remote access container.

func NormalizeBotNameToDeviceName

func NormalizeBotNameToDeviceName(hostname string) string

NormalizeBotNameToDeviceName takes a bot name or a DUT name and normalizes it to a DUT name. The prefix "crossk-" or "cros-" is suspicious and should be removed. The suffix ".cros" is also suspicious and should be removed.

func NormalizeServoNameToDeviceName

func NormalizeServoNameToDeviceName(servo string) string

NormalizeServoNameToDeviceName converts a servo name (ending in "-servo") to a device name by stripping the "-servo" suffix, which is a longstanding convention.

func NormalizeTextualData

func NormalizeTextualData(data string) string

NormalizeTextualData lowercases data and removes leading and trailing whitespace.

func ParseUsingCommand

func ParseUsingCommand(c *subcommands.Command, args []string, validate func(subcommands.CommandRun) error) (*flag.FlagSet, error)

ParseUsingCommand is a test helper for subcommands.

func TruncateErrorString

func TruncateErrorString(msg string) string

TruncateErrorString truncates a string to 1400 characters, a number that can safely be stored in both datastore and bigquery. Returns the truncated string.

Types

type TaskType

type TaskType int

TaskType is the high level type of a task such as repair or audit. It indicates what implementation (legacy or paris) and what level of stability (prod vs canary) should be used.

const (
	// ProdTaskType refers to the paris task on the prod cipd label.
	ProdTaskType TaskType = 100
	// LatestTaskType refers to the paris task on the latest cipd label.
	LatestTaskType TaskType = 200
)

Jump to

Keyboard shortcuts

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