本文整理汇总了Golang中github.com/juju/juju/state.Settings.Write方法的典型用法代码示例。如果您正苦于以下问题:Golang Settings.Write方法的具体用法?Golang Settings.Write怎么用?Golang Settings.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/state.Settings
的用法示例。
在下文中一共展示了Settings.Write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UpdateSettings
// UpdateSettings persists all changes made to the local settings of
// all given pairs of relation and unit. Keys with empty values are
// considered a signal to delete these values.
func (u *UniterAPIV3) UpdateSettings(args params.RelationUnitsSettings) (params.ErrorResults, error) {
result := params.ErrorResults{
Results: make([]params.ErrorResult, len(args.RelationUnits)),
}
canAccess, err := u.accessUnit()
if err != nil {
return params.ErrorResults{}, err
}
for i, arg := range args.RelationUnits {
unit, err := names.ParseUnitTag(arg.Unit)
if err != nil {
result.Results[i].Error = common.ServerError(common.ErrPerm)
continue
}
relUnit, err := u.getRelationUnit(canAccess, arg.Relation, unit)
if err == nil {
var settings *state.Settings
settings, err = relUnit.Settings()
if err == nil {
for k, v := range arg.Settings {
if v == "" {
settings.Delete(k)
} else {
settings.Set(k, v)
}
}
_, err = settings.Write()
}
}
result.Results[i].Error = common.ServerError(err)
}
return result, nil
}