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

oc rsh: properly shadow position of -- #375

Conversation

ingvagabund
Copy link
Member

As of k8s 1.18, kubectl exec expects the command preceded by '--' as seen from the help:

Usage:
  kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...] [options]

If '--' is not present, kubectl exec prints the following informative message:

kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.

The message is still informative though given oc rsh does not require additional '--',
it's confusing.

In more detail 1.18 rebase brings the following lines in kubectl exec code:

if argsLenAtDash > -1 {
	p.Command = argsIn[argsLenAtDash:]
} else if len(argsIn) > 1 {
	fmt.Fprint(p.ErrOut, "kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.\n")
	p.Command = argsIn[1:]
} else if len(argsIn) > 0 && len(p.FilenameOptions.Filenames) != 0 {
	fmt.Fprint(p.ErrOut, "kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.\n")
	p.Command = argsIn[0:]
	p.ResourceName = ""
}

From oc rsh help:

$ ./oc rsh --help
Open a remote shell session to a container
 ...
Options:
  -c, --container='': Container name; defaults to first container
  -T, --no-tty=false: Disable pseudo-terminal allocation
      --pod-running-timeout=1m0s: The length of time (like 5s, 2m, or 3h, higher than zero) to wait
until at least one pod is running
      --shell='/bin/sh': Path to the shell command
  -t, --tty=false: Force a pseudo-terminal to be allocated

Use "oc options" for a list of global command-line options (applies to all commands).

there's no --filename option present (as it in kubectl exec), Thus, no need to assume else if len(argsIn) > 0 && len(p.FilenameOptions.Filenames) != 0 branch gets executed. Leaving only else if len(argsIn) > 1 case which, when argsLenAtDash is set to 1, the first if branch is executed and thus skipping the deprecated message.

As of k8s 1.18, kubectl exec expects the command preceded by '--' as seen from the help:
```
Usage:
  kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...] [options]
```

If '--' is not present, kubectl exec prints the following informative message:
```
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl kubectl exec [POD] -- [COMMAND] instead.
```

The message is still informative though given oc rsh does not require additional '--',
it's confusing.
Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ingvagabund, soltysh

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

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 6, 2020
@openshift-merge-robot openshift-merge-robot merged commit 005c62a into openshift:master Apr 6, 2020
@ingvagabund ingvagabund deleted the oc-rsh-shadow-dash-dash-position branch April 6, 2020 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants