Commit Graph

126 Commits

Author SHA1 Message Date
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
Suresh Kumar Ponnusamy
6a6b2af8ea Support TLS Server Name overrides in kubeconfig file
Signed-off-by: Suresh Kumar Ponnusamy <suresh.ponnusamy@freshworks.com>

Kubernetes-commit: 37c81ed79ac6836bce4b96f888aa407dc18d747c
2019-08-28 10:51:14 +05:30
Tim Allclair
8462896174 Ensure testing credentials are labeled as such
Kubernetes-commit: 9d3670f3586c98c02cdca93b7c98dd91fc0b87bd
2020-02-04 10:36:05 -08:00
Ted Yu
efe42e9182 Allocate map when out points to nil map
Kubernetes-commit: 53080bda9c95db33227b02b5b7df7e7737a2904e
2019-12-18 14:17:48 -08:00
Jordan Liggitt
a2a1463427 Test writing configurations with numeric names
Kubernetes-commit: 1f2feb2e7ec307fafa615e001ccb9bbac7d273db
2019-11-17 14:36:52 -05:00
wojtekt
6ec083fb70 Autogenerated
Kubernetes-commit: c7916ca081682aaf07b3476f4facdb9695ddf498
2019-10-29 09:43:45 +01:00
wojtekt
62f256057d tags
Kubernetes-commit: 4096a0aa48ce83a7ac9dd791930f13fc9587f55c
2019-10-30 08:18:36 +01:00
wojtekt
cc78c193ee Cleanup clientcmd conversion
Kubernetes-commit: 328295c635449746ca83ac0fb2c9217491d59600
2019-10-29 09:30:27 +01:00
Jordan Liggitt
24302e441b Overriding CA file should override skip TLS and CA data
Kubernetes-commit: 857572168e79430af2dbf05e9d4705dfb3f0d99b
2019-10-06 13:40:21 -04:00
RainbowMango
532b6f676e Cleanup staticcheck issues for package in client-go.
Kubernetes-commit: c8c055b3163dd2661b3f9dd1b0ffb718a61aba24
2019-08-26 20:55:32 +08:00
Peter Swica
579ad46bdc Kubectl user exec should accept zero-length environment values #652 (#78875)
* Kubectl user exec should accept zero-length environment values #652

* Changing TestValidateAuthInfoExecInvalidEnv to allow for empty strings as Exec values

Kubernetes-commit: f30af9dd6da46f0f01e38b477d455907da9f1b6c
2019-07-25 19:01:41 -04:00
Sukeesh
94daee0164 Cleanup: Audit log and error capitalization
Kubernetes-commit: 346fdbccf0ac06ab3fa0e51ab3b92fdc041bb4cc
2019-06-30 11:56:27 +09:00
Himanshu Pandey
79ec8b81e2 Added custom error message when wrong file is provided with KUBECONFIG (#78185)
* Added custom error message when wrong file is provided with KUBECONFIG

* Modified test case

* Updated the code to warn the missing files

* Renamed the variable

Kubernetes-commit: a5eedcde611658c220c56d2819bf0420aded4ed6
2019-07-10 20:24:54 -07:00
Jordan Liggitt
9ae57bd75e honor overridden tokenfile, add InClusterConfig override tests
Kubernetes-commit: 7306fb7a89739a2fb48bfeb74595a5daa25060bd
2019-05-15 08:15:02 -04:00
Mike Danese
459cb72bc6 BoundServiceAccountTokenVolume: fix InClusterConfig
Kubernetes-commit: 4198f28855cbda6dac61408fcba6f2d576a9347c
2019-05-14 09:29:16 -07:00
Davanum Srinivas
2537fc5f76 remove unused code
Change-Id: If821920ec8872e326b7d85437ad8d2620807799d

Kubernetes-commit: 7b8c9acc09d51a8f6018eafc49490102ae7cb0c4
2019-04-18 17:22:45 -04:00
Ihar Hrachyshka
e413b96486 Fixed log message in client-go
An example of incorrect log message:

{
  "component":"virtctl",
  "level":"info",
  "msg":"Config loaded from fileocp/auth/kubeconfig",
  "pos":"loader.go:359",
  "timestamp":"2019-03-07T18:50:20.923470Z"
}

Note how the resulting message has no characters between the text and
file name.

Kubernetes-commit: 65fb63a15473589f615bdfeb2f35e56414050f94
2019-03-07 08:55:43 -08:00
Andrew Lytvynov
420f3f77fb Implement fmt.Stringer on rest.Config to sanitize sensitive fields
It's very easy to add glog.Info(config) calls for debugging (or actual
logging). In some scenarios those configs will carry sensitive tokens
and those tokens will end up in logs or response bodies.
Leaking of those stringified configs compromises the cluster.

Also implement fmt.GoStringer.

Kubernetes-commit: c9ad1d7339b164dfba0846ec49fa4a52474d3e23
2018-11-02 11:39:14 -07:00
Jordan Liggitt
84dcc145e1 Use overridden config when determining if default namespace came from config
Kubernetes-commit: f19399096b8a783b943029c0083af58bdc0f29ee
2019-01-03 12:26:28 -05:00
Jordan Liggitt
66e83da33c Plumb token and token file through rest.Config
Kubernetes-commit: dba85e58debadfcb66aff2b68ba8bcc2eafeac2d
2018-12-04 11:24:29 -05:00