iximiuz / client-go-examples

Collection of mini-programs demonstrating Kubernetes client-go usage.
https://labs.iximiuz.com/playgrounds/k8s-client-go/
Apache License 2.0
1.02k stars 131 forks source link

Fix label-selector example #2

Closed nikhil-thomas closed 2 years ago

nikhil-thomas commented 2 years ago

At present, the selector remains empty even after the sel.Add(req) call.

fmt.Printf("%v", sel) prints empty string.

This is because the mutated sel is not reveived and assigned to sel at the caller.

note: the signature of sel.Add function is Add(r ...Requirement) Selector

Signed-off-by: Nikhil Thomas nikhilthomas1@gmail.com

iximiuz commented 2 years ago

Good catch! The Add() behavior turns out to be quite confusing!