Merge pull request #69167 from apelisse/kubectl-diff

Move `diff` command from alpha sub-command to root cmd
pull/58/head
k8s-ci-robot 2018-09-27 20:52:11 -07:00 committed by GitHub
commit 8fd28eface
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 10 deletions

View File

@ -194,7 +194,6 @@ docs/man/man1/kubeadm-upgrade-plan.1
docs/man/man1/kubeadm-upgrade.1 docs/man/man1/kubeadm-upgrade.1
docs/man/man1/kubeadm-version.1 docs/man/man1/kubeadm-version.1
docs/man/man1/kubeadm.1 docs/man/man1/kubeadm.1
docs/man/man1/kubectl-alpha-diff.1
docs/man/man1/kubectl-alpha.1 docs/man/man1/kubectl-alpha.1
docs/man/man1/kubectl-annotate.1 docs/man/man1/kubectl-annotate.1
docs/man/man1/kubectl-api-resources.1 docs/man/man1/kubectl-api-resources.1
@ -255,6 +254,7 @@ docs/man/man1/kubectl-create-serviceaccount.1
docs/man/man1/kubectl-create.1 docs/man/man1/kubectl-create.1
docs/man/man1/kubectl-delete.1 docs/man/man1/kubectl-delete.1
docs/man/man1/kubectl-describe.1 docs/man/man1/kubectl-describe.1
docs/man/man1/kubectl-diff.1
docs/man/man1/kubectl-drain.1 docs/man/man1/kubectl-drain.1
docs/man/man1/kubectl-edit.1 docs/man/man1/kubectl-edit.1
docs/man/man1/kubectl-exec.1 docs/man/man1/kubectl-exec.1
@ -297,8 +297,6 @@ docs/man/man1/kubectl-wait.1
docs/man/man1/kubectl.1 docs/man/man1/kubectl.1
docs/man/man1/kubelet.1 docs/man/man1/kubelet.1
docs/user-guide/kubectl/kubectl.md docs/user-guide/kubectl/kubectl.md
docs/user-guide/kubectl/kubectl_alpha.md
docs/user-guide/kubectl/kubectl_alpha_diff.md
docs/user-guide/kubectl/kubectl_annotate.md docs/user-guide/kubectl/kubectl_annotate.md
docs/user-guide/kubectl/kubectl_api-resources.md docs/user-guide/kubectl/kubectl_api-resources.md
docs/user-guide/kubectl/kubectl_api-versions.md docs/user-guide/kubectl/kubectl_api-versions.md
@ -358,6 +356,7 @@ docs/user-guide/kubectl/kubectl_create_service_nodeport.md
docs/user-guide/kubectl/kubectl_create_serviceaccount.md docs/user-guide/kubectl/kubectl_create_serviceaccount.md
docs/user-guide/kubectl/kubectl_delete.md docs/user-guide/kubectl/kubectl_delete.md
docs/user-guide/kubectl/kubectl_describe.md docs/user-guide/kubectl/kubectl_describe.md
docs/user-guide/kubectl/kubectl_diff.md
docs/user-guide/kubectl/kubectl_drain.md docs/user-guide/kubectl/kubectl_drain.md
docs/user-guide/kubectl/kubectl_edit.md docs/user-guide/kubectl/kubectl_edit.md
docs/user-guide/kubectl/kubectl_exec.md docs/user-guide/kubectl/kubectl_exec.md
@ -414,6 +413,7 @@ docs/yaml/kubectl/kubectl_cp.yaml
docs/yaml/kubectl/kubectl_create.yaml docs/yaml/kubectl/kubectl_create.yaml
docs/yaml/kubectl/kubectl_delete.yaml docs/yaml/kubectl/kubectl_delete.yaml
docs/yaml/kubectl/kubectl_describe.yaml docs/yaml/kubectl/kubectl_describe.yaml
docs/yaml/kubectl/kubectl_diff.yaml
docs/yaml/kubectl/kubectl_drain.yaml docs/yaml/kubectl/kubectl_drain.yaml
docs/yaml/kubectl/kubectl_edit.yaml docs/yaml/kubectl/kubectl_edit.yaml
docs/yaml/kubectl/kubectl_exec.yaml docs/yaml/kubectl/kubectl_exec.yaml

View File

@ -36,7 +36,6 @@ func NewCmdAlpha(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.
// Alpha commands should be added here. As features graduate from alpha they should move // Alpha commands should be added here. As features graduate from alpha they should move
// from here to the CommandGroups defined by NewKubeletCommand() in cmd.go. // from here to the CommandGroups defined by NewKubeletCommand() in cmd.go.
//cmd.AddCommand(NewCmdDebug(f, in, out, err)) //cmd.AddCommand(NewCmdDebug(f, in, out, err))
cmd.AddCommand(NewCmdDiff(f, streams))
// NewKubeletCommand() will hide the alpha command if it has no subcommands. Overriding // NewKubeletCommand() will hide the alpha command if it has no subcommands. Overriding
// the help function ensures a reasonable message if someone types the hidden command anyway. // the help function ensures a reasonable message if someone types the hidden command anyway.

View File

@ -468,6 +468,7 @@ func NewKubectlCommand(in io.Reader, out, err io.Writer) *cobra.Command {
{ {
Message: "Advanced Commands:", Message: "Advanced Commands:",
Commands: []*cobra.Command{ Commands: []*cobra.Command{
NewCmdDiff(f, ioStreams),
NewCmdApply("kubectl", f, ioStreams), NewCmdApply("kubectl", f, ioStreams),
NewCmdPatch(f, ioStreams), NewCmdPatch(f, ioStreams),
NewCmdReplace(f, ioStreams), NewCmdReplace(f, ioStreams),

View File

@ -54,10 +54,10 @@ var (
run with "-u" (unicode) and "-N" (treat new files as empty) options.`)) run with "-u" (unicode) and "-N" (treat new files as empty) options.`))
diffExample = templates.Examples(i18n.T(` diffExample = templates.Examples(i18n.T(`
# Diff resources included in pod.json. # Diff resources included in pod.json.
kubectl alpha diff -f pod.json kubectl diff -f pod.json
# Diff file read from stdin # Diff file read from stdin
cat service.yaml | kubectl alpha diff -f -`)) cat service.yaml | kubectl diff -f -`))
) )
type DiffOptions struct { type DiffOptions struct {

View File

@ -18,21 +18,21 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
# Runs tests for kubectl alpha diff # Runs tests for kubectl diff
run_kubectl_diff_tests() { run_kubectl_diff_tests() {
set -o nounset set -o nounset
set -o errexit set -o errexit
create_and_use_new_namespace create_and_use_new_namespace
kube::log::status "Testing kubectl alpha diff" kube::log::status "Testing kubectl diff"
# Test that it works when the live object doesn't exist # Test that it works when the live object doesn't exist
output_message=$(kubectl alpha diff -f hack/testdata/pod.yaml) output_message=$(kubectl diff -f hack/testdata/pod.yaml)
kube::test::if_has_string "${output_message}" 'test-pod' kube::test::if_has_string "${output_message}" 'test-pod'
kubectl apply -f hack/testdata/pod.yaml kubectl apply -f hack/testdata/pod.yaml
output_message=$(kubectl alpha diff -f hack/testdata/pod-changed.yaml) output_message=$(kubectl diff -f hack/testdata/pod-changed.yaml)
kube::test::if_has_string "${output_message}" 'k8s.gcr.io/pause:3.0' kube::test::if_has_string "${output_message}" 'k8s.gcr.io/pause:3.0'
kubectl delete -f hack/testdata/pod.yaml kubectl delete -f hack/testdata/pod.yaml