Skip to content

Commit

Permalink
fix: Updating schema definition as per comment
Browse files Browse the repository at this point in the history
  • Loading branch information
srushti-patl committed Sep 17, 2024
1 parent 7090b64 commit 0fa0ca5
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 73 deletions.
10 changes: 2 additions & 8 deletions internal/fabric/testing_helpers/env_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ import (
)

const (
FabricDedicatedPortEnvVar = "TF_ACC_FABRIC_DEDICATED_PORTS"
)

const (
FabricDedicatedPortEnvVar = "TF_ACC_FABRIC_DEDICATED_PORTS"
FabricConnectionsTestDataEnvVar = "TF_ACC_FABRIC_CONNECTIONS_TEST_DATA"
)

const (
FabricSubscriptionEnvVar = "TF_ACC_FABRIC_MARKET_PLACE_SUBSCRIPTION_ID"
FabricSubscriptionEnvVar = "TF_ACC_FABRIC_MARKET_PLACE_SUBSCRIPTION_ID"
)

type EnvPorts map[string]map[string][]fabricv4.PortResponse
Expand Down
118 changes: 59 additions & 59 deletions internal/resources/fabric/marketplace/datasources_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,87 +40,87 @@ func fabricMarketplaceSubscriptionDataSourceSchema() map[string]*schema.Schema {
Type: schema.TypeSet,
Computed: true,
Description: "Subscription Trial",
Elem: &schema.Resource{
Schema: marketplaceSubscriptionTrialSch(),
},
Elem: marketplaceSubscriptionTrialSch(),
},
"entitlements": {
Type: schema.TypeList,
Computed: true,
Description: "Subscription entitlements",
Elem: &schema.Resource{
Schema: marketplaceSubscriptionEntitlementsSch(),
},
Elem: marketplaceSubscriptionEntitlementsSch(),
},
}
}

func marketplaceSubscriptionTrialSch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "Marketplace Subscription Trial Enabled",
func marketplaceSubscriptionTrialSch() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "Marketplace Subscription Trial Enabled",
},
},
}
}

func marketplaceSubscriptionEntitlementsSch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"uuid": {
Type: schema.TypeString,
Computed: true,
Description: "Subscription Entitlement Id",
},
"quantity_entitled": {
Type: schema.TypeInt,
Computed: true,
Description: "Entitled Quantity",
},
"quantity_consumed": {
Type: schema.TypeInt,
Computed: true,
Description: "Consumed Quantity",
},
"quantity_available": {
Type: schema.TypeInt,
Computed: true,
Description: "Available Quantity",
},
"asset": {
Type: schema.TypeSet,
Computed: true,
Description: "Asset information",
Elem: &schema.Resource{
Schema: marketplaceSubscriptionAssetSch(),
func marketplaceSubscriptionEntitlementsSch() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"uuid": {
Type: schema.TypeString,
Computed: true,
Description: "Subscription Entitlement Id",
},
"quantity_entitled": {
Type: schema.TypeInt,
Computed: true,
Description: "Entitled Quantity",
},
"quantity_consumed": {
Type: schema.TypeInt,
Computed: true,
Description: "Consumed Quantity",
},
"quantity_available": {
Type: schema.TypeInt,
Computed: true,
Description: "Available Quantity",
},
"asset": {
Type: schema.TypeSet,
Computed: true,
Description: "Asset information",
Elem: marketplaceSubscriptionAssetSch(),
},
},
}
}

func marketplaceSubscriptionAssetSch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Computed: true,
Description: "Defines the FCR type like; XF_ROUTER",
},
"package": {
Type: schema.TypeSet,
Computed: true,
Description: "Fabric Cloud Router Package Type",
Elem: &schema.Resource{
Schema: marketplaceSubscriptionPackageSch(),
func marketplaceSubscriptionAssetSch() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Computed: true,
Description: "Defines the FCR type like; XF_ROUTER",
},
"package": {
Type: schema.TypeSet,
Computed: true,
Description: "Fabric Cloud Router Package Type",
Elem: marketplaceSubscriptionPackageSch(),
},
},
}
}
func marketplaceSubscriptionPackageSch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"code": {
Type: schema.TypeString,
Computed: true,
Description: "Cloud Router package code",
func marketplaceSubscriptionPackageSch() *schema.Resource {
return &schema.Resource{
Schema: map[string]*schema.Schema{
"code": {
Type: schema.TypeString,
Computed: true,
Description: "Cloud Router package code",
},
},
}
}
9 changes: 3 additions & 6 deletions internal/resources/fabric/marketplace/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ func subscriptionTrialGoToTerraform(trial *fabricv4.SubscriptionTrial) *schema.S
mappedTrial := make(map[string]interface{})
mappedTrial["enabled"] = trial.GetEnabled()
trialSet := schema.NewSet(
schema.HashResource(&schema.Resource{
Schema: marketplaceSubscriptionTrialSch()}),
schema.HashResource(marketplaceSubscriptionTrialSch()),
[]interface{}{mappedTrial},
)
return trialSet
Expand Down Expand Up @@ -76,8 +75,7 @@ func subscriptionAssetGoToTerraform(asset *fabricv4.SubscriptionAsset) *schema.S
package_ := asset.GetPackage()
mappedAsset["package"] = subscriptionPackageGoToTerraform(&package_)
assetSet := schema.NewSet(
schema.HashResource(&schema.Resource{
Schema: marketplaceSubscriptionAssetSch()}),
schema.HashResource(marketplaceSubscriptionAssetSch()),
[]interface{}{mappedAsset},
)
return assetSet
Expand All @@ -90,8 +88,7 @@ func subscriptionPackageGoToTerraform(package_ *fabricv4.SubscriptionRouterPacka
mappedPackage := make(map[string]interface{})
mappedPackage["code"] = string(package_.GetCode())
packageSet := schema.NewSet(
schema.HashResource(&schema.Resource{
Schema: marketplaceSubscriptionPackageSch()}),
schema.HashResource(marketplaceSubscriptionPackageSch()),
[]interface{}{mappedPackage},
)
return packageSet
Expand Down

0 comments on commit 0fa0ca5

Please sign in to comment.