launchpad.net/~rogpeppe/juju-core/500-errgo-fix@v0.0.0-20140213181702-000000002356/state/testing/config.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package testing
     5  
     6  import (
     7  	"launchpad.net/errgo/errors"
     8  	"launchpad.net/juju-core/state"
     9  )
    10  
    11  var mask = errors.Mask
    12  
    13  // UpdateConfig sets the current agent version in the state's
    14  // environment configuration.
    15  func UpdateConfig(st *state.State, newValues map[string]interface{}) error {
    16  	cfg, err := st.EnvironConfig()
    17  	if err != nil {
    18  		return mask(err)
    19  	}
    20  	newcfg, err := cfg.Apply(newValues)
    21  	if err != nil {
    22  		return mask(err)
    23  	}
    24  	return st.SetEnvironConfig(newcfg, cfg)
    25  }