Noticed some behavior when testing an extension ag...
# extensions
c
Noticed some behavior when testing an extension against Rancher 2.12.1. We are using
store.dispatch('cluster/request', { url })
with a url like:
k8s/clusters/local/v1/apps.deployments?labelSelector=<http://app.kubernetes.io/component=test,app.kubernetes.io/name=test|app.kubernetes.io/component=test,app.kubernetes.io/name=test>
but instead of just returning the the filtered deployments, it returns all deployments within that cluster. This was previously working, so just wondering if there is a different approach we should take via the extension? Right now I am using local js filtering to get functionality working.
s
that url points to an internal rancher api liable to change, which in 2.12 did. best to stick to the vuex findX actions for fetching resources. for this case there's the new
findLabelSelector
which takes into account that change in api, and will also handle if server-side pagination is enabled or disabled
b
Examples of usage:
Copy code
const response = await this.$store.dispatch('cluster/findLabelSelector', {
        type:     SERVICE,
        matching: { labelSelector: { matchLabels: { app: 'longhorn-ui' } } },
        opt:      { transient: true }
      });
Copy code
return this.$dispatch('findLabelSelector', {
        type:     POD,
        matching: {
          namespace:     this.metadata.namespace,
          labelSelector: { matchExpressions: this.podMatchExpression },
        },
      });
or
Copy code
return await this.$dispatch('findLabelSelector', {
      type:     POD,
      matching: {
        namespace:     this.metadata.namespace,
        labelSelector: { matchExpressions: parse(this.podRelationship?.selector) },
      }
    });
c
Thanks @stocky-account-63046 & @busy-ability-54059 for explanation and examples!