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: Correct multiple labels filtering for get commadn #59

Conversation

nieomylnieja
Copy link
Contributor

@nieomylnieja nieomylnieja commented Feb 22, 2024

Motivation

Our backend only interprets the first query parameter value it receives.
Since we've been setting url.Values labels query parameter key to a list of parsed values, this caused our backend to only interpret the first value.

With example Projects:

- apiVersion: n9/v1alpha
  kind: Project
  metadata:
    displayName: azure-agent
    labels:
      env:
      - dev
      - dev-demo-1
      team:
      - bees
    name: azure-agent
  spec:
    description: azure-agent
- apiVersion: n9/v1alpha
  kind: Project
  metadata:
    labels:
      team:
      - bees
    name: project-two
  spec:
    description: ""

When running:

sloctl get project -l env=dev,team=bees
sloctl get project -l team=bees,env=dev

We got:

  • for the first command, both Projects
  • for the second one, only one Project, azure-agent

What should've happened?

Both commands should only return azure-agent, as this should've been interpreted as AND condition between labels. As a side effect, OR conditions have been broken too (same key, multiple labels), so these should work now too.

Testing

  • Extended e2e tests coverage.

Release Notes

Fixed labels filtering for sloctl get command which was causing incorrect results to be returned by our backend.
Issue affects every sloctl version starting from and including v0.0.95.

Copy link
Contributor

@daniel-zelazny daniel-zelazny left a comment

Choose a reason for hiding this comment

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

👍

@nieomylnieja nieomylnieja merged commit 210c475 into main Feb 22, 2024
7 checks passed
@nieomylnieja nieomylnieja deleted the PC-12154-sdk-labels-are-created-as-multiple-query-parameters-but-should-be-a-single-one branch February 22, 2024 14:55
BSski pushed a commit that referenced this pull request May 7, 2024
## Motivation

Our backend only interprets the first query parameter value it receives.
Since we've been setting `url.Values` labels query parameter key to a
list of parsed values, this caused our backend to only interpret the
first value.

With example Projects:

```yaml
- apiVersion: n9/v1alpha
  kind: Project
  metadata:
    displayName: azure-agent
    labels:
      env:
      - dev
      - dev-demo-1
      team:
      - bees
    name: azure-agent
  spec:
    description: azure-agent
- apiVersion: n9/v1alpha
  kind: Project
  metadata:
    labels:
      team:
      - bees
    name: project-two
  spec:
    description: ""
```

When running:

```sh
sloctl get project -l env=dev,team=bees
sloctl get project -l team=bees,env=dev
```

We got:
- for the first command, both Projects
- for the second one, only one Project, `azure-agent`

**What should've happened?**

Both commands should only return `azure-agent`, as this should've been
interpreted as AND condition between labels. As a side effect, OR
conditions have been broken too (same key, multiple labels), so these
should work now too.

## Testing

- Extended e2e tests coverage.

## Release Notes

Fixed labels filtering for `sloctl get` command which was causing
incorrect results to be returned by our backend.
Issue affects every sloctl version starting from and including v0.0.95.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working go patch release-notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants