cloudfoundry / multiapps-cli-plugin

A CLI plugin for Multi-Target Application (MTA) operations in Cloud Foundry
Apache License 2.0
82 stars 41 forks source link

Implement filtering CF entities with mta_namespace label #190

Closed schulzh closed 11 months ago

schulzh commented 11 months ago

Description:

Implement filtering using the mta_namespace label on CF resources (apps and service instances).

Issue:

Fixes https://github.com/cloudfoundry/multiapps-cli-plugin/issues/189

schulzh commented 11 months ago

Looks like it does not filter correctly yet when namespace is not set, I'll see if I can fix that as well

schulzh commented 11 months ago

Works correctly now: image

IvanBorislavovDimitrov commented 11 months ago

Hi @schulzh,

Thank you very much for the contribution, but I'd suggest instead of so many checks on whether there is a namespace or not to check whether the 'mta_namespace' is empty you could use '!mta_namespace' thus filtering only these apps/services without mta_namspace:

Example: cf curl 'v3/apps?label_selector=mta_id=595b4fc924d1b0615b395b2dad14f950,!mta_namespace&space_guids=5c52910a-4072-4b3a-b5b2-bc9497f63aa7' -v

cf curl 'v3/apps?label_selector=mta_id=595b4fc924d1b0615b395b2dad14f950,mta_namespace=YOUR-NAMESPACE&space_guids=5c52910a-4072-4b3a-b5b2-bc9497f63aa7' -v

You can calculate the URL based on whether there is or isn't a namespace then just execute 1 call and return the results instead of filtering already filtered results.

Thanks and best regards, Ivan

schulzh commented 11 months ago

Thanks @IvanBorislavovDimitrov , I searched for a way to filter on the absence of a label but did not find it. I'll update the PR.

IvanBorislavovDimitrov commented 11 months ago

Thanks again for the contribution