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

support listing works with its labels #135

Merged
merged 1 commit into from
Jun 25, 2024
Merged

Conversation

skeeey
Copy link
Contributor

@skeeey skeeey commented Jun 19, 2024

No description provided.

@skeeey
Copy link
Contributor Author

skeeey commented Jun 19, 2024

should wait for #133 and #136 is merged

@skeeey skeeey changed the title WIP: support listing works with its labels support listing works with its labels Jun 24, 2024
@machi1990
Copy link
Contributor

lgtm

Once merged, I can test it against the client I am building.

}

notEqualsLabels = append(notEqualsLabels, fmt.Sprintf(`payload->'metadata'->'labels'->>'%s'<>'%s'`,
requirement.Key(), values.List()[0]))
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe extract payload->'metadata'->'labels' as a constant since it is using in many places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

labelSearch = append(labelSearch, notEqualsLabels...)
labelSearch = append(labelSearch, existsKeys...)
labelSearch = append(labelSearch, doesNotExistKeys...)
return labelSelector, strings.Join(labelSearch, " and "), true, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Does kube label selector support or?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, it does not

@clyang82
Copy link
Contributor

/ok-to-test

Copy link
Contributor

@clyang82 clyang82 left a comment

Choose a reason for hiding this comment

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

LGTM

@clyang82 clyang82 merged commit d5654af into openshift-online:main Jun 25, 2024
5 checks passed
@machi1990
Copy link
Contributor

lgtm

Once merged, I can test it against the client I am building.

Just an FYI; I've tested the PR with a code similar to this


l := &corev1.NamespaceList{}

err = client.List(ctx, l, k8sClient.MatchingLabels(map[string]string{
"key": "label",
}))

and works as expected. Thanks @skeeey @clyang82 @qiujian16

@skeeey skeeey deleted the search branch July 1, 2024 03:54
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