Skip to content

Commit

Permalink
Fix duplicate CIDR error in cluster creating (#70)
Browse files Browse the repository at this point in the history
* Fix duplicate CIDR error in cluster creating

* Fix #70 (comment)

---------

Co-authored-by: shi yuhang <[email protected]>
  • Loading branch information
sgykfjsm and shiyuhang0 authored Aug 28, 2023
1 parent f435b99 commit 5ebaa8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions internal/provider/cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package provider
import (
"context"
"fmt"
"strings"

clusterApi "github.com/c4pt0r/go-tidbcloud-sdk-v1/client/cluster"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand All @@ -13,7 +15,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"strings"
)

const dev = "DEVELOPER"
Expand Down Expand Up @@ -468,8 +469,9 @@ func buildCreateClusterBody(data clusterResourceData) clusterApi.CreateClusterBo
if data.Config.IPAccessList != nil {
var IPAccessList []*clusterApi.CreateClusterParamsBodyConfigIPAccessListItems0
for _, key := range data.Config.IPAccessList {
cidr := key.CIDR
IPAccessList = append(IPAccessList, &clusterApi.CreateClusterParamsBodyConfigIPAccessListItems0{
Cidr: &key.CIDR,
Cidr: &cidr,
Description: key.Description,
})
}
Expand Down
4 changes: 3 additions & 1 deletion internal/provider/restore_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package provider
import (
"context"
"fmt"

restoreApi "github.com/c4pt0r/go-tidbcloud-sdk-v1/client/restore"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down Expand Up @@ -319,8 +320,9 @@ func buildCreateRestoreTaskBody(data restoreResourceData) restoreApi.CreateResto
if data.Config.IPAccessList != nil {
var IPAccessList []*restoreApi.CreateRestoreTaskParamsBodyConfigIPAccessListItems0
for _, key := range data.Config.IPAccessList {
cidr := key.CIDR
IPAccessList = append(IPAccessList, &restoreApi.CreateRestoreTaskParamsBodyConfigIPAccessListItems0{
Cidr: &key.CIDR,
Cidr: &cidr,
Description: key.Description,
})
}
Expand Down

0 comments on commit 5ebaa8c

Please sign in to comment.