knative / client-contrib

Community contributed `kn` plugins.
Apache License 2.0
10 stars 23 forks source link

avoid runtime error if kubectl context is not set #74

Closed chaozbj closed 4 years ago

chaozbj commented 4 years ago

To avoid runtime error if kubectl context is not set, we delay creating the kubenets client interface like what kn admin did:

  1. Added NewKubeClient in AdminParams and set it with a default kubenets client creator when initializing admin command
  2. Improved subcommand RunE function to Call AdminParams.NewKubeClient() to create kubenets client interface when need
  3. Added NewTestAdminParams to help write UT.
  4. Improved all UT codes with the NewTestAdminParams function.
knative-prow-robot commented 4 years ago

Hi @chaozbj. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
zhanggbj commented 4 years ago

/ok-to-test

knative-prow-robot commented 4 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chaozbj, zhanggbj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[plugins/admin/OWNERS](https://github.com/knative/client-contrib/blob/master/plugins/admin/OWNERS)~~ [zhanggbj] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
zhanggbj commented 4 years ago

As discussed on the WG meeting, merging it. @chaozbj Thanks for your PR! @maximilien @rhuss thanks for your review!

zhanggbj commented 4 years ago

/lgtm

zhanggbj commented 4 years ago

@rhuss The infra setup failed for integration test, would you please help to take a look? Thanks!

ERROR: timeout waiting for pods to come up
eventing-controller-84cdd69d89-cpxbc    1/1   Running            0     5m35s
eventing-webhook-7988dd78f5-fdm5c       0/1   CrashLoopBackOff   5     5m34s
imc-controller-7f5d6765f5-vz4v7         1/1   Running            0     5m23s
imc-dispatcher-5786ddf564-zmqhs         1/1   Running            0     5m22s
mt-broker-controller-84c4758486-fgpvt   1/1   Running            0     5m25s
navidshaikh commented 4 years ago

/test pull-knative-client-contrib-integration-tests