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

Support --all-namespaces option for service and revision list #32

Merged
merged 6 commits into from Apr 9, 2019

Conversation

nak3
Copy link
Contributor

@nak3 nak3 commented Mar 4, 2019

Currently kn {service, revision} list does not have the all-namespaces
options. Although it is possible to list them by kn service list -n ""(empty string), it is difficult to find such secret trick.

Hence, this patch adds --all-namespaces option.

@knative-prow-robot knative-prow-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 4, 2019
@knative-prow-robot knative-prow-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 4, 2019
@cppforlife
Copy link

@nak3 we should probably move this into KnParams or some other object (like NamespaceParams) that's injecting; otherwise, we would have to duplicate this functionality everywhere.

@knative knative deleted a comment from cppforlife Mar 11, 2019
@nak3
Copy link
Contributor Author

nak3 commented Mar 11, 2019

@cppforlife Thank you! Updated by adding the option into KnParams and adding the flag to revision,service command instead of list only.

@@ -24,6 +24,9 @@ func NewRevisionCommand(p *KnParams) *cobra.Command {
Short: "Revision command group",
}
revisionCmd.PersistentFlags().StringP("namespace", "n", "default", "Namespace to use.")
revisionCmd.PersistentFlags().BoolVar(&p.getAllNamespaces, "all-namespaces", false,

Choose a reason for hiding this comment

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

could we also share following 3 lines as well between commands?

Copy link
Contributor Author

@nak3 nak3 Mar 12, 2019

Choose a reason for hiding this comment

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

Do you mean that --all-namespace should move to root level option like --config and --kubeconfig?
I put --all-namespace here to align with --namespace(-n). Should I share --namespace between commands as well?

Choose a reason for hiding this comment

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

@nak3 probably not global, but doesnt mean we cannot reuse this code so that we dont have duplicate flag definitions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd love to see an AddNamespaceFlags fn and a GetNamespace(cmd) fn.

@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 19, 2019
@nak3
Copy link
Contributor Author

nak3 commented Mar 19, 2019

@cppforlife @sixolet Thank you! Updated.

@cppforlife
Copy link

+1 for @navidshaikh suggestions

@nak3
Copy link
Contributor Author

nak3 commented Mar 21, 2019

Thank you, updated the help messages.

Copy link
Collaborator

@navidshaikh navidshaikh left a comment

Choose a reason for hiding this comment

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

LGTM!

@cppforlife
Copy link

/ok-to-test

@knative-prow-robot knative-prow-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 26, 2019
@bbrowning
Copy link
Contributor

Kicking these tests since a fix for these CI failures has since been merged.

/retest

@nak3
Copy link
Contributor Author

nak3 commented Mar 30, 2019

rebased to solve confliction.

@cppforlife
Copy link

/lgtm
/approve

@knative-prow-robot knative-prow-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 8, 2019
@nak3
Copy link
Contributor Author

nak3 commented Apr 8, 2019

/test pull-knative-client-unit-tests

@nak3
Copy link
Contributor Author

nak3 commented Apr 8, 2019

The test was failed at TestServiceCreateImage. It looks like I need to rebase this PR again(?) Let's see the result of secod try.

I0408 17:44:11.183] --- FAIL: TestServiceCreateImage (0.00s)
I0408 17:44:11.183] panic: runtime error: invalid memory address or nil pointer dereference [recovered]
I0408 17:44:11.183] 	panic: runtime error: invalid memory address or nil pointer dereference
I0408 17:44:11.184] [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1827351]
I0408 17:44:11.184] 
I0408 17:44:11.184] goroutine 26 [running]:
I0408 17:44:11.184] testing.tRunner.func1(0xc0000efa00)
I0408 17:44:11.185] 	/usr/local/go/src/testing/testing.go:830 +0x68a
I0408 17:44:11.185] panic(0x1944e40, 0x29115e0)
I0408 17:44:11.185] 	/usr/local/go/src/runtime/panic.go:522 +0x1b5
I0408 17:44:11.185] github.com/knative/client/pkg/kn/commands.NewServiceCreateCommand.func1(0xc000492280, 0xc000289d40, 0x1, 0x3, 0x0, 0x0)
I0408 17:44:11.185] 	/go/src/github.com/knative/client/pkg/kn/commands/service_create.go:42 +0x1e1
I0408 17:44:11.186] github.com/spf13/cobra.(*Command).execute(0xc000492280, 0xc000289cb0, 0x3, 0x3, 0xc000492280, 0xc000289cb0)
I0408 17:44:11.186] 	/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:762 +0x528
I0408 17:44:11.186] github.com/spf13/cobra.(*Command).ExecuteC(0xc0002df680, 0x0, 0x0, 0x0)
I0408 17:44:11.187] 	/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:852 +0x3ee
I0408 17:44:11.187] github.com/spf13/cobra.(*Command).Execute(...)
I0408 17:44:11.187] 	/go/pkg/mod/github.com/spf13/cobra@v0.0.3/command.go:800
I0408 17:44:11.187] github.com/knative/client/pkg/kn/commands.fakeServiceCreate(0xc0000fc9b0, 0x5, 0x5, 0xc00019d760, 0xc00009b380, 0xc000482000, 0xc00019d730, 0x455cdd, 0x1eda418, 0xf)
I0408 17:44:11.188] 	/go/src/github.com/knative/client/pkg/kn/commands/service_create_test.go:59 +0x514
I0408 17:44:11.188] github.com/knative/client/pkg/kn/commands.TestServiceCreateImage(0xc0000efa00)
I0408 17:44:11.188] 	/go/src/github.com/knative/client/pkg/kn/commands/service_create_test.go:68 +0xc1
I0408 17:44:11.188] testing.tRunner(0xc0000efa00, 0x1b157f0)
I0408 17:44:11.189] 	/usr/local/go/src/testing/testing.go:865 +0x164
I0408 17:44:11.189] created by testing.(*T).Run
I0408 17:44:11.189] 	/usr/local/go/src/testing/testing.go:916 +0x69a
I0408 17:44:11.189] FAIL	github.com/knative/client/pkg/kn/commands	1.051s

`kn {service, revision} list` does not have the all-namespaces
options. Although it is possible to list them by `kn service list -n
""`(empty string), it is difficult to find such secret trick.

Hence, This patch adds `--all-namespaces` option.
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 8, 2019
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/kn/commands/namespaced.go Do not exist 78.6%
pkg/kn/commands/revision_describe.go 81.0% 79.2% -1.8
pkg/kn/commands/revision_list.go 21.1% 22.7% 1.7
pkg/kn/commands/service_create.go 75.0% 74.1% -0.9
pkg/kn/commands/service_describe.go 81.0% 79.2% -1.8
pkg/kn/commands/service_list.go 78.9% 77.3% -1.7

@nak3
Copy link
Contributor Author

nak3 commented Apr 9, 2019

@cppforlife @cppforlife @bbrowning @navidshaikh
Thank you. Sorry LGTM label was dropped as I rebased and added AddNamespaceFlags() to service create command - 3cad3dc. Could you please take a look again?

@cppforlife
Copy link

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 9, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cppforlife, nak3, navidshaikh

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot merged commit 6b2b7f2 into knative:master Apr 9, 2019
@nak3 nak3 deleted the all-namespaces branch April 10, 2019 00:44
coryrc pushed a commit to coryrc/client that referenced this pull request May 14, 2020
Add missing jobs, group similar tasks, update settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants