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

US69000: Adding support for new volume attributes in schema #217

Merged
merged 6 commits into from
Sep 2, 2024

Conversation

achu-1612
Copy link
Contributor

@achu-1612 achu-1612 commented Aug 28, 2024

Description:

Added new volume attributes from the client to the schema.
Client release - https://github.com/HewlettPackard/hpegl-metal-client/releases/tag/v1.5.21

Note: As fields are populated by the backend, they are marked as computed which will make sure the resources are not affected when a re-apply is issued.

Test:

  • Build the provider post the changes
  • Write a terraform template to create a volume setting for the simulator as the target. Create the volume
  • Validate the terraform state to check the newly added attributes
  • Update the volume fields manually with random data
  • Do a terraform refresh so that those data will show up in the state.

State after creating the volume
tf.state.before.json

Start after refresh the volume post manually data population
tf.state.after.json

Diff of states post manual updates to db record
Screenshot 2024-08-28 144534

Re-apply of the resource
Screenshot 2024-08-28 141629

go.mod Outdated Show resolved Hide resolved
@achu-1612 achu-1612 added enhancement New feature or request DO NOT MERGE Don't merge the PR while the label is attached. labels Aug 28, 2024
@achu-1612 achu-1612 requested a review from mchuang3 August 29, 2024 12:00
@achu-1612 achu-1612 marked this pull request as ready for review August 29, 2024 12:00
@achu-1612 achu-1612 requested a review from a team as a code owner August 29, 2024 12:00
@neilgierman
Copy link
Contributor

Please update your PR description about the non-released client version.

@achu-1612 achu-1612 removed the DO NOT MERGE Don't merge the PR while the label is attached. label Aug 29, 2024
internal/resources/resource_volume.go Show resolved Hide resolved
internal/resources/resource_volume.go Show resolved Hide resolved
@@ -326,6 +371,26 @@ func resourceMetalVolumeRead(d *schema.ResourceData, meta interface{}) (err erro
return fmt.Errorf("set Size: %v", err)
}

if err = d.Set(vSizeInUse, math.Round(float64(volume.CapacityUsed)/KiBToGBConversion)); err != nil {
return fmt.Errorf("resourceMetalVolumeRead: set %s : %v", vSizeInUse, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd remove "resourceMetalVolumeRead" from the error messages to be more secure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As this is a public repo, I decided to put more context to the error on where it is coming from.
Anyway, I have removed the method names to align with other implementations.
Thanks.

@achu-1612 achu-1612 merged commit 850d1d0 into master Sep 2, 2024
2 checks passed
@achu-1612 achu-1612 deleted the ac/vol-attr branch September 2, 2024 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants