135
135
type SetCharmConfig struct {
136
136
// ApplicationName is the name of the application to set the charm on.
137
137
ApplicationName string
138
139
// CharmID identifies the charm.
139
140
CharmID charmstore.CharmID
142
// ConfigSettings is the charm settings to set during the upgrade.
143
// This field is only understood by Application facade version 2
145
ConfigSettings map[string]string `json:"config-settings,omitempty"`
147
// ConfigSettingsYAML is the charm settings in YAML format to set
148
// during the upgrade. If this is non-empty, it will take precedence
149
// over ConfigSettings. This field is only understood by Application
151
ConfigSettingsYAML string `json:"config-settings-yaml,omitempty"`
140
153
// ForceSeries forces the use of the charm even if it doesn't match the
141
154
// series of the unit.
143
157
// ForceUnits forces the upgrade on units in an error state.
145
160
// ResourceIDs is a map of resource names to resource IDs to activate during
147
162
ResourceIDs map[string]string
164
// StorageConstraints is a map of storage names to storage constraints to
165
// update during the upgrade. This field is only understood by Application
166
// facade version 2 and greater.
167
StorageConstraints map[string]storage.Constraints `json:"storage-constraints,omitempty"`
150
170
// SetCharm sets the charm for a given service.
151
171
func (c *Client) SetCharm(cfg SetCharmConfig) error {
172
var storageConstraints map[string]params.StorageConstraints
173
if len(cfg.StorageConstraints) > 0 {
174
storageConstraints = make(map[string]params.StorageConstraints)
175
for name, cons := range cfg.StorageConstraints {
176
size, count := cons.Size, cons.Count
177
var sizePtr, countPtr *uint64
184
storageConstraints[name] = params.StorageConstraints{
152
191
args := params.ApplicationSetCharm{
153
ApplicationName: cfg.ApplicationName,
154
CharmUrl: cfg.CharmID.URL.String(),
155
Channel: string(cfg.CharmID.Channel),
156
ForceSeries: cfg.ForceSeries,
157
ForceUnits: cfg.ForceUnits,
158
ResourceIDs: cfg.ResourceIDs,
192
ApplicationName: cfg.ApplicationName,
193
CharmUrl: cfg.CharmID.URL.String(),
194
Channel: string(cfg.CharmID.Channel),
195
ConfigSettings: cfg.ConfigSettings,
196
ConfigSettingsYAML: cfg.ConfigSettingsYAML,
197
ForceSeries: cfg.ForceSeries,
198
ForceUnits: cfg.ForceUnits,
199
ResourceIDs: cfg.ResourceIDs,
200
StorageConstraints: storageConstraints,
160
202
return c.facade.FacadeCall("SetCharm", args, nil)