func (m *mode) UnmarshalJSON(raw []byte) error {
	var str string
	if err := json.Unmarshal(raw, &str); err != nil {
		return controlError("failed to unmarshal mode: %v", err)
	}
	switch strings.ToLower(str) {
	case "disabled", "disable":
		*m = Disabled
	case "required", "mandatory":
		*m = Required
	case "optional":
		*m = Optional
	case "relaxed":
		*m = Relaxed
	default:
		return controlError("invalid mode %s", str)
	}
	return nil
}
UnmarshalJSON is the JSON unmarshaller for mode.
package control
import (
	"encoding/json"
	"fmt"
	"github.com/intel/cri-resource-manager/pkg/config"
	"strings"
)
type options struct {
	Controllers map[string]mode
}
var opt = defaultOptions().(*options)
type mode int
const (
	Disabled mode = iota
	Required
	Optional
	Relaxed
	Default = Relaxed
)
func (o *options) ControllerMode(name string) mode {
	if m, ok := o.Controllers[name]; ok {
		return m
	}
	return Default
}
func (o *options) configNotify(event config.Event, source config.Source) error {
	log.Info("configuration updated")
	for name, controller := range controllers {
		controller.mode = o.ControllerMode(name)
	}
	return nil
}
func (m mode) String() string {
	switch m {
	case Disabled:
		return "disabled"
	case Required:
		return "required"
	case Optional:
		return "optional"
	case Relaxed:
		return "relaxed"
	default:
		return fmt.Sprintf("<unknown mode %d>", m)
	}
}
func (m mode) MarshalJSON() ([]byte, error) {
	return json.Marshal(m.String())
}