Skip to content

Commit

Permalink
edits
Browse files Browse the repository at this point in the history
  • Loading branch information
skpratt committed Mar 21, 2024
1 parent 97ec08f commit 8fdc405
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
10 changes: 5 additions & 5 deletions consul/data_source_consul_config_entry_v2_exported_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ 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)
if err != nil || resp == nil {
if err != nil || resp == nil || resp["id"] == nil || resp["data"] == nil {
return fmt.Errorf("exported services config not found: %s", name)
}
respData, err := json.Marshal(resp["data"])
Expand All @@ -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
Expand Down
22 changes: 10 additions & 12 deletions consul/resource_consul_config_entry_v2_exported_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8fdc405

Please sign in to comment.