Skip to content

Commit

Permalink
[clc] password now computed+optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ack committed May 4, 2016
1 parent 5b7f12e commit 3a8cc2b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions builtin/providers/clc/resource_clc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ func resourceCLCServer() *schema.Resource {
Type: schema.TypeInt,
Required: true,
},
"password": &schema.Schema{
Type: schema.TypeString,
Required: true,
},
// optional
"description": &schema.Schema{
Type: schema.TypeString,
Expand Down Expand Up @@ -88,6 +84,12 @@ func resourceCLCServer() *schema.Resource {
},

// sorta computed
"password": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
Default: nil,
},
"private_ip_address": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -195,6 +197,12 @@ func resourceCLCServerRead(d *schema.ResourceData, meta interface{}) error {
d.Set("storage_type", s.Storagetype)
d.Set("created_date", s.ChangeInfo.CreatedDate)
d.Set("modified_date", s.ChangeInfo.ModifiedDate)

creds, err := client.Server.GetCredentials(d.Id())
if err != nil {
return err
}
d.Set("password", creds.Password)
return nil
}

Expand Down Expand Up @@ -231,8 +239,8 @@ func resourceCLCServerUpdate(d *schema.ResourceData, meta interface{}) error {
// updates are queue processed
if d.HasChange("password") {
d.SetPartial("password")
o, _ := d.GetChange("password")
old := o.(string)
creds, _ := client.Server.GetCredentials(id)
old := creds.Password
pass := d.Get("password").(string)
updates = append(updates, server.UpdateCredentials(old, pass))
}
Expand Down

0 comments on commit 3a8cc2b

Please sign in to comment.