Commit Graph

1028 Commits

Author SHA1 Message Date
Arda Güçlü 351ebce2c4 Stop passing source as parameter
This commit removes passing source field as parameter. Instead,
this commit returns error verb and error functions to caller function.
Caller function can add source field by generating correct message.

Kubernetes-commit: d336f7df874dc978ebd97971e1fc93d891c21e7d
2022-06-20 10:04:18 +03:00
Arda Güçlü 2ca41173d3 (kubectl apply): Split patching types into functions and refactorings
Patch type determination is done by checking existence
of resource in schema and if it exists, it uses strategic merge patch.
Otherwise, like for CRDs, it uses merge patch type.

Currently, this code portion is not easily extensible and this PR
splits required checks into their own function to increase extensibility.

Kubernetes-commit: 15512210e3e14b0c827d13334394d658dc7ddc88
2022-06-16 11:12:17 +03:00
21kyu 0bf778323e Change reflect.Ptr to reflect.Pointer
Kubernetes-commit: df168d5b5c2dab7414fc00ead1a51257ec326a98
2022-06-26 01:23:43 +09:00
Brian Pursley 7a7b2a177c Remove unused flags from kubectl run
The following flags, which do not apply to kubectl run,
have been removed:
--cascade
--filename
--force
--grace-period
--kustomize
--recursive
--timeout
--wait

These flags were being added to the run command to support
pod deletion after attach, but they are not used if set, so
they effectively do nothing.

This PR also displays an error message if the pod fails to be
deleted (when the --rm flag is used).  Previously any error
during deletion would be suppressed and the pod would remain.

This PR also adds some unit tests for run and attach with and
without the --rm flag.  As such, some minor refactoring of the
run command has been done to support mocking dependencies.

Kubernetes-commit: 25e713ba777ec1158fad749e9467601526ba096a
2022-06-21 10:51:30 -04:00
Maciej Szulik 6707e9d96c Improve run and debug attach message upon failure
Kubernetes-commit: 43c2ae479f056f9e420062e11f3251b7095c3108
2022-06-24 09:07:44 +02:00
Arda Güçlü ec010ddaa3 Remove redundant validateFlag checks
Kubernetes-commit: 5b274249400157028f1d9107b6bbd0686be2c076
2022-06-13 10:06:51 +03:00
Arda Güçlü aa46caeecd Define NoOptDefVal for validate flag
validate flag does not have default value defined when there is no
parameter passed, therefore it tries to use next irrelevant flag.

This PR defines NoOptDefVal for validate flag which is set "strict".

Kubernetes-commit: 0245e74590a658ea911f1e5cacd270960883af2d
2022-05-06 10:25:40 +03:00
Davanum Srinivas 29180f31b7 Adapt to newer APIs
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: feca7983b77be3d7d578f3d5b64cbb1be6f327af
2022-06-10 17:23:47 -04:00
Davanum Srinivas 4bf64b9877 Switch to v1.0.2 of github.com/chai2010/gettext-go
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 1ff96ede747639dbb1c7778befc79c48410e470c
2022-06-10 16:07:52 -04:00
Abirdcfly 3215e635ee update kubectl api-resources help info
Signed-off-by: Abirdcfly <fp544037857@gmail.com>

Kubernetes-commit: 58043b936aa9332deeecd57a7f48177bd05bd755
2022-06-06 10:21:17 +08:00
Daniel Helfand 76bcd89a57 include powershell in short description for kubectl completion
Kubernetes-commit: 67e692d521a5904aaaea446fd1642d2696cab61f
2022-05-03 20:56:41 -05:00
Dave Chen e0318c203f Remove `newlineReporter` custom report
The `newlineReporter` intends to print a new line after the test to
prevent the something print to the stdout and mess up the test result
while cause the tool like `go-junit-report` fail to parse the result.

But this is no longer needed based on following evidence.

- The issue that was first introduced in `go-junit-report` has already fixed in the version
referenced in `go.mod`.
- The `newlineReporter` report doesn't fix anything for `Ginkgo` v1 or V2 or `go test`, it just prints a
new line before the test summarization.

Signed-off-by: Dave Chen <dave.chen@arm.com>

Kubernetes-commit: 9953dde65dfaede9f1d481296053adc301ad9773
2022-06-01 13:09:47 +08:00
Dave Chen bdd48ac8f1 Fix the naming of the test suites
Signed-off-by: Dave Chen <dave.chen@arm.com>

Kubernetes-commit: 3c594d61567fc3cd5ef196a1419be957cdfaa5e1
2022-06-01 13:03:59 +08:00
Jian Zeng f125772691 feat(kubectl): add debug profile applier
Signed-off-by: Jian Zeng <anonymousknight96@gmail.com>

Kubernetes-commit: fd0c15cce3d66bc2b32fc6943688425ec269d97d
2021-11-12 00:57:02 +08:00
jlsong01 ec9d0484e5 add a warning printer in cli-runtime to coordinate warning style
modified:   staging/src/k8s.io/kubectl/pkg/cmd/auth/auth.go

Kubernetes-commit: 272e245f06e425fc912b1e477e8b6763850b161e
2022-02-18 20:33:38 +08:00
Arda Güçlü 81a25f37b5 Set validate functions requiring no parameters for all commands
Validate function is used to validate command options and should not get
any additional parameter. To preserve compatibility across all
kubectl commands, this PR removes all parameters in validate functions.

Kubernetes-commit: 8fb423bfabe0d53934cc94c154c7da2dc3ce1332
2022-05-17 11:38:20 +03:00
Brian Pursley 0c3ff4c860 Add unit tests for completion command
Kubernetes-commit: a8ec462e6fdbceb0a0e96446511b8b7e5e4b7781
2022-05-14 11:12:00 -04:00
Brian Pursley 96f0c72304 Add unit tests for api-resources and api-versions commands
Kubernetes-commit: 13e0120bf0662c4530df2badf1f8f73426cf9e51
2022-05-14 11:06:49 -04:00
xin.li 8207383170 update kubectl doc url
Signed-off-by: xin.li <xin.li@daocloud.io>

Kubernetes-commit: e89a87f708a03c5a8331639739982d426077ad3a
2022-05-05 21:27:52 +08:00
Philip Ottesen 13c8d95987 kubectl rollout: support recursive flag for rollout status
Kubernetes-commit: 9d8286c82ca3c79d68d36c58e69d91cbb7032b2c
2022-03-17 15:41:10 -04:00
Kazuki Suda 08a1f36bc3 Fix discovery cache TTL to 6 hours
Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>

Kubernetes-commit: d2b4c017c8c4103199a4f85ba63fd3ab659f5f42
2022-05-09 12:22:43 +09:00
Maciej Szulik aa2aec18b6 Export function returning kustomize version
Kubernetes-commit: 8074ef58677ed41468fe82ee89f020c481c6c33b
2022-04-12 11:01:08 +02:00
Arda Güçlü 02b163261f Show topologySpreadConstraints in Describe command
Currently describe command does not show `topologySpreadConstraints`
field. This PR adds support for showing topologySpreadConstraints in
describe command.For simplicity, if this field is not set, it will not show
(unlike to other core fields whose are shown as `<none>` even if they are null).

Kubernetes-commit: 64ce73f5fe2f095ba751d78aa03cf48bca42c055
2022-04-20 15:37:02 +03:00
Paco Xu 266e17f8a6 remove deprecated kubectl.kubernetes.io/default-logs-container support
Kubernetes-commit: 3a9c6f2a2f59cb05fc505f66afe2bd923a0d9f58
2022-04-02 16:40:34 +08:00
Mayank Kumar 884f866fd0 add maxunavailable to kubectl describe
Kubernetes-commit: c352fa514655bd154e69734e365477e753fa3409
2022-04-01 20:25:36 -07:00
Shubham Kuchhal e767a9773e Update rs.extensions to rs.apps
Kubernetes-commit: ce17a027477efd933775e320b1ce6c3876c136c3
2022-03-29 16:40:28 +05:30
Shubham Kuchhal bb7ded5a2e typo fix.
Kubernetes-commit: d350eb75d62bc51290826b94aa1d89bb6137595b
2022-03-30 18:57:43 +05:30
Shubham Kuchhal 32aa8d698a Updated the user and group flag.
Kubernetes-commit: bf77c2c3e7cdd67079742996cf47bac1003ffc26
2022-03-30 13:03:05 +05:30
Shubham Kuchhal 357211463f Improvement: Updated the serviceaccount flag for multiple subjects.
Kubernetes-commit: 3aa53c99a99f4dfe7d2e0faf2bf51e8252359e8d
2022-03-11 11:40:30 +05:30
Alexandre Garnier 459942a56d Do not raise an error proposing to use '--overwrite' when labeling with the same value (#105936)
* Do not propose to use '--overwrite' when labeling with the same value

* Check expected error value in label_test.TestLabelFunc

Kubernetes-commit: 10eb7092f854c71122c03752465e868bce23c0b6
2022-05-04 02:17:49 +02:00
Chok Yip Lau 7254bd442d Added --sum flag to kubectl top pod
Kubernetes-commit: 71acf56766c966653c3d1fe0ef6f3f036277d546
2021-09-16 09:28:30 -04:00
Maciej Szulik 5190a503cb Do not wrap lines if we can't read term size
Kubernetes-commit: a1c90674b5490d06ab4baccedc897e598882c457
2022-04-29 14:01:14 +02:00
James Laverack 03614470e1 Revert "Introduce APIs to support multiple ClusterCIDRs (#108290)"
This reverts commit b9792a9daef4d978c5c30b6d10cbcdfa77a9b6ac.

Kubernetes-commit: 7d57d5c70d04f652b431d2b86b8af40e119cd66a
2022-04-12 16:00:35 +01:00
Sarvesh Rangnekar f0ce177e80 Introduce APIs to support multiple ClusterCIDRs (#108290)
* Introduce networking/v1alpha1 api, ClusterCIDRConfig type

Introduce networking/v1alpha1 api group.

Add `ClusterCIDRConfig` type to networking/v1alpha1 api group, this type
will enable the NodeIPAM controller to support multiple ClusterCIDRs.

* Change ClusterCIDRConfig.NodeSelector type in api

* Fix review comments for API

* Update ClusterCIDRConfig API Spec

Introduce PerNodeHostBits field, remove PerNodeMaskSize

Kubernetes-commit: b9792a9daef4d978c5c30b6d10cbcdfa77a9b6ac
2022-03-31 06:17:21 +00:00
Katrina Verey 4424f53c23 Update kubectl kustomize to kyaml/v0.13.6, cmd/config/v0.10.6, api/v0.11.4, kustomize/v4.5.4
Kubernetes-commit: a8e1c67667288fb3aacc0a63a04b77aaac13bb4a
2022-03-28 19:22:08 -04:00
Chok Yip Lau de77e6a05b Remove generator dependency of expose.go
Kubernetes-commit: d7ab8d442b7913e5eb69fc2ce93b2b704645b089
2021-12-04 16:38:01 -05:00
Maciej Szulik 9ca2ff9172 Allow adding new verbs in AddSpecialVerb
Kubernetes-commit: 790396caba63f18ac529cf381b405390b62ad3e7
2022-03-28 12:49:02 +02:00
Filip Křepinský 0636d103cb resume kubectl cp with tail when --retries is negative
- count retries from 1 when printing info for users

Kubernetes-commit: a81f674a05a5747df1109ed3e572042caf6d607b
2022-03-16 19:59:39 +01:00
aimuz 062618c2be fix Kubectl describe node missing event
Kubectl describe node ignores the node events created by the controller
https://github.com/kubernetes/kubernetes/issues/106475

Kubernetes-commit: 8baac2ec951eba0669436d382752bfb3a38ff454
2021-11-17 16:24:26 +08:00
Daniel 12ebe4811f Fix: kubectl create -f and kubectl delete -f are not glob friendly (#102265)
* Fix: kubectl create -f and kubectl delete -f are not glob friendly

* gofmt fix

* removing unused receiver

* adding extra test

* log paths used

* fixing bad merge

* klog/v2 mod

* rebase fixes

* better error fmt

* error fmt unit test

* PR comments and tests

* Add reference to globbing to help snippets

Kubernetes-commit: 2cb3c7f706dbf266820fbde2e1b23a320e5d3de7
2022-03-28 05:45:26 +00:00
Rey Lejano b062628db1 updates for kubectl generated ref docs
Kubernetes-commit: 37a86e3e33349baa8fdfd25506dddb6009973337
2022-03-25 12:31:12 -07:00
Kevin Delgado 61f42e595f add server-side validation support to kubectl
Kubernetes-commit: fe3772890f650f9bcf020b43dc5a51fab0fa17f4
2022-03-09 14:52:32 +00:00
Arda Güçlü 11acf004c8 Remove deprecated discovery/ServerResources function
ServerResources function was deprecated and instead ServerGroupsAndResources
function is suggested.

This PR removes ServerResources function and move every place to use ServerGroupsAndResources.

Kubernetes-commit: ef39a8914291ba200bd5486c88a7575ffd4b7d1d
2021-12-22 11:14:09 +03:00
Ikko Ashimine be8cd595fc Fix typo in get_test.go
overide -> override

Kubernetes-commit: 10cdb0546aa7b89d8d6ab93d0826e4cda5c060eb
2021-12-13 22:56:22 +09:00
Maciej Szulik d2031a1eed Start deprecating long/golang version information
Kubernetes-commit: 43c09f6f9dc22771ac1b6b4459e4c2ce5d55c82a
2022-03-24 18:02:14 +01:00
Marc Khouzam cd5b039b42 Refactor completion code into its own package
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: c4f8c57b43843abd13bae677b73c622e1c30b46f
2022-03-24 09:06:05 -04:00
Marc Khouzam cd245d2e22 Support completion for the <type>/<name> form
This commit teaches the shell completion logic how to handle the
<type>/<name> form for resource specification.

It also teaches the 'exec' command how to complete its '--container/-c'
flag using container names.

Also, for commands that work on pods, kubectl will now also suggest
completion choices of the form <type>/<name> for resource types that
contain pods (see below for more details).

The following commands can now have completion of the <type>/<name>
form. Commands that accept any resource type:

annotate
apply edit-last-applied
apply view-last-applied
delete
describe
edit
get
label
patch

Commands that accept a subset of resource types:

autoscale
expose
rollout history
rollout pause
rollout restart
rollout resume
rollout status
rollout undo
scale
taint

Commands that apply to resource types that contain pods:

attach
exec
logs
port-foward

For these last four commands, the possible resource types are now
included in the completion choices.  For example:
    kubectl exec d<TAB>
will suggest
    daemonsets/   deployments/

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: cf66f5c3cbd0a0e2f223af438ee4c6bc7e4a907c
2022-03-01 10:45:59 -05:00
Yuvaraj Kakaraparthi 38487e770c kubectl: add --support to get, patch, edit and replace commands
Co-authored-by: Nikhita Raghunath <nikitaraghunath@gmail.com>

Kubernetes-commit: a5aa858d44651ba48bdce634a39b55be91216614
2021-07-07 08:30:59 -07:00
Patrick Ohly 7c4cfc5d12 enhance and fix log calls
Some of these changes are cosmetic (repeatedly calling klog.V instead of
reusing the result), others address real issues:

- Logging a message only above a certain verbosity threshold without
  recording that verbosity level (if klog.V().Enabled() { klog.Info... }):
  this matters when using a logging backend which records the verbosity
  level.

- Passing a format string with parameters to a logging function that
  doesn't do string formatting.

All of these locations where found by the enhanced logcheck tool from
https://github.com/kubernetes/klog/pull/297.

In some cases it reports false positives, but those can be suppressed with
source code comments.

Kubernetes-commit: edffc700a43e610f641907290a5152ca593bad79
2022-02-16 12:17:47 +01:00
Chok Yip Lau 6a5a78c26b Beautify kubectl help flag commands
Kubernetes-commit: 1c031d4fa8450550fa9a6bd5abe7fac45816156e
2021-09-02 13:41:07 -04:00