Commit Graph

690 Commits

Author SHA1 Message Date
Sean Sullivan 969a47ceed StreamTranslator and FallbackExecutor for WebSockets
Kubernetes-commit: 168998e87bfd49a1b0bc6402761fafd5ace3bb3b
2023-07-06 21:22:07 -07:00
Maciej Szulik bdf68c0441 Allow using upper and lower case true|false when setting kubectl feature flags
Kubernetes-commit: e74f2d41aabc2c27db6f2a2a005572c8dd332912
2023-10-23 11:40:41 +02:00
Arda Güçlü c2f0957625 KEP-3638: Promote plugin resolution to beta (#120663)
* Promote plugin resolution to beta

* Not use plugin for kubectl create -f command execution

`kubectl create -f` is legitimate command execution and we shouldn't
search plugins if user invokes this.

* Add integration test for plugin resolution for create command

* Reintroduce feature flag to ability to disable it explicitly

Kubernetes-commit: 074a8b00840e85cc95fd83b1825b14ab21ad09c4
2023-10-23 14:41:38 +03:00
Arda Güçlü 55333c0817 KEP-3895: Promote interactive delete to beta
Kubernetes-commit: e8564d6c5bcf5757238176f90318ae0164274af9
2023-09-05 10:40:12 +03:00
mochizuki875 04a8b4e325 add CAP_NET_RAW to netadmin profile and remove privileged
Kubernetes-commit: e22f8ed553c0c2ed86fa22c5b281ddf13577b8b1
2023-06-13 13:08:06 +09:00
ithrael 84a37fbc5d fix(test): fix error handling condition in test
Kubernetes-commit: d680bc540b5703510c95b9290bfb4317edc7b2e9
2023-08-27 21:11:39 +08:00
Arda Güçlü 507fbad069 Add shortname ambiguity warning in shortcut expander (#117668)
* Add warning handler callback function in shortcut expander

Currently, errors in client-go are propagated back to the callers via
function returns. However, there is no elegant way for just warning users.
For example, when user wants to get a resource with it's short name format
and if there are multiple resources belonging to this short name, we need to
warn user about this ambugity which one is picked and which ones are discarded.

Not only to overcome this particular case mentioned above, but also propose a
way for the possible warnings in the future, this commit adds a warningHandler
callback function in shortcutExpander.

* Add warningPrinter functionality in ConfigFlags

ConfigFlags has neither warning user in a standardized
format functionality nor passing warning callback functions to other upper level
libraries such as client-go.

This commit adds an ability that user can set warningPrinters
according to their IOStreams and this warningPrinters will be used
to raise possible warnings happening not only in cli-runtime but
also in client-go.

* Pass warning callback function in ConfigFlags to shortcutExpander

This commit passes warning callback function to print possible
warnings happened in shortcut expander to warn user in a
standardized format.

* Add integration test for CRDs having ambiguous short names

This commit adds integration test to assure that warning message
related to this ambiguity is printed when resources are being retrieved via their short name
representations in cases where multiple resources have same
short names.

This integration test also ensures that the logic behind which resource
will be selected hasn't been changed which may cause disperancies in
clusters.

* Remove defaultConfigFlag global variable

* Move default config flags initialization into function

* Skip warning for versions of same group/resource

* Run update-vendor

* Warn only once when there are multiple versions registered for ambiguous resource

* Apply gocritic review

* Add multi-resource multi-version ambiguity unit test

Kubernetes-commit: a504aed54d028dbc8ea2508142c94d309f5f1ec6
2023-10-11 19:58:38 +00:00
SataQiu 582f2b8418 kubectl: ensure '--duration' must be positive for 'kubectl create token' command
Kubernetes-commit: 4a8267f26bea6d47801ea8a18bf2635443de1a46
2023-10-07 11:19:33 +08:00
Abid Malik 64fc8b1f67 fixes the issue in the documentation of kubectl events
Signed-off-by: Abid Malik <AbidMunirMalik@gmail.com>

Kubernetes-commit: d8c145d20da7906722798218652583dea34b48bb
2023-07-13 13:10:33 -04:00
justinsb eda2d31bdd kubectl prune v2: switch to contains-group-kinds annotation
The contains-group-resources was an implementation error, we specified
contains-group-kinds in the KEP.

Because it is in alpha, we simply switch to the new annotation.

We will recognize the old annotation and migrate existing alpha
applysets, but support for this migration can be removed in beta/GA of
applyset.

Kubernetes-commit: 10caecb3b22cf93c7caa2ac70d40af9b550c0da2
2023-06-28 11:27:00 -04:00
Arda Güçlü 5691f5e6f9 Gracefully handle empty config error when local flag is used
`f.ToRawKubeConfigLoader().Namespace()` throws `ErrEmptyConfig` when
default configuration file can not be found, even if it invalid.

However, when user explicitly passes `--local` flag, that means
we can gracefully handle this error and continue. This commit does that
for the commands having `--local` flag.

Kubernetes-commit: ba49ccdbc9b4761d0c9589ab7ca9f41029a99568
2023-06-15 10:13:52 +03:00
Matthias Riegler 90963a2f06 feat: make user-defined plugins discoverable with e.g. kubectl help (#116752)
* feat: make user-defined plugins discoverable with e.g. kubectl help

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: make help text localizable & rename it

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* chore: address CRs, cleanup

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

* fix: plugin execution

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

---------

Signed-off-by: Matthias Riegler <matthias.riegler@ankorstore.com>

Kubernetes-commit: d7b7a85fbc0b3831cbc6a750a47dfdcdf777d519
2023-09-06 18:12:52 +02:00
ithrael 296dae746e fix(kubectl): kubectl events doesn't filter events by GroupVersion for resource with full name
Kubernetes-commit: 28621f1eb3f3a9ba212c844db4696f7f17450942
2023-08-23 11:34:44 +08:00
Davanum Srinivas 1fb897b3e0 New repo who dis? distribution/reference
github.com/docker/distribution/reference has a new home github.com/distribution/reference

and a new tag v0.5.0. Let's switch to that.

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

Kubernetes-commit: 889c8e919bdc8115ad579bb092a4dafdf695754e
2023-08-31 10:48:53 -04:00
ithrael 3225b852aa doc: Add example for restarting all deployments in a namespace
Kubernetes-commit: f4fc4b16b1d9837b4980850480421da318db04eb
2023-09-01 19:25:54 +08:00
ithrael e01bb717e0 doc(kubectl): Kubectl restart command without specific deployment will restart all deployments
Kubernetes-commit: 79466886a179d61b94e0ba0aa9bc39622849448f
2023-08-23 11:22:53 +08:00
adil ghaffar e112354038 adding more callbacks in kubedrain helper
Kubernetes-commit: 0323fe42e23aee176ff14f3385bc15e81216c7bb
2023-04-20 16:16:11 +03:00
Arda Güçlü 53768a14a7 Add comment about why AttachFunc be overridable
Kubernetes-commit: fa37bebcd4b239cc5ad8eb3899d9868b015b34de
2023-08-28 08:36:32 +03:00
Arda Güçlü 1e115c1960 kubectl debug: Remove legacy server support
Legacy server support for ephemeral containers were added in kubetl
debug in 1.22. Since now we are in 1.29, we can safely remove ephemeral
container legacy server support because 1.22 is already far away from
supported version skew boundary.

Kubernetes-commit: fdea6ad17d74c7f39e55d4ae2b57f2430c12eaba
2023-07-24 15:32:26 +03:00
Arda Güçlü 366796b7e2 kubectl debug: Introduce customizable AttachFunc instead static one
Currently, kubectl debug statically relies on handleAttachPod function
in order to attach to the pod.
However, external tools would want to set their own customized attach
function and this commit introduces generic `AttachFunc` function interface
which can also override by external tools.
From the point of kubectl debug, there is no functionality change.

Kubernetes-commit: baed6240468250c855a5ec235e47a64e078bd042
2023-07-24 15:28:21 +03:00
git-jxj 826006cdb9 cleanup: Update deprecated FromInt to FromInt32 (#119858)
* redo commit

* apply suggestions from liggitt

* update Parse function based on suggestions

Kubernetes-commit: a5b3a4b738e9576b68c3083de8b72002e0b45551
2023-08-16 21:07:06 +00:00
Stephen Kitt 4729836f7f Use intstr.Parse instead of reimplementing it
Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 7f53f7649e178622ad1a64988913f025399f152b
2023-07-13 12:02:26 +02:00
Andreas Karis 1b4373f26b Improve conditionFuncFor expression parsing for wait --for jsonpath
Make it possible to parse jsonpath filter expressions: Split
jsonpath expressions on single '=' only and leave '==' as part of the
string.

Reported-at: https://github.com/kubernetes/kubernetes/issues/119206
Signed-off-by: Andreas Karis <ak.karis@gmail.com>

Kubernetes-commit: 41889984304c44b879d8bcae92c9ed7aa3fd8c67
2023-06-20 03:34:50 +02:00
Arda Güçlü 042ec77890 Remove KUBECTL_EXPLAIN_OPENAPIV3 environment variable
Since explain openapiv3 has been moved to beta already, there is no
point to having this environment variable.

This PR removes it.

Kubernetes-commit: 4d8f569b037d2979c1d9c5825e5227aadfc8077f
2023-07-13 13:37:03 +03:00
Arda Güçlü 7e050c1e1d kubectl delete: Introduce new interactive flag for interactive deletion (#114530)
Kubernetes-commit: 3267dd9d5294893580538e98c1e410f64583c0cd
2023-07-11 16:05:11 +03:00
Maciej Szulik e0816cbaa1 Remove long/golang version information making short the default
Kubernetes-commit: 3f07fc3acc9014f33fb9bbde12937b35e3f48c75
2023-03-17 15:20:56 +01:00
aimuz 2ec2847518 fix: kubectl expose fails for apps with same-port, different-protocol
Fixed: https://github.com/kubernetes/kubernetes/issues/114402
Signed-off-by: aimuz <mr.imuz@gmail.com>

Kubernetes-commit: e5116a39c96a78511fc8c0da4730d3262b2c121c
2023-06-19 09:58:54 +08:00
minherz bd48fd4c16 chore: address review feedback
add integration test to wait for json without value
refactor JSON condition value parsing and validating
adjusting test to reflect the error message refactoring

Kubernetes-commit: dbdd861ea366af50fb74983426587dad7222cb89
2023-06-29 00:36:07 -07:00
minherz baf5b1c999 chore(fix): test jsonpath condition parsing errors
Test parsing logic for invalid JSONPath condition formats,
excluding JSON path expression parsing.
Fix error in parsing logic

Kubernetes-commit: a5c4fbe979188335f4f414a1aef303f1c0f353f6
2023-06-03 21:40:16 -07:00
minherz 0c921b2f35 Support JSONPath condition without value
Extend current JSONPath condition logic to return from wait on "any" value.
Change parsing JSONPath input to support the syntax without value.
Match any simple or complex (object or array) values.

Kubernetes-commit: 9d3e55ec431f3f595a7739fcc592602f7cc1d69b
2023-05-21 19:03:24 -07:00
Frederic Branczyk eca0d6a8b1 kubectl: Allow parallelizing diffing
Kubernetes-commit: 1cfb932111e53e296a3b0f001b6f5d03f212f32f
2023-06-05 13:18:49 +02:00
Varsha Prasad Narsing a49f0e6d53 [refactor] refactoring flags and options in Expose cmd
This PR decouples the command options from the input flags.
The input flags from the command are then translated to
options which are further used while running the command.

Signed-off-by: Varsha Prasad Narsing <varshaprasad96@gmail.com>

Kubernetes-commit: 8f229057484453bd1b820d00c940efbbc56addc5
2023-05-05 11:31:03 -04:00
Ritikaa96 d5606514d9 Adding review changs to update
Kubernetes-commit: fff5b35023b2b9cd9ec681e188c077225d1293a3
2023-06-16 16:33:07 +05:30
Ritikaa96 13f1a1e448 Updated kubectl explain help output
Kubernetes-commit: e213448db12abb91450028c89a9e8330d693a110
2023-06-14 12:33:18 +05:30
Ritikaa96 26d4d62bb1 Details added in kubectl explain help
Kubernetes-commit: 8c06ca68d7d3a286425ab89bcafb109e83199a94
2023-06-13 17:01:46 +05:30
Andrea Hoffer b676723184 Update CLI help text for grammar and consistency
Kubernetes-commit: a86380c7813a6d0cfa248c9165c878038730526a
2023-06-12 15:55:59 -04:00
carlory f4c3a1c36a fix Cronjob status.lastSuccessfulTime not populated by a manually triggered job
Kubernetes-commit: f2a64cb91d7cf7216db60c2e1c8b1e530c85f94f
2023-06-07 19:01:51 +08:00
Mihai Costea 900a7ab781 Remove StartupProbe on debug with pod copy
Kubernetes-commit: ea6495e8284b7eccd292c67e21a32081c4a29967
2023-06-07 15:40:10 +03:00
TommyStarK e88f1b3589 kubectl: use bytes.Buffer.String
Signed-off-by: TommyStarK <thomasmilox@gmail.com>

Kubernetes-commit: da4a8d831b933475cfdb20cb7e6d0ed027d516eb
2023-06-04 15:45:24 +02:00
LronDC 22b4cf895f Optimize usage message of commands which have subcommands.
Signed-off-by: LronDC <lun.su@daocloud.io>

Kubernetes-commit: 15678e4a67e1b725368ca1bd3a97b670c5d97776
2023-05-10 18:10:28 +08:00
HirazawaUi 08300912da fix fd leaks and failed file removing for pkg kubectl and pod-security-admission
Kubernetes-commit: b94c6daa0b7602e2d30e35cf2b94f9d1e8fde56e
2023-05-03 01:36:46 +08:00
Stephen Kitt cfd2169f88 cli: replace intstr.FromInt with intstr.FromInt32
This touches cases where FromInt() is used on numeric constants, or
values which are already int32s, or int variables which are defined
close by and can be changed to int32s with little impact.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 45836971f27ca70cd7742e8ee66e99e3c648cf9f
2023-03-14 16:17:48 +01:00
Keita Mochizuki f118a887e5 Fix: Restricted profile comply with PSS (#117543)
* restricted profile comply with PSA v1.27

* add test case

* Reflect review comments

* Reflect review comments 2

* Reflect review comments 3

Kubernetes-commit: 0813904404034fd760d8e7e1e3ca5444610a7fa8
2023-05-24 20:16:49 +09:00
Filip Křepinský a71362e506 rename err to lookupErr
Kubernetes-commit: bafae5c0764a222e336de1d7ce2645186bb455dd
2023-05-15 16:41:54 +02:00
Filip Křepinský 3ebdc043ce fix false positive kubectl plugin unit tests
- test.args should be passed instead of the os.Args of the test framework
  to prevent simple invocation of kubectl without args that could
  manifest in false positive test runs
- plugin execution should have a different test path
- tests should invoke functioning kubectl commands instead of the mock
  ones to ensure the correct subcommand is executed without a failure

Kubernetes-commit: 8b9cbe62025da49a31518870f2aea0ce9797d3ce
2023-05-11 20:12:38 +02:00
adil ghaffar 76565cfba8 Changing annotate PrintFlags from annotate to annotated
Kubernetes-commit: d6e488b998effbda9675d4dc3d297a142a4079f7
2023-05-16 14:39:15 +03:00
Arda Güçlü 1fecf3ab58 Simplify plugin resolution check function
Kubernetes-commit: daebf1c735df845f5e8429381593a4de1762361e
2023-05-15 08:51:46 +03:00
Arda Güçlü f53c5f479c Use getter function for plugin subcommand resolution
Plugin subcommand resolution is relatively less used than the
builtin subcommands. That's why, instead always initializing a
hash map on memory, it would be better to use a getter function only
serves as needed.

In addition to that this function will be exported that external
libraries can use it.

Kubernetes-commit: 4634073d0b979d2827106a0a1010456ac420baa8
2023-05-10 10:41:43 +03:00
gxwilkerson33 1b129f017b add no resources found message to rollout-status command (#117884)
* add no resources found message to rollout-status command

* return err if not nil before no resource message

Kubernetes-commit: a5575425b039bf7c15dfaa9a7acf257fdc4fde3f
2023-05-11 23:28:58 +00:00
Chris Bandy facdb16b53 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: 2181eea48435310d1b6e366ea8db2968c4941b93
2023-04-15 10:09:47 -05:00