Skip to content

Commit

Permalink
Fix read for data_source_network_routes (#98)
Browse files Browse the repository at this point in the history
* Fix read for data_source_network_routes

* Fix read for data_source_network_routes

* Update version

* Check for an empty ID

---------

Co-authored-by: vladhanzha <[email protected]>
  • Loading branch information
vladhss and vladhanzha authored Feb 27, 2025
1 parent 66c28a4 commit 790c4c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions cloudconnexa/data_source_network_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func dataSourceNetworkRoutes() *schema.Resource {
"type": {
Type: schema.TypeString,
Computed: true,
Description: "The type of route. Valid values are `IP_V4`, `IP_V6`, and others.",
Description: "The type of route. Valid values are `IP_V4`, `IP_V6`.",
},
"subnet": {
Type: schema.TypeString,
Expand All @@ -56,14 +56,17 @@ func dataSourceNetworkRoutesRead(ctx context.Context, d *schema.ResourceData, m
c := m.(*cloudconnexa.Client)
var diags diag.Diagnostics

networkId := d.Get("network_item_id").(string)
routes, err := c.Routes.List(networkId)
networkId := d.Get("id").(string)
if networkId == "" {
return append(diags, diag.Errorf("ID cannot be empty")...)
}
network, err := c.Networks.Get(networkId)
if err != nil {
return append(diags, diag.FromErr(err)...)
}

configRoutes := make([]map[string]interface{}, len(routes))
for i, r := range routes {
configRoutes := make([]map[string]interface{}, len(network.Routes))
for i, r := range network.Routes {
route := make(map[string]interface{})
route["id"] = r.ID
route["type"] = r.Type
Expand Down
2 changes: 1 addition & 1 deletion cloudconnexa/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
)

var (
version = "v1.0.1"
version = "v1.0.2"
)

type Token struct {
Expand Down

0 comments on commit 790c4c1

Please sign in to comment.