github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/state/controller.go (about)

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package state
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/juju/errors"
    10  
    11  	jujucontroller "github.com/juju/juju/controller"
    12  )
    13  
    14  const (
    15  	// controllerSettingsGlobalKey is the key for the controller and its settings.
    16  	controllerSettingsGlobalKey = "controllerSettings"
    17  
    18  	// controllerGlobalKey is the key for controller.
    19  	controllerGlobalKey = "c"
    20  )
    21  
    22  // controllerKey will return the key for a given controller using the
    23  // controller uuid and the controllerGlobalKey.
    24  func controllerKey(controllerUUID string) string {
    25  	return fmt.Sprintf("%s#%s", controllerGlobalKey, controllerUUID)
    26  }
    27  
    28  // ControllerConfig returns the config values for the controller.
    29  func (st *State) ControllerConfig() (jujucontroller.Config, error) {
    30  	settings, err := readSettings(st, controllersC, controllerSettingsGlobalKey)
    31  	if err != nil {
    32  		return nil, errors.Trace(err)
    33  	}
    34  	return settings.Map(), nil
    35  }