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

Improve Compute Manager data source #976

Merged
merged 2 commits into from
Sep 26, 2023
Merged

Improve Compute Manager data source #976

merged 2 commits into from
Sep 26, 2023

Conversation

annakhm
Copy link
Collaborator

@annakhm annakhm commented Sep 19, 2023

Since usually only one compute manager is configured, it is useful to retrieve its ID without providing any filters. This PR enables this.

Since usually only one compute manager is configured, it is useful
to retrieve its ID without providing any filters. This PR enables this.

Signed-off-by: Anna Khmelnitsky <[email protected]>
@annakhm annakhm requested a review from ksamoray September 19, 2023 22:42
@annakhm
Copy link
Collaborator Author

annakhm commented Sep 19, 2023

/test-all

@@ -57,6 +55,11 @@ func dataSourceNsxtComputeManagerRead(d *schema.ResourceData, m interface{}) err
var perfectMatch []model.ComputeManager
var prefixMatch []model.ComputeManager
for _, objInList := range objList.Results {
if len(objName) == 0 {
// We want to grab single compute manager
perfectMatch = append(perfectMatch, objInList)
Copy link
Collaborator

@GraysonWu GraysonWu Sep 20, 2023

Choose a reason for hiding this comment

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

So if there are multiple compute managers, an empty display_name will cause an error. I'm wondering if we should add a more informative err msg indicating empty display_name can only be used with single compute manager to reduce the confusion or change the behavior here to just grab the first compute manager or just treat it as a match all for prefixMatch. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think we should decide which manager to grab without further input from the user.
Failing the data source because multiple objects are matching is a behavior present in most data sources in the provider. Regarding error messages - perhaps we should unify these messages across all data sources for consistency?
I can add more info in the doc for the case of compute manager.


resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccOnlyLocalManager(t)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure whether we need testAccTestMP() for these resources or not. Other than this LGTM

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should rename testAccTestMP to testAccTestDeprecated. I think we should include the new fabric resources in the main test suite

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense. I think that I added testAccTestMP to a some fabric resource(s) which I coded. I'll remove these and rename testAccTestMP

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks!

@vmwclabot
Copy link
Member

@annakhm, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding Signed-off-by: John Doe <[email protected]> to the last line of each Git commit message. The e-mail address used to sign must match the e-mail address of the Git author. Click here to view the Developer Certificate of Origin agreement.

@vmwclabot vmwclabot added the dco-required DCO Required label Sep 25, 2023
@annakhm annakhm merged commit 7e25a0d into master Sep 26, 2023
@annakhm annakhm deleted the compute-manager-ds branch February 5, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dco-required DCO Required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants