-
Notifications
You must be signed in to change notification settings - Fork 36
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
kubectl operator list-operands library code #37
Conversation
ee47b3e
to
21d837a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great start! I went through and did a first pass review, mainly with an eye toward consistency with kubectl
user expectations and consistency with patterns used elsewhere in kubectl-operator
.
|
||
func bindOperatorListCustomResourcesFlags(fs *pflag.FlagSet, CRLister *action.OperatorListCustomResources) { | ||
fs.BoolVarP(&CRLister.ListAll, "list-all", "y", true, "List all CRs in the result without batching. Defaults to true.") | ||
fs.StringVarP(&CRLister.Namespace, "namespace", "n", "default", "Set namespace in which to look for operator.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You misunderstood my first comment. You'll get --namespace
for free. You can access it via config.Namespace
. If --namespace
is unset, it will be the value of the namespace from the context. If --namespace
is set, it will be whatever it is set to.
After having talked about this more today, I think we explicitly don't want an --all-namespaces
flag, because we're always looking for a specific operator in a specific namespace.
May as well bump |
d6ae90b
to
f42b05d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My big concern is making the public API surface only as big as necessary. This PR is the first time we'll be making any of the Go code in this repo public, so I think we should be judicious.
So most of this review is my thoughts on doing that and giving other clients what they would need to list operands for a particular operator.
pkg/action/custom_resource_lister.go
Outdated
"k8s.io/apimachinery/pkg/types" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest:
- Combining
internal/pkg/action/operator_list_custom_resources.go
and this file. - Putting the combined file at
pkg/action/operator_list_operands.go
so that it can be imported for external client's uses. - Unexporting everything except
OperatorListOperands
and itsRun
function. - Moving
internal/pkg/action/config.go
topkg/action/config.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pulling out the Configuration
to its standalone file is producing a pretty big diff so right now I'm just going to import the existing struct and we can pull it out in another PR or commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. We just have to do that before external projects can use it because action.Configuration
is needed when constructing the action struct.
5abae9e
to
7806cc3
Compare
e012e0b
to
bddc951
Compare
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
library code for listing custom resources on-cluster that can then be fed to a command or other callers