* kubectl: strict check for exec command
Fix https://github.com/kubernetes/kubectl/issues/1745
The current implementation doesn't properly check for arguments between
the resource name and the dash separator. This can lead to unexpected
behavior when using commands like 'kubectl exec -it pod-0 bash -- run.sh',
which should raise an error but doesn't.
This fix ensures that when a dash separator (--) is used, there are no
extra arguments between the resource name and the dash.
- Only allow argsLenAtDash == 0 or == 1 (exactly one arg before --)
- Add test for extra args between pod and --
- Add test for flag-like args without dash separator
* test: add kubectl exec container flag coverage
* Apply suggestion from @soltysh
Co-authored-by: Maciej Szulik <soltysh@gmail.com>
---------
Co-authored-by: Maciej Szulik <soltysh@gmail.com>
* Remove deprecated kubectl exec command execution without dash
* Use command execution with dash in kubectl exec
* Modify unit tests to only use command after dash
`kubectl exec` command supports getting files as inputs. However,
if the file contains multiple resources, it returns unclear error message;
`cannot attach to *v1.List: selector for *v1.List not implemented`.
Since `exec` command does not support multi resources, this PR
handles that and returns descriptive error message earlier.