From fd7733a8b707cc7eb399d014b26c576fe2fa8237 Mon Sep 17 00:00:00 2001 From: michaelfmnk Date: Tue, 30 Jul 2024 11:56:51 +0200 Subject: [PATCH] fixed connector datasource --- cloudconnexa/data_source_connector.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cloudconnexa/data_source_connector.go b/cloudconnexa/data_source_connector.go index 717faaa..aef6612 100644 --- a/cloudconnexa/data_source_connector.go +++ b/cloudconnexa/data_source_connector.go @@ -63,10 +63,15 @@ func dataSourceConnector() *schema.Resource { func dataSourceConnectorRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { c := m.(*cloudconnexa.Client) var diags diag.Diagnostics - connector, err := c.Connectors.GetByName(d.Get("name").(string)) + name := d.Get("name").(string) + connector, err := c.Connectors.GetByName(name) if err != nil { return append(diags, diag.FromErr(err)...) } + if connector == nil { + return append(diags, diag.Errorf("Connector with name %s was not found", name)...) + } + d.SetId(connector.Id) d.Set("name", connector.Name) d.Set("description", connector.Description)