From e552730e4207a4a77877d2cc788b44d2f9d0ab79 Mon Sep 17 00:00:00 2001 From: FalcoSuessgott Date: Tue, 13 Feb 2024 11:13:33 +0100 Subject: [PATCH] error if server profile template cannot be found --- oneview/data_source_server_profile_template.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/oneview/data_source_server_profile_template.go b/oneview/data_source_server_profile_template.go index f27f0164..f7c09d5a 100644 --- a/oneview/data_source_server_profile_template.go +++ b/oneview/data_source_server_profile_template.go @@ -12,6 +12,7 @@ package oneview import ( + "fmt" "log" "reflect" @@ -1068,14 +1069,10 @@ func dataSourceServerProfileTemplateRead(d *schema.ResourceData, meta interface{ name := d.Get("name").(string) spt, err := config.ovClient.GetProfileTemplateByName(name) - - if err != nil { - d.SetId("") - return err - } else if spt.URI.IsNil() { - d.SetId("") - return nil + if err != nil || spt.URI.IsNil() { + return fmt.Errorf("error fetching server profile template: %w", err) } + d.Set("affinity", spt.Affinity) d.Set("category", spt.Category) d.Set("created", spt.Created)