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

Add filters to GET clusters API #8

Merged
merged 1 commit into from
Apr 26, 2024

Conversation

gianlucam76
Copy link
Member

When requesting both ClusterAPI powered clusters (/capiclusters) and SveltosClusters (/sveltosclusters) following filters are added:

  1. namespace=: this filter allows selecting clusters in namespaces containing such string
  2. name=: this filter allows selecting clusters with a name containing such string
  3. labels=key1:value1,key2:value2 (labels must be encoded to form a correct URI)

This PR also returns the total number of clusters matching all filters.

For instance:

http://localhost:9000/capiclusters?limit=1&skip=0&namespace=default&labels=env:fv,cluster.x-k8s.io%2Fcluster-name:clusterapi-workload

will return:

{"totalClusters":1,"managedClusters":[{"namespace":"default","name":"clusterapi-workload","clusterInfo":{"labels":{"cluster.x-k8s.io/cluster-name":"clusterapi-workload","env":"fv","topology.cluster.x-k8s.io/owned":""},"version":"v1.27.0","ready":true,"failureMessage":null}}]}

Fixes #7 #6

When requesting both ClusterAPI powered clusters (/capiclusters)
and SveltosClusters (/sveltosclusters) following filters are added:

1. namespace=<namespace>: this filter allows selecting clusters in namespaces
containing such string
2. name=<name>: this filter allows selecting clusters with a name containing
such string
3. labels=<key1:value1,key2:value2> (labels must be encoded to form a correct URI)

This PR also returns the total number of clusters matching all filters.

For instance:
```
http://localhost:9000/capiclusters?limit=1&skip=0&namespace=default&labels=env:fv,cluster.x-k8s.io%2Fcluster-name:clusterapi-workload
```

will return:
```
{"totalClusters":1,"managedClusters":[{"namespace":"default","name":"clusterapi-workload","clusterInfo":{"labels":{"cluster.x-k8s.io/cluster-name":"clusterapi-workload","env":"fv","topology.cluster.x-k8s.io/owned":""},"version":"v1.27.0","ready":true,"failureMessage":null}}]}
```
@gianlucam76 gianlucam76 merged commit c72fb64 into projectsveltos:dev Apr 26, 2024
2 checks passed
@gianlucam76 gianlucam76 deleted the filters branch April 26, 2024 17:05
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.

1 participant