-
-
Notifications
You must be signed in to change notification settings - Fork 46
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 field selector support to K8s.Selector #117
add field selector support to K8s.Selector #117
Conversation
Hey thanks for the PR! Sorry for the late response it’s been a busy couple of months. I think this looks good have you tested it against a cluster already? I think removing the to_s function is going to require a version bump unless we defdelegate to label_to_s |
Yes, a local cluster running a redis pod in default namespace: apiVersion: v1
kind: Pod
metadata:
name: redis
labels:
component: redis
spec:
containers:
- name: redis
image: redis:5.0.4
command:
- redis-server
env:
- name: MASTER
value: "true"
ports:
- containerPort: 6379
resources:
limits:
cpu: "0.1"
volumes:
- name: data
emptyDir: {} Testing between fetching pods in
Ok! Should I put an |
I would definitely keep
|
I like this one, the behaviour for those relying on iex(1)> {"status.phase", "Running"} |> K8s.Selector.field() |> K8s.Selector.label({"component", "redis"})
%K8s.Selector{
match_expressions: [],
match_fields: %{"status.phase" => {"=", "Running"}},
match_labels: %{"component" => "redis"}
} And how would one tell them apart? Returning a tuple would solve it but again it would require a version bump. |
Yeah you are right, that's not very clean either. I guess the question is: Should the same struct ( |
OR: you keep one single |
btw: you can rebase onto the latest develop branch in order to please the dialyzer ;) |
1d6e1e9
to
1d0b1f3
Compare
@drowzy what do you think about that? |
1d0b1f3
to
37c163a
Compare
Yeah, seems like a good idea. See updated PR! 😃 |
Yes, this looks better. Might add some integrtion tests at some point... |
Is it okay if I take this over? I'm planning on refactoring/simplifying the selector module a bit. I'm gonna keep your commits in and build on top of them. Thanks anyway for the PR. I really want to get this feature in. |
It’s fine! Go ahead :) |
Alright, I'm done refactoring.
Thanks again @drowzy for your contribution! |
Lgtm! |
Took a quick stab at #40. Adds a new
match_fields
toK8s.Selector
to hold key, values relatedto the field selectors. As field selectors only work with equality-based requirements I embedded the operator in the value part of the kv-pair
Changed
merge
to branch depending on type of selector (:label
,:field
). Soand with an operation:
I'm a little bit unsure what you had in mind so I thought I'll start simple. Let me know what you think!