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

fix: expand tenant view output #174

Merged
merged 5 commits into from
Dec 14, 2022
Merged

fix: expand tenant view output #174

merged 5 commits into from
Dec 14, 2022

Conversation

benPearce1
Copy link
Contributor

@benPearce1 benPearce1 commented Dec 14, 2022

This change is to support filtering tenants by tag using jq

json before:
image

json after:
image

  • note: the change to pull all fields from the api means that we end up with the default json serialisation on the client model. In the case of the Tenants, the TenantTags field is marked as omitempty so an empty array ends up being left out. Previously we were ending up with the default values of an empty array in the json, making the contract more stable.

image

table before:
image

table after:
image

@benPearce1 benPearce1 requested a review from a team December 14, 2022 04:12

func getEnvironmentMap(client *client.Client) (map[string]string, error) {
environmentMap := make(map[string]string)
allEnvs, err := client.Environments.GetAll()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid GetAll. It does not scale. Is there any way of getting this information from another 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.

fair point, I can modify it to find all the ids it needs and call the query endpoint with a list

Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity, which endpoint can we use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can filter by a list of id values
api/Spaces-1/environments?ids=Environments-1,Environments-282


func getProjectMap(client *client.Client) (map[string]string, error) {
projectMap := make(map[string]string)
allEnvs, err := client.Projects.GetAll()
Copy link
Contributor

Choose a reason for hiding this comment

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

We should avoid GetAll. It does not scale. Is there any way of getting this information from another API?

Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed, in the api for all resources when you do client.Projects.Get() on the returned struct you can use the .GetAllPages() function to get all.

@benPearce1 benPearce1 merged commit 7e3efce into main Dec 14, 2022
@benPearce1 benPearce1 deleted the fix/tenant-list-detail branch December 14, 2022 07:34
This was referenced Jul 28, 2023
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