Documentation
¶
Index ¶
- Variables
- func ConstructJsonPaths(dutAttr *api.DutAttribute) ([]string, error)
- func GetLabelNames(dutAttr *api.DutAttribute) ([]string, error)
- func GetLabelValues(jsonGetPath string, pm proto.Message) ([]string, error)
- func GetProtoExistence(jsonGetPath string, pm proto.Message) (bool, error)
- func ParseLabelValuesToArray(labelVals interface{}) ([]string, error)
- type Dimensions
Constants ¶
This section is empty.
Variables ¶
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:
- FlatConfigSource
- 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 ¶
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 ¶
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 ¶
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 ¶
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.