swarming

package
v0.0.0-...-fb8c843 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LabelMarshaler = jsonpb.Marshaler{
	EnumsAsInts:  false,
	EmitDefaults: true,
	Indent:       "  ",
	OrigName:     true,
}

LabelMarshaler contains the json marshaling params.

Functions

func ConstructJsonPaths

func ConstructJsonPaths(dutAttr *api.DutAttribute) ([]string, error)

ConstructJsonPaths returns config paths defined by a DutAttribute.

It takes a DutAttribute and returns an array of field paths defined in jsonpath syntax. The sources that are currently supported are:

  1. FlatConfigSource
  2. HwidSource

func GetLabelNames

func GetLabelNames(dutAttr *api.DutAttribute) ([]string, error)

GetLabelNames extracts all possible label names from a DutAttribute.

For each DutAttribute, the main label name is defined by its ID value. In addition, users can define other aliases. GetLabelNames will return all as valid label names. The first label is always the main label as defined by the ID value.

func GetLabelValues

func GetLabelValues(jsonGetPath string, pm proto.Message) ([]string, error)

GetLabelValues takes a path and returns the proto values.

It uses a jsonpath string to try to find corresponding values in a proto. It returns a string array of the values found.

func GetProtoExistence

func GetProtoExistence(jsonGetPath string, pm proto.Message) (bool, error)

GetProtoExistence takes a path and returns the whether the proto exists.

It uses a jsonpath string to try to find corresponding values in a proto. If the destination proto is not nil, then it exists and the method returns true.

func ParseLabelValuesToArray

func ParseLabelValuesToArray(labelVals interface{}) ([]string, error)

ParseLabelValuesToArray takes label values and returns a string array.

It takes an interface of label values parsed from a json object and returns a an array of the values casted to string. The interfaces supported are primitive types and iterable interfaces.

Types

type Dimensions

type Dimensions map[string][]string

Dimensions is the type for Swarming dimensions.

func CombineDims

func CombineDims(d1 Dimensions, d2 Dimensions) Dimensions

CombineDims takes two maps of dimensions and combines them.

CombineDims will overwrite the first map with the second map when a key collides. A Dimensions map is returned.

func ConvertAll

func ConvertAll(dutAttr *api.DutAttribute, flatConfig *payload.FlatConfig) (Dimensions, error)

ConvertAll converts one DutAttribute label to multiple Swarming labels.

The converted labels are returned in a map where keys are label names and values are string arrays of the label values. Label labelNames are the DutAttribute ID and the aliases listed.

func FormLabels

func FormLabels(labelNames []string, values []string) (Dimensions, error)

FormLabels pairs label names with the label values.

FormLabels takes each label name from labelNames as a key. The values of the label are stored as an array of string. FormLabels returns a key-value map.

Jump to

Keyboard shortcuts

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