Compare commits

...

18 Commits

Author SHA1 Message Date
Kubernetes Publisher
33bed69e72 Fix Godeps.json to point to kubernetes-1.12.0-beta.0 tags 2018-09-08 14:16:24 +00:00
Kubernetes Publisher
791991630f Merge pull request #67178 from cblecker/cfssl
Automatic merge from submit-queue (batch tested with PRs 66602, 67178, 67207, 67125, 66332). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Vendor cfssl/cfssljson utilities

**What this PR does / why we need it**:
Vendors the `cfssl` and `cfssljson` tools. Updates `kube::util::ensure-cfssl` to use them.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
fixes #66995, fixes #60070

**Special notes for your reviewer**:
1. Add cfssl/cfssljson ot the required bins for saving
2. Manually cloned/checked out the new dependencies to my gopath. `godep restore` doesn't pull them down because they aren't required or already in the `Godeps.json`. Used @BenTheElder's list here: https://github.com/kubernetes/kubernetes/issues/66995#issuecomment-410594532
3. `hack/godep-save.sh` to add the packages and dependencies to godep
4. Fixed two bugs when building:
  a. `golang.org/x/crypto` needed to be updated
  b. `github.com/cloudflare/cfssl` needed to be updated to 56268a613a so we can vendor their fork of `crypto/tls`, as we discard their modified vendored stdlib.
5. Update staging godeps
6. Update the `kube::util::ensure-cfssl` to install from vendor

**Release note**:
```release-note
NONE
```

Kubernetes-commit: 818e632c1fde5fb01bc8ccf9b9ee6201f33a28b4
2018-08-16 13:34:53 +00:00
Kubernetes Publisher
961ecfb9a2 Merge pull request #67093 from juanvallejo/jvallejo/improve-config-context-update
Automatic merge from submit-queue (batch tested with PRs 67161, 67093, 67077). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

improve kubeconfig file modification time

In cases where there are few destination filenames for a given
amount of contexts, but a large amount of contexts, this patch
prevents reading and writing to the same file (or small number
of files) over and over again needlessly.

**Release note**:
```release-note
Decrease the amount of time it takes to modify kubeconfig files with large amounts of contexts
```

cc @deads2k

Kubernetes-commit: 3587aa4206ddf502540d388466985bb51fc4a0e6
2018-08-16 13:33:56 +00:00
Christoph Blecker
33d45c1319 Update staging godeps
Kubernetes-commit: c14a9c7c2be3f66efc62297598e4c1b98fedcb4c
2018-08-09 14:42:48 -07:00
juanvallejo
61141c1efe improve kubeconfig file modification time
Trades runtime complexity for spacial complexity when modifying
large amounts of contexts on a kubeconfig.

In cases where there are few destination filenames for a given
amount of contexts, but a large amount of contexts, this patch
prevents reading and writing to the same file (or small number
of files) over and over again needlessly.

Kubernetes-commit: d5651948cf1a14ed284b4708e2057e4cbc72bcbe
2018-08-07 15:13:57 -04:00
Kubernetes Publisher
bdfc4cfc12 Merge pull request #67024 from juanvallejo/jvallejo/add-cancel-req-discovery-rt
Automatic merge from submit-queue (batch tested with PRs 66958, 67024). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

add CancelRequest to discovery round-tripper

**Release note**:
```release-note
NONE
```

Make discovery roundtripper implement the RequestCanceler interface

cc @deads2k

Kubernetes-commit: a945b5d9281ac5cba5e4a2976a0747592c0cff87
2018-08-06 21:26:58 +00:00
juanvallejo
12e8bc7b09 add CancelRequest to discovery round-tripper
Kubernetes-commit: 07eae3a1725c65860d85956f4fda20293a8d0a9e
2018-08-06 11:51:13 -04:00
Kubernetes Publisher
02384dbe12 Merge pull request #66967 from deads2k/kubectl-09-naughty
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

stop adding internal types to external schemes

at some point someone starting internal types to external schemes in kubectl tests.  This fixes that mistake.

@kubernetes/sig-cli-maintainers
/assign @soltysh

```release-note
NONE
```

Kubernetes-commit: dab04dc6e0103c1778f047594e5405d433cff96c
2018-08-06 13:26:01 +00:00
Kubernetes Publisher
32a482af20 Merge pull request #66837 from deads2k/client-02-panic
Automatic merge from submit-queue (batch tested with PRs 66870, 66929, 66837). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

fix panic fake SAR client expansion

if the object is nil, the type assertion fails.

@kubernetes/sig-api-machinery-bugs

```release-note
NONE
```

Kubernetes-commit: a2223e9a9281ca83fd85814c8e7c32b3c8fde53f
2018-08-06 13:25:27 +00:00
Kubernetes Publisher
d0ef5a1c7d Merge pull request #66929 from deads2k/client-03-wrapping-log
Automatic merge from submit-queue (batch tested with PRs 66870, 66929, 66837). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

add logging to find offending transports

When a transport can't be cancelled, we're notified, but we don't which transport is missing the ability.  This adds logging to give us a target type.

@kubernetes/sig-api-machinery-bugs
/assign @juanvallejo

since you hit it.

```release-note
NONE
```

Kubernetes-commit: 99f96511fdb8438f85ebeb4c22c929c97fabcbb6
2018-08-06 13:25:26 +00:00
David Eads
03b9b1062a stop adding internal types to external schemes
Kubernetes-commit: 8a1eae451bb0c8eb651675cecb46db628208f003
2018-08-03 07:51:44 -04:00
Kubernetes Publisher
30599d9dba Merge pull request #66870 from apelisse/dry-run-client
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

dry-run: Update DynamicClient to pass Create/Update options

Change dynamic client to accept Create and Update options on Create/Update/Patch methods.

**What this PR does / why we need it**:

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```

Kubernetes-commit: b90485560185085ae7a8ad3fab60cb417f7654bf
2018-08-02 17:00:29 -07:00
Kubernetes Publisher
453b064209 Merge pull request #66779 from deads2k/api-05-easy-unit
Automatic merge from submit-queue (batch tested with PRs 66850, 66902, 66779, 66864, 66912). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

add methods to apimachinery to easy unit testing

When unit testing, you often want a selective scheme and codec factory.  Rather than writing the vars and the init function and the error handling, you can simply do

`scheme, codecs := testing.SchemeForInstallOrDie(install.Install)`

@kubernetes/sig-api-machinery-misc
@sttts

```release-note
NONE
```

Kubernetes-commit: 4a54f3f0d6fe73bcced14442b60981819a1744e2
2018-08-06 13:25:25 +00:00
David Eads
5f3a23fd53 add logging to find offending transports
Kubernetes-commit: 8b61c5a08846221503ad039a53e3f38328c9c127
2018-08-02 15:14:27 -04:00
Antoine Pelisse
29424b90cb dry-run: Update DynamicClient to pass Create/Update options
Kubernetes-commit: 71970d6475f6570d933fa9f22be2ebc20a9ace6f
2018-08-01 10:35:43 -07:00
David Eads
b46e3962ed generated
Kubernetes-commit: efb160c945587fbfdde3d7b24952cacb55d90450
2018-08-01 10:18:41 -04:00
David Eads
3e9a51baf5 make package name match all the import aliases
Kubernetes-commit: d3bd0eb1d5cefc25e4476d8dc086ebd90439ef4e
2018-08-01 10:01:32 -04:00
David Eads
5798b4e636 fix panic fake SAR client expansion
Kubernetes-commit: 13db7c77c968f95b8f5d7b4a041d8e89001e4f7f
2018-07-31 16:17:36 -04:00
16 changed files with 249 additions and 161 deletions

184
Godeps/Godeps.json generated
View File

@@ -188,7 +188,7 @@
},
{
"ImportPath": "golang.org/x/crypto/ssh/terminal",
"Rev": "49796115aa4b964c318aad4f3084fdb41e9aa067"
"Rev": "de0752318171da717af4ce24d0a2e8626afaeb11"
},
{
"ImportPath": "golang.org/x/net/context",
@@ -272,331 +272,331 @@
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/apps/v1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/authentication/v1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/authorization/v1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/batch/v1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/coordination/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/core/v1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/events/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/networking/v1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/rbac/v1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/scheduling/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/storage/v1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/storage/v1alpha1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "2b76beb439ecc68a523fa24b9e98b50c40fa7292"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting",
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip",
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/testing",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/naming",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "183f3326a9353bd6d41430fc80f96259331d029c"
"Rev": "d303caecb8ef47c7025a3c27fcf859cc35404073"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",

View File

@@ -107,11 +107,11 @@ type oldResourceShimType struct {
}
func (s oldResourceShimType) Create(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
return s.ResourceInterface.Create(obj, s.subresources...)
return s.ResourceInterface.Create(obj, metav1.CreateOptions{}, s.subresources...)
}
func (s oldResourceShimType) Update(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
return s.ResourceInterface.Update(obj, s.subresources...)
return s.ResourceInterface.Update(obj, metav1.UpdateOptions{}, s.subresources...)
}
func (s oldResourceShimType) Delete(name string, opts *metav1.DeleteOptions) error {
@@ -127,5 +127,5 @@ func (s oldResourceShimType) List(opts metav1.ListOptions) (runtime.Object, erro
}
func (s oldResourceShimType) Patch(name string, pt types.PatchType, data []byte) (*unstructured.Unstructured, error) {
return s.ResourceInterface.Patch(name, pt, data, s.subresources...)
return s.ResourceInterface.Patch(name, pt, data, metav1.UpdateOptions{}, s.subresources...)
}

View File

@@ -20,6 +20,7 @@ import (
"net/http"
"path/filepath"
"github.com/golang/glog"
"github.com/gregjones/httpcache"
"github.com/gregjones/httpcache/diskcache"
"github.com/peterbourgon/diskv"
@@ -47,4 +48,15 @@ func (rt *cacheRoundTripper) RoundTrip(req *http.Request) (*http.Response, error
return rt.rt.RoundTrip(req)
}
func (rt *cacheRoundTripper) CancelRequest(req *http.Request) {
type canceler interface {
CancelRequest(*http.Request)
}
if cr, ok := rt.rt.Transport.(canceler); ok {
cr.CancelRequest(req)
} else {
glog.Errorf("CancelRequest not implemented by %T", rt.rt.Transport)
}
}
func (rt *cacheRoundTripper) WrappedRoundTripper() http.RoundTripper { return rt.rt.Transport }

View File

@@ -404,7 +404,7 @@ func TestCreate(t *testing.T) {
}
defer srv.Close()
got, err := cl.Resource(resource).Namespace(tc.namespace).Create(tc.obj, tc.subresource...)
got, err := cl.Resource(resource).Namespace(tc.namespace).Create(tc.obj, metav1.CreateOptions{}, tc.subresource...)
if err != nil {
t.Errorf("unexpected error when creating %q: %v", tc.name, err)
continue
@@ -481,7 +481,7 @@ func TestUpdate(t *testing.T) {
}
defer srv.Close()
got, err := cl.Resource(resource).Namespace(tc.namespace).Update(tc.obj, tc.subresource...)
got, err := cl.Resource(resource).Namespace(tc.namespace).Update(tc.obj, metav1.UpdateOptions{}, tc.subresource...)
if err != nil {
t.Errorf("unexpected error when updating %q: %v", tc.name, err)
continue
@@ -638,7 +638,7 @@ func TestPatch(t *testing.T) {
}
defer srv.Close()
got, err := cl.Resource(resource).Namespace(tc.namespace).Patch(tc.name, types.StrategicMergePatchType, tc.patch, tc.subresource...)
got, err := cl.Resource(resource).Namespace(tc.namespace).Patch(tc.name, types.StrategicMergePatchType, tc.patch, metav1.UpdateOptions{}, tc.subresource...)
if err != nil {
t.Errorf("unexpected error when patching %q: %v", tc.name, err)
continue

View File

@@ -86,7 +86,7 @@ func (c *dynamicResourceClient) Namespace(ns string) dynamic.ResourceInterface {
return &ret
}
func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresources ...string) (*unstructured.Unstructured, error) {
func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, opts metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error) {
var uncastRet runtime.Object
var err error
switch {
@@ -132,7 +132,7 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresour
return ret, err
}
func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresources ...string) (*unstructured.Unstructured, error) {
func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) {
var uncastRet runtime.Object
var err error
switch {
@@ -168,7 +168,7 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresour
return ret, err
}
func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opts metav1.UpdateOptions) (*unstructured.Unstructured, error) {
var uncastRet runtime.Object
var err error
switch {
@@ -331,7 +331,7 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface,
panic("math broke")
}
func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*unstructured.Unstructured, error) {
func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []byte, opts metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) {
var uncastRet runtime.Object
var err error
switch {

View File

@@ -29,15 +29,15 @@ type Interface interface {
}
type ResourceInterface interface {
Create(obj *unstructured.Unstructured, subresources ...string) (*unstructured.Unstructured, error)
Update(obj *unstructured.Unstructured, subresources ...string) (*unstructured.Unstructured, error)
UpdateStatus(obj *unstructured.Unstructured) (*unstructured.Unstructured, error)
Create(obj *unstructured.Unstructured, options metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error)
Update(obj *unstructured.Unstructured, options metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error)
UpdateStatus(obj *unstructured.Unstructured, options metav1.UpdateOptions) (*unstructured.Unstructured, error)
Delete(name string, options *metav1.DeleteOptions, subresources ...string) error
DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error
Get(name string, options metav1.GetOptions, subresources ...string) (*unstructured.Unstructured, error)
List(opts metav1.ListOptions) (*unstructured.UnstructuredList, error)
Watch(opts metav1.ListOptions) (watch.Interface, error)
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*unstructured.Unstructured, error)
Patch(name string, pt types.PatchType, data []byte, options metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error)
}
type NamespaceableResourceInterface interface {

View File

@@ -82,7 +82,7 @@ func (c *dynamicResourceClient) Namespace(ns string) ResourceInterface {
return &ret
}
func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresources ...string) (*unstructured.Unstructured, error) {
func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, opts metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error) {
outBytes, err := runtime.Encode(unstructured.UnstructuredJSONScheme, obj)
if err != nil {
return nil, err
@@ -96,7 +96,12 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresour
name = accessor.GetName()
}
result := c.client.client.Post().AbsPath(append(c.makeURLSegments(name), subresources...)...).Body(outBytes).Do()
result := c.client.client.
Post().
AbsPath(append(c.makeURLSegments(name), subresources...)...).
Body(outBytes).
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Do()
if err := result.Error(); err != nil {
return nil, err
}
@@ -112,7 +117,7 @@ func (c *dynamicResourceClient) Create(obj *unstructured.Unstructured, subresour
return uncastObj.(*unstructured.Unstructured), nil
}
func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresources ...string) (*unstructured.Unstructured, error) {
func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) {
accessor, err := meta.Accessor(obj)
if err != nil {
return nil, err
@@ -122,7 +127,12 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresour
return nil, err
}
result := c.client.client.Put().AbsPath(append(c.makeURLSegments(accessor.GetName()), subresources...)...).Body(outBytes).Do()
result := c.client.client.
Put().
AbsPath(append(c.makeURLSegments(accessor.GetName()), subresources...)...).
Body(outBytes).
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Do()
if err := result.Error(); err != nil {
return nil, err
}
@@ -138,7 +148,7 @@ func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, subresour
return uncastObj.(*unstructured.Unstructured), nil
}
func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured) (*unstructured.Unstructured, error) {
func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opts metav1.UpdateOptions) (*unstructured.Unstructured, error) {
accessor, err := meta.Accessor(obj)
if err != nil {
return nil, err
@@ -149,7 +159,12 @@ func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured) (*u
return nil, err
}
result := c.client.client.Put().AbsPath(append(c.makeURLSegments(accessor.GetName()), "status")...).Body(outBytes).Do()
result := c.client.client.
Put().
AbsPath(append(c.makeURLSegments(accessor.GetName()), "status")...).
Body(outBytes).
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Do()
if err := result.Error(); err != nil {
return nil, err
}
@@ -174,7 +189,11 @@ func (c *dynamicResourceClient) Delete(name string, opts *metav1.DeleteOptions,
return err
}
result := c.client.client.Delete().AbsPath(append(c.makeURLSegments(name), subresources...)...).Body(deleteOptionsByte).Do()
result := c.client.client.
Delete().
AbsPath(append(c.makeURLSegments(name), subresources...)...).
Body(deleteOptionsByte).
Do()
return result.Error()
}
@@ -187,7 +206,12 @@ func (c *dynamicResourceClient) DeleteCollection(opts *metav1.DeleteOptions, lis
return err
}
result := c.client.client.Delete().AbsPath(c.makeURLSegments("")...).Body(deleteOptionsByte).SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).Do()
result := c.client.client.
Delete().
AbsPath(c.makeURLSegments("")...).
Body(deleteOptionsByte).
SpecificallyVersionedParams(&listOptions, dynamicParameterCodec, versionV1).
Do()
return result.Error()
}
@@ -259,8 +283,13 @@ func (c *dynamicResourceClient) Watch(opts metav1.ListOptions) (watch.Interface,
WatchWithSpecificDecoders(wrappedDecoderFn, unstructured.UnstructuredJSONScheme)
}
func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*unstructured.Unstructured, error) {
result := c.client.client.Patch(pt).AbsPath(append(c.makeURLSegments(name), subresources...)...).Body(data).Do()
func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []byte, opts metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) {
result := c.client.client.
Patch(pt).
AbsPath(append(c.makeURLSegments(name), subresources...)...).
Body(data).
SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
Do()
if err := result.Error(); err != nil {
return nil, err
}

View File

@@ -23,5 +23,8 @@ import (
func (c *FakeSubjectAccessReviews) Create(sar *authorizationapi.SubjectAccessReview) (result *authorizationapi.SubjectAccessReview, err error) {
obj, err := c.Fake.Invokes(core.NewRootCreateAction(authorizationapi.SchemeGroupVersion.WithResource("subjectaccessreviews"), sar), &authorizationapi.SubjectAccessReview{})
if obj == nil {
return nil, err
}
return obj.(*authorizationapi.SubjectAccessReview), err
}

View File

@@ -94,14 +94,10 @@ func (c *RESTClient) request(verb string) *restclient.Request {
ns := c.NegotiatedSerializer
info, _ := runtime.SerializerInfoForMediaType(ns.SupportedMediaTypes(), runtime.ContentTypeJSON)
internalVersion := schema.GroupVersion{
Group: c.GroupVersion.Group,
Version: runtime.APIVersionInternal,
}
serializers := restclient.Serializers{
// TODO this was hardcoded before, but it doesn't look right
Encoder: ns.EncoderForVersion(info.Serializer, c.GroupVersion),
Decoder: ns.DecoderToVersion(info.Serializer, internalVersion),
Decoder: ns.DecoderToVersion(info.Serializer, c.GroupVersion),
}
if info.StreamSerializer != nil {
serializers.StreamingSerializer = info.StreamSerializer.Serializer

View File

@@ -19,7 +19,7 @@ package scale
import (
"testing"
"k8s.io/apimachinery/pkg/api/testing/roundtrip"
"k8s.io/apimachinery/pkg/api/apitesting/roundtrip"
)
// NB: this can't be in the scheme package, because importing'

View File

@@ -126,6 +126,46 @@ func TestMergeContext(t *testing.T) {
matchStringArg(namespace, actual, t)
}
func TestModifyContext(t *testing.T) {
expectedCtx := map[string]bool{
"updated": true,
"clean": true,
}
pathOptions := NewDefaultPathOptions()
config := createValidTestConfig()
// define new context and assign it - our path options config
config.Contexts["updated"] = &clientcmdapi.Context{
Cluster: "updated",
AuthInfo: "updated",
}
config.CurrentContext = "updated"
if err := ModifyConfig(pathOptions, *config, true); err != nil {
t.Errorf("Unexpected error: %v", err)
}
startingConfig, err := pathOptions.GetStartingConfig()
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
// make sure the current context was updated
matchStringArg("updated", startingConfig.CurrentContext, t)
// there should now be two contexts
if len(startingConfig.Contexts) != len(expectedCtx) {
t.Fatalf("unexpected nuber of contexts, expecting %v, but found %v", len(expectedCtx), len(startingConfig.Contexts))
}
for key := range startingConfig.Contexts {
if !expectedCtx[key] {
t.Fatalf("expected context %q to exist", key)
}
}
}
func TestCertificateData(t *testing.T) {
caData := []byte("ca-data")
certData := []byte("cert-data")

View File

@@ -220,6 +220,9 @@ func ModifyConfig(configAccess ConfigAccess, newConfig clientcmdapi.Config, rela
}
}
// seenConfigs stores a map of config source filenames to computed config objects
seenConfigs := map[string]*clientcmdapi.Config{}
for key, context := range newConfig.Contexts {
startingContext, exists := startingConfig.Contexts[key]
if !reflect.DeepEqual(context, startingContext) || !exists {
@@ -228,15 +231,28 @@ func ModifyConfig(configAccess ConfigAccess, newConfig clientcmdapi.Config, rela
destinationFile = configAccess.GetDefaultFilename()
}
configToWrite, err := getConfigFromFile(destinationFile)
if err != nil {
return err
// we only obtain a fresh config object from its source file
// if we have not seen it already - this prevents us from
// reading and writing to the same number of files repeatedly
// when multiple / all contexts share the same destination file.
configToWrite, seen := seenConfigs[destinationFile]
if !seen {
var err error
configToWrite, err = getConfigFromFile(destinationFile)
if err != nil {
return err
}
seenConfigs[destinationFile] = configToWrite
}
configToWrite.Contexts[key] = context
if err := WriteToFile(*configToWrite, destinationFile); err != nil {
return err
}
configToWrite.Contexts[key] = context
}
}
// actually persist config object changes
for destinationFile, configToWrite := range seenConfigs {
if err := WriteToFile(*configToWrite, destinationFile); err != nil {
return err
}
}

View File

@@ -138,7 +138,7 @@ func (rt *authProxyRoundTripper) CancelRequest(req *http.Request) {
if canceler, ok := rt.rt.(requestCanceler); ok {
canceler.CancelRequest(req)
} else {
glog.Errorf("CancelRequest not implemented")
glog.Errorf("CancelRequest not implemented by %T", rt.rt)
}
}
@@ -166,7 +166,7 @@ func (rt *userAgentRoundTripper) CancelRequest(req *http.Request) {
if canceler, ok := rt.rt.(requestCanceler); ok {
canceler.CancelRequest(req)
} else {
glog.Errorf("CancelRequest not implemented")
glog.Errorf("CancelRequest not implemented by %T", rt.rt)
}
}
@@ -197,7 +197,7 @@ func (rt *basicAuthRoundTripper) CancelRequest(req *http.Request) {
if canceler, ok := rt.rt.(requestCanceler); ok {
canceler.CancelRequest(req)
} else {
glog.Errorf("CancelRequest not implemented")
glog.Errorf("CancelRequest not implemented by %T", rt.rt)
}
}
@@ -257,7 +257,7 @@ func (rt *impersonatingRoundTripper) CancelRequest(req *http.Request) {
if canceler, ok := rt.delegate.(requestCanceler); ok {
canceler.CancelRequest(req)
} else {
glog.Errorf("CancelRequest not implemented")
glog.Errorf("CancelRequest not implemented by %T", rt.delegate)
}
}
@@ -288,7 +288,7 @@ func (rt *bearerAuthRoundTripper) CancelRequest(req *http.Request) {
if canceler, ok := rt.rt.(requestCanceler); ok {
canceler.CancelRequest(req)
} else {
glog.Errorf("CancelRequest not implemented")
glog.Errorf("CancelRequest not implemented by %T", rt.rt)
}
}
@@ -372,7 +372,7 @@ func (rt *debuggingRoundTripper) CancelRequest(req *http.Request) {
if canceler, ok := rt.delegatedRoundTripper.(requestCanceler); ok {
canceler.CancelRequest(req)
} else {
glog.Errorf("CancelRequest not implemented")
glog.Errorf("CancelRequest not implemented by %T", rt.delegatedRoundTripper)
}
}

View File

@@ -108,9 +108,7 @@ func ReadPassword(fd int) ([]byte, error) {
return nil, err
}
defer func() {
unix.IoctlSetTermios(fd, ioctlWriteTermios, termios)
}()
defer unix.IoctlSetTermios(fd, ioctlWriteTermios, termios)
return readPasswordLine(passwordReader(fd))
}

View File

@@ -14,7 +14,7 @@ import (
// State contains the state of a terminal.
type State struct {
state *unix.Termios
termios unix.Termios
}
// IsTerminal returns true if the given file descriptor is a terminal.
@@ -75,47 +75,43 @@ func ReadPassword(fd int) ([]byte, error) {
// restored.
// see http://cr.illumos.org/~webrev/andy_js/1060/
func MakeRaw(fd int) (*State, error) {
oldTermiosPtr, err := unix.IoctlGetTermios(fd, unix.TCGETS)
termios, err := unix.IoctlGetTermios(fd, unix.TCGETS)
if err != nil {
return nil, err
}
oldTermios := *oldTermiosPtr
newTermios := oldTermios
newTermios.Iflag &^= syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON
newTermios.Oflag &^= syscall.OPOST
newTermios.Lflag &^= syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN
newTermios.Cflag &^= syscall.CSIZE | syscall.PARENB
newTermios.Cflag |= syscall.CS8
newTermios.Cc[unix.VMIN] = 1
newTermios.Cc[unix.VTIME] = 0
oldState := State{termios: *termios}
if err := unix.IoctlSetTermios(fd, unix.TCSETS, &newTermios); err != nil {
termios.Iflag &^= unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON
termios.Oflag &^= unix.OPOST
termios.Lflag &^= unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN
termios.Cflag &^= unix.CSIZE | unix.PARENB
termios.Cflag |= unix.CS8
termios.Cc[unix.VMIN] = 1
termios.Cc[unix.VTIME] = 0
if err := unix.IoctlSetTermios(fd, unix.TCSETS, termios); err != nil {
return nil, err
}
return &State{
state: oldTermiosPtr,
}, nil
return &oldState, nil
}
// Restore restores the terminal connected to the given file descriptor to a
// previous state.
func Restore(fd int, oldState *State) error {
return unix.IoctlSetTermios(fd, unix.TCSETS, oldState.state)
return unix.IoctlSetTermios(fd, unix.TCSETS, &oldState.termios)
}
// GetState returns the current state of a terminal which may be useful to
// restore the terminal after a signal.
func GetState(fd int) (*State, error) {
oldTermiosPtr, err := unix.IoctlGetTermios(fd, unix.TCGETS)
termios, err := unix.IoctlGetTermios(fd, unix.TCGETS)
if err != nil {
return nil, err
}
return &State{
state: oldTermiosPtr,
}, nil
return &State{termios: *termios}, nil
}
// GetSize returns the dimensions of the given terminal.

View File

@@ -89,9 +89,7 @@ func ReadPassword(fd int) ([]byte, error) {
return nil, err
}
defer func() {
windows.SetConsoleMode(windows.Handle(fd), old)
}()
defer windows.SetConsoleMode(windows.Handle(fd), old)
var h windows.Handle
p, _ := windows.GetCurrentProcess()