Skip to content

Commit

Permalink
FIX: [TF] Data source "host" crashing Terraform provider
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfmnk authored and sahaqaa committed Jul 30, 2024
1 parent b680fdc commit a0c65ac
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cloudconnexa/data_source_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,15 @@ func dataSourceHost() *schema.Resource {
func dataSourceHostRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
c := m.(*cloudconnexa.Client)
var diags diag.Diagnostics
host, err := c.Hosts.GetByName(d.Get("name").(string))
name := d.Get("name").(string)
host, err := c.Hosts.GetByName(name)
if err != nil {
return append(diags, diag.FromErr(err)...)
}
if host == nil {
return append(diags, diag.Errorf("Host with name %s was not found", name)...)
}

d.SetId(host.Id)
d.Set("name", host.Name)
d.Set("description", host.Description)
Expand Down

0 comments on commit a0c65ac

Please sign in to comment.