[clc] password now computed+optional
This commit is contained in:
parent
f310400e21
commit
eb4963a853
|
@ -44,10 +44,6 @@ func resourceCLCServer() *schema.Resource {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
"password": &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Required: true,
|
|
||||||
},
|
|
||||||
// optional
|
// optional
|
||||||
"description": &schema.Schema{
|
"description": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
@ -88,6 +84,12 @@ func resourceCLCServer() *schema.Resource {
|
||||||
},
|
},
|
||||||
|
|
||||||
// sorta computed
|
// sorta computed
|
||||||
|
"password": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
Default: nil,
|
||||||
|
},
|
||||||
"private_ip_address": &schema.Schema{
|
"private_ip_address": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
@ -195,6 +197,12 @@ func resourceCLCServerRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
d.Set("storage_type", s.Storagetype)
|
d.Set("storage_type", s.Storagetype)
|
||||||
d.Set("created_date", s.ChangeInfo.CreatedDate)
|
d.Set("created_date", s.ChangeInfo.CreatedDate)
|
||||||
d.Set("modified_date", s.ChangeInfo.ModifiedDate)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,8 +239,8 @@ func resourceCLCServerUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
// updates are queue processed
|
// updates are queue processed
|
||||||
if d.HasChange("password") {
|
if d.HasChange("password") {
|
||||||
d.SetPartial("password")
|
d.SetPartial("password")
|
||||||
o, _ := d.GetChange("password")
|
creds, _ := client.Server.GetCredentials(id)
|
||||||
old := o.(string)
|
old := creds.Password
|
||||||
pass := d.Get("password").(string)
|
pass := d.Get("password").(string)
|
||||||
updates = append(updates, server.UpdateCredentials(old, pass))
|
updates = append(updates, server.UpdateCredentials(old, pass))
|
||||||
}
|
}
|
||||||
|
@ -303,7 +311,7 @@ func resourceCLCServerUpdate(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Partial(false)
|
d.Partial(false)
|
||||||
return nil
|
return resourceCLCServerRead(d, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceCLCServerDelete(d *schema.ResourceData, meta interface{}) error {
|
func resourceCLCServerDelete(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
|
@ -46,6 +46,8 @@ func TestAccServerBasic(t *testing.T) {
|
||||||
"clc_server.acc_test_server", "cpu", "2"),
|
"clc_server.acc_test_server", "cpu", "2"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"clc_server.acc_test_server", "memory_mb", "2048"),
|
"clc_server.acc_test_server", "memory_mb", "2048"),
|
||||||
|
resource.TestCheckResourceAttr(
|
||||||
|
"clc_server.acc_test_server", "password", "Green123$"),
|
||||||
testAccCheckServerUpdatedSpec("clc_server.acc_test_server", &resp),
|
testAccCheckServerUpdatedSpec("clc_server.acc_test_server", &resp),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue