Commit Graph

60 Commits

Author SHA1 Message Date
Patrick Ohly 466b483531 initialize logging after flag parsing
It wasn't documented that InitLogs already uses the log flush frequency, so
some commands have called it before parsing (for example, kubectl in the
original code for logs.go). The flag never had an effect in such commands.

Fixing this turned into a major refactoring of how commands set up flags and
run their Cobra command:

- component-base/logs: implicitely registering flags during package init is an
  anti-pattern that makes it impossible to use the package in commands which
  want full control over their command line. Logging flags must be added
  explicitly now, something that the new cli.Run does automatically.

- component-base/logs: AddFlags would have crashed in kubectl-convert if it
  had been called because it relied on the global pflag.CommandLine. This
  has been fixed and kubectl-convert now has the same --log-flush-frequency
  flag as other commands.

- component-base/logs/testinit: an exception are tests where flag.CommandLine has
  to be used. This new package can be imported to add flags to that
  once per test program.

- Normalization of the klog command line flags was inconsistent. Some commands
  unintentionally didn't normalize to the recommended format with hyphens. This
  gets fixed for sample programs, but not for production programs because
  it would be a breaking change.

This refactoring has the following user-visible effects:

- The validation error for `go run ./cmd/kube-apiserver --logging-format=json
  --add-dir-header` now references `add-dir-header` instead of `add_dir_header`.

- `staging/src/k8s.io/cloud-provider/sample` uses flags with hyphen instead of
  underscore.

- `--log-flush-frequency` is not listed anymore in the --logging-format flag's
  `non-default formats don't honor these flags` usage text because it will also
  work for non-default formats once it is needed.

- `cmd/kubelet`: the description of `--logging-format` uses hyphens instead of
  underscores for the flags, which now matches what the command is using.

- `staging/src/k8s.io/component-base/logs/example/cmd`: added logging flags.

- `apiextensions-apiserver` no longer prints a useless stack trace for `main`
  when command line parsing raises an error.

Kubernetes-commit: 21d1bcd6b8498370832fa76f680d3de56837bc83
2021-09-16 18:18:35 +02:00
Stephen Augustus 55e15b6165 generated: Run hack/update-gofmt.sh
Signed-off-by: Stephen Augustus <foo@auggie.dev>

Kubernetes-commit: 481cf6fbe753b9eb2a47ced179211206b0a99540
2021-08-12 17:13:11 -04:00
atiratree 9a63531dee update translations
Kubernetes-commit: 33e6ebc8f8df47864a77c867d78216adb70cd79d
2021-07-06 20:43:49 +02:00
atiratree 9fd6965f54 update translations
- update template.pot
- reformat .po files
- regenerate .mo files
- regenarate and mark obsolete translations
- remove obsolete default/english translations

Kubernetes-commit: 194ed1408dd75ab2765d1b884128c3b7bf7c6823
2021-05-17 15:40:46 +02:00
Nabarun Pal e99a037812 kubectl: use embedded translations instead of generated bindata
Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>

Kubernetes-commit: eb75b34394964fbc325ca08a5d0b126c5ea16b6f
2021-03-04 10:26:41 +05:30
Nabarun Pal f52da0a0a3 kubectl: move translations to i18n package to kubectl staging directory
Go 1.16's embed directive doesn't allow embeding files from parent
directories. Hence, moving the translations data to inside the i18n package.

Logically speaking as well, kubectl related artifacts should be inside
the kubectl package.

Signed-off-by: Nabarun Pal <pal.nabarun95@gmail.com>

Kubernetes-commit: 5ece28b77a284b24b674278378630373196789ac
2021-03-04 09:55:12 +05:30
Chris Henzie cb8bf2d275 Update helper methods to print and parse ReadWriteOncePod access mode
Kubernetes-commit: 5f98f6cfa47e2fcfad46822638b4fd167d8c41df
2021-03-10 20:51:43 -08:00
Chris Henzie 8bd9f6c9c6 Export contains access mode helper method
Will be used during validation of PVs and PVCs

Kubernetes-commit: 358d2e0bd1ffd475274ea08494bc8d39ef0e80cc
2021-06-14 19:31:57 -07:00
Marc Khouzam ef4c461bd5 Add tests for completion utility functions
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: 46aa6045e4c383db2106307ee687abce2910153a
2021-06-05 21:11:34 -04:00
Marc Khouzam 5c679b006e Join common functions for completion
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: 9625872d1e4fd0d4d397b3ab732c6969a3a376fe
2021-05-15 21:22:42 -04:00
Katrina Verey c31d6154d6 Add --chunk-size support to kubectl describe
Kubernetes-commit: 8ad6fd6ddbf6a8e0f2cdca17583af38cf30c2bb2
2021-04-20 11:24:35 -07:00
Gautier Delorme 579299d5e2 remove go-openapi/spec
Signed-off-by: Gautier Delorme <gautier.delorme@gmail.com>

Kubernetes-commit: 34b0fcef5fc47e3fcddf7f6ca1b3e6176b2a5323
2021-04-20 17:48:33 +02:00
Clayton Coleman 56434236a4 kubectl: Inline the containers for the user in attach/exec
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
2021-02-11 11:40:25 -05:00
Maciej Szulik 10f53d93f7 Fix kubectl openapi test to use apps/v1/Deployment
Kubernetes-commit: 7c194bb3e3daaadcf0bb785a16bffb3c1add274f
2021-03-01 19:24:15 +01:00
Julian V. Modesto 04f62ffb0b Cache the OpenAPI schema for server-side dry-run.
Currently, server-side dry-run fetches the OpenAPI schema for every
single object.

This change fetches the OpenAPI schema only once.

Kubernetes-commit: caa158610dfb53de3582ed6df0eb37359206fc66
2021-01-19 16:36:14 -05:00
pacoxu 8d367eb060 move default container annotation to kubectl pkg
Kubernetes-commit: 27bd94e54d2f8a7676411b280ab9d0ac7f9e921b
2021-02-26 10:11:12 +08:00
pacoxu 360e8d2b15 feature: use default container annotation for logs and exec
- update according to KEP: move getContainerName to helper

Signed-off-by: pacoxu <paco.xu@daocloud.io>

Kubernetes-commit: b54e823dbce08bff6fab979243663b0fea5a351f
2020-12-07 15:30:30 +08:00
cpanato 1feceb70c9 add initial translation for pt_BR
Kubernetes-commit: 0697918749ad7f8997f464016f490bc1fa66a1c2
2018-03-23 13:59:35 +01:00
Derek Carr 74ecab5f7e Downward API hugepages
Kubernetes-commit: 45bd6cb186c05eb3a6cdb2cc4927bbcb50a8ff74
2020-11-06 14:22:53 -05:00
Yixiang2019 4f04245659 cleanup: fix some error log capitalization
Signed-off-by: Yixiang2019 <wang.yixiang@zte.com.cn>

Kubernetes-commit: 62710bc0341dc413bba996351f7f6ab2313f3fa1
2020-10-28 16:44:54 +08:00
Renato Viana aaaf1de578 Fixed percentage behavior in instr
fixed syntax, wrote a test

fixed a test

.

1

Update staging/src/k8s.io/apimachinery/pkg/util/intstr/intstr_test.go

Co-Authored-By: Joel Speed <Joel.speed@hotmail.co.uk>

added test

.

fix

fix test

fixed a test

gofmt

lint

fix

function name

validation fix

.

godocs added

.

Kubernetes-commit: 316eff8dee1bb7a5929a28bc07bace910bb0e126
2020-03-22 23:41:45 +00:00
Sally O'Malley 8b7900f520 When combining PolicyRules, don't duplicate verbs
Kubernetes-commit: ea23faa523c8d118a76c636544a01314619ec21c
2020-05-18 15:20:06 -04:00
Jordan Liggitt ad76eea5b3 go1.14: fix gofmt errors
Kubernetes-commit: 14845f0c2d66697be0ae8bce4e1de9d9aad6c796
2020-06-23 15:06:11 -04:00
Jordan Liggitt ad0a815d75 cmd: silence warnings in kube-controller-manager/kube-apiserver, dedupe/color warnings in kubectl
Kubernetes-commit: 0d674c4edb3af80a5630223819d9203e43679ba5
2020-06-08 15:20:19 -04:00
Jordan Liggitt cd341c1697 Add v1 CSR support to kubectl describe
Kubernetes-commit: 92a665e83f223425608e38286fdf147acb85112d
2020-06-04 12:05:51 -04:00
Davanum Srinivas 445ad1366b switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
Guangming Wang 26aadcf184 fix: add space in front of url in command desc
Kubernetes-commit: 016fe425e56f852bf2703c2548d23fb288f9ece2
2019-12-02 23:30:27 +08:00
Jordan Liggitt b0aa950238 github.com/googleapis/gnostic v0.4.1
Kubernetes-commit: 93c7b24562d80959f45c308e7412456a410b9b25
2020-03-31 17:18:56 -04:00
Davanum Srinivas 196f0c117a Move k8s.io/apiserver/pkg/util/term to k8s.io/component-base/term
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 1d057da2f73118893b5cc27c15d59ff03beb271e
2020-03-16 16:27:44 -04:00
Mike Danese 71d8052cb0 generated: run refactor
Kubernetes-commit: 3aa59f7f3077642592dc8a864fcef8ba98699894
2020-02-07 18:16:47 -08:00
Julian V. Modesto a3f7877cd1 Support DryRun in cli-runtime REST Helper.
- Move TestSupportsDryRun to cli-runtime
- Move TestDryRunVerifier to cli-runtime
- Add OpenAPI schema for testdata to cli-runtime
- Use Helper.DryRun and DryRunVerifier for Apply
- Add WithOptions methods to Helper

Kubernetes-commit: 6bea0e469bcfe4967cbf2656a998d60e0b684747
2019-12-18 22:00:34 -05:00
wojtekt 060be6d24d Immutable field and validation
Kubernetes-commit: e612ebfdff22e4bd27ad8345f7c82f074bfedf26
2019-11-26 13:29:26 +01:00
Sally O'Malley 8eb193a6c1 silence usage when pass bad cmd options
Kubernetes-commit: 35dea07ad6d17ce6b7185621753cce468c8cbc97
2019-12-28 10:43:33 -05:00
ritho b0cd1c2290 Do some Kubectl optimizations suggested by the golangci linter
The tool golangci-lint gives a bunch of warnings. This PR solves the easier/less controversial ones, so the code is simpler and a little bit more optimal, since it removes some if conditions.

Kubernetes-commit: cd2adbe760641f844d84d411f9adcf17fb6982ff
2019-06-04 01:25:43 -05:00
Sean Sullivan 3ec9685c39 Rename test/data directory to testdata
Kubernetes-commit: 4ce97d6c48ae4735463f020430dd20539a03e8c5
2019-10-31 13:40:02 -07:00
Sean Sullivan c6a8c8a72e Removes duplicate TabWriter. Several updates to reference the one remaining TabWriter in cli-runtime.
Kubernetes-commit: 958d7d3b6e74b8648fb897ce09f52049eb9823a1
2019-10-17 13:32:40 -07:00
Sally O'Malley 56a4f6edaa kubectl: remove usage info from bad flag error msg
Kubernetes-commit: e36dc3adb4045373eefc002e4afe5298ec715ce9
2019-09-01 10:22:13 -04:00
Ted Yu b89bb29485 Remove unnecessary traversal of pod.Status.Conditions
Kubernetes-commit: 936ae632a0b6e1a83f1729aeff736baebbc4e68c
2019-09-24 10:47:34 -07:00
Eric Ernst 84f773a30b kubectl: take pod overhead into account
Signed-off-by: Eric Ernst <eric.ernst@intel.com>

Kubernetes-commit: 7922d73f98aa8cc41bb27c3a819c0092bf753bc9
2019-08-25 23:55:56 -07:00
Tim Allclair f6a4bcd4ac Delete duplicate resource.Quantity.Copy()
Kubernetes-commit: 49f50484b898f55c1db1e25b2a9c2bb76fb45a5d
2019-08-19 17:23:14 -07:00
Sean Sullivan b35b1f8c56 Move pkg/kubectl/cmd/util/openapi/OWNERS to staging
Kubernetes-commit: 8f0127503d06187588fb89a8751ea4f605dbd8b6
2019-07-30 14:09:18 -07:00
Sean Sullivan a18ed087c5 Move pkg/kubectl/cmd/util/openapi to staging
Kubernetes-commit: 7a64a66d61648ff0768837593d8066d828af262c
2019-07-25 21:49:49 -07:00
Sean Sullivan c1971f30ff Moves pkg/kubectl/util/i18n to staging
Kubernetes-commit: 70984d83858eef3c9c7d046f84d45c53aead673a
2019-07-25 14:44:06 -07:00
Sean Sullivan 0b6b3151ef Move pkg/kubectl/apply.go to staging
Kubernetes-commit: 309de42878f25c8a09b13c4b4ec0488a88da4de3
2019-07-24 20:40:25 -07:00
Sean Sullivan 29453805d1 Move pkg/kubectl/util to staging
Kubernetes-commit: 7083332c634d540c2769b48e32fc4afb8f4f6cd7
2019-07-24 11:59:28 -07:00
Ted Yu 91f15560e3 Remove unnecessay call to findNewReplicaSet
Kubernetes-commit: e2ac674a712fa6b2bffa04ed645ca159386a90f5
2019-06-28 14:10:59 +08:00
Mike Dame 32e1c844d6 Move pkg/util/logs to staging and update ref
Kubernetes-commit: a710a83aa93e2d1c06ffacda3caa06c0e144ac05
2019-06-19 22:37:10 -04:00
Mike Dame da9a085a27 Move pkg/util/slice and update refs
Kubernetes-commit: 5f7dbefa036582410abb52ae54d0af6dd978904e
2019-06-19 23:24:56 -04:00
Sean Sullivan 1abdefd8c0 Move pkg/kubectl/util/fieldpath to staging
Kubernetes-commit: 6274ef995f2cb8a609a83e77a96623021e9299a5
2019-06-19 17:13:57 -07:00
Sean Sullivan fde0975f4c Move pkg/kubectl/util/certificate to staging
Kubernetes-commit: 541cb300c74c6d9b4d02fa3199f5a100c3108860
2019-06-19 13:04:40 -07:00