Compare commits

..

1 Commits

Author SHA1 Message Date
Kubernetes Publisher
1638f8970c Fix Godeps.json to point to kubernetes-1.12.0 tags 2018-10-04 12:42:42 +00:00
15 changed files with 142 additions and 446 deletions

178
Godeps/Godeps.json generated
View File

@@ -192,27 +192,27 @@
},
{
"ImportPath": "golang.org/x/net/context",
"Rev": "0ed95abb35c445290478a5348a7b38bb154135fd"
"Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f"
},
{
"ImportPath": "golang.org/x/net/context/ctxhttp",
"Rev": "0ed95abb35c445290478a5348a7b38bb154135fd"
"Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f"
},
{
"ImportPath": "golang.org/x/net/http2",
"Rev": "0ed95abb35c445290478a5348a7b38bb154135fd"
"Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f"
},
{
"ImportPath": "golang.org/x/net/http2/hpack",
"Rev": "0ed95abb35c445290478a5348a7b38bb154135fd"
"Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f"
},
{
"ImportPath": "golang.org/x/net/idna",
"Rev": "0ed95abb35c445290478a5348a7b38bb154135fd"
"Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f"
},
{
"ImportPath": "golang.org/x/net/lex/httplex",
"Rev": "0ed95abb35c445290478a5348a7b38bb154135fd"
"Rev": "1c05540f6879653db88113bc4a2b70aec4bd491f"
},
{
"ImportPath": "golang.org/x/oauth2",
@@ -272,335 +272,335 @@
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1alpha1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/admissionregistration/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/apps/v1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/apps/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/apps/v1beta2",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/authentication/v1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/authentication/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/authorization/v1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/authorization/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/autoscaling/v1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/autoscaling/v2beta2",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/batch/v1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/batch/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/batch/v2alpha1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/certificates/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/coordination/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/core/v1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/events/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/extensions/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/imagepolicy/v1alpha1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/networking/v1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/policy/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/rbac/v1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/rbac/v1alpha1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/rbac/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/scheduling/v1alpha1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/scheduling/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/settings/v1alpha1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/storage/v1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/storage/v1alpha1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/api/storage/v1beta1",
"Rev": "d89493788bfe2f881a1d1a93e7897617e8e76125"
"Rev": "fd83cbc87e7632ccd8bbab63d2b673d4e0c631cc"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/naming",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "01f179d85dbce0f2e0e4351a92394b38694b7cae"
"Rev": "6dd46049f39503a1fc8d65de4bd566829e95faff"
},
{
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto",

View File

@@ -303,7 +303,6 @@ func (c *dynamicResourceClient) List(opts metav1.ListOptions) (*unstructured.Uns
}
list := &unstructured.UnstructuredList{}
list.SetResourceVersion(entireList.GetResourceVersion())
for i := range entireList.Items {
item := &entireList.Items[i]
metadata, err := meta.Accessor(item)

View File

@@ -70,11 +70,6 @@ type Config struct {
// TODO: demonstrate an OAuth2 compatible client.
BearerToken string
// Path to a file containing a BearerToken.
// If set, the contents are periodically read.
// The last successfully read value takes precedence over BearerToken.
BearerTokenFile string
// Impersonate is the configuration that RESTClient will use for impersonation.
Impersonate ImpersonationConfig
@@ -327,8 +322,9 @@ func InClusterConfig() (*Config, error) {
return nil, ErrNotInCluster
}
token, err := ioutil.ReadFile(tokenFile)
if err != nil {
ts := newCachedPathTokenSource(tokenFile)
if _, err := ts.Token(); err != nil {
return nil, err
}
@@ -344,8 +340,7 @@ func InClusterConfig() (*Config, error) {
// TODO: switch to using cluster DNS.
Host: "https://" + net.JoinHostPort(host, port),
TLSClientConfig: tlsClientConfig,
BearerToken: string(token),
BearerTokenFile: tokenFile,
WrapTransport: TokenSourceWrapTransport(ts),
}, nil
}
@@ -435,13 +430,12 @@ func AnonymousClientConfig(config *Config) *Config {
// CopyConfig returns a copy of the given config
func CopyConfig(config *Config) *Config {
return &Config{
Host: config.Host,
APIPath: config.APIPath,
ContentConfig: config.ContentConfig,
Username: config.Username,
Password: config.Password,
BearerToken: config.BearerToken,
BearerTokenFile: config.BearerTokenFile,
Host: config.Host,
APIPath: config.APIPath,
ContentConfig: config.ContentConfig,
Username: config.Username,
Password: config.Password,
BearerToken: config.BearerToken,
Impersonate: ImpersonationConfig{
Groups: config.Impersonate.Groups,
Extra: config.Impersonate.Extra,

View File

@@ -264,7 +264,6 @@ func TestAnonymousConfig(t *testing.T) {
// is added to Config, update AnonymousClientConfig to preserve the field otherwise.
expected.Impersonate = ImpersonationConfig{}
expected.BearerToken = ""
expected.BearerTokenFile = ""
expected.Username = ""
expected.Password = ""
expected.AuthProvider = nil

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package transport
package rest
import (
"fmt"
@@ -42,19 +42,17 @@ func TokenSourceWrapTransport(ts oauth2.TokenSource) func(http.RoundTripper) htt
}
}
// NewCachedFileTokenSource returns a oauth2.TokenSource reads a token from a
// file at a specified path and periodically reloads it.
func NewCachedFileTokenSource(path string) oauth2.TokenSource {
func newCachedPathTokenSource(path string) oauth2.TokenSource {
return &cachingTokenSource{
now: time.Now,
leeway: 10 * time.Second,
leeway: 1 * time.Minute,
base: &fileTokenSource{
path: path,
// This period was picked because it is half of the duration between when the kubelet
// refreshes a projected service account token and when the original token expires.
// Default token lifetime is 10 minutes, and the kubelet starts refreshing at 80% of lifetime.
// This should induce re-reading at a frequency that works with the token volume source.
period: time.Minute,
// This period was picked because it is half of the minimum validity
// duration for a token provisioned by they TokenRequest API. This is
// unsophisticated and should induce rotation at a frequency that should
// work with the token volume source.
period: 5 * time.Minute,
},
}
}

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package transport
package rest
import (
"fmt"

View File

@@ -24,8 +24,10 @@ import (
"net"
"net/url"
"reflect"
"strconv"
"strings"
"sync"
"sync/atomic"
"syscall"
"time"
@@ -93,10 +95,17 @@ func NewReflector(lw ListerWatcher, expectedType interface{}, store Store, resyn
return NewNamedReflector(naming.GetNameFromCallsite(internalPackages...), lw, expectedType, store, resyncPeriod)
}
// reflectorDisambiguator is used to disambiguate started reflectors.
// initialized to an unstable value to ensure meaning isn't attributed to the suffix.
var reflectorDisambiguator = int64(time.Now().UnixNano() % 12345)
// NewNamedReflector same as NewReflector, but with a specified name for logging
func NewNamedReflector(name string, lw ListerWatcher, expectedType interface{}, store Store, resyncPeriod time.Duration) *Reflector {
reflectorSuffix := atomic.AddInt64(&reflectorDisambiguator, 1)
r := &Reflector{
name: name,
name: name,
// we need this to be unique per process (some names are still the same) but obvious who it belongs to
metrics: newReflectorMetrics(makeValidPrometheusMetricLabel(fmt.Sprintf("reflector_"+name+"_%d", reflectorSuffix))),
listerWatcher: lw,
store: store,
expectedType: reflect.TypeOf(expectedType),
@@ -164,10 +173,13 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
// to be served from cache and potentially be delayed relative to
// etcd contents. Reflector framework will catch up via Watch() eventually.
options := metav1.ListOptions{ResourceVersion: "0"}
r.metrics.numberOfLists.Inc()
start := r.clock.Now()
list, err := r.listerWatcher.List(options)
if err != nil {
return fmt.Errorf("%s: Failed to list %v: %v", r.name, r.expectedType, err)
}
r.metrics.listDuration.Observe(time.Since(start).Seconds())
listMetaInterface, err := meta.ListAccessor(list)
if err != nil {
return fmt.Errorf("%s: Unable to understand list result %#v: %v", r.name, list, err)
@@ -177,6 +189,7 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
if err != nil {
return fmt.Errorf("%s: Unable to understand list result %#v (%v)", r.name, list, err)
}
r.metrics.numberOfItemsInList.Observe(float64(len(items)))
if err := r.syncWith(items, resourceVersion); err != nil {
return fmt.Errorf("%s: Unable to sync list result: %v", r.name, err)
}
@@ -226,6 +239,7 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error {
TimeoutSeconds: &timeoutSeconds,
}
r.metrics.numberOfWatches.Inc()
w, err := r.listerWatcher.Watch(options)
if err != nil {
switch err {
@@ -277,6 +291,11 @@ func (r *Reflector) watchHandler(w watch.Interface, resourceVersion *string, err
// Stopping the watcher should be idempotent and if we return from this function there's no way
// we're coming back in with the same watch interface.
defer w.Stop()
// update metrics
defer func() {
r.metrics.numberOfItemsInWatch.Observe(float64(eventCount))
r.metrics.watchDuration.Observe(time.Since(start).Seconds())
}()
loop:
for {
@@ -332,6 +351,7 @@ loop:
watchDuration := r.clock.Now().Sub(start)
if watchDuration < 1*time.Second && eventCount == 0 {
r.metrics.numberOfShortWatches.Inc()
return fmt.Errorf("very short watch: %s: Unexpected watch close - watch lasted less than a second and no items received", r.name)
}
glog.V(4).Infof("%s: Watch close - %v total %v items received", r.name, r.expectedType, eventCount)
@@ -350,4 +370,9 @@ func (r *Reflector) setLastSyncResourceVersion(v string) {
r.lastSyncResourceVersionMutex.Lock()
defer r.lastSyncResourceVersionMutex.Unlock()
r.lastSyncResourceVersion = v
rv, err := strconv.Atoi(v)
if err == nil {
r.metrics.lastResourceVersion.Set(float64(rv))
}
}

View File

@@ -234,7 +234,6 @@ func (config *DirectClientConfig) getUserIdentificationPartialConfig(configAuthI
return nil, err
}
mergedConfig.BearerToken = string(tokenBytes)
mergedConfig.BearerTokenFile = configAuthInfo.TokenFile
}
if len(configAuthInfo.Impersonate) > 0 {
mergedConfig.Impersonate = restclient.ImpersonationConfig{

View File

@@ -1,69 +0,0 @@
/*
Copyright 2015 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.
*/
package leaderelection
import (
"net/http"
"sync"
"time"
)
// HealthzAdaptor associates the /healthz endpoint with the LeaderElection object.
// It helps deal with the /healthz endpoint being set up prior to the LeaderElection.
// This contains the code needed to act as an adaptor between the leader
// election code the health check code. It allows us to provide health
// status about the leader election. Most specifically about if the leader
// has failed to renew without exiting the process. In that case we should
// report not healthy and rely on the kubelet to take down the process.
type HealthzAdaptor struct {
pointerLock sync.Mutex
le *LeaderElector
timeout time.Duration
}
// Name returns the name of the health check we are implementing.
func (l *HealthzAdaptor) Name() string {
return "leaderElection"
}
// Check is called by the healthz endpoint handler.
// It fails (returns an error) if we own the lease but had not been able to renew it.
func (l *HealthzAdaptor) Check(req *http.Request) error {
l.pointerLock.Lock()
defer l.pointerLock.Unlock()
if l.le == nil {
return nil
}
return l.le.Check(l.timeout)
}
// SetLeaderElection ties a leader election object to a HealthzAdaptor
func (l *HealthzAdaptor) SetLeaderElection(le *LeaderElector) {
l.pointerLock.Lock()
defer l.pointerLock.Unlock()
l.le = le
}
// NewLeaderHealthzAdaptor creates a basic healthz adaptor to monitor a leader election.
// timeout determines the time beyond the lease expiry to be allowed for timeout.
// checks within the timeout period after the lease expires will still return healthy.
func NewLeaderHealthzAdaptor(timeout time.Duration) *HealthzAdaptor {
result := &HealthzAdaptor{
timeout: timeout,
}
return result
}

View File

@@ -1,175 +0,0 @@
/*
Copyright 2015 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.
*/
package leaderelection
import (
"fmt"
"testing"
"time"
"k8s.io/apimachinery/pkg/util/clock"
rl "k8s.io/client-go/tools/leaderelection/resourcelock"
"net/http"
)
type fakeLock struct {
identity string
}
// Get is a dummy to allow us to have a fakeLock for testing.
func (fl *fakeLock) Get() (ler *rl.LeaderElectionRecord, err error) {
return nil, nil
}
// Create is a dummy to allow us to have a fakeLock for testing.
func (fl *fakeLock) Create(ler rl.LeaderElectionRecord) error {
return nil
}
// Update is a dummy to allow us to have a fakeLock for testing.
func (fl *fakeLock) Update(ler rl.LeaderElectionRecord) error {
return nil
}
// RecordEvent is a dummy to allow us to have a fakeLock for testing.
func (fl *fakeLock) RecordEvent(string) {}
// Identity is a dummy to allow us to have a fakeLock for testing.
func (fl *fakeLock) Identity() string {
return fl.identity
}
// Describe is a dummy to allow us to have a fakeLock for testing.
func (fl *fakeLock) Describe() string {
return "Dummy implementation of lock for testing"
}
// TestLeaderElectionHealthChecker tests that the healthcheck for leader election handles its edge cases.
func TestLeaderElectionHealthChecker(t *testing.T) {
current := time.Now()
req := &http.Request{}
tests := []struct {
description string
expected error
adaptorTimeout time.Duration
elector *LeaderElector
}{
{
description: "call check before leader elector initialized",
expected: nil,
adaptorTimeout: time.Second * 20,
elector: nil,
},
{
description: "call check when the the lease is far expired",
expected: fmt.Errorf("failed election to renew leadership on lease %s", "foo"),
adaptorTimeout: time.Second * 20,
elector: &LeaderElector{
config: LeaderElectionConfig{
Lock: &fakeLock{identity: "healthTest"},
LeaseDuration: time.Minute,
Name: "foo",
},
observedRecord: rl.LeaderElectionRecord{
HolderIdentity: "healthTest",
},
observedTime: current,
clock: clock.NewFakeClock(current.Add(time.Hour)),
},
},
{
description: "call check when the the lease is far expired but held by another server",
expected: nil,
adaptorTimeout: time.Second * 20,
elector: &LeaderElector{
config: LeaderElectionConfig{
Lock: &fakeLock{identity: "healthTest"},
LeaseDuration: time.Minute,
Name: "foo",
},
observedRecord: rl.LeaderElectionRecord{
HolderIdentity: "otherServer",
},
observedTime: current,
clock: clock.NewFakeClock(current.Add(time.Hour)),
},
},
{
description: "call check when the the lease is not expired",
expected: nil,
adaptorTimeout: time.Second * 20,
elector: &LeaderElector{
config: LeaderElectionConfig{
Lock: &fakeLock{identity: "healthTest"},
LeaseDuration: time.Minute,
Name: "foo",
},
observedRecord: rl.LeaderElectionRecord{
HolderIdentity: "healthTest",
},
observedTime: current,
clock: clock.NewFakeClock(current),
},
},
{
description: "call check when the the lease is expired but inside the timeout",
expected: nil,
adaptorTimeout: time.Second * 20,
elector: &LeaderElector{
config: LeaderElectionConfig{
Lock: &fakeLock{identity: "healthTest"},
LeaseDuration: time.Minute,
Name: "foo",
},
observedRecord: rl.LeaderElectionRecord{
HolderIdentity: "healthTest",
},
observedTime: current,
clock: clock.NewFakeClock(current.Add(time.Minute).Add(time.Second)),
},
},
}
for _, test := range tests {
adaptor := NewLeaderHealthzAdaptor(test.adaptorTimeout)
if adaptor.le != nil {
t.Errorf("[%s] leaderChecker started with a LeaderElector %v", test.description, adaptor.le)
}
if test.elector != nil {
test.elector.config.WatchDog = adaptor
adaptor.SetLeaderElection(test.elector)
if adaptor.le == nil {
t.Errorf("[%s] adaptor failed to set the LeaderElector", test.description)
}
}
err := adaptor.Check(req)
if test.expected == nil {
if err == nil {
continue
}
t.Errorf("[%s] called check, expected no error but received \"%v\"", test.description, err)
} else {
if err == nil {
t.Errorf("[%s] called check and failed to received the expected error \"%v\"", test.description, test.expected)
}
if err.Error() != test.expected.Error() {
t.Errorf("[%s] called check, expected %v, received %v", test.description, test.expected, err)
}
}
}
}

View File

@@ -56,7 +56,6 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
rl "k8s.io/client-go/tools/leaderelection/resourcelock"
@@ -91,7 +90,6 @@ func NewLeaderElector(lec LeaderElectionConfig) (*LeaderElector, error) {
}
return &LeaderElector{
config: lec,
clock: clock.RealClock{},
}, nil
}
@@ -113,13 +111,6 @@ type LeaderElectionConfig struct {
// Callbacks are callbacks that are triggered during certain lifecycle
// events of the LeaderElector
Callbacks LeaderCallbacks
// WatchDog is the associated health checker
// WatchDog may be null if its not needed/configured.
WatchDog *HealthzAdaptor
// Name is the name of the resource lock for debugging
Name string
}
// LeaderCallbacks are callbacks that are triggered during certain
@@ -148,12 +139,6 @@ type LeaderElector struct {
// value observedRecord.HolderIdentity if the transition has
// not yet been reported.
reportedLeader string
// clock is wrapper around time to allow for less flaky testing
clock clock.Clock
// name is the name of the resource lock for debugging
name string
}
// Run starts the leader election loop
@@ -178,9 +163,6 @@ func RunOrDie(ctx context.Context, lec LeaderElectionConfig) {
if err != nil {
panic(err)
}
if lec.WatchDog != nil {
lec.WatchDog.SetLeaderElection(le)
}
le.Run(ctx)
}
@@ -275,14 +257,14 @@ func (le *LeaderElector) tryAcquireOrRenew() bool {
return false
}
le.observedRecord = leaderElectionRecord
le.observedTime = le.clock.Now()
le.observedTime = time.Now()
return true
}
// 2. Record obtained, check the Identity & Time
if !reflect.DeepEqual(le.observedRecord, *oldLeaderElectionRecord) {
le.observedRecord = *oldLeaderElectionRecord
le.observedTime = le.clock.Now()
le.observedTime = time.Now()
}
if le.observedTime.Add(le.config.LeaseDuration).After(now.Time) &&
!le.IsLeader() {
@@ -305,7 +287,7 @@ func (le *LeaderElector) tryAcquireOrRenew() bool {
return false
}
le.observedRecord = leaderElectionRecord
le.observedTime = le.clock.Now()
le.observedTime = time.Now()
return true
}
@@ -318,19 +300,3 @@ func (le *LeaderElector) maybeReportTransition() {
go le.config.Callbacks.OnNewLeader(le.reportedLeader)
}
}
// Check will determine if the current lease is expired by more than timeout.
func (le *LeaderElector) Check(maxTolerableExpiredLease time.Duration) error {
if !le.IsLeader() {
// Currently not concerned with the case that we are hot standby
return nil
}
// If we are more than timeout seconds after the lease duration that is past the timeout
// on the lease renew. Time to start reporting ourselves as unhealthy. We should have
// died but conditions like deadlock can prevent this. (See #70819)
if le.clock.Since(le.observedTime) > le.config.LeaseDuration+maxTolerableExpiredLease {
return fmt.Errorf("failed election to renew leadership on lease %s", le.config.Name)
}
return nil
}

View File

@@ -26,7 +26,6 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/clock"
fakecorev1 "k8s.io/client-go/kubernetes/typed/core/v1/fake"
core "k8s.io/client-go/testing"
rl "k8s.io/client-go/tools/leaderelection/resourcelock"
@@ -258,7 +257,6 @@ func testTryAcquireOrRenew(t *testing.T, objectType string) {
config: lec,
observedRecord: test.observedRecord,
observedTime: test.observedTime,
clock: clock.RealClock{},
}
if test.expectSuccess != le.tryAcquireOrRenew() {

View File

@@ -39,11 +39,6 @@ type Config struct {
// Bearer token for authentication
BearerToken string
// Path to a file containing a BearerToken.
// If set, the contents are periodically read.
// The last successfully read value takes precedence over BearerToken.
BearerTokenFile string
// Impersonate is the config that this Config will impersonate using
Impersonate ImpersonationConfig
@@ -85,7 +80,7 @@ func (c *Config) HasBasicAuth() bool {
// HasTokenAuth returns whether the configuration has token authentication or not.
func (c *Config) HasTokenAuth() bool {
return len(c.BearerToken) != 0 || len(c.BearerTokenFile) != 0
return len(c.BearerToken) != 0
}
// HasCertAuth returns whether the configuration has certificate authentication or not.

View File

@@ -23,7 +23,6 @@ import (
"time"
"github.com/golang/glog"
"golang.org/x/oauth2"
utilnet "k8s.io/apimachinery/pkg/util/net"
)
@@ -45,11 +44,7 @@ func HTTPWrappersForConfig(config *Config, rt http.RoundTripper) (http.RoundTrip
case config.HasBasicAuth() && config.HasTokenAuth():
return nil, fmt.Errorf("username/password or bearer token may be set, but not both")
case config.HasTokenAuth():
var err error
rt, err = NewBearerAuthWithRefreshRoundTripper(config.BearerToken, config.BearerTokenFile, rt)
if err != nil {
return nil, err
}
rt = NewBearerAuthRoundTripper(config.BearerToken, rt)
case config.HasBasicAuth():
rt = NewBasicAuthRoundTripper(config.Username, config.Password, rt)
}
@@ -270,35 +265,13 @@ func (rt *impersonatingRoundTripper) WrappedRoundTripper() http.RoundTripper { r
type bearerAuthRoundTripper struct {
bearer string
source oauth2.TokenSource
rt http.RoundTripper
}
// NewBearerAuthRoundTripper adds the provided bearer token to a request
// unless the authorization header has already been set.
func NewBearerAuthRoundTripper(bearer string, rt http.RoundTripper) http.RoundTripper {
return &bearerAuthRoundTripper{bearer, nil, rt}
}
// NewBearerAuthRoundTripper adds the provided bearer token to a request
// unless the authorization header has already been set.
// If tokenFile is non-empty, it is periodically read,
// and the last successfully read content is used as the bearer token.
// If tokenFile is non-empty and bearer is empty, the tokenFile is read
// immediately to populate the initial bearer token.
func NewBearerAuthWithRefreshRoundTripper(bearer string, tokenFile string, rt http.RoundTripper) (http.RoundTripper, error) {
if len(tokenFile) == 0 {
return &bearerAuthRoundTripper{bearer, nil, rt}, nil
}
source := NewCachedFileTokenSource(tokenFile)
if len(bearer) == 0 {
token, err := source.Token()
if err != nil {
return nil, err
}
bearer = token.AccessToken
}
return &bearerAuthRoundTripper{bearer, source, rt}, nil
return &bearerAuthRoundTripper{bearer, rt}
}
func (rt *bearerAuthRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
@@ -307,13 +280,7 @@ func (rt *bearerAuthRoundTripper) RoundTrip(req *http.Request) (*http.Response,
}
req = utilnet.CloneRequest(req)
token := rt.bearer
if rt.source != nil {
if refreshedToken, err := rt.source.Token(); err == nil {
token = refreshedToken.AccessToken
}
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", rt.bearer))
return rt.rt.RoundTrip(req)
}

View File

@@ -38,7 +38,7 @@ func RoundTripperFor(config *restclient.Config) (http.RoundTripper, Upgrader, er
if err != nil {
return nil, nil, err
}
upgradeRoundTripper := spdy.NewRoundTripper(tlsConfig, true, false)
upgradeRoundTripper := spdy.NewRoundTripper(tlsConfig, true)
wrapper, err := restclient.HTTPWrappersForConfig(config, upgradeRoundTripper)
if err != nil {
return nil, nil, err