本文整理匯總了Golang中github.com/juju/juju/apiserver/params.ModelConfigResults類的典型用法代碼示例。如果您正苦於以下問題:Golang ModelConfigResults類的具體用法?Golang ModelConfigResults怎麽用?Golang ModelConfigResults使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ModelConfigResults類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ModelGet
// 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
}
示例2: ModelGet
// 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
}
示例3: ModelConfig
// 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
}
示例4: ModelConfig
// 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
}