// ModelGet implements the server-side part of the // model-config CLI command. func (c *ModelConfigAPI) ModelGet() (params.ModelConfigResults, error) { result := params.ModelConfigResults{} if err := c.checkCanWrite(); err != nil { return result, errors.Trace(err) } values, err := c.backend.ModelConfigValues() if err != nil { return result, errors.Trace(err) } result.Config = make(map[string]params.ConfigValue) for attr, val := range values { // Authorized keys are able to be listed using // juju ssh-keys and including them here just // clutters everything. if attr == config.AuthorizedKeysKey { continue } result.Config[attr] = params.ConfigValue{ Value: val.Value, Source: val.Source, } } return result, nil }
// ModelGet implements the server-side part of the // get-model-config CLI command. func (c *Client) ModelGet() (params.ModelConfigResults, error) { result := params.ModelConfigResults{} // Get the existing environment config from the state. config, err := c.api.stateAccessor.ModelConfig() if err != nil { return result, err } result.Config = config.AllAttrs() return result, nil }
// ModelConfig returns the environment config for the controller // environment. For information on the current environment, use // client.ModelGet func (s *ControllerAPI) ModelConfig() (params.ModelConfigResults, error) { result := params.ModelConfigResults{} controllerEnv, err := s.state.ControllerModel() if err != nil { return result, errors.Trace(err) } config, err := controllerEnv.Config() if err != nil { return result, errors.Trace(err) } result.Config = config.AllAttrs() return result, nil }
// ModelConfig returns the environment config for the controller // environment. For information on the current environment, use // client.ModelGet func (s *ControllerAPI) ModelConfig() (params.ModelConfigResults, error) { result := params.ModelConfigResults{} if err := s.checkHasAdmin(); err != nil { return result, errors.Trace(err) } controllerModel, err := s.state.ControllerModel() if err != nil { return result, errors.Trace(err) } cfg, err := controllerModel.Config() if err != nil { return result, errors.Trace(err) } result.Config = make(map[string]params.ConfigValue) for name, val := range cfg.AllAttrs() { result.Config[name] = params.ConfigValue{ Value: val, } } return result, nil }