Skip to content
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

Add PhysicalAddress and CapabilitiesManagedBySatellite to Terraform SatelliteLocation for both resource and data-source #5530

Merged
merged 47 commits into from
Aug 2, 2024

Conversation

FishAndFrog
Copy link
Contributor

@FishAndFrog FishAndFrog commented Jul 25, 2024

PhysicalAddress and CapabilitiesManagedBySatellite have been added as new parameters to SatelliteLocationAPIs already. Here, Address has been added to Create and Get APIs, whereas Capabilities has been added to Create, Get and List APIs.
I would like to submit this Pull-Request, in order to extend Address and Capabilities in the resource and data-source methods of Terraform-Provider-IBM for Satellite-Location Create and Get.


Output from acceptance testing:

Resource Test:
In the following test output, some test fail due to coreos_enabled and post-test destroy issues. But the test TestAccSatelliteLocation_PodAndServiceSubnet does pass and does contain the two new parameter of Satellite-Location (physical_address and capabilities) for test. Thus, the two coreos_enabled and post-test destroy issues can be solved post merging the changes from this Pull Request.
image
image
https://ibm-argonauts.slack.com/archives/GDAE57ZPA/p1721633692291339?thread_ts=1721042399.405719&cid=GDAE57ZPA


Data-Source Test:
The data-source tests for physical-address and capabilities do pass:
image

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Shreenkhala-Keller and others added 30 commits May 13, 2024 09:55
…AndFrog/terraform-provider-ibm into add_satloc_address_and_capabilities
Add Capabilities tests for Create and Get Satellite Location.
Add capabilities to the tests in satloc_nlb_dns
@FishAndFrog
Copy link
Contributor Author

Hi Zoltan @TwoDCube, hi Harini @hkantare, kindly requesting you for a review and merge respectively. Many thanks to both of you in advance : )

@@ -31,6 +32,18 @@ func DataSourceIBMSatelliteLocation() *schema.Resource {
Computed: true,
Description: "The IBM Cloud metro from which the Satellite location is managed",
},
"physical_address": {
Type: schema.TypeString,
Optional: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In datasource physical_address is computed n't optional where user can provide some input

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Done

@@ -85,6 +87,8 @@ Review the argument references that you can specify for your resource.
Nested scheme for `cos_credentials`:
- `access_key-id` - (Required, String)The `HMAC` secret access key ID.
- `secret_access_key`- (Optional, String) The `HMAC` secret access key.
- `physical_address` - (Optional, String) The physical address of the new Satellite location which is deployed on premise.
- `capabilities` - (Optional, Array of Strings) Satellite capabilities attached to the location. It is mandatory to add the value 'on-prem' to 'capabilitiesManagedBySatellite', if a value has been set for 'physicalAddress'. On the other hand, value can be added to 'capabilitiesManagedBySatellite' without setting any value to 'physicalAddress'. In other words, 'capabilitiesManagedBySatellite' is optional, unless 'physicalAddress' gets set.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description is n't clear what do you mean capabilitiesManagedBySatellite here
Can you check if you can add any RequiredWith at schema level

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because, in Kubernetes API, capabilities is called capabilitiesManagedBySatellite. Now, I also added the API link with this info to the markdown.
Thanks for the RequiredWith tipp. Also, added RequiredWith-physical_address to capabilities in resource code.

ibm/flex/structures.go Outdated Show resolved Hide resolved
@@ -31,6 +32,18 @@ func DataSourceIBMSatelliteLocation() *schema.Resource {
Computed: true,
Description: "The IBM Cloud metro from which the Satellite location is managed",
},
"physical_address": {
Type: schema.TypeString,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be

Suggested change
Optional: true,
Computed: true,

This is a data source and the physical address is not helping to retrieve the resource from the provider. This is meant to be a field that is "read" from the API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better if we just not set the physical address and capabilities here, there is no need to test this change in every unrelated test

Comment on lines 97 to 108
"physical_address": {
Type: schema.TypeString,
Optional: true,
Description: "An optional physical address of the new Satellite location which is deployed on premise",
},
"capabilities": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
Description: "The satellite capabilities attached to the location",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with the API, but in case these can be only set once during create time and not updated we need DiffSuppressFunc: flex.ApplyOnce

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right that physical_address and capabilites cannot be changed after creation.

Thanks. Done

Copy link
Contributor Author

@FishAndFrog FishAndFrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Zoltan @TwoDCube, hi Harini @hkantare, your review findings have been now updated. Requesting you to please have a look once again. Thanks in advance

@hkantare hkantare merged commit 52b77de into IBM-Cloud:master Aug 2, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants