Skip to content

Commit

Permalink
Use whitelist when adding clouds.
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiamac committed Aug 20, 2019
1 parent 6d5e31a commit 41f13d2
Show file tree
Hide file tree
Showing 14 changed files with 420 additions and 151 deletions.
8 changes: 7 additions & 1 deletion api/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,21 @@ func (c *Client) AddCredential(tag string, credential jujucloud.Credential) erro
}

// AddCloud adds a new cloud to current controller.
func (c *Client) AddCloud(cloud jujucloud.Cloud) error {
func (c *Client) AddCloud(cloud jujucloud.Cloud, force bool) error {
bestVer := c.BestAPIVersion()
if bestVer < 2 {
return errors.NotImplementedf("AddCloud() (need v2+, have v%d)", bestVer)
}
if bestVer < 6 && force {
return errors.NotImplementedf("AddCloud() with force (need v6+, have v%d)", bestVer)
}
if (len(cloud.Config) > 0 || len(cloud.RegionConfig) > 0) && bestVer < 5 {
return errors.New("adding a cloud with config parameters is not supported by this version of Juju")
}
args := params.AddCloudArgs{Name: cloud.Name, Cloud: common.CloudToParams(cloud)}
if force {
args.Force = &force
}
err := c.facade.FacadeCall("AddCloud", args, nil)
if err != nil {
return errors.Trace(err)
Expand Down
Loading

0 comments on commit 41f13d2

Please sign in to comment.