From c1a68b7d025b05f4d79a4deb3bdbb20d17264d67 Mon Sep 17 00:00:00 2001 From: skpratt Date: Thu, 21 Mar 2024 02:19:20 -0500 Subject: [PATCH] edits --- ...onsul_config_entry_v2_exported_services.go | 8 +++---- ...onsul_config_entry_v2_exported_services.go | 22 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/consul/data_source_consul_config_entry_v2_exported_services.go b/consul/data_source_consul_config_entry_v2_exported_services.go index af7706a0..4d0425cf 100644 --- a/consul/data_source_consul_config_entry_v2_exported_services.go +++ b/consul/data_source_consul_config_entry_v2_exported_services.go @@ -83,9 +83,9 @@ func dataSourceConsulV2ExportedServicesRead(d *schema.ResourceData, meta interfa client, qOpts, _ := getClient(d, meta) name := d.Get("name").(string) kind := d.Get("kind").(string) - gvk := &GVK{ //&api.GVK{ - Group: "multicluster", - Version: "v2", + gvk := &GVK{ + Group: pbmulticluster.GroupName, + Version: pbmulticluster.Version, Kind: kind, } resp, err := v2MulticlusterRead(client, gvk, name, qOpts) @@ -106,7 +106,7 @@ func dataSourceConsulV2ExportedServicesRead(d *schema.ResourceData, meta interfa } id := &pbresource.ID{} if err = protojson.Unmarshal(respID, id); err != nil { - return fmt.Errorf("Failed to unmarshal to proto message: %v", err) + return fmt.Errorf("failed to unmarshal to proto message: %v", err) } var partitions []string var peers []string diff --git a/consul/resource_consul_config_entry_v2_exported_services.go b/consul/resource_consul_config_entry_v2_exported_services.go index cc68ff45..2bb1bb19 100644 --- a/consul/resource_consul_config_entry_v2_exported_services.go +++ b/consul/resource_consul_config_entry_v2_exported_services.go @@ -102,16 +102,13 @@ func resourceConsulV2ExportedServicesUpdate(d *schema.ResourceData, meta interfa Kind: kind, } var consumers []map[string]any - peerConsumers := d.Get("peer_consumers").([]interface{}) - for _, p := range peerConsumers { + for _, p := range d.Get("peer_consumers").([]interface{}) { consumers = append(consumers, map[string]any{"peer": p}) } - partitionConsumers := d.Get("partition_consumers").([]interface{}) - for _, ap := range partitionConsumers { + for _, ap := range d.Get("partition_consumers").([]interface{}) { consumers = append(consumers, map[string]any{"partition": ap}) } - samenessConsumers := d.Get("sameness_group_consumers").([]interface{}) - for _, sg := range samenessConsumers { + for _, sg := range d.Get("sameness_group_consumers").([]interface{}) { consumers = append(consumers, map[string]any{"sameness_group": sg}) } data := map[string]any{"consumers": consumers} @@ -142,8 +139,8 @@ func resourceConsulV2ExportedServicesRead(d *schema.ResourceData, meta interface name := d.Get("name").(string) kind := d.Get("kind").(string) gvk := &GVK{ - Group: "multicluster", - Version: "v2", + Group: pbmulticluster.GroupName, + Version: pbmulticluster.Version, Kind: kind, } resp, err := v2MulticlusterRead(client, gvk, name, qOpts) @@ -164,7 +161,7 @@ func resourceConsulV2ExportedServicesRead(d *schema.ResourceData, meta interface } id := &pbresource.ID{} if err = protojson.Unmarshal(respID, id); err != nil { - return fmt.Errorf("Failed to unmarshal to proto message: %v", err) + return fmt.Errorf("failed to unmarshal to proto message: %v", err) } var partitions []string var peers []string @@ -195,10 +192,11 @@ func resourceConsulV2ExportedServicesRead(d *schema.ResourceData, meta interface func resourceConsulV2ExportedServicesDelete(d *schema.ResourceData, meta interface{}) error { client, qOpts, _ := getClient(d, meta) + kind := d.Get("kind").(string) gvk := &GVK{ - Group: "multicluster", - Version: "v2", - Kind: "ExportedServices", + Group: pbmulticluster.GroupName, + Version: pbmulticluster.Version, + Kind: kind, } name := d.Get("name").(string) return v2MulticlusterDelete(client, gvk, name, qOpts)