Commit Graph

145 Commits

Author SHA1 Message Date
devincd
f242a563ef fix typo in client-go package
Signed-off-by: devincd <505259926@qq.com>

Kubernetes-commit: 975da2fb2393350db504e50652b17c70206e1407
2023-09-08 10:31:07 +08:00
Chris Bandy
3ffcfabea2 Replace os.Setenv with testing.T.Setenv in tests
T.Setenv ensures that the environment is returned to its prior state
when the test ends. It also panics when called from a parallel test to
prevent racy test interdependencies.

Kubernetes-commit: ac5ce5cbce7ddb6ffeff755d1cf670afadb8e1fb
2023-06-05 21:03:21 -05:00
HirazawaUi
84dc0417b2 fix fd leaks and failed file removing for pkg client-go
Kubernetes-commit: 73aeed8766c2c42a6cb4fc8632b1b974f4508dde
2023-05-03 01:35:16 +08:00
Arda Güçlü
4cb373f7ca Add warning log callback in client-go loading rules (#117233)
* Add warning log callback in client-go loading rules

This provides a way to consumers use their own custom warning
mechanisms instead default klog warning.

* Use typed error instead plain string

* Fix interface change in unit test

Kubernetes-commit: 2ea6896f90c8b757d8a247d393b9a13fff2dab58
2023-05-24 18:20:07 +00:00
Chris Bandy
18ffb5c67f Replace os.Setenv with testing.T.Setenv in tests
T.Setenv ensures that the environment is returned to its prior state
when the test ends. It also panics when called from a parallel test to
prevent racy test interdependencies.

Kubernetes-commit: 89467ad3e9b051515fa9632a7373d6ef01723256
2023-04-15 10:09:47 -05:00
Tim Hockin
54190dfee5 Clean up brace whitespace in **/validation_test.go
This was making my eyes bleed as I read over code.

I used the following in vim.  I made them up on the fly, but they seemed
to pass manual inspection.

:g/},\n\s*{$/s//}, {/
:w
:g/{$\n\s*{$/s//{{/
:w
:g/^\(\s*\)},\n\1},$/s//}},/
:w
:g/^\(\s*\)},$\n\1}$/s//}}/
:w

Kubernetes-commit: d55b67b349021b6c46fc6ce78f2a36bd4217145f
2023-05-02 00:36:15 -07:00
Shiming Zhang
3b78b11d95 Add json tag
Kubernetes-commit: d0677f528c03ff5556830bc2e9b9c40824b160ee
2023-05-01 23:05:32 +08:00
Shiming Zhang
1ec6a37b5c Fix LocationOfOrigin shows up unexpectedly
Kubernetes-commit: 4d9261c7567a7498d16754b7c5bf3b9ea834e5a6
2023-04-25 10:58:07 +08:00
Tim Hockin
12553015e2 Replace uses of ObjectReflectDiff with cmp.Diff
ObjectReflectDiff is already a shim over cmp.Diff, so no actual output
or behavior changes

Kubernetes-commit: bc302fa4144d21a338683cd83701661f97be4aba
2023-03-23 11:34:03 -07:00
Marly Puckett
769443557e Update redacting functionality to redact all sensitive info in config when printing with view (#109189)
* Add RedactSecrets function

* Move RedactSecrets method to existing RawBytesData case

* Update TestRedactSecrets to use new pattern of os.CreateTemp()

Kubernetes-commit: e721272d10dd6c4d85ff613182ba0eaddcec9272
2022-11-08 17:30:10 +00:00
Shyam Jeedigunta
49ac40b489 Autogen code
Kubernetes-commit: f9c46a0e3361e19de93c02562fedfff7de448dc2
2022-09-07 18:05:42 -07:00
Shyam Jeedigunta
b8a8d94944 Add DisableCompression option to KubeConfig
Kubernetes-commit: 641fd5b482c6117d459a22d99f76aae086c3524f
2022-09-07 18:04:17 -07:00
inosato
27de641f75 Remove ioutil from client-go
Signed-off-by: inosato <si17_21@yahoo.co.jp>

Kubernetes-commit: 88dfa51b6003c90e8f0a0508939a1d79950a40df
2022-07-30 20:54:41 +09:00
Davanum Srinivas
2a6c116e40 Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: a9593d634c6a053848413e600dadbf974627515f
2022-07-19 20:54:13 -04:00
Abirdcfly
ca60e0ea14 fix a possible panic because of taking the address of nil
Signed-off-by: Abirdcfly <fp544037857@gmail.com>

Kubernetes-commit: c8c2819a4d7327f33a143f65c6af2bff5ef49735
2022-07-19 10:39:08 +08:00
Nick Santos
5ce7078061 client-go: fix panic in ConfirmUsable validation
Fixes https://github.com/kubernetes/client-go/issues/1108

Kubernetes-commit: 7d2c6096c212d9c31e7cd0bccb6dc2dec9a4ef6a
2022-06-07 15:53:16 -04:00
Arda Güçlü
a6257fdee4 Enable setting proxyurl in kubeconfig via kubectl config (#105566)
* Enable setting proxyurl in kubeconfig via kubectl config

This PR enables setting `proxy-url` in kubeconfig via kubectl config.

* Add godoc for proxy-url unit tests

Kubernetes-commit: afdde383210294c3da573decc44b5ce55cffcb94
2021-12-20 21:21:02 +00:00
Antonio Ojea
2e69bf9be0 fix unassigned error on client-go test
Kubernetes-commit: 01a0fba3620c433f49120d82f908069281482a17
2021-11-16 16:58:52 +01:00
Margo Crawford
5fca705b7d --as-uid flag in kubectl and kubeconfigs.
This corresponds to previous work to allow impersonating UIDs:
* Introduce Impersonate-UID header: #99961
* Add UID to client-go impersonation config #104483

Signed-off-by: Margo Crawford <margaretc@vmware.com>

Kubernetes-commit: 7e079f5144474cae05802771f604df2b748d781f
2021-10-19 16:12:31 -07:00
Andrey Smirnov
8f8a83c908 fix: wrap errors correct when validating kubeconfig
This allows to check for specific errors using `errors.Is`.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>

Kubernetes-commit: a5647fa417de6d17ba200f1b4bcd2bb28cceb22c
2021-09-16 22:56:08 +03:00
Jordan Liggitt
5960e3c05a Propagate conversion errors
Kubernetes-commit: ba1ca0d4591f06f796ea2d93463a4c5caaa33cc7
2021-09-13 11:49:17 -04:00
Stephen Augustus
624e6827e6 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
Andrew Keesler
37ed584bed exec credential provider: InteractiveMode support
The value here is that the exec plugin author can use the kubeconfig to assert
how standard input is treated with respect to the exec plugin, e.g.,
- an exec plugin author can ensure that kubectl fails if it cannot provide
  standard input to an exec plugin that needs it (Always)
- an exec plugin author can ensure that an client-go process will still call an
  exec plugin that prefers standard input even if standard input is not
  available (IfAvailable)

Signed-off-by: Andrew Keesler <akeesler@vmware.com>

Kubernetes-commit: cd83d89ac94c5b61fdd38840098e7223e5af0d34
2021-06-14 17:15:36 -04:00
刁浩 10284789
5b0c7191ef simplify returning boolean expression in staging/src/k8s.io/client-go/tools
Signed-off-by: 刁浩 10284789 <diao.hao@zte.com.cn>

Kubernetes-commit: 9173414da6d1c70436b256d6068e3737a7434f6a
2021-05-24 07:15:36 +00:00
Stephen Augustus
b13f594878 Fixup golang.org/x/term staticcheck warnings
Errors from staticcheck:
cmd/preferredimports/preferredimports.go:38:2:
  package golang.org/x/crypto/ssh/terminal is deprecated:
  this package moved to golang.org/x/term.  (SA1019)
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/exec.go:36:2:
  package golang.org/x/crypto/ssh/terminal is deprecated:
  this package moved to golang.org/x/term.  (SA1019)
vendor/k8s.io/client-go/tools/clientcmd/auth_loaders.go:26:2:
  package golang.org/x/crypto/ssh/terminal is deprecated:
  this package moved to golang.org/x/term.  (SA1019)

Please review the above warnings. You can test via:
  hack/verify-staticcheck.sh <failing package>
If the above warnings do not make sense, you can exempt the line or
file. See:
  https://staticcheck.io/docs/#ignoring-problems

generated:
- hack/update-internal-modules.sh
- hack/lint-dependencies.sh
- hack/update-vendor.sh

Signed-off-by: Stephen Augustus <foo@auggie.dev>

Kubernetes-commit: d9435800b65d6787beaf061546599d757b8e87c9
2021-03-02 00:14:47 -05:00
Fabian Ruff
a125444d4d Return error when persister fails to modify config
Kubernetes-commit: 9efd1fd12f646b0a328702cca4c52fdf0966212d
2021-02-16 08:45:59 +01:00
Jordan Liggitt
b620e827ab Isolate TestModifyContext from $KUBECONFIG
Kubernetes-commit: ce7e1e214a9b690f2222397c82c14c0d10905940
2021-02-01 14:03:07 -05:00
xiongzhongliang
d7ba1f2e01 use klog.Info and klog.Warning when had no format
Kubernetes-commit: 90f4aeeea4cc5f96caa6ed87c67ca7e62d1ba21c
2020-11-14 00:55:06 +08:00
Mikhail Mazurskiy
29b07456f5 Check errors of the Close call
Error from out.Close() was not checked

Kubernetes-commit: f9b928f1f13821b65ea4ef783f847993c51fb4dd
2020-06-15 21:47:08 +10:00
Mikhail Mazurskiy
6cc39819fd Make inClusterConfigProvider thread safe
If configuration object is used concurrently
it is not safe to mutate self.
There is no need for mutation so avoid it
just in case.

Kubernetes-commit: 9e360eb05efafd0fcabd5a065b62cb8226da94c2
2020-06-15 21:17:45 +10:00
Mikhail Mazurskiy
6d09f8e62e Stop using mergo.MergeWithOverwrite
Use the recommended replacement instead.

Kubernetes-commit: 243a9b204e14dc9c92f08cd3252c31731b9532fd
2020-06-15 21:11:27 +10:00
Mikhail Mazurskiy
277eea62aa Cleanup currentMigrationRules
1. Use filepath for filename manipulations
2. Restructure method logic

Kubernetes-commit: 11800147f51e85b9a4fb7eb2654cae3ded9d8cf0
2020-06-15 20:59:21 +10:00
Marek Siarkowicz
e93788d387 Add datapolicy tags to staging/src/k8s.io/client-go/
Kubernetes-commit: e29c568c4a9cd45d15665345aa015e21bcff52dd
2020-10-29 18:15:52 +01:00
Maciej Szulik
87661a7415 kubeconfig: add explicit path, if specified to loading precedence
Kubernetes-commit: 7c8e4c83fbe66548aeb446562c29c42efe1d4386
2020-07-21 15:45:36 +02:00
Andrew Keesler
a7ba87c612 exec credential provider: ProvideClusterInfo and kubeconfig shadow
- The main idea here is that we want to 1) prevent potentially large CA
  bundles from being set in an exec plugin's environment and 2) ensure
  that the exec plugin is getting everything it needs in order to talk to
  a cluster.
- Avoid breaking existing manual declarations of rest.Config instances by
  moving exec Cluster to kubeconfig internal type.
- Use client.authentication.k8s.io/exec to qualify exec cluster extension.
- Deep copy the exec Cluster.Config when we copy a rest.Config.

Signed-off-by: Andrew Keesler <akeesler@vmware.com>

Kubernetes-commit: c4299d15d5289768808034676858e76a177eeae5
2020-10-29 13:38:42 -04:00
Monis Khan
9e147f192f exec credential provider: wire in cluster info
Signed-off-by: Monis Khan <mok@vmware.com>

Kubernetes-commit: f97422c8bd57692f5a1a3aa6dc6abc31051ebc82
2020-05-06 01:01:09 -04:00
Andrew Keesler
11ef39e643 Fix typo: authentiction -> authentication
Signed-off-by: Andrew Keesler <akeesler@vmware.com>

Kubernetes-commit: eefed60e2300bdb9f5827e2da63d6949bb080d4c
2020-05-21 20:13:20 -04:00
Andrew Keesler
6b620f1777 exec credential provider: add install hint
This commit adds the ability for users to specify an install hint for
their exec credential provider binary.

In the exec credential provider workflow, if the exec credential binary
does not exist, then the user will see some sort of ugly

  exec: exec: "does-not-exist": executable file not found in $PATH

error message.  If some user downloads a kubeconfig from somewhere, they
may not know that kubectl is trying to use a binary to obtain
credentials to auth to the API, and scratch their head when they see
this error message.  Furthermore, even if a user does know that their
kubeconfig is trying to run a binary, they might not know how to obtain
the binary.  This install hint seeks to ease the above 2 user pains.

Signed-off-by: Andrew Keesler <akeesler@vmware.com>

Kubernetes-commit: 94e2065df2eef3b198942efb156ef6e27abcc6f9
2020-05-20 15:20:20 -04:00
Maciej Szulik
18374dcbea Add the ability to opt-out from config lock file
Kubernetes-commit: 3574d88e22d68fc3291bf1c8432326d0e14fa3bd
2020-06-25 17:29:32 +02:00
Dr. Stefan Schimanski
8f2b164e09 clientcmd: fix NPE in NewNonInteractiveDeferredLoadingClientConfig with nil overrides
Kubernetes-commit: 945991b40275b096707c7b9eb0f192e99bd15b6d
2020-06-26 15:59:17 +02:00
Mikhail Mazurskiy
afa880fea1 Fix data race on config.clientConfig
config.clientConfig can have an unlocked read
and a locked write

Kubernetes-commit: 609da52afaf6395d738f529c78daadc05e619f68
2020-06-15 21:53:11 +10:00
Davanum Srinivas
75fea27a27 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
Mike Danese
0caa50056a rest.Config: support configuring an explict proxy URL
With support of http, https, and socks5 proxy support. We already
support configuring this via environmnet variables, but this approach
becomes inconvenient dealing with multiple clusters on different
networks, that require different proxies to connect to. Most solutions
require wrapping clients (like kubectl) in bash scripts.

Part of: https://github.com/kubernetes/client-go/issues/351

Kubernetes-commit: f3f666d5f1f6f74a8c948a5c64af993696178244
2019-05-03 13:50:17 -07:00
Maciej Szulik
71473e9b7b Revert "stop defaulting kubeconfig to http://localhost:8080"
This reverts commit b19ad9e7a78fea0ecdffe7aa53bbe309d9d346ee.

Kubernetes-commit: a871738c86a0bdf7c3b8924d1932e6f2c85ea8d8
2020-04-17 16:37:15 +02:00
zhouya0
1c7ee45b9b Fix kubectl version should print version info
Kubernetes-commit: 948f4de2dbba3affca2de460d836158cbde5db78
2020-04-07 15:18:38 +08:00
Brian Pursley
d4a54d1ba8 Changed kubectl config view to redact token
Kubernetes-commit: 6fad4ee5e5f5fa6fbf38e88f165b012fa0ae5795
2020-03-17 15:13:50 -04:00
Alvaro Aleman
6b7675c693 Utilerrors.Aggregate: Allow using with errors.Is()
Kubernetes-commit: 212190e25e18600bbca2eb5c77aa3fe5bcc55af1
2020-02-24 15:15:04 +01:00
Maciej Szulik
3eda474fce Provide more verbose empty config error based on the context
Kubernetes-commit: 07dc17ffd9aadd9918511334e13b02dc817828a5
2020-03-03 18:42:19 +01:00
David Eads
72322d0c6d stop defaulting kubeconfig to http://localhost:8080
Kubernetes-commit: b19ad9e7a78fea0ecdffe7aa53bbe309d9d346ee
2018-04-12 09:42:25 -04:00
David Eads
32fece0e08 update override behavior for kubectl --tls-server-name
Kubernetes-commit: 9dcbc0bf909a794cf77a801bfd29e306791b1e24
2020-03-03 13:16:50 -05:00