* cmd/kubectl: make 'kubectl logs' default to the first container.
While running 'kubectl logs <pod>', If '-c' is omited and the pod has more than one container, and no default container can be determined from annotations, this command shows an error message and exits. With this fix, it defaults to the first container in such scenarios and show its logs. This aligns behavior with what 'kubectl exec' does currently, and is more in line with KEP SIG-CLI 2227 design.
* fix unit test(forgotten)
* fix spelling typo
Kubernetes-commit: 0977a5d7cda59d5bd324bf2730846905e072fbbf
The behavior of the container defaulting in attach/exec is inconsistent
and should be unified. As a user, when we default the vast majority of
pods will have a small number of containers and so printing the container
names inline (as kubectl logs did) is more appropriate. The debug message
we printed about using describe was already longer than 99% of all pod
container names, so we were wasting user time.
Unify container selection for exec and attach to be consistent with old
behavior. Properly handle the --quiet flag (should not print in that case)
for both commands. Remove EnableCmdSuggestion and the machinery it needs.
The message now prints:
> Defaulted container "etcdctl" out of: etcdctl, etcd, etcd-metrics, etcd-ensure-env-vars (init), etcd-resources-copy (init)
Kubernetes-commit: 43e8ebbbcd3f57d18d8151efb6242f88a763b06d
Right now, there is no way to use these annotations, support multiple
`kubectl` versions, and not give users annoying warnings every time they
run `kubectl log`.
If a user is setting *both* annotations, they clearly know that the old
on is deprecated. Therefor, we should not warn them.
Kubernetes-commit: a7882d8a4264cdb9eaab9dc3d67cf0cc5afd5886
- update according to KEP: move getContainerName to helper
Signed-off-by: pacoxu <paco.xu@daocloud.io>
Kubernetes-commit: b54e823dbce08bff6fab979243663b0fea5a351f