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

move "openshift ex" -> "oc ex" #17486

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
578 changes: 578 additions & 0 deletions contrib/completions/bash/oc

Large diffs are not rendered by default.

605 changes: 0 additions & 605 deletions contrib/completions/bash/openshift

Large diffs are not rendered by default.

578 changes: 578 additions & 0 deletions contrib/completions/zsh/oc

Large diffs are not rendered by default.

605 changes: 0 additions & 605 deletions contrib/completions/zsh/openshift

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/cli_hacking_guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Commands are organized in the package structure as:

* https://github.com/openshift/origin/tree/master/pkg/oc[pkg/oc]
** https://github.com/openshift/origin/tree/master/pkg/oc/cli[pkg/cmd/cli] - `oc` or `openshift cli`, and `kubectl` commands.
** https://github.com/openshift/origin/tree/master/pkg/oc/experimental[pkg/cmd/experimental] - `openshift ex` command.
** https://github.com/openshift/origin/tree/master/pkg/oc/experimental[pkg/cmd/experimental] - `oc ex` command.

=== Command Structure

Expand Down
12 changes: 12 additions & 0 deletions docs/man/man1/.files_generated_oc
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ oc-deploy.1
oc-describe.1
oc-edit.1
oc-env.1
oc-ex-build-chain.1
oc-ex-config-patch.1
oc-ex-config.1
oc-ex-diagnostics.1
oc-ex-dockergc.1
oc-ex-ipfailover.1
oc-ex-options.1
oc-ex-prune-groups.1
oc-ex-sync-groups.1
oc-ex-validate-master-config.1
oc-ex-validate-node-config.1
oc-ex-validate.1
oc-ex.1
oc-exec.1
oc-explain.1
Expand Down
13 changes: 0 additions & 13 deletions docs/man/man1/.files_generated_openshift
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
openshift-completion.1
openshift-ex-build-chain.1
openshift-ex-config-patch.1
openshift-ex-config.1
openshift-ex-diagnostics.1
openshift-ex-dockergc.1
openshift-ex-ipfailover.1
openshift-ex-options.1
openshift-ex-prune-groups.1
openshift-ex-sync-groups.1
openshift-ex-validate-master-config.1
openshift-ex-validate-node-config.1
openshift-ex-validate.1
openshift-ex.1
openshift-options.1
openshift-start-etcd.1
openshift-start-master-api.1
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions docs/man/man1/openshift-ex.1

This file was deleted.

14 changes: 7 additions & 7 deletions hack/lib/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ readonly -f os::start::internal::configure_master
function os::start::internal::patch_master_config() {
local sudo=${USE_SUDO:+sudo}
cp "${SERVER_CONFIG_DIR}/master/master-config.yaml" "${SERVER_CONFIG_DIR}/master/master-config.orig.yaml"
openshift ex config patch "${SERVER_CONFIG_DIR}/master/master-config.orig.yaml" --patch="{\"etcdConfig\": {\"address\": \"${API_HOST}:${ETCD_PORT}\"}}" | \
openshift ex config patch - --patch="{\"etcdConfig\": {\"servingInfo\": {\"bindAddress\": \"${API_HOST}:${ETCD_PORT}\"}}}" | \
openshift ex config patch - --type json --patch="[{\"op\": \"replace\", \"path\": \"/etcdClientInfo/urls\", \"value\": [\"${API_SCHEME}://${API_HOST}:${ETCD_PORT}\"]}]" | \
openshift ex config patch - --patch="{\"etcdConfig\": {\"peerAddress\": \"${API_HOST}:${ETCD_PEER_PORT}\"}}" | \
openshift ex config patch - --patch="{\"etcdConfig\": {\"peerServingInfo\": {\"bindAddress\": \"${API_HOST}:${ETCD_PEER_PORT}\"}}}" | \
openshift ex config patch - --patch="{\"auditConfig\": {\"enabled\": true}}" | \
openshift ex config patch - --patch="{\"imagePolicyConfig\": {\"maxImagesBulkImportedPerRepository\": ${MAX_IMAGES_BULK_IMPORTED_PER_REPOSITORY:-5}}}" > "${SERVER_CONFIG_DIR}/master/master-config.yaml"
oc ex config patch "${SERVER_CONFIG_DIR}/master/master-config.orig.yaml" --patch="{\"etcdConfig\": {\"address\": \"${API_HOST}:${ETCD_PORT}\"}}" | \
oc ex config patch - --patch="{\"etcdConfig\": {\"servingInfo\": {\"bindAddress\": \"${API_HOST}:${ETCD_PORT}\"}}}" | \
oc ex config patch - --type json --patch="[{\"op\": \"replace\", \"path\": \"/etcdClientInfo/urls\", \"value\": [\"${API_SCHEME}://${API_HOST}:${ETCD_PORT}\"]}]" | \
oc ex config patch - --patch="{\"etcdConfig\": {\"peerAddress\": \"${API_HOST}:${ETCD_PEER_PORT}\"}}" | \
oc ex config patch - --patch="{\"etcdConfig\": {\"peerServingInfo\": {\"bindAddress\": \"${API_HOST}:${ETCD_PEER_PORT}\"}}}" | \
oc ex config patch - --patch="{\"auditConfig\": {\"enabled\": true}}" | \
oc ex config patch - --patch="{\"imagePolicyConfig\": {\"maxImagesBulkImportedPerRepository\": ${MAX_IMAGES_BULK_IMPORTED_PER_REPOSITORY:-5}}}" > "${SERVER_CONFIG_DIR}/master/master-config.yaml"

# Make oc use ${MASTER_CONFIG_DIR}/admin.kubeconfig, and ignore anything in the running user's $HOME dir
export ADMIN_KUBECONFIG="${MASTER_CONFIG_DIR}/admin.kubeconfig"
Expand Down
42 changes: 0 additions & 42 deletions pkg/cmd/openshift/openshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,8 @@ import (
"github.com/openshift/origin/pkg/cmd/server/start"
"github.com/openshift/origin/pkg/cmd/templates"
cmdutil "github.com/openshift/origin/pkg/cmd/util"
"github.com/openshift/origin/pkg/oc/admin"
diagnostics "github.com/openshift/origin/pkg/oc/admin/diagnostics"
sync "github.com/openshift/origin/pkg/oc/admin/groups/sync/cli"
"github.com/openshift/origin/pkg/oc/admin/validate"
"github.com/openshift/origin/pkg/oc/cli/cmd"
"github.com/openshift/origin/pkg/oc/cli/util/clientcmd"
"github.com/openshift/origin/pkg/oc/experimental/buildchain"
configcmd "github.com/openshift/origin/pkg/oc/experimental/config"
"github.com/openshift/origin/pkg/oc/experimental/dockergc"
exipfailover "github.com/openshift/origin/pkg/oc/experimental/ipfailover"
)

var (
Expand Down Expand Up @@ -103,7 +95,6 @@ func NewCommandOpenShift(name string) *cobra.Command {

startAllInOne, _ := start.NewCommandStartAllInOne(name, out, errout)
root.AddCommand(startAllInOne)
root.AddCommand(newExperimentalCommand("ex", name+" ex"))
root.AddCommand(newCompletionCommand("completion", name+" completion"))
root.AddCommand(cmd.NewCmdVersion(name, f, out, cmd.VersionOptions{PrintEtcdVersion: true, IsServer: true}))
root.AddCommand(cmd.NewCmdOptions(out))
Expand All @@ -114,39 +105,6 @@ func NewCommandOpenShift(name string) *cobra.Command {
return root
}

func newExperimentalCommand(name, fullName string) *cobra.Command {
out := os.Stdout
errout := os.Stderr

experimental := &cobra.Command{
Use: name,
Short: "Experimental commands under active development",
Long: "The commands grouped here are under development and may change without notice.",
Run: func(c *cobra.Command, args []string) {
c.SetOutput(out)
c.Help()
},
BashCompletionFunction: admin.BashCompletionFunc,
}

f := clientcmd.New(experimental.PersistentFlags())

experimental.AddCommand(validate.NewCommandValidate(validate.ValidateRecommendedName, fullName+" "+validate.ValidateRecommendedName, out, errout))
experimental.AddCommand(exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out, errout))
experimental.AddCommand(dockergc.NewCmdDockerGCConfig(f, fullName, "dockergc", out, errout))
experimental.AddCommand(buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, out))
experimental.AddCommand(configcmd.NewCmdConfig(configcmd.ConfigRecommendedName, fullName+" "+configcmd.ConfigRecommendedName, f, out, errout))
deprecatedDiag := diagnostics.NewCmdDiagnostics(diagnostics.DiagnosticsRecommendedName, fullName+" "+diagnostics.DiagnosticsRecommendedName, out)
deprecatedDiag.Deprecated = fmt.Sprintf(`use "oc adm %[1]s" to run diagnostics instead.`, diagnostics.DiagnosticsRecommendedName)
experimental.AddCommand(deprecatedDiag)
experimental.AddCommand(cmd.NewCmdOptions(out))

// these groups also live under `oc adm groups {sync,prune}` and are here only for backwards compatibility
experimental.AddCommand(sync.NewCmdSync("sync-groups", fullName+" "+"sync-groups", f, out))
experimental.AddCommand(sync.NewCmdPrune("prune-groups", fullName+" "+"prune-groups", f, out))
return experimental
}

var (
completion_long = ktemplates.LongDesc(`
Output shell completion code for the given shell (bash or zsh).
Expand Down
4 changes: 2 additions & 2 deletions pkg/oc/admin/diagnostics/diagnostics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ logic. This provides two major benefits:
Having configuration files where ansible places them means you will generally
not even need to specify where to find them. Running:

openshift ex diagnostics
oc ex diagnostics

by itself will look for master and node configs (in addition to client
config file) in the standard locations and use them if found; so this
should make the ansible-installed use case as simple as possible. It's also
very easy to use configuration files when they are not in the expected
Enterprise locations:

openshift ex diagnostics --master-config=... --node-config=...
oc ex diagnostics --master-config=... --node-config=...

Having logs in journald is necessary for the current log analysis
logic. Other usage may have logs going into files, output to stdout,
Expand Down
48 changes: 41 additions & 7 deletions pkg/oc/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import (
"github.com/openshift/origin/pkg/cmd/templates"
"github.com/openshift/origin/pkg/cmd/util/term"
"github.com/openshift/origin/pkg/oc/admin"
diagnostics "github.com/openshift/origin/pkg/oc/admin/diagnostics"
sync "github.com/openshift/origin/pkg/oc/admin/groups/sync/cli"
"github.com/openshift/origin/pkg/oc/admin/validate"
"github.com/openshift/origin/pkg/oc/cli/cmd"
"github.com/openshift/origin/pkg/oc/cli/cmd/cluster"
"github.com/openshift/origin/pkg/oc/cli/cmd/image"
Expand All @@ -30,6 +33,10 @@ import (
"github.com/openshift/origin/pkg/oc/cli/sa"
"github.com/openshift/origin/pkg/oc/cli/secrets"
"github.com/openshift/origin/pkg/oc/cli/util/clientcmd"
"github.com/openshift/origin/pkg/oc/experimental/buildchain"
configcmd "github.com/openshift/origin/pkg/oc/experimental/config"
"github.com/openshift/origin/pkg/oc/experimental/dockergc"
exipfailover "github.com/openshift/origin/pkg/oc/experimental/ipfailover"
)

const productName = `OpenShift`
Expand Down Expand Up @@ -192,13 +199,7 @@ func NewCommandCLI(name, fullName string, in io.Reader, out, errout io.Writer) *
templates.ActsAsRootCommand(cmds, filters, groups...).
ExposeFlags(loginCmd, "certificate-authority", "insecure-skip-tls-verify", "token")

// experimental commands are those that are bundled with the binary but not displayed to end users
// directly
experimental := &cobra.Command{
Use: "ex", // Because this command exposes no description, it will not be shown in help
}
experimental.AddCommand()
cmds.AddCommand(experimental)
cmds.AddCommand(newExperimentalCommand("ex", name+"ex"))

cmds.AddCommand(cmd.NewCmdPlugin(fullName, f, in, out, errout))
if name == fullName {
Expand Down Expand Up @@ -254,6 +255,39 @@ func changeSharedFlagDefaults(rootCmd *cobra.Command) {
}
}

func newExperimentalCommand(name, fullName string) *cobra.Command {
out := os.Stdout
errout := os.Stderr

experimental := &cobra.Command{
Use: name,
Short: "Experimental commands under active development",
Long: "The commands grouped here are under development and may change without notice.",
Run: func(c *cobra.Command, args []string) {
c.SetOutput(out)
c.Help()
},
BashCompletionFunction: admin.BashCompletionFunc,
}

f := clientcmd.New(experimental.PersistentFlags())

experimental.AddCommand(validate.NewCommandValidate(validate.ValidateRecommendedName, fullName+" "+validate.ValidateRecommendedName, out, errout))
experimental.AddCommand(exipfailover.NewCmdIPFailoverConfig(f, fullName, "ipfailover", out, errout))
experimental.AddCommand(dockergc.NewCmdDockerGCConfig(f, fullName, "dockergc", out, errout))
experimental.AddCommand(buildchain.NewCmdBuildChain(name, fullName+" "+buildchain.BuildChainRecommendedCommandName, f, out))
experimental.AddCommand(configcmd.NewCmdConfig(configcmd.ConfigRecommendedName, fullName+" "+configcmd.ConfigRecommendedName, f, out, errout))
deprecatedDiag := diagnostics.NewCmdDiagnostics(diagnostics.DiagnosticsRecommendedName, fullName+" "+diagnostics.DiagnosticsRecommendedName, out)
deprecatedDiag.Deprecated = fmt.Sprintf(`use "oc adm %[1]s" to run diagnostics instead.`, diagnostics.DiagnosticsRecommendedName)
experimental.AddCommand(deprecatedDiag)
experimental.AddCommand(cmd.NewCmdOptions(out))

// these groups also live under `oc adm groups {sync,prune}` and are here only for backwards compatibility
experimental.AddCommand(sync.NewCmdSync("sync-groups", fullName+" "+"sync-groups", f, out))
experimental.AddCommand(sync.NewCmdPrune("prune-groups", fullName+" "+"prune-groups", f, out))
return experimental
}

// CommandFor returns the appropriate command for this base name,
// or the OpenShift CLI command.
func CommandFor(basename string) *cobra.Command {
Expand Down
4 changes: 2 additions & 2 deletions test/cmd/diagnostics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ os::cmd::expect_failure_and_text 'oc adm diagnostics AnalyzeLogs AlsoMissing' 'N
os::cmd::expect_success_and_text 'oc adm diagnostics MetricsApiProxy' 'Skipping diagnostic: MetricsApiProxy'
os::cmd::expect_success_and_text 'oc adm diagnostics NetworkCheck --prevent-modification' 'Skipping diagnostic: NetworkCheck'

# openshift ex diagnostics is deprecated but not removed. Make sure it works until we consciously remove it.
os::cmd::expect_success 'openshift ex diagnostics ClusterRoleBindings ClusterRoles ConfigContexts '
# oc ex diagnostics is deprecated but not removed. Make sure it works until we consciously remove it.
os::cmd::expect_success 'oc ex diagnostics ClusterRoleBindings ClusterRoles ConfigContexts '
echo "diagnostics: ok"
os::test::junit::declare_suite_end
8 changes: 4 additions & 4 deletions test/cmd/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ os::test::junit::declare_suite_start "cmd/help"

# verify some default commands
os::cmd::expect_success 'openshift'
os::cmd::expect_success 'openshift ex'
os::cmd::expect_success 'kubectl'
os::cmd::expect_success 'oc'
os::cmd::expect_success 'oc ex'
os::cmd::expect_success 'origin'

# help for root commands must be consistent
Expand Down Expand Up @@ -75,9 +75,9 @@ os::cmd::expect_failure_and_text 'oc login --certificate-authority=/path/to/inva
os::cmd::expect_failure 'oc policy TYPO'
os::cmd::expect_failure 'oc secrets TYPO'

# make sure that LDAP group sync and prune exist under both parents
os::cmd::expect_success_and_text 'openshift ex sync-groups --help' 'external provider'
os::cmd::expect_success_and_text 'openshift ex prune-groups --help' 'external provider'
# make sure that LDAP group sync and prune exist under both experimental and `oc adm`
os::cmd::expect_success_and_text 'oc ex sync-groups --help' 'external provider'
os::cmd::expect_success_and_text 'oc ex prune-groups --help' 'external provider'
os::cmd::expect_success_and_text 'oc adm groups sync --help' 'external provider'
os::cmd::expect_success_and_text 'oc adm groups prune --help' 'external provider'
os::cmd::expect_success_and_text 'oc adm prune groups --help' 'external provider'
Expand Down
2 changes: 1 addition & 1 deletion test/extended/gssapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ backend='https://openshift.default.svc.cluster.local:443'

oauth_patch="$(sed "s/HOST_NAME/${host}/" "${test_data_location}/config/oauth_config.json")"
cp "${SERVER_CONFIG_DIR}/master/master-config.yaml" "${SERVER_CONFIG_DIR}/master/master-config.tmp.yaml"
openshift ex config patch "${SERVER_CONFIG_DIR}/master/master-config.tmp.yaml" --patch="${oauth_patch}" > "${SERVER_CONFIG_DIR}/master/master-config.yaml"
oc ex config patch "${SERVER_CONFIG_DIR}/master/master-config.tmp.yaml" --patch="${oauth_patch}" > "${SERVER_CONFIG_DIR}/master/master-config.yaml"
os::start::server

export KUBECONFIG="${ADMIN_KUBECONFIG}"
Expand Down
8 changes: 4 additions & 4 deletions test/extended/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,24 @@ function os::test::extended::setup () {
# put change there - only want this for extended tests
os::log::info "Turn on audit logging"
cp "${SERVER_CONFIG_DIR}/master/master-config.yaml" "${SERVER_CONFIG_DIR}/master/master-config.orig2.yaml"
openshift ex config patch "${SERVER_CONFIG_DIR}/master/master-config.orig2.yaml" --patch="{\"auditConfig\": {\"enabled\": true, \"auditFilePath\": \"${LOG_DIR}/audit.log\"}}" > "${SERVER_CONFIG_DIR}/master/master-config.yaml"
oc ex config patch "${SERVER_CONFIG_DIR}/master/master-config.orig2.yaml" --patch="{\"auditConfig\": {\"enabled\": true, \"auditFilePath\": \"${LOG_DIR}/audit.log\"}}" > "${SERVER_CONFIG_DIR}/master/master-config.yaml"

cp "${SERVER_CONFIG_DIR}/master/master-config.yaml" "${SERVER_CONFIG_DIR}/master/master-config.orig2.yaml"
openshift ex config patch "${SERVER_CONFIG_DIR}/master/master-config.orig2.yaml" --patch="{\"templateServiceBrokerConfig\": {\"templateNamespaces\": [\"openshift\"]}}" > "${SERVER_CONFIG_DIR}/master/master-config.yaml"
oc ex config patch "${SERVER_CONFIG_DIR}/master/master-config.orig2.yaml" --patch="{\"templateServiceBrokerConfig\": {\"templateNamespaces\": [\"openshift\"]}}" > "${SERVER_CONFIG_DIR}/master/master-config.yaml"

# If the XFS volume dir mount point exists enable local storage quota in node-config.yaml so these tests can pass:
if [[ -n "${LOCAL_STORAGE_QUOTA}" ]]; then
# The ec2 images usually have ~5Gi of space defined for the xfs vol for the registry; want to give /registry a good chunk of that
# to store the images created when the extended tests run
cp "${NODE_CONFIG_DIR}/node-config.yaml" "${NODE_CONFIG_DIR}/node-config.orig2.yaml"
openshift ex config patch "${NODE_CONFIG_DIR}/node-config.orig2.yaml" --patch='{"volumeConfig":{"localQuota":{"perFSGroup":"4480Mi"}}}' > "${NODE_CONFIG_DIR}/node-config.yaml"
oc ex config patch "${NODE_CONFIG_DIR}/node-config.orig2.yaml" --patch='{"volumeConfig":{"localQuota":{"perFSGroup":"4480Mi"}}}' > "${NODE_CONFIG_DIR}/node-config.yaml"
fi
os::log::info "Using VOLUME_DIR=${VOLUME_DIR}"

# This is a bit hacky, but set the pod gc threshold appropriately for the garbage_collector test
# and enable-hostpath-provisioner for StatefulSet tests
cp "${SERVER_CONFIG_DIR}/master/master-config.yaml" "${SERVER_CONFIG_DIR}/master/master-config.orig3.yaml"
openshift ex config patch "${SERVER_CONFIG_DIR}/master/master-config.orig3.yaml" --patch='{"kubernetesMasterConfig":{"controllerArguments":{"terminated-pod-gc-threshold":["100"], "enable-hostpath-provisioner":["true"]}}}' > "${SERVER_CONFIG_DIR}/master/master-config.yaml"
oc ex config patch "${SERVER_CONFIG_DIR}/master/master-config.orig3.yaml" --patch='{"kubernetesMasterConfig":{"controllerArguments":{"terminated-pod-gc-threshold":["100"], "enable-hostpath-provisioner":["true"]}}}' > "${SERVER_CONFIG_DIR}/master/master-config.yaml"

os::start::server "${API_SERVER_VERSION:-}" "${CONTROLLER_VERSION:-}" "${SKIP_NODE:-}"

Expand Down
2 changes: 1 addition & 1 deletion tools/clicheck/check_cli_conventions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
"openshift start kubernetes", // TODO enable when we upstream all these conventions
"openshift cli create quota", // TODO has examples starting with '//', enable when we upstream all these conventions
"openshift cli adm", // already checked in 'openshift admin'
"openshift ex", // we will only care about experimental when they get promoted
"openshift cli ex", // we will only care about experimental when they get promoted
"openshift cli types",
}
)
Expand Down