`kubectl events` writes each event as one tab-separated row into a
tabwriter, passing the message through unchanged. A tabwriter ends a row
at a line break, so an event whose message spans several lines is printed
as extra lines that belong to no event and carry no columns, which breaks
the table.
Event messages are routinely multi-line: an exec probe failure embeds the
probe command's output verbatim, so any probe that prints more than one
line produces one.
The table printer behind `kubectl get events` already cuts a cell at its
first break character and appends "...". Do the same in the events command
so both render the same event the same way.
Signed-off-by: Shuang Zhang <stevenshuang521@gmail.com>
* kubectl: set KUBECTL_PATH environment variable during plugin execution
* Add integration tests to verify that KUBECTL_PATH environment variable is set for plugins.
* Make sure plugin integration tests use $TEMP_PATH as path and make test assertions flexible enough to handle platform differences in how os.Executable() returns either a symlink or the actual binary location.
* 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>
* Update Japanese translation for kubectl
* Update test for kubectl help
* apply kubernetes translations rules https://kubernetes.io/ja/docs/contribute/localization/#basic-policy
* Update kubectl help test string
* rebuild kubectl mo file
* fix k8s specific terms to original one
The latest pause version is 3.10.2 but due to the introduction
of the PATCH level version to the pause image (previously was
only MAJOR.MINOR), various files have remained on an older
version. Either 3.10 or 3.10.1. Our validation with
build/dependencies.yaml ./hack/verify-external-dependencies.sh
did not account for that.
* Add <...> kuberc set --section=credentialplugin
The requirement that the `--command` option be provided is no longer
valid; a solution will need to be found.
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
* Remove required mark on `--command` flag
Move the validation logic to the Validate() function
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
* Remove requirement for `--command`
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
* Add cmd test cases for kuberc
- Verify all error messages added/changed by this PR
- Verify changes are effected by at least one valid `kubectl kuberc
set` invocation with --section=credentialplugin
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
* Add unit tests for --section=credentialplugin
Additionally:
- Update allowlist-entry validation logic to check for empty string in
value of k/v pairs
- Update kuberc cmd test with this case as well
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
* Address linter complaints
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
* Update staging/src/k8s.io/kubectl/pkg/cmd/kuberc/set.go
Co-authored-by: Maciej Szulik <soltysh@gmail.com>
* Add two new test cases
Additionally:
- update error message when policy is invalid
- use utilerrors.NewAggregate instead of custom code
- add --section=credentialplugin example to cli help
- fix copypasted doc comments
- use more descriptive variable names in for loops
- avoid confusion due to variable shadowing
- fix capitalization typo
- check both validate and run errors in credentialplugin tests
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
* Improve cli help for policy flag
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
---------
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
Co-authored-by: Maciej Szulik <soltysh@gmail.com>
Remove reference to internal types in kuberc types
* Remove unserialized types from public APIs
Also remove defaulting
* Don't do conversion gen for plugin policy types
Because the plugin policy types are explicitly allowed to be empty, they
should not affect conversion. The autogenerated conversion functions for
the `Preference` type will leave those fields empty.
* Remove defaulting tests
Comments and simplifications (h/t jordan liggitt)
Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>
kube::test::if_has_string and kube::test::if_has_not_string only match
the first argument, and don't allow regular expressions, so we need to
split the checks into separate buckets, ensuring they are strictly tied
to this particular test.
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
The revised logging emits one log entry at the start of
round-tripping ("Request") and another at the end ("Response"). This avoids the
risk that related output gets interleaved by other output.
No API changes are necessary. A contextual logger is picked up from the context
of the request that is being handled. The verbosity level of that logger is
checked to determine what is supposed to be logged. This enables reducing log
details on a by-request basis by storing a `logger.V(1)` in the context of the
request.
As before, logging only gets injected into request processing at -v6 or higher,
so normally there is no additional overhead.
* 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