Skip to content

Commit

Permalink
PLT-721: Fixed Day2 operations on tenant resource's
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM committed Oct 6, 2023
1 parent 26105b5 commit f4369a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 6 additions & 2 deletions spectrocloud/cluster_common_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ func setPackManifests(pack *models.V1PackValuesEntity, p map[string]interface{},

func updateProfiles(c *client.V1Client, d *schema.ResourceData) error {
log.Printf("Updating profiles")
var clusterContext string
if ct, ok := d.GetOk("context"); ok && c != nil {
clusterContext = ct.(string)
}
profiles, err := toAddonDeplProfiles(c, d)
if err != nil {
return err
Expand All @@ -153,7 +157,8 @@ func updateProfiles(c *client.V1Client, d *schema.ResourceData) error {
Profiles: profiles,
SpcApplySettings: settings,
}
if err := c.UpdateClusterProfileValues(d.Id(), body); err != nil {
clusterContext = d.Get("context").(string)
if err := c.UpdateClusterProfileValues(d.Id(), clusterContext, body); err != nil {

Check failure on line 161 in spectrocloud/cluster_common_profiles.go

View workflow job for this annotation

GitHub Actions / build-with-coverage

too many arguments in call to c.UpdateClusterProfileValues
return err
}

Expand All @@ -162,7 +167,6 @@ func updateProfiles(c *client.V1Client, d *schema.ResourceData) error {
}

ctx := context.Background()
clusterContext := d.Get("context").(string)
if err := waitForProfileDownload(ctx, c, clusterContext, d.Id(), d.Timeout(schema.TimeoutUpdate)); err != nil {
return err
}
Expand Down
13 changes: 11 additions & 2 deletions spectrocloud/resource_cluster_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
Expand Down Expand Up @@ -39,6 +40,13 @@ func resourceClusterImport() *schema.Resource {
Required: true,
ForceNew: true,
},
"context": {
Type: schema.TypeString,
Optional: true,
Default: "project",
ValidateFunc: validation.StringInSlice([]string{"", "project", "tenant"}, false),
Description: "The context of the cluster. Can be `project` or `tenant`. Default is `project`.",
},
"tags": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -103,7 +111,7 @@ func resourceCloudClusterImport(ctx context.Context, d *schema.ResourceData, m i
return diag.FromErr(err)
}
if profiles != nil {
if err := c.UpdateClusterProfileValues(uid, profiles); err != nil {
if err := c.UpdateClusterProfileValues(uid, ClusterContext, profiles); err != nil {

Check failure on line 114 in spectrocloud/resource_cluster_import.go

View workflow job for this annotation

GitHub Actions / build-with-coverage

too many arguments in call to c.UpdateClusterProfileValues
return diag.FromErr(err)
}
}
Expand Down Expand Up @@ -198,7 +206,8 @@ func resourceCloudClusterUpdate(_ context.Context, d *schema.ResourceData, m int
if err != nil {
return diag.FromErr(err)
}
err = c.UpdateClusterProfileValues(d.Id(), profiles)
ClusterContext := d.Get("context").(string)
err = c.UpdateClusterProfileValues(d.Id(), ClusterContext, profiles)

Check failure on line 210 in spectrocloud/resource_cluster_import.go

View workflow job for this annotation

GitHub Actions / build-with-coverage

too many arguments in call to c.UpdateClusterProfileValues
if err != nil {
return diag.FromErr(err)
}
Expand Down

0 comments on commit f4369a1

Please sign in to comment.