blob: fd99b307b1615bd24987a3edde2fd2f969ee01a0 [file] [log] [blame]
// Copyright 2018 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package swmbot
import (
// LocalDUTState contains persistent DUT information that is cached on the
// Skylab drone.
type LocalDUTState struct {
HostState dutstate.State `json:"-"`
ProvisionableLabels ProvisionableLabels `json:"provisionable_labels"`
ProvisionableAttributes ProvisionableAttributes `json:"provisionable_attributes"`
// ProvisionableLabels stores provisionable labels for a DUT.
type ProvisionableLabels map[string]string
// ProvisionableAttributes stores provisionable attributes for a DUT.
type ProvisionableAttributes map[string]string
// Marshal returns the encoding of the LocalDUTState.
func Marshal(lds *LocalDUTState) ([]byte, error) {
return json.Marshal(lds)
// Unmarshal decodes LocalDUTState from the encoded data.
func Unmarshal(data []byte, lds *LocalDUTState) error {
if err := json.Unmarshal(data, lds); err != nil {
return err
if lds.ProvisionableLabels == nil {
lds.ProvisionableLabels = make(map[string]string)
if lds.ProvisionableAttributes == nil {
lds.ProvisionableAttributes = make(map[string]string)
return nil