Update 'hack/versions' and some Kubernetes repo

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
This commit is contained in:
Yanqiang Miao 2017-11-03 15:51:14 +08:00
parent 9f2de2cd02
commit e79bf15dee
28 changed files with 897 additions and 1251 deletions

View File

@ -1,5 +1,5 @@
RUNC_VERSION=74a17296470088de3805e138d3d87c62e613dfc4 RUNC_VERSION=74a17296470088de3805e138d3d87c62e613dfc4
CNI_VERSION=v0.6.0 CNI_VERSION=v0.6.0
CONTAINERD_VERSION=564600ee79aefb0f24cbcecc90d4388bd0ea59de CONTAINERD_VERSION=564600ee79aefb0f24cbcecc90d4388bd0ea59de
CRITOOL_VERSION=8e989f8b7a716534896ee082b7b1fb47bd66df21 CRITOOL_VERSION=4e3c99777477277030734ee2c9253d44a6216955
KUBERNETES_VERSION=d9bc7f0896091ba9879743fe4c9b27f352fe8289 KUBERNETES_VERSION=b958430ec2654bac10f74abbeab402c71cf5fa3b

View File

@ -63,10 +63,10 @@ google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
google.golang.org/grpc v1.3.0 google.golang.org/grpc v1.3.0
gopkg.in/inf.v0 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4 gopkg.in/inf.v0 3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4
gopkg.in/yaml.v2 53feefa2559fb8dfa8d81baad31be332c97d6c77 gopkg.in/yaml.v2 53feefa2559fb8dfa8d81baad31be332c97d6c77
k8s.io/api 691942ee5757375d415f62c34b0f2955887c0ef6 k8s.io/api 3b04a4d688b57f29fb040d71db43f332f22bc7c4
k8s.io/apimachinery 4fd33e5925599d66528ef4f1a5c80f4aa2e27c98 k8s.io/apimachinery e9a29eff7d472df0f7da9ead5ab59b74e74a07ec
k8s.io/apiserver c1e53d745d0fe45bf7d5d44697e6eface25fceca k8s.io/apiserver d3f753a815b5b1a7f4ecc1d2fdf497dc715c98c7
k8s.io/client-go 82aa063804cf055e16e8911250f888bc216e8b61 k8s.io/client-go c80a7b81424d5cf943cc8b7f7c17c892470a6303
k8s.io/kube-openapi abfc5fbe1cf87ee697db107fdfd24c32fe4397a8 k8s.io/kube-openapi 89ae48fe8691077463af5b7fb3b6f194632c5946
k8s.io/kubernetes b958430ec2654bac10f74abbeab402c71cf5fa3b k8s.io/kubernetes b958430ec2654bac10f74abbeab402c71cf5fa3b
k8s.io/utils 4fe312863be2155a7b68acd2aff1c9221b24e68c k8s.io/utils 4fe312863be2155a7b68acd2aff1c9221b24e68c

202
vendor/k8s.io/api/LICENSE generated vendored
View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

1
vendor/k8s.io/api/README.md generated vendored
View File

@ -1 +0,0 @@
This repo is still in the experimental stage. Shortly it will contain the schema of the API that are served by the Kubernetes apiserver.

File diff suppressed because it is too large Load Diff

View File

@ -121,7 +121,7 @@ message AzureDiskVolumeSource {
// +optional // +optional
optional bool readOnly = 5; optional bool readOnly = 5;
// Expected values Shared: mulitple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared // Expected values Shared: multiple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared
optional string kind = 6; optional string kind = 6;
} }

4
vendor/k8s.io/api/core/v1/types.go generated vendored
View File

@ -1322,7 +1322,7 @@ type AzureDiskVolumeSource struct {
// the ReadOnly setting in VolumeMounts. // the ReadOnly setting in VolumeMounts.
// +optional // +optional
ReadOnly *bool `json:"readOnly,omitempty" protobuf:"varint,5,opt,name=readOnly"` ReadOnly *bool `json:"readOnly,omitempty" protobuf:"varint,5,opt,name=readOnly"`
// Expected values Shared: mulitple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared // Expected values Shared: multiple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared
Kind *AzureDataDiskKind `json:"kind,omitempty" protobuf:"bytes,6,opt,name=kind,casttype=AzureDataDiskKind"` Kind *AzureDataDiskKind `json:"kind,omitempty" protobuf:"bytes,6,opt,name=kind,casttype=AzureDataDiskKind"`
} }
@ -2469,7 +2469,7 @@ type Taint struct {
// TimeAdded represents the time at which the taint was added. // TimeAdded represents the time at which the taint was added.
// It is only written for NoExecute taints. // It is only written for NoExecute taints.
// +optional // +optional
TimeAdded metav1.Time `json:"timeAdded,omitempty" protobuf:"bytes,4,opt,name=timeAdded"` TimeAdded *metav1.Time `json:"timeAdded,omitempty" protobuf:"bytes,4,opt,name=timeAdded"`
} }
type TaintEffect string type TaintEffect string

View File

@ -76,7 +76,7 @@ var map_AzureDiskVolumeSource = map[string]string{
"cachingMode": "Host Caching mode: None, Read Only, Read Write.", "cachingMode": "Host Caching mode: None, Read Only, Read Write.",
"fsType": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.", "fsType": "Filesystem type to mount. Must be a filesystem type supported by the host operating system. Ex. \"ext4\", \"xfs\", \"ntfs\". Implicitly inferred to be \"ext4\" if unspecified.",
"readOnly": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.", "readOnly": "Defaults to false (read/write). ReadOnly here will force the ReadOnly setting in VolumeMounts.",
"kind": "Expected values Shared: mulitple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared", "kind": "Expected values Shared: multiple blob disks per storage account Dedicated: single blob disk per storage account Managed: azure managed data disk (only in managed availability set). defaults to shared",
} }
func (AzureDiskVolumeSource) SwaggerDoc() map[string]string { func (AzureDiskVolumeSource) SwaggerDoc() map[string]string {

View File

@ -5905,7 +5905,15 @@ func (in *TCPSocketAction) DeepCopy() *TCPSocketAction {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Taint) DeepCopyInto(out *Taint) { func (in *Taint) DeepCopyInto(out *Taint) {
*out = *in *out = *in
in.TimeAdded.DeepCopyInto(&out.TimeAdded) if in.TimeAdded != nil {
in, out := &in.TimeAdded, &out.TimeAdded
if *in == nil {
*out = nil
} else {
*out = new(meta_v1.Time)
(*in).DeepCopyInto(*out)
}
}
return return
} }

View File

@ -87,6 +87,7 @@ option go_package = "resource";
// +protobuf.embed=string // +protobuf.embed=string
// +protobuf.options.marshal=false // +protobuf.options.marshal=false
// +protobuf.options.(gogoproto.goproto_stringer)=false // +protobuf.options.(gogoproto.goproto_stringer)=false
// +k8s:deepcopy-gen=true
// +k8s:openapi-gen=true // +k8s:openapi-gen=true
message Quantity { message Quantity {
optional string string = 1; optional string string = 1;

View File

@ -93,6 +93,7 @@ import (
// +protobuf.embed=string // +protobuf.embed=string
// +protobuf.options.marshal=false // +protobuf.options.marshal=false
// +protobuf.options.(gogoproto.goproto_stringer)=false // +protobuf.options.(gogoproto.goproto_stringer)=false
// +k8s:deepcopy-gen=true
// +k8s:openapi-gen=true // +k8s:openapi-gen=true
type Quantity struct { type Quantity struct {
// i is the quantity in int64 scaled form, if d.Dec == nil // i is the quantity in int64 scaled form, if d.Dec == nil
@ -415,7 +416,7 @@ func (_ Quantity) OpenAPIDefinition() openapi.OpenAPIDefinition {
// Note about BinarySI: // Note about BinarySI:
// * If q.Format is set to BinarySI and q.Amount represents a non-zero value between // * If q.Format is set to BinarySI and q.Amount represents a non-zero value between
// -1 and +1, it will be emitted as if q.Format were DecimalSI. // -1 and +1, it will be emitted as if q.Format were DecimalSI.
// * Otherwise, if q.Format is set to BinarySI, frational parts of q.Amount will be // * Otherwise, if q.Format is set to BinarySI, fractional parts of q.Amount will be
// rounded up. (1.1i becomes 2i.) // rounded up. (1.1i becomes 2i.)
func (q *Quantity) CanonicalizeBytes(out []byte) (result, suffix []byte) { func (q *Quantity) CanonicalizeBytes(out []byte) (result, suffix []byte) {
if q.IsZero() { if q.IsZero() {

View File

@ -0,0 +1,44 @@
// +build !ignore_autogenerated
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package resource
import (
conversion "k8s.io/apimachinery/pkg/conversion"
reflect "reflect"
)
// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
//
// Deprecated: deepcopy registration will go away when static deepcopy is fully implemented.
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
return []conversion.GeneratedDeepCopyFunc{
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*Quantity).DeepCopyInto(out.(*Quantity))
return nil
}, InType: reflect.TypeOf(&Quantity{})},
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Quantity) DeepCopyInto(out *Quantity) {
*out = in.DeepCopy()
return
}

View File

@ -38,9 +38,6 @@ var (
AddToScheme = localSchemeBuilder.AddToScheme AddToScheme = localSchemeBuilder.AddToScheme
) )
// Copier exposes copying on this scheme.
var Copier runtime.ObjectCopier = scheme
// Codecs provides access to encoding and decoding for the scheme. // Codecs provides access to encoding and decoding for the scheme.
var Codecs = serializer.NewCodecFactory(scheme) var Codecs = serializer.NewCodecFactory(scheme)

View File

@ -175,10 +175,10 @@ func (t *MicroTime) Fuzz(c fuzz.Continue) {
if t == nil { if t == nil {
return return
} }
// Allow for about 1000 years of randomness. Leave off nanoseconds // Allow for about 1000 years of randomness. Accurate to a tenth of
// because JSON doesn't represent them so they can't round-trip // micro second. Leave off nanoseconds because JSON doesn't
// properly. // represent them so they can't round-trip properly.
t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60*1000*1000), 0) t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 1000*c.Rand.Int63n(1000000))
} }
var _ fuzz.Interface = &MicroTime{} var _ fuzz.Interface = &MicroTime{}

View File

@ -145,33 +145,13 @@ func (u *Unstructured) UnmarshalJSON(b []byte) error {
return err return err
} }
func deepCopyJSON(x interface{}) interface{} {
switch x := x.(type) {
case map[string]interface{}:
clone := make(map[string]interface{}, len(x))
for k, v := range x {
clone[k] = deepCopyJSON(v)
}
return clone
case []interface{}:
clone := make([]interface{}, len(x))
for i := range x {
clone[i] = deepCopyJSON(x[i])
}
return clone
default:
// only non-pointer values (float64, int64, bool, string) are left. These can be copied by-value.
return x
}
}
func (in *Unstructured) DeepCopy() *Unstructured { func (in *Unstructured) DeepCopy() *Unstructured {
if in == nil { if in == nil {
return nil return nil
} }
out := new(Unstructured) out := new(Unstructured)
*out = *in *out = *in
out.Object = deepCopyJSON(in.Object).(map[string]interface{}) out.Object = unstructured.DeepCopyJSON(in.Object)
return out return out
} }
@ -181,7 +161,7 @@ func (in *UnstructuredList) DeepCopy() *UnstructuredList {
} }
out := new(UnstructuredList) out := new(UnstructuredList)
*out = *in *out = *in
out.Object = deepCopyJSON(in.Object).(map[string]interface{}) out.Object = unstructured.DeepCopyJSON(in.Object)
out.Items = make([]Unstructured, len(in.Items)) out.Items = make([]Unstructured, len(in.Items))
for i := range in.Items { for i := range in.Items {
in.Items[i].DeepCopyInto(&out.Items[i]) in.Items[i].DeepCopyInto(&out.Items[i])

View File

@ -98,7 +98,7 @@ type TableRowCondition struct {
type RowConditionType string type RowConditionType string
// These are valid conditions of a row. This list is not exhaustive and new conditions may be // These are valid conditions of a row. This list is not exhaustive and new conditions may be
// inculded by other resources. // included by other resources.
const ( const (
// RowCompleted means the underlying resource has reached completion and may be given less // RowCompleted means the underlying resource has reached completion and may be given less
// visual priority than other resources. // visual priority than other resources.

View File

@ -89,9 +89,16 @@ func customMarshalValue(value reflect.Value) (reflect.Value, bool) {
} }
marshaler, ok := value.Interface().(Marshaler) marshaler, ok := value.Interface().(Marshaler)
if !ok {
if !isPointerKind(value.Kind()) && value.CanAddr() {
marshaler, ok = value.Addr().Interface().(Marshaler)
if !ok { if !ok {
return reflect.Value{}, false return reflect.Value{}, false
} }
} else {
return reflect.Value{}, false
}
}
// Don't invoke functions on nil pointers // Don't invoke functions on nil pointers
// If the type implements MarshalQueryParameter, AND the tag is not omitempty, AND the value is a nil pointer, "" seems like a reasonable response // If the type implements MarshalQueryParameter, AND the tag is not omitempty, AND the value is a nil pointer, "" seems like a reasonable response

View File

@ -29,6 +29,7 @@ import (
"sync/atomic" "sync/atomic"
apiequality "k8s.io/apimachinery/pkg/api/equality" apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff" "k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/json"
utilruntime "k8s.io/apimachinery/pkg/util/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@ -106,6 +107,8 @@ func NewConverter(mismatchDetection bool) Converter {
} }
} }
// FromUnstructured converts an object from map[string]interface{} representation into a concrete type.
// It uses encoding/json/Unmarshaler if object implements it or reflection if not.
func (c *converterImpl) FromUnstructured(u map[string]interface{}, obj interface{}) error { func (c *converterImpl) FromUnstructured(u map[string]interface{}, obj interface{}) error {
t := reflect.TypeOf(obj) t := reflect.TypeOf(obj)
value := reflect.ValueOf(obj) value := reflect.ValueOf(obj)
@ -388,19 +391,27 @@ func interfaceFromUnstructured(sv, dv reflect.Value) error {
return nil return nil
} }
// ToUnstructured converts an object into map[string]interface{} representation.
// It uses encoding/json/Marshaler if object implements it or reflection if not.
func (c *converterImpl) ToUnstructured(obj interface{}) (map[string]interface{}, error) { func (c *converterImpl) ToUnstructured(obj interface{}) (map[string]interface{}, error) {
var u map[string]interface{}
var err error
if unstr, ok := obj.(runtime.Unstructured); ok {
u = DeepCopyJSON(unstr.UnstructuredContent())
} else {
t := reflect.TypeOf(obj) t := reflect.TypeOf(obj)
value := reflect.ValueOf(obj) value := reflect.ValueOf(obj)
if t.Kind() != reflect.Ptr || value.IsNil() { if t.Kind() != reflect.Ptr || value.IsNil() {
return nil, fmt.Errorf("ToUnstructured requires a non-nil pointer to an object, got %v", t) return nil, fmt.Errorf("ToUnstructured requires a non-nil pointer to an object, got %v", t)
} }
u := &map[string]interface{}{} u = map[string]interface{}{}
err := toUnstructured(value.Elem(), reflect.ValueOf(u).Elem()) err = toUnstructured(value.Elem(), reflect.ValueOf(&u).Elem())
}
if c.mismatchDetection { if c.mismatchDetection {
newUnstr := &map[string]interface{}{} newUnstr := map[string]interface{}{}
newErr := toUnstructuredViaJSON(obj, newUnstr) newErr := toUnstructuredViaJSON(obj, &newUnstr)
if (err != nil) != (newErr != nil) { if (err != nil) != (newErr != nil) {
glog.Fatalf("ToUnstructured unexpected error for %v: error: %v", obj, err) glog.Fatalf("ToUnstructured unexpected error for %v: error: %v; newErr: %v", obj, err, newErr)
} }
if err == nil && !apiequality.Semantic.DeepEqual(u, newUnstr) { if err == nil && !apiequality.Semantic.DeepEqual(u, newUnstr) {
glog.Fatalf("ToUnstructured mismatch for %#v, diff: %v", u, diff.ObjectReflectDiff(u, newUnstr)) glog.Fatalf("ToUnstructured mismatch for %#v, diff: %v", u, diff.ObjectReflectDiff(u, newUnstr))
@ -409,7 +420,34 @@ func (c *converterImpl) ToUnstructured(obj interface{}) (map[string]interface{},
if err != nil { if err != nil {
return nil, err return nil, err
} }
return *u, nil return u, nil
}
// DeepCopyJSON deep copies the passed value, assuming it is a valid JSON representation i.e. only contains
// types produced by json.Unmarshal().
func DeepCopyJSON(x map[string]interface{}) map[string]interface{} {
return deepCopyJSON(x).(map[string]interface{})
}
func deepCopyJSON(x interface{}) interface{} {
switch x := x.(type) {
case map[string]interface{}:
clone := make(map[string]interface{}, len(x))
for k, v := range x {
clone[k] = deepCopyJSON(v)
}
return clone
case []interface{}:
clone := make([]interface{}, len(x))
for i, v := range x {
clone[i] = deepCopyJSON(v)
}
return clone
case string, int64, bool, float64, nil, encodingjson.Number:
return x
default:
panic(fmt.Errorf("cannot deep copy %T", x))
}
} }
func toUnstructuredViaJSON(obj interface{}, u *map[string]interface{}) error { func toUnstructuredViaJSON(obj interface{}, u *map[string]interface{}) error {

View File

@ -203,13 +203,6 @@ type ObjectCreater interface {
New(kind schema.GroupVersionKind) (out Object, err error) New(kind schema.GroupVersionKind) (out Object, err error)
} }
// ObjectCopier duplicates an object.
type ObjectCopier interface {
// Copy returns an exact copy of the provided Object, or an error if the
// copy could not be completed.
Copy(Object) (Object, error)
}
// ResourceVersioner provides methods for setting and retrieving // ResourceVersioner provides methods for setting and retrieving
// the resource version from an API object. // the resource version from an API object.
type ResourceVersioner interface { type ResourceVersioner interface {

View File

@ -420,20 +420,6 @@ func (s *Scheme) Default(src Object) {
} }
} }
// Copy does a deep copy of an API object.
func (s *Scheme) Copy(src Object) (Object, error) {
dst, err := s.DeepCopy(src)
if err != nil {
return nil, err
}
return dst.(Object), nil
}
// Performs a deep copy of the given object.
func (s *Scheme) DeepCopy(src interface{}) (interface{}, error) {
return s.cloner.DeepCopy(src)
}
// Convert will attempt to convert in into out. Both must be pointers. For easy // Convert will attempt to convert in into out. Both must be pointers. For easy
// testing of conversion functions. Returns an error if the conversion isn't // testing of conversion functions. Returns an error if the conversion isn't
// possible. You can call this with types that haven't been registered (for example, // possible. You can call this with types that haven't been registered (for example,
@ -501,9 +487,9 @@ func (s *Scheme) convertToVersion(copy bool, in Object, target GroupVersioner) (
// TODO: when we move to server API versions, we should completely remove the unversioned concept // TODO: when we move to server API versions, we should completely remove the unversioned concept
if unversionedKind, ok := s.unversionedTypes[t]; ok { if unversionedKind, ok := s.unversionedTypes[t]; ok {
if gvk, ok := target.KindForGroupVersionKinds([]schema.GroupVersionKind{unversionedKind}); ok { if gvk, ok := target.KindForGroupVersionKinds([]schema.GroupVersionKind{unversionedKind}); ok {
return copyAndSetTargetKind(copy, s, in, gvk) return copyAndSetTargetKind(copy, in, gvk)
} }
return copyAndSetTargetKind(copy, s, in, unversionedKind) return copyAndSetTargetKind(copy, in, unversionedKind)
} }
return nil, NewNotRegisteredErrForTarget(t, target) return nil, NewNotRegisteredErrForTarget(t, target)
@ -512,16 +498,16 @@ func (s *Scheme) convertToVersion(copy bool, in Object, target GroupVersioner) (
// target wants to use the existing type, set kind and return (no conversion necessary) // target wants to use the existing type, set kind and return (no conversion necessary)
for _, kind := range kinds { for _, kind := range kinds {
if gvk == kind { if gvk == kind {
return copyAndSetTargetKind(copy, s, in, gvk) return copyAndSetTargetKind(copy, in, gvk)
} }
} }
// type is unversioned, no conversion necessary // type is unversioned, no conversion necessary
if unversionedKind, ok := s.unversionedTypes[t]; ok { if unversionedKind, ok := s.unversionedTypes[t]; ok {
if gvk, ok := target.KindForGroupVersionKinds([]schema.GroupVersionKind{unversionedKind}); ok { if gvk, ok := target.KindForGroupVersionKinds([]schema.GroupVersionKind{unversionedKind}); ok {
return copyAndSetTargetKind(copy, s, in, gvk) return copyAndSetTargetKind(copy, in, gvk)
} }
return copyAndSetTargetKind(copy, s, in, unversionedKind) return copyAndSetTargetKind(copy, in, unversionedKind)
} }
out, err := s.New(gvk) out, err := s.New(gvk)
@ -549,7 +535,7 @@ func (s *Scheme) generateConvertMeta(in interface{}) (conversion.FieldMatchingFl
} }
// copyAndSetTargetKind performs a conditional copy before returning the object, or an error if copy was not successful. // copyAndSetTargetKind performs a conditional copy before returning the object, or an error if copy was not successful.
func copyAndSetTargetKind(copy bool, copier ObjectCopier, obj Object, kind schema.GroupVersionKind) (Object, error) { func copyAndSetTargetKind(copy bool, obj Object, kind schema.GroupVersionKind) (Object, error) {
if copy { if copy {
obj = obj.DeepCopyObject() obj = obj.DeepCopyObject()
} }

View File

@ -21,7 +21,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
) )
// NewCodecForScheme is a convenience method for callers that are using a scheme. // NewCodecForScheme is a convenience method for callers that are using a scheme.
@ -33,7 +32,7 @@ func NewCodecForScheme(
encodeVersion runtime.GroupVersioner, encodeVersion runtime.GroupVersioner,
decodeVersion runtime.GroupVersioner, decodeVersion runtime.GroupVersioner,
) runtime.Codec { ) runtime.Codec {
return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, nil, encodeVersion, decodeVersion) return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, nil, encodeVersion, decodeVersion)
} }
// NewDefaultingCodecForScheme is a convenience method for callers that are using a scheme. // NewDefaultingCodecForScheme is a convenience method for callers that are using a scheme.
@ -45,7 +44,7 @@ func NewDefaultingCodecForScheme(
encodeVersion runtime.GroupVersioner, encodeVersion runtime.GroupVersioner,
decodeVersion runtime.GroupVersioner, decodeVersion runtime.GroupVersioner,
) runtime.Codec { ) runtime.Codec {
return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, scheme, encodeVersion, decodeVersion) return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, encodeVersion, decodeVersion)
} }
// NewCodec takes objects in their internal versions and converts them to external versions before // NewCodec takes objects in their internal versions and converts them to external versions before
@ -56,7 +55,6 @@ func NewCodec(
decoder runtime.Decoder, decoder runtime.Decoder,
convertor runtime.ObjectConvertor, convertor runtime.ObjectConvertor,
creater runtime.ObjectCreater, creater runtime.ObjectCreater,
copier runtime.ObjectCopier,
typer runtime.ObjectTyper, typer runtime.ObjectTyper,
defaulter runtime.ObjectDefaulter, defaulter runtime.ObjectDefaulter,
encodeVersion runtime.GroupVersioner, encodeVersion runtime.GroupVersioner,
@ -67,7 +65,6 @@ func NewCodec(
decoder: decoder, decoder: decoder,
convertor: convertor, convertor: convertor,
creater: creater, creater: creater,
copier: copier,
typer: typer, typer: typer,
defaulter: defaulter, defaulter: defaulter,
@ -82,7 +79,6 @@ type codec struct {
decoder runtime.Decoder decoder runtime.Decoder
convertor runtime.ObjectConvertor convertor runtime.ObjectConvertor
creater runtime.ObjectCreater creater runtime.ObjectCreater
copier runtime.ObjectCopier
typer runtime.ObjectTyper typer runtime.ObjectTyper
defaulter runtime.ObjectDefaulter defaulter runtime.ObjectDefaulter
@ -123,12 +119,7 @@ func (c *codec) Decode(data []byte, defaultGVK *schema.GroupVersionKind, into ru
if c.defaulter != nil { if c.defaulter != nil {
// create a copy to ensure defaulting is not applied to the original versioned objects // create a copy to ensure defaulting is not applied to the original versioned objects
if isVersioned { if isVersioned {
copied, err := c.copier.Copy(obj) versioned.Objects = []runtime.Object{obj.DeepCopyObject()}
if err != nil {
utilruntime.HandleError(err)
copied = obj
}
versioned.Objects = []runtime.Object{copied}
} }
c.defaulter.Default(obj) c.defaulter.Default(obj)
} else { } else {
@ -151,12 +142,7 @@ func (c *codec) Decode(data []byte, defaultGVK *schema.GroupVersionKind, into ru
// Convert if needed. // Convert if needed.
if isVersioned { if isVersioned {
// create a copy, because ConvertToVersion does not guarantee non-mutation of objects // create a copy, because ConvertToVersion does not guarantee non-mutation of objects
copied, err := c.copier.Copy(obj) versioned.Objects = []runtime.Object{obj.DeepCopyObject()}
if err != nil {
utilruntime.HandleError(err)
copied = obj
}
versioned.Objects = []runtime.Object{copied}
} }
// perform defaulting if requested // perform defaulting if requested

View File

@ -142,10 +142,6 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
} }
if sub := objectReflectDiff(path.Child(a.Type().Field(i).Name), a.Field(i), b.Field(i)); len(sub) > 0 { if sub := objectReflectDiff(path.Child(a.Type().Field(i).Name), a.Field(i), b.Field(i)); len(sub) > 0 {
changes = append(changes, sub...) changes = append(changes, sub...)
} else {
if !reflect.DeepEqual(a.Field(i).Interface(), b.Field(i).Interface()) {
changes = append(changes, diff{path: path, a: a.Field(i).Interface(), b: b.Field(i).Interface()})
}
} }
} }
return changes return changes
@ -178,21 +174,18 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
} }
return nil return nil
} }
var diffs []diff
for i := 0; i < l; i++ { for i := 0; i < l; i++ {
if !reflect.DeepEqual(a.Index(i), b.Index(i)) { if !reflect.DeepEqual(a.Index(i), b.Index(i)) {
return objectReflectDiff(path.Index(i), a.Index(i), b.Index(i)) diffs = append(diffs, objectReflectDiff(path.Index(i), a.Index(i), b.Index(i))...)
} }
} }
var diffs []diff
for i := l; i < lA; i++ { for i := l; i < lA; i++ {
diffs = append(diffs, diff{path: path.Index(i), a: a.Index(i), b: nil}) diffs = append(diffs, diff{path: path.Index(i), a: a.Index(i), b: nil})
} }
for i := l; i < lB; i++ { for i := l; i < lB; i++ {
diffs = append(diffs, diff{path: path.Index(i), a: nil, b: b.Index(i)}) diffs = append(diffs, diff{path: path.Index(i), a: nil, b: b.Index(i)})
} }
if len(diffs) == 0 {
diffs = append(diffs, diff{path: path, a: a, b: b})
}
return diffs return diffs
case reflect.Map: case reflect.Map:
if reflect.DeepEqual(a.Interface(), b.Interface()) { if reflect.DeepEqual(a.Interface(), b.Interface()) {

View File

@ -26,6 +26,7 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
"path"
"strconv" "strconv"
"strings" "strings"
@ -33,6 +34,26 @@ import (
"golang.org/x/net/http2" "golang.org/x/net/http2"
) )
// JoinPreservingTrailingSlash does a path.Join of the specified elements,
// preserving any trailing slash on the last non-empty segment
func JoinPreservingTrailingSlash(elem ...string) string {
// do the basic path join
result := path.Join(elem...)
// find the last non-empty segment
for i := len(elem) - 1; i >= 0; i-- {
if len(elem[i]) > 0 {
// if the last segment ended in a slash, ensure our result does as well
if strings.HasSuffix(elem[i], "/") && !strings.HasSuffix(result, "/") {
result += "/"
}
break
}
}
return result
}
// IsProbableEOF returns true if the given error resembles a connection termination // IsProbableEOF returns true if the given error resembles a connection termination
// scenario that would justify assuming that the watch is empty. // scenario that would justify assuming that the watch is empty.
// These errors are what the Go http stack returns back to us which are general // These errors are what the Go http stack returns back to us which are general
@ -235,8 +256,11 @@ func isDefault(transportProxier func(*http.Request) (*url.URL, error)) bool {
// NewProxierWithNoProxyCIDR constructs a Proxier function that respects CIDRs in NO_PROXY and delegates if // NewProxierWithNoProxyCIDR constructs a Proxier function that respects CIDRs in NO_PROXY and delegates if
// no matching CIDRs are found // no matching CIDRs are found
func NewProxierWithNoProxyCIDR(delegate func(req *http.Request) (*url.URL, error)) func(req *http.Request) (*url.URL, error) { func NewProxierWithNoProxyCIDR(delegate func(req *http.Request) (*url.URL, error)) func(req *http.Request) (*url.URL, error) {
// we wrap the default method, so we only need to perform our check if the NO_PROXY envvar has a CIDR in it // we wrap the default method, so we only need to perform our check if the NO_PROXY (or no_proxy) envvar has a CIDR in it
noProxyEnv := os.Getenv("NO_PROXY") noProxyEnv := os.Getenv("NO_PROXY")
if noProxyEnv == "" {
noProxyEnv = os.Getenv("no_proxy")
}
noProxyRules := strings.Split(noProxyEnv, ",") noProxyRules := strings.Split(noProxyEnv, ",")
cidrs := []*net.IPNet{} cidrs := []*net.IPNet{}

View File

@ -19,6 +19,7 @@ package field
import ( import (
"fmt" "fmt"
"reflect" "reflect"
"strconv"
"strings" "strings"
utilerrors "k8s.io/apimachinery/pkg/util/errors" utilerrors "k8s.io/apimachinery/pkg/util/errors"
@ -175,7 +176,11 @@ func Invalid(field *Path, value interface{}, detail string) *Error {
func NotSupported(field *Path, value interface{}, validValues []string) *Error { func NotSupported(field *Path, value interface{}, validValues []string) *Error {
detail := "" detail := ""
if validValues != nil && len(validValues) > 0 { if validValues != nil && len(validValues) > 0 {
detail = "supported values: " + strings.Join(validValues, ", ") quotedValues := make([]string, len(validValues))
for i, v := range validValues {
quotedValues[i] = strconv.Quote(v)
}
detail = "supported values: " + strings.Join(quotedValues, ", ")
} }
return &Error{ErrorTypeNotSupported, field.String(), value, detail} return &Error{ErrorTypeNotSupported, field.String(), value, detail}
} }

202
vendor/k8s.io/apiserver/LICENSE generated vendored
View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

30
vendor/k8s.io/apiserver/README.md generated vendored
View File

@ -1,30 +0,0 @@
# apiserver
Generic library for building a Kubernetes aggregated API server.
## Purpose
This library contains code to create Kubernetes aggregation server complete with delegated authentication and authorization,
`kubectl` compatible discovery information, optional admission chain, and versioned types. It's first consumers are
`k8s.io/kubernetes`, `k8s.io/kube-aggregator`, and `github.com/kubernetes-incubator/service-catalog`.
## Compatibility
There are *NO compatibility guarantees* for this repository, yet. It is in direct support of Kubernetes, so branches
will track Kubernetes and be compatible with that repo. As we more cleanly separate the layers, we will review the
compatibility guarantee. We have a goal to make this easier to use in 2017.
## Where does it come from?
`apiserver` is synced from https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver.
Code changes are made in that location, merged into `k8s.io/kubernetes` and later synced here.
## Things you should *NOT* do
1. Directly modify any files under `pkg` in this repo. Those are driven from `k8s.io/kuberenetes/staging/src/k8s.io/apiserver`.
2. Expect compatibility. This repo is changing quickly in direct support of
Kubernetes and the API isn't yet stable enough for API guarantees.

View File

@ -823,6 +823,23 @@ func (r *Request) transformResponse(resp *http.Response, req *http.Request) Resu
} }
} }
// truncateBody decides if the body should be truncated, based on the glog Verbosity.
func truncateBody(body string) string {
max := 0
switch {
case bool(glog.V(9)):
max = 10240
case bool(glog.V(8)):
max = 1024
}
if len(body) <= max {
return body
}
return body[:max] + fmt.Sprintf(" [truncated %d chars]", len(body)-max)
}
// glogBody logs a body output that could be either JSON or protobuf. It explicitly guards against // glogBody logs a body output that could be either JSON or protobuf. It explicitly guards against
// allocating a new string for the body output unless necessary. Uses a simple heuristic to determine // allocating a new string for the body output unless necessary. Uses a simple heuristic to determine
// whether the body is printable. // whether the body is printable.
@ -831,9 +848,9 @@ func glogBody(prefix string, body []byte) {
if bytes.IndexFunc(body, func(r rune) bool { if bytes.IndexFunc(body, func(r rune) bool {
return r < 0x0a return r < 0x0a
}) != -1 { }) != -1 {
glog.Infof("%s:\n%s", prefix, hex.Dump(body)) glog.Infof("%s:\n%s", prefix, truncateBody(hex.Dump(body)))
} else { } else {
glog.Infof("%s: %s", prefix, string(body)) glog.Infof("%s: %s", prefix, truncateBody(string(body)))
} }
} }
} }

View File

@ -66,10 +66,7 @@ func WriteCert(certPath string, data []byte) error {
if err := os.MkdirAll(filepath.Dir(certPath), os.FileMode(0755)); err != nil { if err := os.MkdirAll(filepath.Dir(certPath), os.FileMode(0755)); err != nil {
return err return err
} }
if err := ioutil.WriteFile(certPath, data, os.FileMode(0644)); err != nil { return ioutil.WriteFile(certPath, data, os.FileMode(0644))
return err
}
return nil
} }
// WriteKey writes the pem-encoded key data to keyPath. // WriteKey writes the pem-encoded key data to keyPath.
@ -80,10 +77,7 @@ func WriteKey(keyPath string, data []byte) error {
if err := os.MkdirAll(filepath.Dir(keyPath), os.FileMode(0755)); err != nil { if err := os.MkdirAll(filepath.Dir(keyPath), os.FileMode(0755)); err != nil {
return err return err
} }
if err := ioutil.WriteFile(keyPath, data, os.FileMode(0600)); err != nil { return ioutil.WriteFile(keyPath, data, os.FileMode(0600))
return err
}
return nil
} }
// LoadOrGenerateKeyFile looks for a key in the file at the given path. If it // LoadOrGenerateKeyFile looks for a key in the file at the given path. If it