Skip to content

Commit

Permalink
Merge pull request #32 from OpenVPN/feature/CAPI-243-fix-host-crashing
Browse files Browse the repository at this point in the history
FIX: [TF] Data source "host" crashing Terraform provider
  • Loading branch information
sahaqaa authored Jul 30, 2024
2 parents b680fdc + a0c65ac commit 7db7c31
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 7db7c31

Please sign in to comment.