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

kubectl operator list-operands library code #37

Merged
merged 5 commits into from
Apr 7, 2021

Conversation

exdx
Copy link
Member

@exdx exdx commented Apr 5, 2021

library code for listing custom resources on-cluster that can then be fed to a command or other callers

@exdx exdx requested review from joelanford and benluddy April 5, 2021 21:57
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 5, 2021
@exdx exdx force-pushed the feat/list-operands branch 2 times, most recently from ee47b3e to 21d837a Compare April 5, 2021 22:10
Copy link
Member

@joelanford joelanford left a 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.

internal/cmd/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/cmd/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/cmd/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/cmd/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/cmd/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved
@exdx exdx force-pushed the feat/list-operands branch from 21d837a to 361eeb9 Compare April 6, 2021 20:04
internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved

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.")
Copy link
Member

@joelanford joelanford Apr 7, 2021

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.

@joelanford
Copy link
Member

May as well bump operator-framework/api to the latest and greatest. Looks like the one we're currently on is pretty old.

@exdx exdx force-pushed the feat/list-operands branch 2 times, most recently from d6ae90b to f42b05d Compare April 7, 2021 14:47
@exdx exdx force-pushed the feat/list-operands branch from f42b05d to d004c0a Compare April 7, 2021 15:12
Copy link
Member

@joelanford joelanford left a 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.

internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Copy link
Member

Choose a reason for hiding this comment

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

I would suggest:

  1. Combining internal/pkg/action/operator_list_custom_resources.go and this file.
  2. Putting the combined file at pkg/action/operator_list_operands.go so that it can be imported for external client's uses.
  3. Unexporting everything except OperatorListOperands and its Run function.
  4. Moving internal/pkg/action/config.go to pkg/action/config.go

Copy link
Member Author

Choose a reason for hiding this comment

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

ok,done

Copy link
Member Author

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

Copy link
Member

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.

internal/pkg/action/operator_list_custom_resources.go Outdated Show resolved Hide resolved
pkg/action/custom_resource_lister.go Outdated Show resolved Hide resolved
internal/cmd/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/cmd/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/cmd/operator_list_custom_resources.go Outdated Show resolved Hide resolved
internal/cmd/operator_list_custom_resources.go Outdated Show resolved Hide resolved
@exdx exdx changed the title [WIP] kubectl operator list-custom-resources kubectl operator list-custom-resources library code Apr 7, 2021
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 7, 2021
@exdx exdx force-pushed the feat/list-operands branch 2 times, most recently from 5abae9e to 7806cc3 Compare April 7, 2021 18:54
pkg/action/custom_resource_lister.go Outdated Show resolved Hide resolved
pkg/action/custom_resource_lister.go Outdated Show resolved Hide resolved
pkg/action/custom_resource_lister.go Outdated Show resolved Hide resolved
pkg/action/custom_resource_lister.go Outdated Show resolved Hide resolved
pkg/action/custom_resource_lister.go Outdated Show resolved Hide resolved
@exdx exdx force-pushed the feat/list-operands branch 3 times, most recently from e012e0b to bddc951 Compare April 7, 2021 20:09
@exdx exdx force-pushed the feat/list-operands branch from bddc951 to aae25e4 Compare April 7, 2021 20:17
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
@joelanford joelanford changed the title kubectl operator list-custom-resources library code kubectl operator list-operands library code Apr 7, 2021
@joelanford joelanford merged commit 50fcce0 into operator-framework:main Apr 7, 2021
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