Closed ari-neto closed 2 years ago
:tada: Thanks for opening this pull request! We really appreciate contributors like you! :raised_hands:
Thank you for this! I will push a commit to the spec test after I merge this, to catch this type of issue:
tkishel$ shellspec spec/resource-count-oci.spec
Running: /bin/sh [bash 3.2.57(1)-release]
..
Finished in 0.54 seconds (user 0.53 seconds, sys 0.10 seconds)
2 examples, 0 failures
:tada: Congrats on getting your first pull request merged! We here at Palo Alto Networks are so grateful! :heart:
Description
This issue was found using the script in a customer environment. And I was able to replicate it on a trial OCI account.
In the 78 line the script will parse the compartment-id, and it appears that it creates and issue listing just the root compartment, considering each child compartment shares the same parent "compartment-id", we could see the script generating a list of "0 resources".
The proposed change is to parse the child compartment id ("id" instead "compartment-id"), avoinding a loop just to the root compartment, because the script is looping against the root compartment ("compartment-id" of a child compartment) instead the child compartments ("id" key).
Motivation and Context
This change intent to solve cases which the oci script would return 0 resources, because it is not looping against the child "id" compartment:
When we have nested compartments, the script is listing just the root compartment, we need to list the child compartments, because the root compartment does not contain any resources usually.
How Has This Been Tested?
I've tested on a trial OCI account. I suggest that the change could be tested in a larger and more complex environment to double check.
Screenshots (if appropriate)
Before the change (looping against the same compartment):
After the change (looping against the first level child compartments):
Types of changes
Checklist