Skip to content

Commit

Permalink
fix: hard code tenant scope for PCG IP pools
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gillson <[email protected]>
  • Loading branch information
TylerGillson committed Sep 13, 2024
1 parent 4b23c2a commit 13541e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
1 change: 0 additions & 1 deletion docs/resources/privatecloudgateway_ippool.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ The following example is for creating an IP pool that belongs to a Private Cloud

### Optional

- `context` (String) Specifies cluster context where IP Pool is created. Allowed values are `project` or `tenant`. Defaults to `project`. If the `project` context is specified, the project name will sourced from the provider configuration parameter [`project_name`](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs#schema).
- `ip_end_range` (String) The end IP address of the IP pool. Required if `network_type` is `range`.
- `ip_start_range` (String) The start IP address of the IP pool. Required if `network_type` is `range`.
- `nameserver_addresses` (Set of String) The list of nameserver IP addresses for the IP pool.
Expand Down
21 changes: 4 additions & 17 deletions spectrocloud/resource_pcg_ippool.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

"github.com/spectrocloud/palette-sdk-go/api/models"
)
Expand All @@ -30,14 +29,6 @@ func resourcePrivateCloudGatewayIpPool() *schema.Resource {

SchemaVersion: 2,
Schema: map[string]*schema.Schema{
"context": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"project", "tenant"}, false),
Default: "project",
Description: "Specifies cluster context where IP Pool is created. " +
"Allowed values are `project` or `tenant`. Defaults to `project`. " + PROJECT_NAME_NUANCE,
},
"name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -110,8 +101,7 @@ func resourcePrivateCloudGatewayIpPool() *schema.Resource {
}

func resourceIpPoolCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
resourceContext := d.Get("context").(string)
c := getV1ClientWithResourceContext(m, resourceContext)
c := getV1ClientWithResourceContext(m, "tenant")
var diags diag.Diagnostics
pcgUID := d.Get("private_cloud_gateway_id").(string)

Expand All @@ -127,8 +117,7 @@ func resourceIpPoolCreate(ctx context.Context, d *schema.ResourceData, m interfa
}

func resourceIpPoolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
resourceContext := d.Get("context").(string)
c := getV1ClientWithResourceContext(m, resourceContext)
c := getV1ClientWithResourceContext(m, "tenant")
var diags diag.Diagnostics

pcgUID := d.Get("private_cloud_gateway_id").(string)
Expand Down Expand Up @@ -182,8 +171,7 @@ func resourceIpPoolRead(ctx context.Context, d *schema.ResourceData, m interface
}

func resourceIpPoolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
resourceContext := d.Get("context").(string)
c := getV1ClientWithResourceContext(m, resourceContext)
c := getV1ClientWithResourceContext(m, "tenant")
var diags diag.Diagnostics

pcgUID := d.Get("private_cloud_gateway_id").(string)
Expand All @@ -199,8 +187,7 @@ func resourceIpPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfa
}

func resourceIpPoolDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
resourceContext := d.Get("context").(string)
c := getV1ClientWithResourceContext(m, resourceContext)
c := getV1ClientWithResourceContext(m, "tenant")
var diags diag.Diagnostics

pcgUID := d.Get("private_cloud_gateway_id").(string)
Expand Down

0 comments on commit 13541e6

Please sign in to comment.