Skip to content

Commit 41f361a

Browse files
committed
remove kubectl from openshift (but not oc)
1 parent 49fb419 commit 41f361a

File tree

4 files changed

+3
-46
lines changed

4 files changed

+3
-46
lines changed

pkg/cmd/openshift/openshift.go

-3
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ func CommandFor(basename string) *cobra.Command {
8181
cmd = cli.NewCommandCLI(basename, basename, in, out, errout)
8282
case "oadm", "osadm":
8383
cmd = admin.NewCommandAdmin(basename, basename, in, out, errout)
84-
case "kubectl":
85-
cmd = cli.NewCmdKubectl(basename, out)
8684
case "kube-apiserver":
8785
cmd = kubernetes.NewAPIServerCommand(basename, basename, out)
8886
case "kube-controller-manager":
@@ -126,7 +124,6 @@ func NewCommandOpenShift(name string) *cobra.Command {
126124
root.AddCommand(startAllInOne)
127125
root.AddCommand(admin.NewCommandAdmin("admin", name+" admin", in, out, errout))
128126
root.AddCommand(cli.NewCommandCLI("cli", name+" cli", in, out, errout))
129-
root.AddCommand(cli.NewCmdKubectl("kube", out))
130127
root.AddCommand(newExperimentalCommand("ex", name+" ex"))
131128
root.AddCommand(newCompletionCommand("completion", name+" completion"))
132129
root.AddCommand(cmd.NewCmdVersion(name, f, out, cmd.VersionOptions{PrintEtcdVersion: true, IsServer: true}))

pkg/oc/cli/cli.go

+1-25
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import (
77
"runtime"
88
"strings"
99

10-
"github.com/golang/glog"
1110
"github.com/spf13/cobra"
12-
"github.com/spf13/pflag"
1311

1412
kubecmd "k8s.io/kubernetes/pkg/kubectl/cmd"
1513
ktemplates "k8s.io/kubernetes/pkg/kubectl/cmd/templates"
@@ -256,28 +254,6 @@ func changeSharedFlagDefaults(rootCmd *cobra.Command) {
256254
}
257255
}
258256

259-
// NewCmdKubectl provides exactly the functionality from Kubernetes,
260-
// but with support for OpenShift resources
261-
func NewCmdKubectl(name string, out io.Writer) *cobra.Command {
262-
flags := pflag.NewFlagSet("", pflag.ContinueOnError)
263-
f := clientcmd.New(flags)
264-
cmds := kubecmd.NewKubectlCommand(f, os.Stdin, out, os.Stderr)
265-
cmds.Aliases = []string{"kubectl"}
266-
cmds.Use = name
267-
cmds.Short = "Kubernetes cluster management via kubectl"
268-
flags.VisitAll(func(flag *pflag.Flag) {
269-
if f := cmds.PersistentFlags().Lookup(flag.Name); f == nil {
270-
cmds.PersistentFlags().AddFlag(flag)
271-
} else {
272-
glog.V(5).Infof("already registered flag %s", flag.Name)
273-
}
274-
})
275-
cmds.PersistentFlags().Var(flags.Lookup("config").Value, "kubeconfig", "Specify a kubeconfig file to define the configuration")
276-
templates.ActsAsRootCommand(cmds, []string{"options"})
277-
cmds.AddCommand(cmd.NewCmdOptions(out))
278-
return cmds
279-
}
280-
281257
// CommandFor returns the appropriate command for this base name,
282258
// or the OpenShift CLI command.
283259
func CommandFor(basename string) *cobra.Command {
@@ -293,7 +269,7 @@ func CommandFor(basename string) *cobra.Command {
293269

294270
switch basename {
295271
case "kubectl":
296-
cmd = NewCmdKubectl(basename, out)
272+
cmd = kubecmd.NewKubectlCommand(kcmdutil.NewFactory(nil), in, out, errout)
297273
default:
298274
cmd = NewCommandCLI("oc", "oc", in, out, errout)
299275
}

test/cmd/basicresources.sh

+2-10
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,13 @@ os::cmd::expect_success_and_not_text "curl -k '${API_SCHEME}://${API_HOST}:${API
4242

4343
# variants I know I have to worry about
4444
# 1. oc (kube and openshift resources)
45-
# 2. openshift kubectl (kube and openshift resources)
46-
# 3. oadm and oc adm (kube and openshift resources)
47-
# 4 openshift cli (kube and openshift resources)
45+
# 2. oadm and oc adm (kube and openshift resources)
46+
# 3 openshift cli (kube and openshift resources)
4847

4948
# example User-Agent: oc/v1.2.0 (linux/amd64) kubernetes/bc4550d
5049
os::cmd::expect_success_and_text 'oc get pods --loglevel=7 2>&1 | grep -A4 "pods" | grep User-Agent' "oc/${kube_git_regex} .* kubernetes/"
5150
# example User-Agent: oc/v1.2.0 (linux/amd64) kubernetes/bc4550d
5251
os::cmd::expect_success_and_text 'oc get dc --loglevel=7 2>&1 | grep -A4 "deploymentconfig" | grep User-Agent' "oc/${kube_git_regex} .* kubernetes/"
53-
# example User-Agent: openshift/v1.2.0 (linux/amd64) kubernetes/bc4550d
54-
# this is probably broken and should be `kubectl/<kube version> kubernetes/...`
55-
os::cmd::expect_success_and_text 'openshift kubectl get pods --loglevel=7 2>&1 | grep -A4 "pods" | grep User-Agent' "openshift/${kube_git_regex} .* kubernetes/"
56-
# example User-Agent: openshift/v1.2.0 (linux/amd64) kubernetes/bc4550d
57-
# this is probably broken and should be `kubectl/<kube version> kubernetes/...`
58-
os::cmd::expect_success_and_text 'openshift kubectl get dc --loglevel=7 2>&1 | grep -A4 "deploymentconfig" | grep User-Agent' "openshift/${kube_git_regex} .* kubernetes/"
59-
# example User-Agent: oadm/v1.2.0 (linux/amd64) kubernetes/bc4550d
6052
# this is probably broken and should be `oadm/<oc version>... openshift/...`
6153
os::cmd::expect_success_and_text 'oadm policy reconcile-sccs --loglevel=7 2>&1 | grep -A4 "securitycontextconstraints" | grep User-Agent' "oadm/${kube_git_regex} .* kubernetes/"
6254
# example User-Agent: oc/v1.1.3 (linux/amd64) openshift/b348c2f

test/cmd/help.sh

-8
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ os::cmd::expect_success 'openshift ex'
1212
os::cmd::expect_success 'openshift admin config'
1313
os::cmd::expect_success 'openshift cli config'
1414
os::cmd::expect_success 'openshift admin policy '
15-
os::cmd::expect_success 'openshift kubectl'
16-
os::cmd::expect_success 'openshift kube'
1715
os::cmd::expect_success 'openshift admin'
1816
os::cmd::expect_success 'openshift start kubernetes'
1917
os::cmd::expect_success 'kubernetes'
@@ -35,7 +33,6 @@ os::cmd::expect_success_and_not_text 'oc -h' 'Options'
3533
os::cmd::expect_success_and_not_text 'oc -h' 'Global Options'
3634
os::cmd::expect_success_and_text 'openshift cli' 'OpenShift Client'
3735
os::cmd::expect_success_and_text 'oc types' 'Deployment Config'
38-
os::cmd::expect_success_and_text 'openshift kubectl' 'Kubernetes cluster'
3936
os::cmd::expect_success_and_text 'oadm' 'Administrative Commands'
4037
os::cmd::expect_success_and_text 'openshift admin' 'Administrative Commands'
4138
os::cmd::expect_success_and_text 'oadm' 'Component Installation:'
@@ -58,19 +55,16 @@ os::cmd::expect_success_and_text 'oc login --help' 'Options'
5855
os::cmd::expect_success_and_not_text 'oc login --help' 'Global Options'
5956
os::cmd::expect_success_and_text 'oc login --help' 'insecure-skip-tls-verify'
6057
os::cmd::expect_success_and_text 'openshift cli --help' 'OpenShift Client'
61-
os::cmd::expect_success_and_text 'openshift kubectl --help' 'Kubernetes cluster'
6258
os::cmd::expect_success_and_text 'oadm --help' 'Administrative Commands'
6359
os::cmd::expect_success_and_text 'openshift admin --help' 'Administrative Commands'
6460

6561
# help for root commands through help command must be consistent
6662
os::cmd::expect_success_and_text 'openshift help cli' 'OpenShift Client'
67-
os::cmd::expect_success_and_text 'openshift help kubectl' 'Kubernetes cluster'
6863
os::cmd::expect_success_and_text 'openshift help admin' 'Administrative Commands'
6964

7065
# help for given command with --help flag must be consistent
7166
os::cmd::expect_success_and_text 'oc get --help' 'Display one or many resources'
7267
os::cmd::expect_success_and_text 'openshift cli get --help' 'Display one or many resources'
73-
os::cmd::expect_success_and_text 'openshift kubectl get --help' 'Display one or many resources'
7468
os::cmd::expect_success_and_text 'openshift start --help' 'Start an all-in-one server'
7569
os::cmd::expect_success_and_text 'openshift start master --help' 'Start a master'
7670
os::cmd::expect_success_and_text 'openshift start node --help' 'Start a node'
@@ -83,7 +77,6 @@ os::cmd::expect_success_and_text 'oc get --help' 'oc'
8377
# help for given command through help command must be consistent
8478
os::cmd::expect_success_and_text 'oc help get' 'Display one or many resources'
8579
os::cmd::expect_success_and_text 'openshift help cli get' 'Display one or many resources'
86-
os::cmd::expect_success_and_text 'openshift help kubectl get' 'Display one or many resources'
8780
os::cmd::expect_success_and_text 'openshift help start' 'Start an all-in-one server'
8881
os::cmd::expect_success_and_text 'openshift help start master' 'Start a master'
8982
os::cmd::expect_success_and_text 'openshift help start node' 'Start a node'
@@ -102,7 +95,6 @@ os::cmd::expect_success_and_text 'oc set env --help' 'Use "oc options" for a lis
10295
# runnable commands with required flags must error consistently
10396
os::cmd::expect_failure_and_text 'oc get' 'Required resource not specified'
10497
os::cmd::expect_failure_and_text 'openshift cli get' 'Required resource not specified'
105-
os::cmd::expect_failure_and_text 'openshift kubectl get' 'Required resource not specified'
10698

10799
# commands that expect file paths must validate and error out correctly
108100
os::cmd::expect_failure_and_text 'oc login --certificate-authority=/path/to/invalid' 'no such file or directory'

0 commit comments

Comments
 (0)