-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adding Marketplace Subscription capability to Fabric Cloud Router Resource #762
Conversation
srushti-patl
commented
Aug 27, 2024
- Added marketplace_subscription schema to fabric_cloud_router resource
- Marked 'account' schema as optional and computed because this parameter is optional while creating Fabric Cloud Router using Marketplace Subscription id.
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #762 +/- ##
==========================================
+ Coverage 34.38% 34.43% +0.04%
==========================================
Files 154 154
Lines 21080 21116 +36
==========================================
+ Hits 7249 7271 +22
- Misses 13670 13686 +16
+ Partials 161 159 -2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR also needs the document changes to the schema for the cloud router resource. We should also update the Cloud Router data source schemas for the same changes to allow users to grab that data as well.
We should merge Charles' docs PR first
@@ -273,6 +313,10 @@ func resourceFabricCloudRouterCreate(ctx context.Context, d *schema.ResourceData | |||
package_ := packageCloudRouterTerraformToGo(schemaPackage) | |||
createCloudRouterRequest.SetPackage(package_) | |||
|
|||
schemaMarketplaceSubscription := d.Get("marketplace_subscription").(*schema.Set).List() | |||
marketplaceSubscription := marketplaceSubscriptionCloudRouterTerraformToGo(schemaMarketplaceSubscription) | |||
createCloudRouterRequest.SetMarketplaceSubscription(marketplaceSubscription) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should only set the subscription if the value is provided. Do a reflect deep equal check on empty return struct to avoid empty value in JSON request body.
} | ||
marketplaceSubscription := fabricv4.MarketplaceSubscription{} | ||
marketplaceSubscriptionMap := marketplaceSubscriptionTerraform[0].(map[string]interface{}) | ||
subscriptionUUID := marketplaceSubscriptionMap["uuid"].(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You added type as Optional/Computed but you aren't accounting for type as an input here. Additionally, do empty string checks before setting, and use setters instead of direct assignment on attributes.
return map[string]*schema.Schema{ | ||
"type": { | ||
Type: schema.TypeString, | ||
Computed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double checking, you can send type and uuid in the request AND they will be returned in the response if not provided, correct? We need to be spot on with attribute behaviors to prepare for terraform-plugin-framework migration when we move to tf-plugin-protocol v6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we can send type and UUID in the request.
UUID is required parameter in marketplacesubscription filed. I have marked it as required in schema definition.
we will get the type in response if it's not provided.
"account": { | ||
Type: schema.TypeSet, | ||
Required: true, | ||
Optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question about account. I believe this is correct but double checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
account number is required in the account filed and I have marked it as required in schema definition.
…rketplace subscription
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last changes requested. Other than that it looks good.
@@ -0,0 +1,29 @@ | |||
--- | |||
# generated by https://github.com/hashicorp/terraform-plugin-docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Unnecessary change. You can remove lines 2, 3, 5, and 6. They aren't being added by the default implementation and aren't needed.
## Example Usage | ||
|
||
Fabric Cloud Router | ||
{{tffile "examples/resources/equinix_fabric_cloud_router/example_1.tf"}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I don't know how the resources/fabric_cloud_router.md
got updated correctly based on how you've oriented the examples in this template. The Code shows that example_1.tf is for the marketplace subscription and example_2.tf
is for the standard cloud router. Could you run this again and see if it shows a diff? I think there's a disconnect here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I will rename example files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Ship it