Skip to content

Commit

Permalink
feat: Add write_password to instance schema
Browse files Browse the repository at this point in the history
  • Loading branch information
uzaxirr committed Aug 13, 2024
1 parent 3c04140 commit cb5c153
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion civo/instances/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ func ResourceInstance() *schema.Resource {
Sensitive: true,
Description: "Initial password for login",
},
"write_password": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If set to true, initial_password for instance will be saved to terraform state file",
ValidateDiagFunc: utils.ValidateProviderVersion,
},
"private_ip": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -348,14 +355,19 @@ func resourceInstanceRead(_ context.Context, d *schema.ResourceData, m interface
return diag.Errorf("[ERR] failed to get the disk image: %s", err)
}

if d.Get("write_password").(bool) {
d.Set("initial_password", resp.InitialPassword)
} else {
d.Set("initial_password", "")
}

d.Set("hostname", resp.Hostname)
d.Set("reverse_dns", resp.ReverseDNS)
d.Set("size", resp.Size)
d.Set("cpu_cores", resp.CPUCores)
d.Set("ram_mb", resp.RAMMegabytes)
d.Set("disk_gb", resp.DiskGigabytes)
d.Set("initial_user", resp.InitialUser)
d.Set("initial_password", resp.InitialPassword)
d.Set("source_type", resp.SourceType)
d.Set("source_id", resp.SourceID)
d.Set("sshkey_id", resp.SSHKeyID)
Expand Down

0 comments on commit cb5c153

Please sign in to comment.