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

Implement custom help command for kubectl #27049

Merged
merged 1 commit into from
Jun 30, 2016

Conversation

andreykurilin
Copy link
Contributor

@andreykurilin andreykurilin commented Jun 8, 2016

* kubectl help now provides "Did you mean this?" suggestions for typo/invalid command names.

Custom implementation of help command allows to print Did you mean this? with
suggestions, which is missed in embed help command from github.com/spf13/cobra

Also, it can be extended with different search features. At this patch, help
command searches query in short descriptions of commands in case of mismatch
with commands names.

fixes #25234

@k8s-bot
Copy link

k8s-bot commented Jun 8, 2016

Can one of the admins verify that this patch is reasonable to test? If so, please reply "ok to test".
(Note: "add to whitelist" is no longer supported. Please update configurations in kubernetes/test-infra/jenkins/job-configs/kubernetes-jenkins-pull instead.)

This message may repeat a few times in short succession due to jenkinsci/ghprb-plugin#292. Sorry.

Otherwise, if this message is too spammy, please complain to ixdy.

2 similar comments
@k8s-bot
Copy link

k8s-bot commented Jun 8, 2016

Can one of the admins verify that this patch is reasonable to test? If so, please reply "ok to test".
(Note: "add to whitelist" is no longer supported. Please update configurations in kubernetes/test-infra/jenkins/job-configs/kubernetes-jenkins-pull instead.)

This message may repeat a few times in short succession due to jenkinsci/ghprb-plugin#292. Sorry.

Otherwise, if this message is too spammy, please complain to ixdy.

@k8s-bot
Copy link

k8s-bot commented Jun 8, 2016

Can one of the admins verify that this patch is reasonable to test? If so, please reply "ok to test".
(Note: "add to whitelist" is no longer supported. Please update configurations in kubernetes/test-infra/jenkins/job-configs/kubernetes-jenkins-pull instead.)

This message may repeat a few times in short succession due to jenkinsci/ghprb-plugin#292. Sorry.

Otherwise, if this message is too spammy, please complain to ixdy.

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-label-needed labels Jun 8, 2016
@andreykurilin
Copy link
Contributor Author

andreykurilin commented Jun 8, 2016

help message for typo:

$ ./kubectl help got
unknown command "got" for "kubectl"

Did you mean this?
        get
        set

Usage:
  kubectl [flags]
  kubectl [command]

Available Commands:
  get            Display one or many resources
  set            Set specific features on objects
  describe       Show details of a specific resource or group of resources
  create         Create a resource by filename or stdin
  replace        Replace a resource by filename or stdin.
  patch          Update field(s) of a resource using strategic merge patch.
  delete         Delete resources by filenames, stdin, resources and names, or by resources and label selector.
  edit           Edit a resource on the server
  apply          Apply a configuration to a resource by filename or stdin
  namespace      SUPERSEDED: Set and view the current Kubernetes namespace
  logs           Print the logs for a container in a pod.
  rolling-update Perform a rolling update of the given ReplicationController.
  scale          Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job.
  cordon         Mark node as unschedulable
  drain          Drain node in preparation for maintenance
  uncordon       Mark node as schedulable
  attach         Attach to a running container.
  exec           Execute a command in a container.
  port-forward   Forward one or more local ports to a pod.
  proxy          Run a proxy to the Kubernetes API server
  run            Run a particular image on the cluster.
  expose         Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
  autoscale      Auto-scale a Deployment, ReplicaSet, or ReplicationController
  rollout        rollout manages a deployment
  label          Update the labels on a resource
  annotate       Update the annotations on a resource
  taint          Update the taints on one or more nodes
  config         config modifies kubeconfig files
  cluster-info   Display cluster info
  api-versions   Print the supported API versions on the server, in the form of "group/version".
  version        Print the client and server version information.
  explain        Documentation of resources.
  convert        Convert config files between different API versions
  completion     Output shell completion code for the given shell (bash or zsh)

Flags:
      --alsologtostderr[=false]: log to standard error as well as files
      --as="": Username to impersonate for the operation.
      --certificate-authority="": Path to a cert. file for the certificate authority.
      --client-certificate="": Path to a client certificate file for TLS.
      --client-key="": Path to a client key file for TLS.
      --cluster="": The name of the kubeconfig cluster to use
      --context="": The name of the kubeconfig context to use
      --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
      --kubeconfig="": Path to the kubeconfig file to use for CLI requests.
      --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace
      --log-dir="": If non-empty, write log files in this directory
      --log-flush-frequency=5s: Maximum number of seconds between log flushes
      --logtostderr[=true]: log to standard error instead of files
      --match-server-version[=false]: Require server version to match client version
      --namespace="": If present, the namespace scope for this CLI request.
      --password="": Password for basic authentication to the API server.
  -s, --server="": The address and port of the Kubernetes API server
      --stderrthreshold=2: logs at or above this threshold go to stderr
      --token="": Bearer token for authentication to the API server.
      --user="": The name of the kubeconfig user to use
      --username="": Username for basic authentication to the API server.
      --v=0: log level for V logs
      --vmodule=: comma-separated list of pattern=N settings for file-filtered logging

Use "kubectl [command] --help" for more information about a command.

help message for search query:

$ ./kubectl help versions
unknown command "versions" for "kubectl"

Did you mean this?
        version

Matchers of string 'versions' in short descriptions of commands: 
  api-versions   Print the supported API versions on the server, in the form of "group/version".
  convert        Convert config files between different API versions

Before this patch, help command had two options: display usage message with all commands or display help message for particular command.

@j3ffml
Copy link
Contributor

j3ffml commented Jun 8, 2016

@k8s-bot ok to test

@j3ffml
Copy link
Contributor

j3ffml commented Jun 8, 2016

Thanks for the pr. We're currently in code slush pending 1.3 release cut this Friday. Will take a look afterwards.

@k8s-bot
Copy link

k8s-bot commented Jun 9, 2016

GCE e2e build/test passed for commit ac90ddb01ac7739008e995ba8c355cdb53d7dfb3.

@andreykurilin andreykurilin changed the title Implement own help command for kubectl Implement custom command for kubectl Jun 9, 2016
@k8s-bot
Copy link

k8s-bot commented Jun 14, 2016

Can one of the admins verify that this patch is reasonable to test? If so, please reply "ok to test".
(Note: "add to whitelist" is no longer supported. Please update configurations in kubernetes/test-infra/jenkins/job-configs/kubernetes-jenkins-pull instead.)

This message may repeat a few times in short succession due to jenkinsci/ghprb-plugin#292. Sorry.

Otherwise, if this message is too spammy, please complain to ixdy.

2 similar comments
@k8s-bot
Copy link

k8s-bot commented Jun 15, 2016

Can one of the admins verify that this patch is reasonable to test? If so, please reply "ok to test".
(Note: "add to whitelist" is no longer supported. Please update configurations in kubernetes/test-infra/jenkins/job-configs/kubernetes-jenkins-pull instead.)

This message may repeat a few times in short succession due to jenkinsci/ghprb-plugin#292. Sorry.

Otherwise, if this message is too spammy, please complain to ixdy.

@k8s-bot
Copy link

k8s-bot commented Jun 23, 2016

Can one of the admins verify that this patch is reasonable to test? If so, please reply "ok to test".
(Note: "add to whitelist" is no longer supported. Please update configurations in kubernetes/test-infra/jenkins/job-configs/kubernetes-jenkins-pull instead.)

This message may repeat a few times in short succession due to jenkinsci/ghprb-plugin#292. Sorry.

Otherwise, if this message is too spammy, please complain to ixdy.

@janetkuo
Copy link
Member

ok to test

@k8s-bot
Copy link

k8s-bot commented Jun 27, 2016

GCE e2e build/test passed for commit ac90ddb01ac7739008e995ba8c355cdb53d7dfb3.

@j3ffml j3ffml changed the title Implement custom command for kubectl Implement custom help command for kubectl Jun 28, 2016
foundCmd, a, e := cmd.Root().Find(args)

// NOTE(andreykurilin): actually, I did not find any cases when foundCmd can be nill,
// but let's make this checks since it is included in original code of initHelpCmd from
Copy link
Contributor

Choose a reason for hiding this comment

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

s/nill/nil, s/checks/check

@j3ffml
Copy link
Contributor

j3ffml commented Jun 28, 2016

Nice improvement. This deserves a brief release-note mention. Add a line like

kubectl help now provides "Did you mean this?" suggestions for typo/invalid command names.

in top level comment.

@j3ffml j3ffml added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Jun 28, 2016
@andreykurilin
Copy link
Contributor Author

@jlowdermilk done

@k8s-bot
Copy link

k8s-bot commented Jun 29, 2016

GCE e2e build/test passed for commit b6b36264e898a318de99caec4b50df87c4e65179.

@j3ffml
Copy link
Contributor

j3ffml commented Jun 29, 2016

lgtm. Verify script is complaining that you need to run go fmt on help.go.

@andreykurilin
Copy link
Contributor Author

@jlowdermilk fixed

@k8s-bot
Copy link

k8s-bot commented Jun 30, 2016

GCE e2e build/test passed for commit 296cfeee6f7dfb84741331b85a5a219806459345.

@j3ffml j3ffml added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 30, 2016
@@ -0,0 +1,79 @@
/*
Copyright 2014 The Kubernetes Authors All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

2016

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 30, 2016
@andreykurilin
Copy link
Contributor Author

@jlowdermilk the year is uptodate now. please put LGTM again:)

@j3ffml j3ffml added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 30, 2016
@k8s-bot
Copy link

k8s-bot commented Jun 30, 2016

GCE e2e build/test passed for commit 669a466efcb19fdc567028e6a5eb92ed96e037e0.

@j3ffml
Copy link
Contributor

j3ffml commented Jun 30, 2016

Ah, there was a recent change to the header wording across all files. You'll need to update boilerplate in help.go to match hack/boilerplate/boilerplate.go.txt. For future reference, you can run the verification check locally using hack/verify-all.sh -v and it will tell you what to fix.

Own implemenation of help command allows to print `Did you mean this?` with
suggestions, which is missed in embed help command from github.com/spf13/cobra

Also, it can be extended with different search features. At this patch, help
command search query in short descriptions of commands in case of mismatch
with commands names.

fixes #25234
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 30, 2016
@j3ffml j3ffml added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 30, 2016
@k8s-bot
Copy link

k8s-bot commented Jun 30, 2016

GCE e2e build/test passed for commit 48d47b1.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Jun 30, 2016

GCE e2e build/test passed for commit 48d47b1.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 23e7b66 into kubernetes:master Jun 30, 2016
@andreykurilin andreykurilin deleted the kubectl_help branch July 1, 2016 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Enable search in kubectl help
6 participants