Skip to content

Commit

Permalink
PLT-685: Fixing context for virtual cluster.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikchern committed Sep 14, 2023
1 parent b6ad60f commit 53d0491
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 17 deletions.
3 changes: 1 addition & 2 deletions spectrocloud/cluster_common_profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (
"github.com/spectrocloud/terraform-provider-spectrocloud/types"
)

func toProfiles(c *client.V1Client, d *schema.ResourceData) ([]*models.V1SpectroClusterProfileEntity, error) {
clusterContext := d.Get("context").(string)
func toProfiles(c *client.V1Client, d *schema.ResourceData, clusterContext string) ([]*models.V1SpectroClusterProfileEntity, error) {
return toProfilesCommon(c, d, d.Id(), clusterContext)
}

Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_aks.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ func toAksCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectro
}
}

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ func toAwsCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectro
// gnarly, I know! =/
cloudConfig := d.Get("cloud_config").([]interface{})[0].(map[string]interface{})

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ func toAzureCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spect
cloudConfig := d.Get("cloud_config").([]interface{})[0].(map[string]interface{})
//clientSecret := strfmt.Password(d.Get("azure_client_secret").(string))

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_coxedge.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,8 @@ func toCoxEdgeCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spe
}
}

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_edge_native.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ func toEdgeNativeCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1
}
}

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_edge_vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ func toEdgeVsphereCluster(c *client.V1Client, d *schema.ResourceData) (*models.V

vip := cloudConfig["vip"].(string)

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,8 @@ func toEksCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectro
}
}

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ func toGcpCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectro
cloudConfig := d.Get("cloud_config").([]interface{})[0].(map[string]interface{})
//clientSecret := strfmt.Password(d.Get("gcp_client_secret").(string))

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ func resourceCloudClusterUpdate(_ context.Context, d *schema.ResourceData, m int

func toCloudClusterProfiles(c *client.V1Client, d *schema.ResourceData) (*models.V1SpectroClusterProfiles, error) {
if profiles := d.Get("cluster_profile").([]interface{}); len(profiles) > 0 {
profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_libvirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,8 @@ func toLibvirtCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spe
return nil, err
}

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_maas.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ func toMaasCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectr
cloudConfig := d.Get("cloud_config").([]interface{})[0].(map[string]interface{})
DomainVal := cloudConfig["domain"].(string)

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ func toOpenStackCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1S

cloudConfig := d.Get("cloud_config").([]interface{})[0].(map[string]interface{})

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_tke.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ func toTkeCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spectro
sshKeyIds = append(sshKeyIds, cloudConfig["ssh_key_name"].(string))
}

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
9 changes: 8 additions & 1 deletion spectrocloud/resource_cluster_virtual.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ func resourceClusterVirtual() *schema.Resource {
Required: true,
ForceNew: true,
},
"context": {
Type: schema.TypeString,
Optional: true,
Default: "project",
ValidateFunc: validation.StringInSlice([]string{"project", "cluster"}, false),
},
"tags": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -368,7 +374,8 @@ func toVirtualCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spe
kubernetesVersion = cloudConfig["k8s_version"].(string)
}

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion spectrocloud/resource_cluster_vsphere.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,8 @@ func toVsphereCluster(c *client.V1Client, d *schema.ResourceData) (*models.V1Spe
cloudConfig := d.Get("cloud_config").([]interface{})[0].(map[string]interface{})
//clientSecret := strfmt.Password(d.Get("azure_client_secret").(string))

profiles, err := toProfiles(c, d)
clusterContext := d.Get("context").(string)
profiles, err := toProfiles(c, d, clusterContext)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 53d0491

Please sign in to comment.