Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Make Svcat print help text if command is incorrect #2171

Merged
merged 2 commits into from
Jul 24, 2018
Merged

Make Svcat print help text if command is incorrect #2171

merged 2 commits into from
Jul 24, 2018

Conversation

jichenjc
Copy link
Contributor

@jichenjc jichenjc commented Jun 29, 2018

Make Svcat print help text if command is incorrect

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 29, 2018
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 29, 2018
@duglin
Copy link
Contributor

duglin commented Jun 29, 2018

Can you please use a more descriptive title. "Issue/2166" doesn't mean anything w/o a lot more clicks/work.

@jichenjc
Copy link
Contributor Author

Thanks for the reminder, I know gerrit process but I am brand new to github process :(
I will refer to other submit patches ...

@MHBauer
Copy link
Contributor

MHBauer commented Jul 12, 2018

@carolynvs @jberkhahn close or hold?
@jichenjc this needs to be gofmt'd according to the build result.

@jichenjc
Copy link
Contributor Author

ok, I ran make format locally and this should be ok now

@carolynvs
Copy link
Contributor

@jichenjc There is one more change that needs to be made to make the build happy

https://travis-ci.org/kubernetes-incubator/service-catalog/jobs/403481082#L582

@carolynvs carolynvs added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 13, 2018
@carolynvs
Copy link
Contributor

I just took a look at what you had to do in order to make this work. Let me check and see if we have a way to do this universally for all commands such that when validate fails, we print the help text.

@carolynvs
Copy link
Contributor

Found it!

https://github.com/kubernetes-incubator/service-catalog/blob/7b9f8bd470031d9506cddb5928a665b9d53f9687/cmd/svcat/command/command.go#L45-L75

This is a function used by ALL commands and you should be able to test for an error (instead of returning it directly) and then displaying the command help. You have access to the command directly in that function, so no other changes are necessary to the individual commands themselves.

Copy link
Contributor

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

Let's switch this to work for all commands (see my comment on the PR with a link to the shared function that will let you do that).

@jichenjc
Copy link
Contributor Author

ok, I need check this code and learn how it works ... will submit a patch after I get it :), thanks ~

@duglin duglin changed the title Issue/2166 Make Svcat print help text if command is incorrect Jul 16, 2018
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 18, 2018
@jichenjc
Copy link
Contributor Author

my local test seems better now with a few lines change only

root@k8s:~/go/src/github.com/kubernetes-incubator/service-catalog# bin/svcat/svcat provision
an instance name is required
Usage:
svcat provision NAME --plan PLAN --class CLASS [flags]

Examples:
svcat provision wordpress-mysql-instance --class mysqldb --plan free -p location=eastus -p sslEnforcement=disabled
svcat provision wordpress-mysql-instance --external-id a7c00676-4398-11e8-842f-0ed5f89f718b --class mysqldb --plan free
svcat provision wordpress-mysql-instance --class mysqldb --plan free -s mysecret[dbparams]
svcat provision secure-instance --class mysqldb --plan secureDB --params-json '{
"encrypt" : true,
"firewallRules" : [
{
"name": "AllowSome",
"startIPAddress": "75.70.113.50",
"endIPAddress" : "75.70.113.131"
}
]
}'

Flags:
--class string The class name (Required)
--external-id string The ID of the instance for use with the OSB SB API (Optional)
-h, --help help for provision
--interval string Poll interval for --wait, specified in human readable format: 30s, 1m, 1h (default "1s")
-n, --namespace string If present, the namespace scope for this request
-p, --param strings Additional parameter to use when provisioning the service, format: NAME=VALUE. Cannot be combined with --params-json, Sensitive information should be placed in a secret and specified with --secret
--params-json string Additional parameters to use when provisioning the service, provided as a JSON object. Cannot be combined with --param
--plan string The plan name (Required)
-s, --secret strings Additional parameter, whose value is stored in a secret, to use when provisioning the service, format: SECRET[KEY]
--timeout string Timeout for --wait, specified in human readable format: 30s, 1m, 1h. Specify -1 to wait indefinitely. (default "5m")
--wait Wait until the operation completes.

Global Flags:
--context string name of the kubeconfig context to use.
--kubeconfig string path to kubeconfig file. Overrides $KUBECONFIG
--logtostderr log to standard error instead of files (default false)
-v, --v Level log level for V logs

Error: required flag(s) "class", "plan" not set

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 18, 2018
@jichenjc
Copy link
Contributor Author

saw this in previous comments just now..
https://travis-ci.org/kubernetes-incubator/service-catalog/jobs/403481082#L582
maybe golden files need to be changed as well? need watch new CI result and see whether need take further action...

Copy link
Contributor

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

Oh that's much easier! Let me look at the failure and figure out why the build isn't green...

@carolynvs
Copy link
Contributor

Here's the failing tests TestCommandValidation

Looks like the way that we are checking for the error message isn't working anymore in that test. Can you take a look and see if we can change the test to figure out why?

Let me know if you get stuck on that and I can help figure it out tomorrow.

--- FAIL: TestCommandValidation (0.14s)
    --- FAIL: TestCommandValidation/describe_broker_requires_name (0.01s)
    	svcat_test.go:502: unexpected error 
    		
    		WANT:
    		"a broker name is required"
    		
    		GOT:
    		""

Make Svcat print help text when a command is entered incorrectly.

Closes: #2166
@jichenjc
Copy link
Contributor Author

sorry still be familiar with how github works,
just pushed to issue/2166 and comments there, copied from there:

made a minor change, and UT now succeed , hopefully better now ...

ok github.com/kubernetes-incubator/service-catalog/cmd/svcat 7.238s

@jberkhahn
Copy link
Contributor

/lgtm

This seems pretty reasonable now.

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2018
@jberkhahn jberkhahn removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 23, 2018
@jichenjc
Copy link
Contributor Author

/retest

@jichenjc
Copy link
Contributor Author

thanks for info , I just triggered the retest

@k8s-ci-robot
Copy link
Contributor

@jichenjc: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jichenjc
Copy link
Contributor Author

/test pull-service-catalog-xbuild

@k8s-ci-robot
Copy link
Contributor

@jichenjc: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test pull-service-catalog-xbuild

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@MHBauer
Copy link
Contributor

MHBauer commented Jul 24, 2018

/ok-to-test
/test pull-service-catalog-xbuild

@MHBauer MHBauer added the LGTM1 label Jul 24, 2018
@carolynvs
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: carolynvs

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 24, 2018
@k8s-ci-robot k8s-ci-robot merged commit 907c50d into kubernetes-retired:master Jul 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. LGTM1 LGTM2 size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants