From cfe006b48192654ca49f2f2fd94cb2e875a3ad09 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Fri, 23 Sep 2016 11:23:41 -0700 Subject: [PATCH] run copy.sh --- .../k8s.io/client-go/1.5/Godeps/Godeps.json | 109 + .../1.5/_vendor/cloud.google.com/go/LICENSE | 202 + .../go/compute/metadata/metadata.go | 438 ++ .../cloud.google.com/go/internal/cloud.go | 64 + .../_vendor/github.com/coreos/go-oidc/LICENSE | 202 + .../_vendor/github.com/coreos/go-oidc/NOTICE | 5 + .../github.com/coreos/go-oidc/http/client.go | 7 + .../github.com/coreos/go-oidc/http/http.go | 156 + .../github.com/coreos/go-oidc/http/url.go | 29 + .../github.com/coreos/go-oidc/jose/claims.go | 126 + .../github.com/coreos/go-oidc/jose/jose.go | 112 + .../github.com/coreos/go-oidc/jose/jwk.go | 135 + .../github.com/coreos/go-oidc/jose/jws.go | 51 + .../github.com/coreos/go-oidc/jose/jwt.go | 82 + .../github.com/coreos/go-oidc/jose/sig.go | 24 + .../coreos/go-oidc/jose/sig_hmac.go | 67 + .../github.com/coreos/go-oidc/jose/sig_rsa.go | 67 + .../github.com/coreos/go-oidc/key/key.go | 153 + .../github.com/coreos/go-oidc/key/manager.go | 99 + .../github.com/coreos/go-oidc/key/repo.go | 55 + .../github.com/coreos/go-oidc/key/rotate.go | 159 + .../github.com/coreos/go-oidc/key/sync.go | 91 + .../github.com/coreos/go-oidc/oauth2/error.go | 29 + .../coreos/go-oidc/oauth2/oauth2.go | 416 ++ .../github.com/coreos/go-oidc/oidc/client.go | 846 +++ .../coreos/go-oidc/oidc/identity.go | 44 + .../coreos/go-oidc/oidc/interface.go | 3 + .../github.com/coreos/go-oidc/oidc/key.go | 67 + .../coreos/go-oidc/oidc/provider.go | 690 +++ .../coreos/go-oidc/oidc/transport.go | 88 + .../github.com/coreos/go-oidc/oidc/util.go | 109 + .../coreos/go-oidc/oidc/verification.go | 190 + .../1.5/_vendor/github.com/coreos/pkg/LICENSE | 202 + .../1.5/_vendor/github.com/coreos/pkg/NOTICE | 5 + .../github.com/coreos/pkg/health/health.go | 127 + .../github.com/coreos/pkg/httputil/cookie.go | 21 + .../github.com/coreos/pkg/httputil/json.go | 27 + .../github.com/coreos/pkg/timeutil/backoff.go | 15 + .../go-restful/swagger/model_builder.go | 2 +- .../github.com/golang/protobuf/LICENSE | 31 + .../github.com/golang/protobuf/proto/Makefile | 43 + .../github.com/golang/protobuf/proto/clone.go | 229 + .../golang/protobuf/proto/decode.go | 869 +++ .../golang/protobuf/proto/encode.go | 1363 +++++ .../github.com/golang/protobuf/proto/equal.go | 296 ++ .../golang/protobuf/proto/extensions.go | 555 ++ .../github.com/golang/protobuf/proto/lib.go | 898 ++++ .../golang/protobuf/proto/message_set.go | 311 ++ .../golang/protobuf/proto/pointer_reflect.go | 484 ++ .../golang/protobuf/proto/pointer_unsafe.go | 270 + .../golang/protobuf/proto/properties.go | 864 +++ .../github.com/golang/protobuf/proto/text.go | 854 +++ .../golang/protobuf/proto/text_parser.go | 880 ++++ .../github.com/jonboulle/clockwork/.gitignore | 25 + .../github.com/jonboulle/clockwork/LICENSE | 201 + .../jonboulle/clockwork/clockwork.go | 161 + .../x/net/context/ctxhttp/ctxhttp.go | 64 + .../x/net/context/ctxhttp/ctxhttp_pre17.go | 147 + .../1.5/_vendor/golang.org/x/oauth2/AUTHORS | 3 + .../golang.org/x/oauth2/CONTRIBUTING.md | 31 + .../_vendor/golang.org/x/oauth2/CONTRIBUTORS | 3 + .../1.5/_vendor/golang.org/x/oauth2/LICENSE | 27 + .../golang.org/x/oauth2/client_appengine.go | 25 + .../golang.org/x/oauth2/google/appengine.go | 86 + .../x/oauth2/google/appengine_hook.go | 13 + .../x/oauth2/google/appenginevm_hook.go | 14 + .../golang.org/x/oauth2/google/default.go | 155 + .../golang.org/x/oauth2/google/google.go | 153 + .../_vendor/golang.org/x/oauth2/google/jwt.go | 74 + .../_vendor/golang.org/x/oauth2/google/sdk.go | 168 + .../golang.org/x/oauth2/internal/oauth2.go | 76 + .../golang.org/x/oauth2/internal/token.go | 225 + .../golang.org/x/oauth2/internal/transport.go | 69 + .../_vendor/golang.org/x/oauth2/jws/jws.go | 182 + .../_vendor/golang.org/x/oauth2/jwt/jwt.go | 157 + .../1.5/_vendor/golang.org/x/oauth2/oauth2.go | 341 ++ .../1.5/_vendor/golang.org/x/oauth2/token.go | 158 + .../_vendor/golang.org/x/oauth2/transport.go | 132 + .../google.golang.org/appengine/LICENSE | 202 + .../google.golang.org/appengine/appengine.go | 112 + .../appengine/appengine_vm.go | 20 + .../google.golang.org/appengine/errors.go | 46 + .../google.golang.org/appengine/identity.go | 142 + .../appengine/internal/api.go | 646 +++ .../appengine/internal/api_classic.go | 159 + .../appengine/internal/api_common.go | 86 + .../appengine/internal/app_id.go | 28 + .../app_identity/app_identity_service.pb.go | 296 ++ .../app_identity/app_identity_service.proto | 64 + .../appengine/internal/base/api_base.pb.go | 133 + .../appengine/internal/base/api_base.proto | 33 + .../internal/datastore/datastore_v3.pb.go | 2778 ++++++++++ .../internal/datastore/datastore_v3.proto | 541 ++ .../appengine/internal/identity.go | 14 + .../appengine/internal/identity_classic.go | 27 + .../appengine/internal/identity_vm.go | 97 + .../appengine/internal/internal.go | 110 + .../appengine/internal/log/log_service.pb.go | 899 ++++ .../appengine/internal/log/log_service.proto | 150 + .../appengine/internal/main.go | 15 + .../appengine/internal/main_vm.go | 44 + .../appengine/internal/metadata.go | 61 + .../internal/modules/modules_service.pb.go | 375 ++ .../internal/modules/modules_service.proto | 80 + .../appengine/internal/net.go | 56 + .../internal/remote_api/remote_api.pb.go | 231 + .../internal/remote_api/remote_api.proto | 44 + .../appengine/internal/transaction.go | 107 + .../google.golang.org/appengine/namespace.go | 25 + .../google.golang.org/appengine/timeout.go | 20 + .../client-go/1.5/discovery/restmapper.go | 9 + .../client-go/1.5/kubernetes/clientset.go | 86 + .../k8s.io/client-go/1.5/kubernetes/doc.go | 2 +- .../kubernetes/fake/clientset_generated.go | 35 + .../client-go/1.5/kubernetes/fake/doc.go | 2 +- .../1.5/kubernetes/import_known_versions.go | 3 + .../typed/apps/v1alpha1/apps_client.go | 96 + .../1.5/kubernetes/typed/apps/v1alpha1/doc.go | 20 + .../typed/apps/v1alpha1/fake/doc.go | 20 + .../apps/v1alpha1/fake/fake_apps_client.go | 37 + .../typed/apps/v1alpha1/fake/fake_petset.go | 127 + .../apps/v1alpha1/generated_expansion.go | 19 + .../kubernetes/typed/apps/v1alpha1/petset.go | 165 + .../v1beta1/authentication_client.go | 96 + .../typed/authentication/v1beta1/doc.go | 20 + .../typed/authentication/v1beta1/fake/doc.go | 20 + .../fake/fake_authentication_client.go | 37 + .../v1beta1/fake/fake_tokenreview.go | 22 + .../v1beta1/generated_expansion.go | 19 + .../authentication/v1beta1/tokenreview.go | 40 + .../typed/authorization/v1beta1/doc.go | 2 +- .../typed/authorization/v1beta1/fake/doc.go | 2 +- .../kubernetes/typed/autoscaling/v1/doc.go | 2 +- .../typed/autoscaling/v1/fake/doc.go | 2 +- .../1.5/kubernetes/typed/batch/v1/doc.go | 2 +- .../1.5/kubernetes/typed/batch/v1/fake/doc.go | 2 +- .../v1alpha1/certificates_client.go | 96 + .../v1alpha1/certificatesigningrequest.go | 154 + .../typed/certificates/v1alpha1/doc.go | 20 + .../typed/certificates/v1alpha1/fake/doc.go | 20 + .../v1alpha1/fake/fake_certificates_client.go | 37 + .../fake/fake_certificatesigningrequest.go | 118 + .../v1alpha1/generated_expansion.go | 19 + .../1.5/kubernetes/typed/core/v1/doc.go | 2 +- .../1.5/kubernetes/typed/core/v1/fake/doc.go | 2 +- .../typed/extensions/v1beta1/doc.go | 2 +- .../typed/extensions/v1beta1/fake/doc.go | 2 +- .../kubernetes/typed/policy/v1alpha1/doc.go | 2 +- .../typed/policy/v1alpha1/fake/doc.go | 2 +- .../typed/rbac/v1alpha1/clusterrole.go | 141 + .../typed/rbac/v1alpha1/clusterrolebinding.go | 141 + .../1.5/kubernetes/typed/rbac/v1alpha1/doc.go | 20 + .../typed/rbac/v1alpha1/fake/doc.go | 20 + .../rbac/v1alpha1/fake/fake_clusterrole.go | 109 + .../v1alpha1/fake/fake_clusterrolebinding.go | 109 + .../rbac/v1alpha1/fake/fake_rbac_client.go | 49 + .../typed/rbac/v1alpha1/fake/fake_role.go | 117 + .../rbac/v1alpha1/fake/fake_rolebinding.go | 117 + .../rbac/v1alpha1/generated_expansion.go | 25 + .../typed/rbac/v1alpha1/rbac_client.go | 111 + .../kubernetes/typed/rbac/v1alpha1/role.go | 151 + .../typed/rbac/v1alpha1/rolebinding.go | 151 + .../kubernetes/typed/storage/v1beta1/doc.go | 20 + .../typed/storage/v1beta1/fake/doc.go | 20 + .../v1beta1/fake/fake_storage_client.go | 37 + .../storage/v1beta1/fake/fake_storageclass.go | 109 + .../storage/v1beta1/generated_expansion.go | 19 + .../typed/storage/v1beta1/storage_client.go | 96 + .../typed/storage/v1beta1/storageclass.go | 141 + .../k8s.io/client-go/1.5/pkg/api/context.go | 14 + .../client-go/1.5/pkg/api/install/install.go | 6 - .../k8s.io/client-go/1.5/pkg/api/mapper.go | 10 - .../1.5/pkg/api/meta/firsthit_restmapper.go | 97 + .../client-go/1.5/pkg/api/meta/restmapper.go | 4 +- .../client-go/1.5/pkg/api/requestcontext.go | 26 +- .../1.5/pkg/api/resource/quantity.go | 2 +- .../client-go/1.5/pkg/api/testapi/testapi.go | 10 +- .../src/k8s.io/client-go/1.5/pkg/api/types.go | 8 +- .../client-go/1.5/pkg/api/unversioned/time.go | 2 +- .../client-go/1.5/pkg/api/v1/conversion.go | 17 + .../client-go/1.5/pkg/api/v1/generated.proto | 8 +- .../k8s.io/client-go/1.5/pkg/api/v1/types.go | 17 +- .../pkg/api/v1/types_swagger_doc_generated.go | 4 +- .../pkg/apimachinery/announced/announced.go | 107 + .../apimachinery/announced/group_factory.go | 247 + .../pkg/apimachinery/registered/registered.go | 19 +- .../client-go/1.5/pkg/apimachinery/types.go | 43 +- .../1.5/pkg/apis/apps/install/install.go | 114 +- .../1.5/pkg/apis/apps/v1alpha1/types.go | 2 + .../apis/authentication/install/install.go | 112 +- .../pkg/apis/authorization/install/install.go | 117 +- .../pkg/apis/autoscaling/install/install.go | 118 +- .../1.5/pkg/apis/batch/install/install.go | 129 +- .../pkg/apis/certificates/install/install.go | 120 +- .../1.5/pkg/apis/certificates/v1alpha1/doc.go | 2 +- .../apis/componentconfig/install/install.go | 118 +- .../apis/componentconfig/types.generated.go | 4636 +++++++++-------- .../1.5/pkg/apis/componentconfig/types.go | 3 + .../apis/componentconfig/v1alpha1/types.go | 3 + .../v1alpha1/zz_generated.conversion.go | 2 + .../v1alpha1/zz_generated.deepcopy.go | 1 + .../componentconfig/zz_generated.deepcopy.go | 1 + .../pkg/apis/extensions/install/install.go | 122 +- .../pkg/apis/imagepolicy/install/install.go | 108 +- .../1.5/pkg/apis/imagepolicy/v1alpha1/doc.go | 2 +- .../v1alpha1/types_swagger_doc_generated.go | 70 + .../1.5/pkg/apis/policy/install/install.go | 118 +- .../client-go/1.5/pkg/apis/policy/types.go | 1 - .../client-go/1.5/pkg/apis/rbac/helpers.go | 71 + .../1.5/pkg/apis/rbac/install/install.go | 119 +- .../1.5/pkg/apis/rbac/v1alpha1/doc.go | 2 +- .../1.5/pkg/apis/storage/install/install.go | 120 +- .../apis/federation/install/install.go | 1 - .../openapi}/common/common.go | 0 .../genericapiserver/openapi}/common/doc.go | 0 .../client-go/1.5/pkg/kubelet/qos/policy.go | 9 +- .../client-go/1.5/pkg/kubelet/qos/qos.go | 23 +- .../client-go/1.5/pkg/util/cert/cert.go | 190 + .../k8s.io/client-go/1.5/pkg/util/cert/csr.go | 81 + .../k8s.io/client-go/1.5/pkg/util/cert/io.go | 108 + .../k8s.io/client-go/1.5/pkg/util/cert/pem.go | 107 + .../client-go/1.5/pkg/util/crypto/crypto.go | 212 - .../client-go/1.5/pkg/util/intstr/intstr.go | 2 +- .../k8s.io/client-go/1.5/pkg/util/net/http.go | 28 + .../token/oidc/testing/provider.go | 200 + .../1.5/plugin/pkg/client/auth/gcp/gcp.go | 105 + .../1.5/plugin/pkg/client/auth/oidc/OWNERS | 2 + .../1.5/plugin/pkg/client/auth/oidc/oidc.go | 270 + .../plugin/pkg/client/auth/oidc/oidc_test.go | 646 +++ .../1.5/plugin/pkg/client/auth/plugins.go | 23 + .../src/k8s.io/client-go/1.5/rest/client.go | 2 +- .../src/k8s.io/client-go/1.5/rest/config.go | 6 +- .../src/k8s.io/client-go/1.5/rest/request.go | 20 +- .../src/k8s.io/client-go/1.5/testing/fake.go | 80 +- .../k8s.io/client-go/1.5/testing/fixture.go | 2 +- .../client-go/1.5/tools/cache/controller.go | 325 ++ .../1.5/tools/cache/controller_test.go | 401 ++ .../client-go/1.5/tools/cache/delta_fifo.go | 2 +- .../1.5/tools/cache/delta_fifo_test.go | 2 +- .../k8s.io/client-go/1.5/tools/cache/doc.go | 2 +- .../1.5/tools/cache/expiration_cache.go | 2 +- .../1.5/tools/cache/expiration_cache_fakes.go | 2 +- .../1.5/tools/cache/expiration_cache_test.go | 2 +- .../1.5/tools/cache/fake_custom_store.go | 2 +- .../k8s.io/client-go/1.5/tools/cache/fifo.go | 2 +- .../client-go/1.5/tools/cache/fifo_test.go | 2 +- .../k8s.io/client-go/1.5/tools/cache/index.go | 2 +- .../client-go/1.5/tools/cache/index_test.go | 2 +- .../client-go/1.5/tools/cache/listers.go | 160 +- .../client-go/1.5/tools/cache/listers_core.go | 135 + .../client-go/1.5/tools/cache/listers_test.go | 21 +- .../client-go/1.5/tools/cache/listwatch.go | 2 +- .../tools/cache/processor_listener_test.go | 48 + .../client-go/1.5/tools/cache/reflector.go | 2 +- .../1.5/tools/cache/reflector_test.go | 16 +- .../1.5/tools/cache/shared_informer.go | 413 ++ .../k8s.io/client-go/1.5/tools/cache/store.go | 2 +- .../client-go/1.5/tools/cache/store_test.go | 2 +- .../cache/testing/fake_controller_source.go | 262 + .../testing/fake_controller_source_test.go | 94 + .../1.5/tools/cache/thread_safe_store.go | 2 +- .../1.5/tools/cache/undelta_store.go | 2 +- .../1.5/tools/cache/undelta_store_test.go | 2 +- .../1.5/tools/clientcmd/client_config.go | 26 +- .../1.5/tools/clientcmd/client_config_test.go | 8 +- .../client-go/1.5/tools/clientcmd/loader.go | 25 + .../tools/clientcmd/merged_client_builder.go | 22 +- .../clientcmd/merged_client_builder_test.go | 43 +- 268 files changed, 33562 insertions(+), 4100 deletions(-) create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/LICENSE create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/compute/metadata/metadata.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/internal/cloud.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/LICENSE create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/NOTICE create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/client.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/http.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/url.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/claims.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jose.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jwk.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jws.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jwt.go create mode 100755 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig.go create mode 100755 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig_hmac.go create mode 100755 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig_rsa.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/key.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/manager.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/repo.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/rotate.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/sync.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oauth2/error.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oauth2/oauth2.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/client.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/identity.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/interface.go create mode 100755 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/key.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/provider.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/transport.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/util.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/verification.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/LICENSE create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/NOTICE create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/health/health.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/httputil/cookie.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/httputil/json.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/timeutil/backoff.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/LICENSE create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/Makefile create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/clone.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/decode.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/encode.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/equal.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/extensions.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/lib.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/message_set.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/pointer_reflect.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/pointer_unsafe.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/properties.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/text.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/text_parser.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/.gitignore create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/LICENSE create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/clockwork.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/AUTHORS create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/CONTRIBUTING.md create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/CONTRIBUTORS create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/LICENSE create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/client_appengine.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appengine.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appengine_hook.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appenginevm_hook.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/default.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/google.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/jwt.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/sdk.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/oauth2.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/token.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/transport.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/jws/jws.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/jwt/jwt.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/oauth2.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/token.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/transport.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/LICENSE create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/appengine.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/appengine_vm.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/errors.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/identity.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api_classic.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api_common.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_id.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.pb.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.proto create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/base/api_base.pb.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/base/api_base.proto create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go create mode 100755 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity_classic.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity_vm.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/internal.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/log/log_service.pb.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/log/log_service.proto create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/main.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/main_vm.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/metadata.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/modules/modules_service.pb.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/modules/modules_service.proto create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/net.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/transaction.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/namespace.go create mode 100644 staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/timeout.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/apps_client.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/doc.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/doc.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/fake_apps_client.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/fake_petset.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/generated_expansion.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/petset.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/authentication_client.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/doc.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/doc.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/fake_authentication_client.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/fake_tokenreview.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/generated_expansion.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/tokenreview.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/certificates_client.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/certificatesigningrequest.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/doc.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/doc.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/fake_certificates_client.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/fake_certificatesigningrequest.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/generated_expansion.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/clusterrole.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/doc.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/doc.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrole.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrolebinding.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_rbac_client.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_role.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_rolebinding.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/generated_expansion.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/rbac_client.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/role.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/rolebinding.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/doc.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/doc.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/fake_storage_client.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/fake_storageclass.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/generated_expansion.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/storage_client.go create mode 100644 staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/storageclass.go create mode 100644 staging/src/k8s.io/client-go/1.5/pkg/api/meta/firsthit_restmapper.go create mode 100644 staging/src/k8s.io/client-go/1.5/pkg/apimachinery/announced/announced.go create mode 100644 staging/src/k8s.io/client-go/1.5/pkg/apimachinery/announced/group_factory.go create mode 100644 staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/v1alpha1/types_swagger_doc_generated.go rename staging/src/k8s.io/client-go/1.5/{cmd/libs/go2idl/openapi-gen/generators => pkg/genericapiserver/openapi}/common/common.go (100%) rename staging/src/k8s.io/client-go/1.5/{cmd/libs/go2idl/openapi-gen/generators => pkg/genericapiserver/openapi}/common/doc.go (100%) create mode 100644 staging/src/k8s.io/client-go/1.5/pkg/util/cert/cert.go create mode 100644 staging/src/k8s.io/client-go/1.5/pkg/util/cert/csr.go create mode 100644 staging/src/k8s.io/client-go/1.5/pkg/util/cert/io.go create mode 100644 staging/src/k8s.io/client-go/1.5/pkg/util/cert/pem.go delete mode 100644 staging/src/k8s.io/client-go/1.5/pkg/util/crypto/crypto.go create mode 100644 staging/src/k8s.io/client-go/1.5/plugin/pkg/auth/authenticator/token/oidc/testing/provider.go create mode 100644 staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/gcp/gcp.go create mode 100644 staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/OWNERS create mode 100644 staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/oidc.go create mode 100644 staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/oidc_test.go create mode 100644 staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/plugins.go create mode 100644 staging/src/k8s.io/client-go/1.5/tools/cache/controller.go create mode 100644 staging/src/k8s.io/client-go/1.5/tools/cache/controller_test.go create mode 100644 staging/src/k8s.io/client-go/1.5/tools/cache/listers_core.go create mode 100644 staging/src/k8s.io/client-go/1.5/tools/cache/processor_listener_test.go create mode 100644 staging/src/k8s.io/client-go/1.5/tools/cache/shared_informer.go create mode 100644 staging/src/k8s.io/client-go/1.5/tools/cache/testing/fake_controller_source.go create mode 100644 staging/src/k8s.io/client-go/1.5/tools/cache/testing/fake_controller_source_test.go diff --git a/staging/src/k8s.io/client-go/1.5/Godeps/Godeps.json b/staging/src/k8s.io/client-go/1.5/Godeps/Godeps.json index e98216c536a8..d9aeabf2852a 100644 --- a/staging/src/k8s.io/client-go/1.5/Godeps/Godeps.json +++ b/staging/src/k8s.io/client-go/1.5/Godeps/Godeps.json @@ -6,6 +6,16 @@ "./..." ], "Deps": [ + { + "ImportPath": "cloud.google.com/go/compute/metadata", + "Comment": "v0.1.0-115-g3b1ae45", + "Rev": "3b1ae45394a234c385be014e9a488f2bb6eef821" + }, + { + "ImportPath": "cloud.google.com/go/internal", + "Comment": "v0.1.0-115-g3b1ae45", + "Rev": "3b1ae45394a234c385be014e9a488f2bb6eef821" + }, { "ImportPath": "github.com/PuerkitoBio/purell", "Comment": "v1.0.0", @@ -20,6 +30,41 @@ "Comment": "v3.0.1", "Rev": "31b736133b98f26d5e078ec9eb591666edfd091f" }, + { + "ImportPath": "github.com/coreos/go-oidc/http", + "Rev": "5644a2f50e2d2d5ba0b474bc5bc55fea1925936d" + }, + { + "ImportPath": "github.com/coreos/go-oidc/jose", + "Rev": "5644a2f50e2d2d5ba0b474bc5bc55fea1925936d" + }, + { + "ImportPath": "github.com/coreos/go-oidc/key", + "Rev": "5644a2f50e2d2d5ba0b474bc5bc55fea1925936d" + }, + { + "ImportPath": "github.com/coreos/go-oidc/oauth2", + "Rev": "5644a2f50e2d2d5ba0b474bc5bc55fea1925936d" + }, + { + "ImportPath": "github.com/coreos/go-oidc/oidc", + "Rev": "5644a2f50e2d2d5ba0b474bc5bc55fea1925936d" + }, + { + "ImportPath": "github.com/coreos/pkg/health", + "Comment": "v2-8-gfa29b1d", + "Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8" + }, + { + "ImportPath": "github.com/coreos/pkg/httputil", + "Comment": "v2-8-gfa29b1d", + "Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8" + }, + { + "ImportPath": "github.com/coreos/pkg/timeutil", + "Comment": "v2-8-gfa29b1d", + "Rev": "fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8" + }, { "ImportPath": "github.com/davecgh/go-spew/spew", "Rev": "5215b55f46b2b919f50a1df0eaa5886afe4e3b3d" @@ -87,6 +132,10 @@ "ImportPath": "github.com/golang/groupcache/lru", "Rev": "02826c3e79038b59d737d3b1c0a1d937f71a4433" }, + { + "ImportPath": "github.com/golang/protobuf/proto", + "Rev": "8616e8ee5e20a1704615e6c8d7afcdac06087a67" + }, { "ImportPath": "github.com/google/gofuzz", "Rev": "bbcb9da2d746f8bdbd6a936686a0a6067ada0ec5" @@ -100,6 +149,10 @@ "Comment": "0.1.3-8-g6633656", "Rev": "6633656539c1639d9d78127b7d47c622b5d7b6dc" }, + { + "ImportPath": "github.com/jonboulle/clockwork", + "Rev": "72f9bd7c4e0c2a40055ab3d0f09654f730cce982" + }, { "ImportPath": "github.com/juju/ratelimit", "Rev": "77ed1c8a01217656d2080ad51981f6e99adaa177" @@ -136,6 +189,10 @@ "ImportPath": "golang.org/x/net/context", "Rev": "e90d6d0afc4c315a0d87a568ae68577cc15149a0" }, + { + "ImportPath": "golang.org/x/net/context/ctxhttp", + "Rev": "e90d6d0afc4c315a0d87a568ae68577cc15149a0" + }, { "ImportPath": "golang.org/x/net/http2", "Rev": "e90d6d0afc4c315a0d87a568ae68577cc15149a0" @@ -152,6 +209,26 @@ "ImportPath": "golang.org/x/net/lex/httplex", "Rev": "e90d6d0afc4c315a0d87a568ae68577cc15149a0" }, + { + "ImportPath": "golang.org/x/oauth2", + "Rev": "3c3a985cb79f52a3190fbc056984415ca6763d01" + }, + { + "ImportPath": "golang.org/x/oauth2/google", + "Rev": "3c3a985cb79f52a3190fbc056984415ca6763d01" + }, + { + "ImportPath": "golang.org/x/oauth2/internal", + "Rev": "3c3a985cb79f52a3190fbc056984415ca6763d01" + }, + { + "ImportPath": "golang.org/x/oauth2/jws", + "Rev": "3c3a985cb79f52a3190fbc056984415ca6763d01" + }, + { + "ImportPath": "golang.org/x/oauth2/jwt", + "Rev": "3c3a985cb79f52a3190fbc056984415ca6763d01" + }, { "ImportPath": "golang.org/x/sys/unix", "Rev": "9c60d1c508f5134d1ca726b4641db998f2523357" @@ -196,6 +273,38 @@ "ImportPath": "golang.org/x/text/width", "Rev": "2910a502d2bf9e43193af9d68ca516529614eed3" }, + { + "ImportPath": "google.golang.org/appengine", + "Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05" + }, + { + "ImportPath": "google.golang.org/appengine/internal", + "Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05" + }, + { + "ImportPath": "google.golang.org/appengine/internal/app_identity", + "Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05" + }, + { + "ImportPath": "google.golang.org/appengine/internal/base", + "Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05" + }, + { + "ImportPath": "google.golang.org/appengine/internal/datastore", + "Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05" + }, + { + "ImportPath": "google.golang.org/appengine/internal/log", + "Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05" + }, + { + "ImportPath": "google.golang.org/appengine/internal/modules", + "Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05" + }, + { + "ImportPath": "google.golang.org/appengine/internal/remote_api", + "Rev": "4f7eeb5305a4ba1966344836ba4af9996b7b4e05" + }, { "ImportPath": "gopkg.in/inf.v0", "Comment": "v0.9.0", diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/LICENSE b/staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/LICENSE new file mode 100644 index 000000000000..a4c5efd822fb --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/LICENSE @@ -0,0 +1,202 @@ + + 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 2014 Google Inc. + + 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. diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/compute/metadata/metadata.go b/staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/compute/metadata/metadata.go new file mode 100644 index 000000000000..5c6f3bf382e9 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/compute/metadata/metadata.go @@ -0,0 +1,438 @@ +// Copyright 2014 Google Inc. All Rights Reserved. +// +// 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 metadata provides access to Google Compute Engine (GCE) +// metadata and API service accounts. +// +// This package is a wrapper around the GCE metadata service, +// as documented at https://developers.google.com/compute/docs/metadata. +package metadata + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "net" + "net/http" + "net/url" + "os" + "runtime" + "strings" + "sync" + "time" + + "golang.org/x/net/context" + "golang.org/x/net/context/ctxhttp" + + "cloud.google.com/go/internal" +) + +const ( + // metadataIP is the documented metadata server IP address. + metadataIP = "169.254.169.254" + + // metadataHostEnv is the environment variable specifying the + // GCE metadata hostname. If empty, the default value of + // metadataIP ("169.254.169.254") is used instead. + // This is variable name is not defined by any spec, as far as + // I know; it was made up for the Go package. + metadataHostEnv = "GCE_METADATA_HOST" +) + +type cachedValue struct { + k string + trim bool + mu sync.Mutex + v string +} + +var ( + projID = &cachedValue{k: "project/project-id", trim: true} + projNum = &cachedValue{k: "project/numeric-project-id", trim: true} + instID = &cachedValue{k: "instance/id", trim: true} +) + +var ( + metaClient = &http.Client{ + Transport: &internal.Transport{ + Base: &http.Transport{ + Dial: (&net.Dialer{ + Timeout: 2 * time.Second, + KeepAlive: 30 * time.Second, + }).Dial, + ResponseHeaderTimeout: 2 * time.Second, + }, + }, + } + subscribeClient = &http.Client{ + Transport: &internal.Transport{ + Base: &http.Transport{ + Dial: (&net.Dialer{ + Timeout: 2 * time.Second, + KeepAlive: 30 * time.Second, + }).Dial, + }, + }, + } +) + +// NotDefinedError is returned when requested metadata is not defined. +// +// The underlying string is the suffix after "/computeMetadata/v1/". +// +// This error is not returned if the value is defined to be the empty +// string. +type NotDefinedError string + +func (suffix NotDefinedError) Error() string { + return fmt.Sprintf("metadata: GCE metadata %q not defined", string(suffix)) +} + +// Get returns a value from the metadata service. +// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/". +// +// If the GCE_METADATA_HOST environment variable is not defined, a default of +// 169.254.169.254 will be used instead. +// +// If the requested metadata is not defined, the returned error will +// be of type NotDefinedError. +func Get(suffix string) (string, error) { + val, _, err := getETag(metaClient, suffix) + return val, err +} + +// getETag returns a value from the metadata service as well as the associated +// ETag using the provided client. This func is otherwise equivalent to Get. +func getETag(client *http.Client, suffix string) (value, etag string, err error) { + // Using a fixed IP makes it very difficult to spoof the metadata service in + // a container, which is an important use-case for local testing of cloud + // deployments. To enable spoofing of the metadata service, the environment + // variable GCE_METADATA_HOST is first inspected to decide where metadata + // requests shall go. + host := os.Getenv(metadataHostEnv) + if host == "" { + // Using 169.254.169.254 instead of "metadata" here because Go + // binaries built with the "netgo" tag and without cgo won't + // know the search suffix for "metadata" is + // ".google.internal", and this IP address is documented as + // being stable anyway. + host = metadataIP + } + url := "http://" + host + "/computeMetadata/v1/" + suffix + req, _ := http.NewRequest("GET", url, nil) + req.Header.Set("Metadata-Flavor", "Google") + res, err := client.Do(req) + if err != nil { + return "", "", err + } + defer res.Body.Close() + if res.StatusCode == http.StatusNotFound { + return "", "", NotDefinedError(suffix) + } + if res.StatusCode != 200 { + return "", "", fmt.Errorf("status code %d trying to fetch %s", res.StatusCode, url) + } + all, err := ioutil.ReadAll(res.Body) + if err != nil { + return "", "", err + } + return string(all), res.Header.Get("Etag"), nil +} + +func getTrimmed(suffix string) (s string, err error) { + s, err = Get(suffix) + s = strings.TrimSpace(s) + return +} + +func (c *cachedValue) get() (v string, err error) { + defer c.mu.Unlock() + c.mu.Lock() + if c.v != "" { + return c.v, nil + } + if c.trim { + v, err = getTrimmed(c.k) + } else { + v, err = Get(c.k) + } + if err == nil { + c.v = v + } + return +} + +var ( + onGCEOnce sync.Once + onGCE bool +) + +// OnGCE reports whether this process is running on Google Compute Engine. +func OnGCE() bool { + onGCEOnce.Do(initOnGCE) + return onGCE +} + +func initOnGCE() { + onGCE = testOnGCE() +} + +func testOnGCE() bool { + // The user explicitly said they're on GCE, so trust them. + if os.Getenv(metadataHostEnv) != "" { + return true + } + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + resc := make(chan bool, 2) + + // Try two strategies in parallel. + // See https://github.com/GoogleCloudPlatform/google-cloud-go/issues/194 + go func() { + res, err := ctxhttp.Get(ctx, metaClient, "http://"+metadataIP) + if err != nil { + resc <- false + return + } + defer res.Body.Close() + resc <- res.Header.Get("Metadata-Flavor") == "Google" + }() + + go func() { + addrs, err := net.LookupHost("metadata.google.internal") + if err != nil || len(addrs) == 0 { + resc <- false + return + } + resc <- strsContains(addrs, metadataIP) + }() + + tryHarder := systemInfoSuggestsGCE() + if tryHarder { + res := <-resc + if res { + // The first strategy succeeded, so let's use it. + return true + } + // Wait for either the DNS or metadata server probe to + // contradict the other one and say we are running on + // GCE. Give it a lot of time to do so, since the system + // info already suggests we're running on a GCE BIOS. + timer := time.NewTimer(5 * time.Second) + defer timer.Stop() + select { + case res = <-resc: + return res + case <-timer.C: + // Too slow. Who knows what this system is. + return false + } + } + + // There's no hint from the system info that we're running on + // GCE, so use the first probe's result as truth, whether it's + // true or false. The goal here is to optimize for speed for + // users who are NOT running on GCE. We can't assume that + // either a DNS lookup or an HTTP request to a blackholed IP + // address is fast. Worst case this should return when the + // metaClient's Transport.ResponseHeaderTimeout or + // Transport.Dial.Timeout fires (in two seconds). + return <-resc +} + +// systemInfoSuggestsGCE reports whether the local system (without +// doing network requests) suggests that we're running on GCE. If this +// returns true, testOnGCE tries a bit harder to reach its metadata +// server. +func systemInfoSuggestsGCE() bool { + if runtime.GOOS != "linux" { + // We don't have any non-Linux clues available, at least yet. + return false + } + slurp, _ := ioutil.ReadFile("/sys/class/dmi/id/product_name") + name := strings.TrimSpace(string(slurp)) + return name == "Google" || name == "Google Compute Engine" +} + +// Subscribe subscribes to a value from the metadata service. +// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/". +// The suffix may contain query parameters. +// +// Subscribe calls fn with the latest metadata value indicated by the provided +// suffix. If the metadata value is deleted, fn is called with the empty string +// and ok false. Subscribe blocks until fn returns a non-nil error or the value +// is deleted. Subscribe returns the error value returned from the last call to +// fn, which may be nil when ok == false. +func Subscribe(suffix string, fn func(v string, ok bool) error) error { + const failedSubscribeSleep = time.Second * 5 + + // First check to see if the metadata value exists at all. + val, lastETag, err := getETag(subscribeClient, suffix) + if err != nil { + return err + } + + if err := fn(val, true); err != nil { + return err + } + + ok := true + if strings.ContainsRune(suffix, '?') { + suffix += "&wait_for_change=true&last_etag=" + } else { + suffix += "?wait_for_change=true&last_etag=" + } + for { + val, etag, err := getETag(subscribeClient, suffix+url.QueryEscape(lastETag)) + if err != nil { + if _, deleted := err.(NotDefinedError); !deleted { + time.Sleep(failedSubscribeSleep) + continue // Retry on other errors. + } + ok = false + } + lastETag = etag + + if err := fn(val, ok); err != nil || !ok { + return err + } + } +} + +// ProjectID returns the current instance's project ID string. +func ProjectID() (string, error) { return projID.get() } + +// NumericProjectID returns the current instance's numeric project ID. +func NumericProjectID() (string, error) { return projNum.get() } + +// InternalIP returns the instance's primary internal IP address. +func InternalIP() (string, error) { + return getTrimmed("instance/network-interfaces/0/ip") +} + +// ExternalIP returns the instance's primary external (public) IP address. +func ExternalIP() (string, error) { + return getTrimmed("instance/network-interfaces/0/access-configs/0/external-ip") +} + +// Hostname returns the instance's hostname. This will be of the form +// ".c..internal". +func Hostname() (string, error) { + return getTrimmed("instance/hostname") +} + +// InstanceTags returns the list of user-defined instance tags, +// assigned when initially creating a GCE instance. +func InstanceTags() ([]string, error) { + var s []string + j, err := Get("instance/tags") + if err != nil { + return nil, err + } + if err := json.NewDecoder(strings.NewReader(j)).Decode(&s); err != nil { + return nil, err + } + return s, nil +} + +// InstanceID returns the current VM's numeric instance ID. +func InstanceID() (string, error) { + return instID.get() +} + +// InstanceName returns the current VM's instance ID string. +func InstanceName() (string, error) { + host, err := Hostname() + if err != nil { + return "", err + } + return strings.Split(host, ".")[0], nil +} + +// Zone returns the current VM's zone, such as "us-central1-b". +func Zone() (string, error) { + zone, err := getTrimmed("instance/zone") + // zone is of the form "projects//zones/". + if err != nil { + return "", err + } + return zone[strings.LastIndex(zone, "/")+1:], nil +} + +// InstanceAttributes returns the list of user-defined attributes, +// assigned when initially creating a GCE VM instance. The value of an +// attribute can be obtained with InstanceAttributeValue. +func InstanceAttributes() ([]string, error) { return lines("instance/attributes/") } + +// ProjectAttributes returns the list of user-defined attributes +// applying to the project as a whole, not just this VM. The value of +// an attribute can be obtained with ProjectAttributeValue. +func ProjectAttributes() ([]string, error) { return lines("project/attributes/") } + +func lines(suffix string) ([]string, error) { + j, err := Get(suffix) + if err != nil { + return nil, err + } + s := strings.Split(strings.TrimSpace(j), "\n") + for i := range s { + s[i] = strings.TrimSpace(s[i]) + } + return s, nil +} + +// InstanceAttributeValue returns the value of the provided VM +// instance attribute. +// +// If the requested attribute is not defined, the returned error will +// be of type NotDefinedError. +// +// InstanceAttributeValue may return ("", nil) if the attribute was +// defined to be the empty string. +func InstanceAttributeValue(attr string) (string, error) { + return Get("instance/attributes/" + attr) +} + +// ProjectAttributeValue returns the value of the provided +// project attribute. +// +// If the requested attribute is not defined, the returned error will +// be of type NotDefinedError. +// +// ProjectAttributeValue may return ("", nil) if the attribute was +// defined to be the empty string. +func ProjectAttributeValue(attr string) (string, error) { + return Get("project/attributes/" + attr) +} + +// Scopes returns the service account scopes for the given account. +// The account may be empty or the string "default" to use the instance's +// main account. +func Scopes(serviceAccount string) ([]string, error) { + if serviceAccount == "" { + serviceAccount = "default" + } + return lines("instance/service-accounts/" + serviceAccount + "/scopes") +} + +func strsContains(ss []string, s string) bool { + for _, v := range ss { + if v == s { + return true + } + } + return false +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/internal/cloud.go b/staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/internal/cloud.go new file mode 100644 index 000000000000..8e0c8f8e525c --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/cloud.google.com/go/internal/cloud.go @@ -0,0 +1,64 @@ +// Copyright 2014 Google Inc. All Rights Reserved. +// +// 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 internal provides support for the cloud packages. +// +// Users should not import this package directly. +package internal + +import ( + "fmt" + "net/http" +) + +const userAgent = "gcloud-golang/0.1" + +// Transport is an http.RoundTripper that appends Google Cloud client's +// user-agent to the original request's user-agent header. +type Transport struct { + // TODO(bradfitz): delete internal.Transport. It's too wrappy for what it does. + // Do User-Agent some other way. + + // Base is the actual http.RoundTripper + // requests will use. It must not be nil. + Base http.RoundTripper +} + +// RoundTrip appends a user-agent to the existing user-agent +// header and delegates the request to the base http.RoundTripper. +func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { + req = cloneRequest(req) + ua := req.Header.Get("User-Agent") + if ua == "" { + ua = userAgent + } else { + ua = fmt.Sprintf("%s %s", ua, userAgent) + } + req.Header.Set("User-Agent", ua) + return t.Base.RoundTrip(req) +} + +// cloneRequest returns a clone of the provided *http.Request. +// The clone is a shallow copy of the struct and its Header map. +func cloneRequest(r *http.Request) *http.Request { + // shallow copy of the struct + r2 := new(http.Request) + *r2 = *r + // deep copy of the Header + r2.Header = make(http.Header) + for k, s := range r.Header { + r2.Header[k] = s + } + return r2 +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/LICENSE b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/LICENSE new file mode 100644 index 000000000000..e06d2081865a --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/LICENSE @@ -0,0 +1,202 @@ +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. + diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/NOTICE b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/NOTICE new file mode 100644 index 000000000000..b39ddfa5cbde --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/NOTICE @@ -0,0 +1,5 @@ +CoreOS Project +Copyright 2014 CoreOS, Inc + +This product includes software developed at CoreOS, Inc. +(http://www.coreos.com/). diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/client.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/client.go new file mode 100644 index 000000000000..fd079b4950f0 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/client.go @@ -0,0 +1,7 @@ +package http + +import "net/http" + +type Client interface { + Do(*http.Request) (*http.Response, error) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/http.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/http.go new file mode 100644 index 000000000000..c3f512151336 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/http.go @@ -0,0 +1,156 @@ +package http + +import ( + "encoding/base64" + "encoding/json" + "errors" + "log" + "net/http" + "net/url" + "path" + "strconv" + "strings" + "time" +) + +func WriteError(w http.ResponseWriter, code int, msg string) { + e := struct { + Error string `json:"error"` + }{ + Error: msg, + } + b, err := json.Marshal(e) + if err != nil { + log.Printf("go-oidc: failed to marshal %#v: %v", e, err) + code = http.StatusInternalServerError + b = []byte(`{"error":"server_error"}`) + } + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(code) + w.Write(b) +} + +// BasicAuth parses a username and password from the request's +// Authorization header. This was pulled from golang master: +// https://codereview.appspot.com/76540043 +func BasicAuth(r *http.Request) (username, password string, ok bool) { + auth := r.Header.Get("Authorization") + if auth == "" { + return + } + + if !strings.HasPrefix(auth, "Basic ") { + return + } + c, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(auth, "Basic ")) + if err != nil { + return + } + cs := string(c) + s := strings.IndexByte(cs, ':') + if s < 0 { + return + } + return cs[:s], cs[s+1:], true +} + +func cacheControlMaxAge(hdr string) (time.Duration, bool, error) { + for _, field := range strings.Split(hdr, ",") { + parts := strings.SplitN(strings.TrimSpace(field), "=", 2) + k := strings.ToLower(strings.TrimSpace(parts[0])) + if k != "max-age" { + continue + } + + if len(parts) == 1 { + return 0, false, errors.New("max-age has no value") + } + + v := strings.TrimSpace(parts[1]) + if v == "" { + return 0, false, errors.New("max-age has empty value") + } + + age, err := strconv.Atoi(v) + if err != nil { + return 0, false, err + } + + if age <= 0 { + return 0, false, nil + } + + return time.Duration(age) * time.Second, true, nil + } + + return 0, false, nil +} + +func expires(date, expires string) (time.Duration, bool, error) { + if date == "" || expires == "" { + return 0, false, nil + } + + te, err := time.Parse(time.RFC1123, expires) + if err != nil { + return 0, false, err + } + + td, err := time.Parse(time.RFC1123, date) + if err != nil { + return 0, false, err + } + + ttl := te.Sub(td) + + // headers indicate data already expired, caller should not + // have to care about this case + if ttl <= 0 { + return 0, false, nil + } + + return ttl, true, nil +} + +func Cacheable(hdr http.Header) (time.Duration, bool, error) { + ttl, ok, err := cacheControlMaxAge(hdr.Get("Cache-Control")) + if err != nil || ok { + return ttl, ok, err + } + + return expires(hdr.Get("Date"), hdr.Get("Expires")) +} + +// MergeQuery appends additional query values to an existing URL. +func MergeQuery(u url.URL, q url.Values) url.URL { + uv := u.Query() + for k, vs := range q { + for _, v := range vs { + uv.Add(k, v) + } + } + u.RawQuery = uv.Encode() + return u +} + +// NewResourceLocation appends a resource id to the end of the requested URL path. +func NewResourceLocation(reqURL *url.URL, id string) string { + var u url.URL + u = *reqURL + u.Path = path.Join(u.Path, id) + u.RawQuery = "" + u.Fragment = "" + return u.String() +} + +// CopyRequest returns a clone of the provided *http.Request. +// The returned object is a shallow copy of the struct and a +// deep copy of its Header field. +func CopyRequest(r *http.Request) *http.Request { + r2 := *r + r2.Header = make(http.Header) + for k, s := range r.Header { + r2.Header[k] = s + } + return &r2 +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/url.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/url.go new file mode 100644 index 000000000000..df60eb1a6b5a --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/http/url.go @@ -0,0 +1,29 @@ +package http + +import ( + "errors" + "net/url" +) + +// ParseNonEmptyURL checks that a string is a parsable URL which is also not empty +// since `url.Parse("")` does not return an error. Must contian a scheme and a host. +func ParseNonEmptyURL(u string) (*url.URL, error) { + if u == "" { + return nil, errors.New("url is empty") + } + + ur, err := url.Parse(u) + if err != nil { + return nil, err + } + + if ur.Scheme == "" { + return nil, errors.New("url scheme is empty") + } + + if ur.Host == "" { + return nil, errors.New("url host is empty") + } + + return ur, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/claims.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/claims.go new file mode 100644 index 000000000000..8b48bfd230b0 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/claims.go @@ -0,0 +1,126 @@ +package jose + +import ( + "encoding/json" + "fmt" + "math" + "time" +) + +type Claims map[string]interface{} + +func (c Claims) Add(name string, value interface{}) { + c[name] = value +} + +func (c Claims) StringClaim(name string) (string, bool, error) { + cl, ok := c[name] + if !ok { + return "", false, nil + } + + v, ok := cl.(string) + if !ok { + return "", false, fmt.Errorf("unable to parse claim as string: %v", name) + } + + return v, true, nil +} + +func (c Claims) StringsClaim(name string) ([]string, bool, error) { + cl, ok := c[name] + if !ok { + return nil, false, nil + } + + if v, ok := cl.([]string); ok { + return v, true, nil + } + + // When unmarshaled, []string will become []interface{}. + if v, ok := cl.([]interface{}); ok { + var ret []string + for _, vv := range v { + str, ok := vv.(string) + if !ok { + return nil, false, fmt.Errorf("unable to parse claim as string array: %v", name) + } + ret = append(ret, str) + } + return ret, true, nil + } + + return nil, false, fmt.Errorf("unable to parse claim as string array: %v", name) +} + +func (c Claims) Int64Claim(name string) (int64, bool, error) { + cl, ok := c[name] + if !ok { + return 0, false, nil + } + + v, ok := cl.(int64) + if !ok { + vf, ok := cl.(float64) + if !ok { + return 0, false, fmt.Errorf("unable to parse claim as int64: %v", name) + } + v = int64(vf) + } + + return v, true, nil +} + +func (c Claims) Float64Claim(name string) (float64, bool, error) { + cl, ok := c[name] + if !ok { + return 0, false, nil + } + + v, ok := cl.(float64) + if !ok { + vi, ok := cl.(int64) + if !ok { + return 0, false, fmt.Errorf("unable to parse claim as float64: %v", name) + } + v = float64(vi) + } + + return v, true, nil +} + +func (c Claims) TimeClaim(name string) (time.Time, bool, error) { + v, ok, err := c.Float64Claim(name) + if !ok || err != nil { + return time.Time{}, ok, err + } + + s := math.Trunc(v) + ns := (v - s) * math.Pow(10, 9) + return time.Unix(int64(s), int64(ns)).UTC(), true, nil +} + +func decodeClaims(payload []byte) (Claims, error) { + var c Claims + if err := json.Unmarshal(payload, &c); err != nil { + return nil, fmt.Errorf("malformed JWT claims, unable to decode: %v", err) + } + return c, nil +} + +func marshalClaims(c Claims) ([]byte, error) { + b, err := json.Marshal(c) + if err != nil { + return nil, err + } + return b, nil +} + +func encodeClaims(c Claims) (string, error) { + b, err := marshalClaims(c) + if err != nil { + return "", err + } + + return encodeSegment(b), nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jose.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jose.go new file mode 100644 index 000000000000..6209926596c9 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jose.go @@ -0,0 +1,112 @@ +package jose + +import ( + "encoding/base64" + "encoding/json" + "fmt" + "strings" +) + +const ( + HeaderMediaType = "typ" + HeaderKeyAlgorithm = "alg" + HeaderKeyID = "kid" +) + +const ( + // Encryption Algorithm Header Parameter Values for JWS + // See: https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40#page-6 + AlgHS256 = "HS256" + AlgHS384 = "HS384" + AlgHS512 = "HS512" + AlgRS256 = "RS256" + AlgRS384 = "RS384" + AlgRS512 = "RS512" + AlgES256 = "ES256" + AlgES384 = "ES384" + AlgES512 = "ES512" + AlgPS256 = "PS256" + AlgPS384 = "PS384" + AlgPS512 = "PS512" + AlgNone = "none" +) + +const ( + // Algorithm Header Parameter Values for JWE + // See: https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40#section-4.1 + AlgRSA15 = "RSA1_5" + AlgRSAOAEP = "RSA-OAEP" + AlgRSAOAEP256 = "RSA-OAEP-256" + AlgA128KW = "A128KW" + AlgA192KW = "A192KW" + AlgA256KW = "A256KW" + AlgDir = "dir" + AlgECDHES = "ECDH-ES" + AlgECDHESA128KW = "ECDH-ES+A128KW" + AlgECDHESA192KW = "ECDH-ES+A192KW" + AlgECDHESA256KW = "ECDH-ES+A256KW" + AlgA128GCMKW = "A128GCMKW" + AlgA192GCMKW = "A192GCMKW" + AlgA256GCMKW = "A256GCMKW" + AlgPBES2HS256A128KW = "PBES2-HS256+A128KW" + AlgPBES2HS384A192KW = "PBES2-HS384+A192KW" + AlgPBES2HS512A256KW = "PBES2-HS512+A256KW" +) + +const ( + // Encryption Algorithm Header Parameter Values for JWE + // See: https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40#page-22 + EncA128CBCHS256 = "A128CBC-HS256" + EncA128CBCHS384 = "A128CBC-HS384" + EncA256CBCHS512 = "A256CBC-HS512" + EncA128GCM = "A128GCM" + EncA192GCM = "A192GCM" + EncA256GCM = "A256GCM" +) + +type JOSEHeader map[string]string + +func (j JOSEHeader) Validate() error { + if _, exists := j[HeaderKeyAlgorithm]; !exists { + return fmt.Errorf("header missing %q parameter", HeaderKeyAlgorithm) + } + + return nil +} + +func decodeHeader(seg string) (JOSEHeader, error) { + b, err := decodeSegment(seg) + if err != nil { + return nil, err + } + + var h JOSEHeader + err = json.Unmarshal(b, &h) + if err != nil { + return nil, err + } + + return h, nil +} + +func encodeHeader(h JOSEHeader) (string, error) { + b, err := json.Marshal(h) + if err != nil { + return "", err + } + + return encodeSegment(b), nil +} + +// Decode JWT specific base64url encoding with padding stripped +func decodeSegment(seg string) ([]byte, error) { + if l := len(seg) % 4; l != 0 { + seg += strings.Repeat("=", 4-l) + } + return base64.URLEncoding.DecodeString(seg) +} + +// Encode JWT specific base64url encoding with padding stripped +func encodeSegment(seg []byte) string { + return strings.TrimRight(base64.URLEncoding.EncodeToString(seg), "=") +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jwk.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jwk.go new file mode 100644 index 000000000000..b7a8e235583a --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jwk.go @@ -0,0 +1,135 @@ +package jose + +import ( + "bytes" + "encoding/base64" + "encoding/binary" + "encoding/json" + "math/big" + "strings" +) + +// JSON Web Key +// https://tools.ietf.org/html/draft-ietf-jose-json-web-key-36#page-5 +type JWK struct { + ID string + Type string + Alg string + Use string + Exponent int + Modulus *big.Int + Secret []byte +} + +type jwkJSON struct { + ID string `json:"kid"` + Type string `json:"kty"` + Alg string `json:"alg"` + Use string `json:"use"` + Exponent string `json:"e"` + Modulus string `json:"n"` +} + +func (j *JWK) MarshalJSON() ([]byte, error) { + t := jwkJSON{ + ID: j.ID, + Type: j.Type, + Alg: j.Alg, + Use: j.Use, + Exponent: encodeExponent(j.Exponent), + Modulus: encodeModulus(j.Modulus), + } + + return json.Marshal(&t) +} + +func (j *JWK) UnmarshalJSON(data []byte) error { + var t jwkJSON + err := json.Unmarshal(data, &t) + if err != nil { + return err + } + + e, err := decodeExponent(t.Exponent) + if err != nil { + return err + } + + n, err := decodeModulus(t.Modulus) + if err != nil { + return err + } + + j.ID = t.ID + j.Type = t.Type + j.Alg = t.Alg + j.Use = t.Use + j.Exponent = e + j.Modulus = n + + return nil +} + +type JWKSet struct { + Keys []JWK `json:"keys"` +} + +func decodeExponent(e string) (int, error) { + decE, err := decodeBase64URLPaddingOptional(e) + if err != nil { + return 0, err + } + var eBytes []byte + if len(decE) < 8 { + eBytes = make([]byte, 8-len(decE), 8) + eBytes = append(eBytes, decE...) + } else { + eBytes = decE + } + eReader := bytes.NewReader(eBytes) + var E uint64 + err = binary.Read(eReader, binary.BigEndian, &E) + if err != nil { + return 0, err + } + return int(E), nil +} + +func encodeExponent(e int) string { + b := make([]byte, 8) + binary.BigEndian.PutUint64(b, uint64(e)) + var idx int + for ; idx < 8; idx++ { + if b[idx] != 0x0 { + break + } + } + return base64.URLEncoding.EncodeToString(b[idx:]) +} + +// Turns a URL encoded modulus of a key into a big int. +func decodeModulus(n string) (*big.Int, error) { + decN, err := decodeBase64URLPaddingOptional(n) + if err != nil { + return nil, err + } + N := big.NewInt(0) + N.SetBytes(decN) + return N, nil +} + +func encodeModulus(n *big.Int) string { + return base64.URLEncoding.EncodeToString(n.Bytes()) +} + +// decodeBase64URLPaddingOptional decodes Base64 whether there is padding or not. +// The stdlib version currently doesn't handle this. +// We can get rid of this is if this bug: +// https://github.com/golang/go/issues/4237 +// ever closes. +func decodeBase64URLPaddingOptional(e string) ([]byte, error) { + if m := len(e) % 4; m != 0 { + e += strings.Repeat("=", 4-m) + } + return base64.URLEncoding.DecodeString(e) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jws.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jws.go new file mode 100644 index 000000000000..1049ece831c5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jws.go @@ -0,0 +1,51 @@ +package jose + +import ( + "fmt" + "strings" +) + +type JWS struct { + RawHeader string + Header JOSEHeader + RawPayload string + Payload []byte + Signature []byte +} + +// Given a raw encoded JWS token parses it and verifies the structure. +func ParseJWS(raw string) (JWS, error) { + parts := strings.Split(raw, ".") + if len(parts) != 3 { + return JWS{}, fmt.Errorf("malformed JWS, only %d segments", len(parts)) + } + + rawSig := parts[2] + jws := JWS{ + RawHeader: parts[0], + RawPayload: parts[1], + } + + header, err := decodeHeader(jws.RawHeader) + if err != nil { + return JWS{}, fmt.Errorf("malformed JWS, unable to decode header, %s", err) + } + if err = header.Validate(); err != nil { + return JWS{}, fmt.Errorf("malformed JWS, %s", err) + } + jws.Header = header + + payload, err := decodeSegment(jws.RawPayload) + if err != nil { + return JWS{}, fmt.Errorf("malformed JWS, unable to decode payload: %s", err) + } + jws.Payload = payload + + sig, err := decodeSegment(rawSig) + if err != nil { + return JWS{}, fmt.Errorf("malformed JWS, unable to decode signature: %s", err) + } + jws.Signature = sig + + return jws, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jwt.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jwt.go new file mode 100644 index 000000000000..3b3e9634b002 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/jwt.go @@ -0,0 +1,82 @@ +package jose + +import "strings" + +type JWT JWS + +func ParseJWT(token string) (jwt JWT, err error) { + jws, err := ParseJWS(token) + if err != nil { + return + } + + return JWT(jws), nil +} + +func NewJWT(header JOSEHeader, claims Claims) (jwt JWT, err error) { + jwt = JWT{} + + jwt.Header = header + jwt.Header[HeaderMediaType] = "JWT" + + claimBytes, err := marshalClaims(claims) + if err != nil { + return + } + jwt.Payload = claimBytes + + eh, err := encodeHeader(header) + if err != nil { + return + } + jwt.RawHeader = eh + + ec, err := encodeClaims(claims) + if err != nil { + return + } + jwt.RawPayload = ec + + return +} + +func (j *JWT) KeyID() (string, bool) { + kID, ok := j.Header[HeaderKeyID] + return kID, ok +} + +func (j *JWT) Claims() (Claims, error) { + return decodeClaims(j.Payload) +} + +// Encoded data part of the token which may be signed. +func (j *JWT) Data() string { + return strings.Join([]string{j.RawHeader, j.RawPayload}, ".") +} + +// Full encoded JWT token string in format: header.claims.signature +func (j *JWT) Encode() string { + d := j.Data() + s := encodeSegment(j.Signature) + return strings.Join([]string{d, s}, ".") +} + +func NewSignedJWT(claims Claims, s Signer) (*JWT, error) { + header := JOSEHeader{ + HeaderKeyAlgorithm: s.Alg(), + HeaderKeyID: s.ID(), + } + + jwt, err := NewJWT(header, claims) + if err != nil { + return nil, err + } + + sig, err := s.Sign([]byte(jwt.Data())) + if err != nil { + return nil, err + } + jwt.Signature = sig + + return &jwt, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig.go new file mode 100755 index 000000000000..7b2b253cca53 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig.go @@ -0,0 +1,24 @@ +package jose + +import ( + "fmt" +) + +type Verifier interface { + ID() string + Alg() string + Verify(sig []byte, data []byte) error +} + +type Signer interface { + Verifier + Sign(data []byte) (sig []byte, err error) +} + +func NewVerifier(jwk JWK) (Verifier, error) { + if jwk.Type != "RSA" { + return nil, fmt.Errorf("unsupported key type %q", jwk.Type) + } + + return NewVerifierRSA(jwk) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig_hmac.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig_hmac.go new file mode 100755 index 000000000000..b3ca3ef3d491 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig_hmac.go @@ -0,0 +1,67 @@ +package jose + +import ( + "bytes" + "crypto" + "crypto/hmac" + _ "crypto/sha256" + "errors" + "fmt" +) + +type VerifierHMAC struct { + KeyID string + Hash crypto.Hash + Secret []byte +} + +type SignerHMAC struct { + VerifierHMAC +} + +func NewVerifierHMAC(jwk JWK) (*VerifierHMAC, error) { + if jwk.Alg != "" && jwk.Alg != "HS256" { + return nil, fmt.Errorf("unsupported key algorithm %q", jwk.Alg) + } + + v := VerifierHMAC{ + KeyID: jwk.ID, + Secret: jwk.Secret, + Hash: crypto.SHA256, + } + + return &v, nil +} + +func (v *VerifierHMAC) ID() string { + return v.KeyID +} + +func (v *VerifierHMAC) Alg() string { + return "HS256" +} + +func (v *VerifierHMAC) Verify(sig []byte, data []byte) error { + h := hmac.New(v.Hash.New, v.Secret) + h.Write(data) + if !bytes.Equal(sig, h.Sum(nil)) { + return errors.New("invalid hmac signature") + } + return nil +} + +func NewSignerHMAC(kid string, secret []byte) *SignerHMAC { + return &SignerHMAC{ + VerifierHMAC: VerifierHMAC{ + KeyID: kid, + Secret: secret, + Hash: crypto.SHA256, + }, + } +} + +func (s *SignerHMAC) Sign(data []byte) ([]byte, error) { + h := hmac.New(s.Hash.New, s.Secret) + h.Write(data) + return h.Sum(nil), nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig_rsa.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig_rsa.go new file mode 100755 index 000000000000..004e45dd835c --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/jose/sig_rsa.go @@ -0,0 +1,67 @@ +package jose + +import ( + "crypto" + "crypto/rand" + "crypto/rsa" + "fmt" +) + +type VerifierRSA struct { + KeyID string + Hash crypto.Hash + PublicKey rsa.PublicKey +} + +type SignerRSA struct { + PrivateKey rsa.PrivateKey + VerifierRSA +} + +func NewVerifierRSA(jwk JWK) (*VerifierRSA, error) { + if jwk.Alg != "" && jwk.Alg != "RS256" { + return nil, fmt.Errorf("unsupported key algorithm %q", jwk.Alg) + } + + v := VerifierRSA{ + KeyID: jwk.ID, + PublicKey: rsa.PublicKey{ + N: jwk.Modulus, + E: jwk.Exponent, + }, + Hash: crypto.SHA256, + } + + return &v, nil +} + +func NewSignerRSA(kid string, key rsa.PrivateKey) *SignerRSA { + return &SignerRSA{ + PrivateKey: key, + VerifierRSA: VerifierRSA{ + KeyID: kid, + PublicKey: key.PublicKey, + Hash: crypto.SHA256, + }, + } +} + +func (v *VerifierRSA) ID() string { + return v.KeyID +} + +func (v *VerifierRSA) Alg() string { + return "RS256" +} + +func (v *VerifierRSA) Verify(sig []byte, data []byte) error { + h := v.Hash.New() + h.Write(data) + return rsa.VerifyPKCS1v15(&v.PublicKey, v.Hash, h.Sum(nil), sig) +} + +func (s *SignerRSA) Sign(data []byte) ([]byte, error) { + h := s.Hash.New() + h.Write(data) + return rsa.SignPKCS1v15(rand.Reader, &s.PrivateKey, s.Hash, h.Sum(nil)) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/key.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/key.go new file mode 100644 index 000000000000..208c1fc1492c --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/key.go @@ -0,0 +1,153 @@ +package key + +import ( + "crypto/rand" + "crypto/rsa" + "encoding/hex" + "encoding/json" + "io" + "time" + + "github.com/coreos/go-oidc/jose" +) + +func NewPublicKey(jwk jose.JWK) *PublicKey { + return &PublicKey{jwk: jwk} +} + +type PublicKey struct { + jwk jose.JWK +} + +func (k *PublicKey) MarshalJSON() ([]byte, error) { + return json.Marshal(&k.jwk) +} + +func (k *PublicKey) UnmarshalJSON(data []byte) error { + var jwk jose.JWK + if err := json.Unmarshal(data, &jwk); err != nil { + return err + } + k.jwk = jwk + return nil +} + +func (k *PublicKey) ID() string { + return k.jwk.ID +} + +func (k *PublicKey) Verifier() (jose.Verifier, error) { + return jose.NewVerifierRSA(k.jwk) +} + +type PrivateKey struct { + KeyID string + PrivateKey *rsa.PrivateKey +} + +func (k *PrivateKey) ID() string { + return k.KeyID +} + +func (k *PrivateKey) Signer() jose.Signer { + return jose.NewSignerRSA(k.ID(), *k.PrivateKey) +} + +func (k *PrivateKey) JWK() jose.JWK { + return jose.JWK{ + ID: k.KeyID, + Type: "RSA", + Alg: "RS256", + Use: "sig", + Exponent: k.PrivateKey.PublicKey.E, + Modulus: k.PrivateKey.PublicKey.N, + } +} + +type KeySet interface { + ExpiresAt() time.Time +} + +type PublicKeySet struct { + keys []PublicKey + index map[string]*PublicKey + expiresAt time.Time +} + +func NewPublicKeySet(jwks []jose.JWK, exp time.Time) *PublicKeySet { + keys := make([]PublicKey, len(jwks)) + index := make(map[string]*PublicKey) + for i, jwk := range jwks { + keys[i] = *NewPublicKey(jwk) + index[keys[i].ID()] = &keys[i] + } + return &PublicKeySet{ + keys: keys, + index: index, + expiresAt: exp, + } +} + +func (s *PublicKeySet) ExpiresAt() time.Time { + return s.expiresAt +} + +func (s *PublicKeySet) Keys() []PublicKey { + return s.keys +} + +func (s *PublicKeySet) Key(id string) *PublicKey { + return s.index[id] +} + +type PrivateKeySet struct { + keys []*PrivateKey + ActiveKeyID string + expiresAt time.Time +} + +func NewPrivateKeySet(keys []*PrivateKey, exp time.Time) *PrivateKeySet { + return &PrivateKeySet{ + keys: keys, + ActiveKeyID: keys[0].ID(), + expiresAt: exp.UTC(), + } +} + +func (s *PrivateKeySet) Keys() []*PrivateKey { + return s.keys +} + +func (s *PrivateKeySet) ExpiresAt() time.Time { + return s.expiresAt +} + +func (s *PrivateKeySet) Active() *PrivateKey { + for i, k := range s.keys { + if k.ID() == s.ActiveKeyID { + return s.keys[i] + } + } + + return nil +} + +type GeneratePrivateKeyFunc func() (*PrivateKey, error) + +func GeneratePrivateKey() (*PrivateKey, error) { + pk, err := rsa.GenerateKey(rand.Reader, 2048) + if err != nil { + return nil, err + } + keyID := make([]byte, 20) + if _, err := io.ReadFull(rand.Reader, keyID); err != nil { + return nil, err + } + + k := PrivateKey{ + KeyID: hex.EncodeToString(keyID), + PrivateKey: pk, + } + + return &k, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/manager.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/manager.go new file mode 100644 index 000000000000..476ab6a8d2b9 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/manager.go @@ -0,0 +1,99 @@ +package key + +import ( + "errors" + "time" + + "github.com/jonboulle/clockwork" + + "github.com/coreos/go-oidc/jose" + "github.com/coreos/pkg/health" +) + +type PrivateKeyManager interface { + ExpiresAt() time.Time + Signer() (jose.Signer, error) + JWKs() ([]jose.JWK, error) + PublicKeys() ([]PublicKey, error) + + WritableKeySetRepo + health.Checkable +} + +func NewPrivateKeyManager() PrivateKeyManager { + return &privateKeyManager{ + clock: clockwork.NewRealClock(), + } +} + +type privateKeyManager struct { + keySet *PrivateKeySet + clock clockwork.Clock +} + +func (m *privateKeyManager) ExpiresAt() time.Time { + if m.keySet == nil { + return m.clock.Now().UTC() + } + + return m.keySet.ExpiresAt() +} + +func (m *privateKeyManager) Signer() (jose.Signer, error) { + if err := m.Healthy(); err != nil { + return nil, err + } + + return m.keySet.Active().Signer(), nil +} + +func (m *privateKeyManager) JWKs() ([]jose.JWK, error) { + if err := m.Healthy(); err != nil { + return nil, err + } + + keys := m.keySet.Keys() + jwks := make([]jose.JWK, len(keys)) + for i, k := range keys { + jwks[i] = k.JWK() + } + return jwks, nil +} + +func (m *privateKeyManager) PublicKeys() ([]PublicKey, error) { + jwks, err := m.JWKs() + if err != nil { + return nil, err + } + keys := make([]PublicKey, len(jwks)) + for i, jwk := range jwks { + keys[i] = *NewPublicKey(jwk) + } + return keys, nil +} + +func (m *privateKeyManager) Healthy() error { + if m.keySet == nil { + return errors.New("private key manager uninitialized") + } + + if len(m.keySet.Keys()) == 0 { + return errors.New("private key manager zero keys") + } + + if m.keySet.ExpiresAt().Before(m.clock.Now().UTC()) { + return errors.New("private key manager keys expired") + } + + return nil +} + +func (m *privateKeyManager) Set(keySet KeySet) error { + privKeySet, ok := keySet.(*PrivateKeySet) + if !ok { + return errors.New("unable to cast to PrivateKeySet") + } + + m.keySet = privKeySet + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/repo.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/repo.go new file mode 100644 index 000000000000..1acdeb3614c5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/repo.go @@ -0,0 +1,55 @@ +package key + +import ( + "errors" + "sync" +) + +var ErrorNoKeys = errors.New("no keys found") + +type WritableKeySetRepo interface { + Set(KeySet) error +} + +type ReadableKeySetRepo interface { + Get() (KeySet, error) +} + +type PrivateKeySetRepo interface { + WritableKeySetRepo + ReadableKeySetRepo +} + +func NewPrivateKeySetRepo() PrivateKeySetRepo { + return &memPrivateKeySetRepo{} +} + +type memPrivateKeySetRepo struct { + mu sync.RWMutex + pks PrivateKeySet +} + +func (r *memPrivateKeySetRepo) Set(ks KeySet) error { + pks, ok := ks.(*PrivateKeySet) + if !ok { + return errors.New("unable to cast to PrivateKeySet") + } else if pks == nil { + return errors.New("nil KeySet") + } + + r.mu.Lock() + defer r.mu.Unlock() + + r.pks = *pks + return nil +} + +func (r *memPrivateKeySetRepo) Get() (KeySet, error) { + r.mu.RLock() + defer r.mu.RUnlock() + + if r.pks.keys == nil { + return nil, ErrorNoKeys + } + return KeySet(&r.pks), nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/rotate.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/rotate.go new file mode 100644 index 000000000000..bc6cdfb1bd89 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/rotate.go @@ -0,0 +1,159 @@ +package key + +import ( + "errors" + "log" + "time" + + ptime "github.com/coreos/pkg/timeutil" + "github.com/jonboulle/clockwork" +) + +var ( + ErrorPrivateKeysExpired = errors.New("private keys have expired") +) + +func NewPrivateKeyRotator(repo PrivateKeySetRepo, ttl time.Duration) *PrivateKeyRotator { + return &PrivateKeyRotator{ + repo: repo, + ttl: ttl, + + keep: 2, + generateKey: GeneratePrivateKey, + clock: clockwork.NewRealClock(), + } +} + +type PrivateKeyRotator struct { + repo PrivateKeySetRepo + generateKey GeneratePrivateKeyFunc + clock clockwork.Clock + keep int + ttl time.Duration +} + +func (r *PrivateKeyRotator) expiresAt() time.Time { + return r.clock.Now().UTC().Add(r.ttl) +} + +func (r *PrivateKeyRotator) Healthy() error { + pks, err := r.privateKeySet() + if err != nil { + return err + } + + if r.clock.Now().After(pks.ExpiresAt()) { + return ErrorPrivateKeysExpired + } + + return nil +} + +func (r *PrivateKeyRotator) privateKeySet() (*PrivateKeySet, error) { + ks, err := r.repo.Get() + if err != nil { + return nil, err + } + + pks, ok := ks.(*PrivateKeySet) + if !ok { + return nil, errors.New("unable to cast to PrivateKeySet") + } + return pks, nil +} + +func (r *PrivateKeyRotator) nextRotation() (time.Duration, error) { + pks, err := r.privateKeySet() + if err == ErrorNoKeys { + return 0, nil + } + if err != nil { + return 0, err + } + + now := r.clock.Now() + + // Ideally, we want to rotate after half the TTL has elapsed. + idealRotationTime := pks.ExpiresAt().Add(-r.ttl / 2) + + // If we are past the ideal rotation time, rotate immediatly. + return max(0, idealRotationTime.Sub(now)), nil +} + +func max(a, b time.Duration) time.Duration { + if a > b { + return a + } + return b +} + +func (r *PrivateKeyRotator) Run() chan struct{} { + attempt := func() { + k, err := r.generateKey() + if err != nil { + log.Printf("go-oidc: failed generating signing key: %v", err) + return + } + + exp := r.expiresAt() + if err := rotatePrivateKeys(r.repo, k, r.keep, exp); err != nil { + log.Printf("go-oidc: key rotation failed: %v", err) + return + } + } + + stop := make(chan struct{}) + go func() { + for { + var nextRotation time.Duration + var sleep time.Duration + var err error + for { + if nextRotation, err = r.nextRotation(); err == nil { + break + } + sleep = ptime.ExpBackoff(sleep, time.Minute) + log.Printf("go-oidc: error getting nextRotation, retrying in %v: %v", sleep, err) + time.Sleep(sleep) + } + + select { + case <-r.clock.After(nextRotation): + attempt() + case <-stop: + return + } + } + }() + + return stop +} + +func rotatePrivateKeys(repo PrivateKeySetRepo, k *PrivateKey, keep int, exp time.Time) error { + ks, err := repo.Get() + if err != nil && err != ErrorNoKeys { + return err + } + + var keys []*PrivateKey + if ks != nil { + pks, ok := ks.(*PrivateKeySet) + if !ok { + return errors.New("unable to cast to PrivateKeySet") + } + keys = pks.Keys() + } + + keys = append([]*PrivateKey{k}, keys...) + if l := len(keys); l > keep { + keys = keys[0:keep] + } + + nks := PrivateKeySet{ + keys: keys, + ActiveKeyID: k.ID(), + expiresAt: exp, + } + + return repo.Set(KeySet(&nks)) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/sync.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/sync.go new file mode 100644 index 000000000000..b887f7b5a560 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/key/sync.go @@ -0,0 +1,91 @@ +package key + +import ( + "errors" + "log" + "time" + + "github.com/jonboulle/clockwork" + + "github.com/coreos/pkg/timeutil" +) + +func NewKeySetSyncer(r ReadableKeySetRepo, w WritableKeySetRepo) *KeySetSyncer { + return &KeySetSyncer{ + readable: r, + writable: w, + clock: clockwork.NewRealClock(), + } +} + +type KeySetSyncer struct { + readable ReadableKeySetRepo + writable WritableKeySetRepo + clock clockwork.Clock +} + +func (s *KeySetSyncer) Run() chan struct{} { + stop := make(chan struct{}) + go func() { + var failing bool + var next time.Duration + for { + exp, err := syncKeySet(s.readable, s.writable, s.clock) + if err != nil || exp == 0 { + if !failing { + failing = true + next = time.Second + } else { + next = timeutil.ExpBackoff(next, time.Minute) + } + if exp == 0 { + log.Printf("Synced to already expired key set, retrying in %v: %v", next, err) + + } else { + log.Printf("Failed syncing key set, retrying in %v: %v", next, err) + } + } else { + failing = false + next = exp / 2 + } + + select { + case <-s.clock.After(next): + continue + case <-stop: + return + } + } + }() + + return stop +} + +func Sync(r ReadableKeySetRepo, w WritableKeySetRepo) (time.Duration, error) { + return syncKeySet(r, w, clockwork.NewRealClock()) +} + +// syncKeySet copies the keyset from r to the KeySet at w and returns the duration in which the KeySet will expire. +// If keyset has already expired, returns a zero duration. +func syncKeySet(r ReadableKeySetRepo, w WritableKeySetRepo, clock clockwork.Clock) (exp time.Duration, err error) { + var ks KeySet + ks, err = r.Get() + if err != nil { + return + } + + if ks == nil { + err = errors.New("no source KeySet") + return + } + + if err = w.Set(ks); err != nil { + return + } + + now := clock.Now() + if ks.ExpiresAt().After(now) { + exp = ks.ExpiresAt().Sub(now) + } + return +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oauth2/error.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oauth2/error.go new file mode 100644 index 000000000000..50d890949a23 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oauth2/error.go @@ -0,0 +1,29 @@ +package oauth2 + +const ( + ErrorAccessDenied = "access_denied" + ErrorInvalidClient = "invalid_client" + ErrorInvalidGrant = "invalid_grant" + ErrorInvalidRequest = "invalid_request" + ErrorServerError = "server_error" + ErrorUnauthorizedClient = "unauthorized_client" + ErrorUnsupportedGrantType = "unsupported_grant_type" + ErrorUnsupportedResponseType = "unsupported_response_type" +) + +type Error struct { + Type string `json:"error"` + Description string `json:"error_description,omitempty"` + State string `json:"state,omitempty"` +} + +func (e *Error) Error() string { + if e.Description != "" { + return e.Type + ": " + e.Description + } + return e.Type +} + +func NewError(typ string) *Error { + return &Error{Type: typ} +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oauth2/oauth2.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oauth2/oauth2.go new file mode 100644 index 000000000000..72d1d6715bfd --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oauth2/oauth2.go @@ -0,0 +1,416 @@ +package oauth2 + +import ( + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "mime" + "net/http" + "net/url" + "sort" + "strconv" + "strings" + + phttp "github.com/coreos/go-oidc/http" +) + +// ResponseTypesEqual compares two response_type values. If either +// contains a space, it is treated as an unordered list. For example, +// comparing "code id_token" and "id_token code" would evaluate to true. +func ResponseTypesEqual(r1, r2 string) bool { + if !strings.Contains(r1, " ") || !strings.Contains(r2, " ") { + // fast route, no split needed + return r1 == r2 + } + + // split, sort, and compare + r1Fields := strings.Fields(r1) + r2Fields := strings.Fields(r2) + if len(r1Fields) != len(r2Fields) { + return false + } + sort.Strings(r1Fields) + sort.Strings(r2Fields) + for i, r1Field := range r1Fields { + if r1Field != r2Fields[i] { + return false + } + } + return true +} + +const ( + // OAuth2.0 response types registered by OIDC. + // + // See: https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#RegistryContents + ResponseTypeCode = "code" + ResponseTypeCodeIDToken = "code id_token" + ResponseTypeCodeIDTokenToken = "code id_token token" + ResponseTypeIDToken = "id_token" + ResponseTypeIDTokenToken = "id_token token" + ResponseTypeToken = "token" + ResponseTypeNone = "none" +) + +const ( + GrantTypeAuthCode = "authorization_code" + GrantTypeClientCreds = "client_credentials" + GrantTypeUserCreds = "password" + GrantTypeImplicit = "implicit" + GrantTypeRefreshToken = "refresh_token" + + AuthMethodClientSecretPost = "client_secret_post" + AuthMethodClientSecretBasic = "client_secret_basic" + AuthMethodClientSecretJWT = "client_secret_jwt" + AuthMethodPrivateKeyJWT = "private_key_jwt" +) + +type Config struct { + Credentials ClientCredentials + Scope []string + RedirectURL string + AuthURL string + TokenURL string + + // Must be one of the AuthMethodXXX methods above. Right now, only + // AuthMethodClientSecretPost and AuthMethodClientSecretBasic are supported. + AuthMethod string +} + +type Client struct { + hc phttp.Client + creds ClientCredentials + scope []string + authURL *url.URL + redirectURL *url.URL + tokenURL *url.URL + authMethod string +} + +type ClientCredentials struct { + ID string + Secret string +} + +func NewClient(hc phttp.Client, cfg Config) (c *Client, err error) { + if len(cfg.Credentials.ID) == 0 { + err = errors.New("missing client id") + return + } + + if len(cfg.Credentials.Secret) == 0 { + err = errors.New("missing client secret") + return + } + + if cfg.AuthMethod == "" { + cfg.AuthMethod = AuthMethodClientSecretBasic + } else if cfg.AuthMethod != AuthMethodClientSecretPost && cfg.AuthMethod != AuthMethodClientSecretBasic { + err = fmt.Errorf("auth method %q is not supported", cfg.AuthMethod) + return + } + + au, err := phttp.ParseNonEmptyURL(cfg.AuthURL) + if err != nil { + return + } + + tu, err := phttp.ParseNonEmptyURL(cfg.TokenURL) + if err != nil { + return + } + + // Allow empty redirect URL in the case where the client + // only needs to verify a given token. + ru, err := url.Parse(cfg.RedirectURL) + if err != nil { + return + } + + c = &Client{ + creds: cfg.Credentials, + scope: cfg.Scope, + redirectURL: ru, + authURL: au, + tokenURL: tu, + hc: hc, + authMethod: cfg.AuthMethod, + } + + return +} + +// Return the embedded HTTP client +func (c *Client) HttpClient() phttp.Client { + return c.hc +} + +// Generate the url for initial redirect to oauth provider. +func (c *Client) AuthCodeURL(state, accessType, prompt string) string { + v := c.commonURLValues() + v.Set("state", state) + if strings.ToLower(accessType) == "offline" { + v.Set("access_type", "offline") + } + + if prompt != "" { + v.Set("prompt", prompt) + } + v.Set("response_type", "code") + + q := v.Encode() + u := *c.authURL + if u.RawQuery == "" { + u.RawQuery = q + } else { + u.RawQuery += "&" + q + } + return u.String() +} + +func (c *Client) commonURLValues() url.Values { + return url.Values{ + "redirect_uri": {c.redirectURL.String()}, + "scope": {strings.Join(c.scope, " ")}, + "client_id": {c.creds.ID}, + } +} + +func (c *Client) newAuthenticatedRequest(urlToken string, values url.Values) (*http.Request, error) { + var req *http.Request + var err error + switch c.authMethod { + case AuthMethodClientSecretPost: + values.Set("client_secret", c.creds.Secret) + req, err = http.NewRequest("POST", urlToken, strings.NewReader(values.Encode())) + if err != nil { + return nil, err + } + case AuthMethodClientSecretBasic: + req, err = http.NewRequest("POST", urlToken, strings.NewReader(values.Encode())) + if err != nil { + return nil, err + } + encodedID := url.QueryEscape(c.creds.ID) + encodedSecret := url.QueryEscape(c.creds.Secret) + req.SetBasicAuth(encodedID, encodedSecret) + default: + panic("misconfigured client: auth method not supported") + } + + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + return req, nil + +} + +// ClientCredsToken posts the client id and secret to obtain a token scoped to the OAuth2 client via the "client_credentials" grant type. +// May not be supported by all OAuth2 servers. +func (c *Client) ClientCredsToken(scope []string) (result TokenResponse, err error) { + v := url.Values{ + "scope": {strings.Join(scope, " ")}, + "grant_type": {GrantTypeClientCreds}, + } + + req, err := c.newAuthenticatedRequest(c.tokenURL.String(), v) + if err != nil { + return + } + + resp, err := c.hc.Do(req) + if err != nil { + return + } + defer resp.Body.Close() + + return parseTokenResponse(resp) +} + +// UserCredsToken posts the username and password to obtain a token scoped to the OAuth2 client via the "password" grant_type +// May not be supported by all OAuth2 servers. +func (c *Client) UserCredsToken(username, password string) (result TokenResponse, err error) { + v := url.Values{ + "scope": {strings.Join(c.scope, " ")}, + "grant_type": {GrantTypeUserCreds}, + "username": {username}, + "password": {password}, + } + + req, err := c.newAuthenticatedRequest(c.tokenURL.String(), v) + if err != nil { + return + } + + resp, err := c.hc.Do(req) + if err != nil { + return + } + defer resp.Body.Close() + + return parseTokenResponse(resp) +} + +// RequestToken requests a token from the Token Endpoint with the specified grantType. +// If 'grantType' == GrantTypeAuthCode, then 'value' should be the authorization code. +// If 'grantType' == GrantTypeRefreshToken, then 'value' should be the refresh token. +func (c *Client) RequestToken(grantType, value string) (result TokenResponse, err error) { + v := c.commonURLValues() + + v.Set("grant_type", grantType) + v.Set("client_secret", c.creds.Secret) + switch grantType { + case GrantTypeAuthCode: + v.Set("code", value) + case GrantTypeRefreshToken: + v.Set("refresh_token", value) + default: + err = fmt.Errorf("unsupported grant_type: %v", grantType) + return + } + + req, err := c.newAuthenticatedRequest(c.tokenURL.String(), v) + if err != nil { + return + } + + resp, err := c.hc.Do(req) + if err != nil { + return + } + defer resp.Body.Close() + + return parseTokenResponse(resp) +} + +func parseTokenResponse(resp *http.Response) (result TokenResponse, err error) { + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + badStatusCode := resp.StatusCode < 200 || resp.StatusCode > 299 + + contentType, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return + } + + result = TokenResponse{ + RawBody: body, + } + + newError := func(typ, desc, state string) error { + if typ == "" { + return fmt.Errorf("unrecognized error %s", body) + } + return &Error{typ, desc, state} + } + + if contentType == "application/x-www-form-urlencoded" || contentType == "text/plain" { + var vals url.Values + vals, err = url.ParseQuery(string(body)) + if err != nil { + return + } + if error := vals.Get("error"); error != "" || badStatusCode { + err = newError(error, vals.Get("error_description"), vals.Get("state")) + return + } + e := vals.Get("expires_in") + if e == "" { + e = vals.Get("expires") + } + if e != "" { + result.Expires, err = strconv.Atoi(e) + if err != nil { + return + } + } + result.AccessToken = vals.Get("access_token") + result.TokenType = vals.Get("token_type") + result.IDToken = vals.Get("id_token") + result.RefreshToken = vals.Get("refresh_token") + result.Scope = vals.Get("scope") + } else { + var r struct { + AccessToken string `json:"access_token"` + TokenType string `json:"token_type"` + IDToken string `json:"id_token"` + RefreshToken string `json:"refresh_token"` + Scope string `json:"scope"` + State string `json:"state"` + ExpiresIn json.Number `json:"expires_in"` // Azure AD returns string + Expires int `json:"expires"` + Error string `json:"error"` + Desc string `json:"error_description"` + } + if err = json.Unmarshal(body, &r); err != nil { + return + } + if r.Error != "" || badStatusCode { + err = newError(r.Error, r.Desc, r.State) + return + } + result.AccessToken = r.AccessToken + result.TokenType = r.TokenType + result.IDToken = r.IDToken + result.RefreshToken = r.RefreshToken + result.Scope = r.Scope + if expiresIn, err := r.ExpiresIn.Int64(); err != nil { + result.Expires = r.Expires + } else { + result.Expires = int(expiresIn) + } + } + return +} + +type TokenResponse struct { + AccessToken string + TokenType string + Expires int + IDToken string + RefreshToken string // OPTIONAL. + Scope string // OPTIONAL, if identical to the scope requested by the client, otherwise, REQUIRED. + RawBody []byte // In case callers need some other non-standard info from the token response +} + +type AuthCodeRequest struct { + ResponseType string + ClientID string + RedirectURL *url.URL + Scope []string + State string +} + +func ParseAuthCodeRequest(q url.Values) (AuthCodeRequest, error) { + acr := AuthCodeRequest{ + ResponseType: q.Get("response_type"), + ClientID: q.Get("client_id"), + State: q.Get("state"), + Scope: make([]string, 0), + } + + qs := strings.TrimSpace(q.Get("scope")) + if qs != "" { + acr.Scope = strings.Split(qs, " ") + } + + err := func() error { + if acr.ClientID == "" { + return NewError(ErrorInvalidRequest) + } + + redirectURL := q.Get("redirect_uri") + if redirectURL != "" { + ru, err := url.Parse(redirectURL) + if err != nil { + return NewError(ErrorInvalidRequest) + } + acr.RedirectURL = ru + } + + return nil + }() + + return acr, err +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/client.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/client.go new file mode 100644 index 000000000000..7a3cb40f6450 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/client.go @@ -0,0 +1,846 @@ +package oidc + +import ( + "encoding/json" + "errors" + "fmt" + "net/http" + "net/mail" + "net/url" + "sync" + "time" + + phttp "github.com/coreos/go-oidc/http" + "github.com/coreos/go-oidc/jose" + "github.com/coreos/go-oidc/key" + "github.com/coreos/go-oidc/oauth2" +) + +const ( + // amount of time that must pass after the last key sync + // completes before another attempt may begin + keySyncWindow = 5 * time.Second +) + +var ( + DefaultScope = []string{"openid", "email", "profile"} + + supportedAuthMethods = map[string]struct{}{ + oauth2.AuthMethodClientSecretBasic: struct{}{}, + oauth2.AuthMethodClientSecretPost: struct{}{}, + } +) + +type ClientCredentials oauth2.ClientCredentials + +type ClientIdentity struct { + Credentials ClientCredentials + Metadata ClientMetadata +} + +type JWAOptions struct { + // SigningAlg specifies an JWA alg for signing JWTs. + // + // Specifying this field implies different actions depending on the context. It may + // require objects be serialized and signed as a JWT instead of plain JSON, or + // require an existing JWT object use the specified alg. + // + // See: http://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata + SigningAlg string + // EncryptionAlg, if provided, specifies that the returned or sent object be stored + // (or nested) within a JWT object and encrypted with the provided JWA alg. + EncryptionAlg string + // EncryptionEnc specifies the JWA enc algorithm to use with EncryptionAlg. If + // EncryptionAlg is provided and EncryptionEnc is omitted, this field defaults + // to A128CBC-HS256. + // + // If EncryptionEnc is provided EncryptionAlg must also be specified. + EncryptionEnc string +} + +func (opt JWAOptions) valid() error { + if opt.EncryptionEnc != "" && opt.EncryptionAlg == "" { + return errors.New("encryption encoding provided with no encryption algorithm") + } + return nil +} + +func (opt JWAOptions) defaults() JWAOptions { + if opt.EncryptionAlg != "" && opt.EncryptionEnc == "" { + opt.EncryptionEnc = jose.EncA128CBCHS256 + } + return opt +} + +var ( + // Ensure ClientMetadata satisfies these interfaces. + _ json.Marshaler = &ClientMetadata{} + _ json.Unmarshaler = &ClientMetadata{} +) + +// ClientMetadata holds metadata that the authorization server associates +// with a client identifier. The fields range from human-facing display +// strings such as client name, to items that impact the security of the +// protocol, such as the list of valid redirect URIs. +// +// See http://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata +// +// TODO: support language specific claim representations +// http://openid.net/specs/openid-connect-registration-1_0.html#LanguagesAndScripts +type ClientMetadata struct { + RedirectURIs []url.URL // Required + + // A list of OAuth 2.0 "response_type" values that the client wishes to restrict + // itself to. Either "code", "token", or another registered extension. + // + // If omitted, only "code" will be used. + ResponseTypes []string + // A list of OAuth 2.0 grant types the client wishes to restrict itself to. + // The grant type values used by OIDC are "authorization_code", "implicit", + // and "refresh_token". + // + // If ommitted, only "authorization_code" will be used. + GrantTypes []string + // "native" or "web". If omitted, "web". + ApplicationType string + + // List of email addresses. + Contacts []mail.Address + // Name of client to be presented to the end-user. + ClientName string + // URL that references a logo for the Client application. + LogoURI *url.URL + // URL of the home page of the Client. + ClientURI *url.URL + // Profile data policies and terms of use to be provided to the end user. + PolicyURI *url.URL + TermsOfServiceURI *url.URL + + // URL to or the value of the client's JSON Web Key Set document. + JWKSURI *url.URL + JWKS *jose.JWKSet + + // URL referencing a flie with a single JSON array of redirect URIs. + SectorIdentifierURI *url.URL + + SubjectType string + + // Options to restrict the JWS alg and enc values used for server responses and requests. + IDTokenResponseOptions JWAOptions + UserInfoResponseOptions JWAOptions + RequestObjectOptions JWAOptions + + // Client requested authorization method and signing options for the token endpoint. + // + // Defaults to "client_secret_basic" + TokenEndpointAuthMethod string + TokenEndpointAuthSigningAlg string + + // DefaultMaxAge specifies the maximum amount of time in seconds before an authorized + // user must reauthroize. + // + // If 0, no limitation is placed on the maximum. + DefaultMaxAge int64 + // RequireAuthTime specifies if the auth_time claim in the ID token is required. + RequireAuthTime bool + + // Default Authentication Context Class Reference values for authentication requests. + DefaultACRValues []string + + // URI that a third party can use to initiate a login by the relaying party. + // + // See: http://openid.net/specs/openid-connect-core-1_0.html#ThirdPartyInitiatedLogin + InitiateLoginURI *url.URL + // Pre-registered request_uri values that may be cached by the server. + RequestURIs []url.URL +} + +// Defaults returns a shallow copy of ClientMetadata with default +// values replacing omitted fields. +func (m ClientMetadata) Defaults() ClientMetadata { + if len(m.ResponseTypes) == 0 { + m.ResponseTypes = []string{oauth2.ResponseTypeCode} + } + if len(m.GrantTypes) == 0 { + m.GrantTypes = []string{oauth2.GrantTypeAuthCode} + } + if m.ApplicationType == "" { + m.ApplicationType = "web" + } + if m.TokenEndpointAuthMethod == "" { + m.TokenEndpointAuthMethod = oauth2.AuthMethodClientSecretBasic + } + m.IDTokenResponseOptions = m.IDTokenResponseOptions.defaults() + m.UserInfoResponseOptions = m.UserInfoResponseOptions.defaults() + m.RequestObjectOptions = m.RequestObjectOptions.defaults() + return m +} + +func (m *ClientMetadata) MarshalJSON() ([]byte, error) { + e := m.toEncodableStruct() + return json.Marshal(&e) +} + +func (m *ClientMetadata) UnmarshalJSON(data []byte) error { + var e encodableClientMetadata + if err := json.Unmarshal(data, &e); err != nil { + return err + } + meta, err := e.toStruct() + if err != nil { + return err + } + if err := meta.Valid(); err != nil { + return err + } + *m = meta + return nil +} + +type encodableClientMetadata struct { + RedirectURIs []string `json:"redirect_uris"` // Required + ResponseTypes []string `json:"response_types,omitempty"` + GrantTypes []string `json:"grant_types,omitempty"` + ApplicationType string `json:"application_type,omitempty"` + Contacts []string `json:"contacts,omitempty"` + ClientName string `json:"client_name,omitempty"` + LogoURI string `json:"logo_uri,omitempty"` + ClientURI string `json:"client_uri,omitempty"` + PolicyURI string `json:"policy_uri,omitempty"` + TermsOfServiceURI string `json:"tos_uri,omitempty"` + JWKSURI string `json:"jwks_uri,omitempty"` + JWKS *jose.JWKSet `json:"jwks,omitempty"` + SectorIdentifierURI string `json:"sector_identifier_uri,omitempty"` + SubjectType string `json:"subject_type,omitempty"` + IDTokenSignedResponseAlg string `json:"id_token_signed_response_alg,omitempty"` + IDTokenEncryptedResponseAlg string `json:"id_token_encrypted_response_alg,omitempty"` + IDTokenEncryptedResponseEnc string `json:"id_token_encrypted_response_enc,omitempty"` + UserInfoSignedResponseAlg string `json:"userinfo_signed_response_alg,omitempty"` + UserInfoEncryptedResponseAlg string `json:"userinfo_encrypted_response_alg,omitempty"` + UserInfoEncryptedResponseEnc string `json:"userinfo_encrypted_response_enc,omitempty"` + RequestObjectSigningAlg string `json:"request_object_signing_alg,omitempty"` + RequestObjectEncryptionAlg string `json:"request_object_encryption_alg,omitempty"` + RequestObjectEncryptionEnc string `json:"request_object_encryption_enc,omitempty"` + TokenEndpointAuthMethod string `json:"token_endpoint_auth_method,omitempty"` + TokenEndpointAuthSigningAlg string `json:"token_endpoint_auth_signing_alg,omitempty"` + DefaultMaxAge int64 `json:"default_max_age,omitempty"` + RequireAuthTime bool `json:"require_auth_time,omitempty"` + DefaultACRValues []string `json:"default_acr_values,omitempty"` + InitiateLoginURI string `json:"initiate_login_uri,omitempty"` + RequestURIs []string `json:"request_uris,omitempty"` +} + +func (c *encodableClientMetadata) toStruct() (ClientMetadata, error) { + p := stickyErrParser{} + m := ClientMetadata{ + RedirectURIs: p.parseURIs(c.RedirectURIs, "redirect_uris"), + ResponseTypes: c.ResponseTypes, + GrantTypes: c.GrantTypes, + ApplicationType: c.ApplicationType, + Contacts: p.parseEmails(c.Contacts, "contacts"), + ClientName: c.ClientName, + LogoURI: p.parseURI(c.LogoURI, "logo_uri"), + ClientURI: p.parseURI(c.ClientURI, "client_uri"), + PolicyURI: p.parseURI(c.PolicyURI, "policy_uri"), + TermsOfServiceURI: p.parseURI(c.TermsOfServiceURI, "tos_uri"), + JWKSURI: p.parseURI(c.JWKSURI, "jwks_uri"), + JWKS: c.JWKS, + SectorIdentifierURI: p.parseURI(c.SectorIdentifierURI, "sector_identifier_uri"), + SubjectType: c.SubjectType, + TokenEndpointAuthMethod: c.TokenEndpointAuthMethod, + TokenEndpointAuthSigningAlg: c.TokenEndpointAuthSigningAlg, + DefaultMaxAge: c.DefaultMaxAge, + RequireAuthTime: c.RequireAuthTime, + DefaultACRValues: c.DefaultACRValues, + InitiateLoginURI: p.parseURI(c.InitiateLoginURI, "initiate_login_uri"), + RequestURIs: p.parseURIs(c.RequestURIs, "request_uris"), + IDTokenResponseOptions: JWAOptions{ + c.IDTokenSignedResponseAlg, + c.IDTokenEncryptedResponseAlg, + c.IDTokenEncryptedResponseEnc, + }, + UserInfoResponseOptions: JWAOptions{ + c.UserInfoSignedResponseAlg, + c.UserInfoEncryptedResponseAlg, + c.UserInfoEncryptedResponseEnc, + }, + RequestObjectOptions: JWAOptions{ + c.RequestObjectSigningAlg, + c.RequestObjectEncryptionAlg, + c.RequestObjectEncryptionEnc, + }, + } + if p.firstErr != nil { + return ClientMetadata{}, p.firstErr + } + return m, nil +} + +// stickyErrParser parses URIs and email addresses. Once it encounters +// a parse error, subsequent calls become no-op. +type stickyErrParser struct { + firstErr error +} + +func (p *stickyErrParser) parseURI(s, field string) *url.URL { + if p.firstErr != nil || s == "" { + return nil + } + u, err := url.Parse(s) + if err == nil { + if u.Host == "" { + err = errors.New("no host in URI") + } else if u.Scheme != "http" && u.Scheme != "https" { + err = errors.New("invalid URI scheme") + } + } + if err != nil { + p.firstErr = fmt.Errorf("failed to parse %s: %v", field, err) + return nil + } + return u +} + +func (p *stickyErrParser) parseURIs(s []string, field string) []url.URL { + if p.firstErr != nil || len(s) == 0 { + return nil + } + uris := make([]url.URL, len(s)) + for i, val := range s { + if val == "" { + p.firstErr = fmt.Errorf("invalid URI in field %s", field) + return nil + } + if u := p.parseURI(val, field); u != nil { + uris[i] = *u + } + } + return uris +} + +func (p *stickyErrParser) parseEmails(s []string, field string) []mail.Address { + if p.firstErr != nil || len(s) == 0 { + return nil + } + addrs := make([]mail.Address, len(s)) + for i, addr := range s { + if addr == "" { + p.firstErr = fmt.Errorf("invalid email in field %s", field) + return nil + } + a, err := mail.ParseAddress(addr) + if err != nil { + p.firstErr = fmt.Errorf("invalid email in field %s: %v", field, err) + return nil + } + addrs[i] = *a + } + return addrs +} + +func (m *ClientMetadata) toEncodableStruct() encodableClientMetadata { + return encodableClientMetadata{ + RedirectURIs: urisToStrings(m.RedirectURIs), + ResponseTypes: m.ResponseTypes, + GrantTypes: m.GrantTypes, + ApplicationType: m.ApplicationType, + Contacts: emailsToStrings(m.Contacts), + ClientName: m.ClientName, + LogoURI: uriToString(m.LogoURI), + ClientURI: uriToString(m.ClientURI), + PolicyURI: uriToString(m.PolicyURI), + TermsOfServiceURI: uriToString(m.TermsOfServiceURI), + JWKSURI: uriToString(m.JWKSURI), + JWKS: m.JWKS, + SectorIdentifierURI: uriToString(m.SectorIdentifierURI), + SubjectType: m.SubjectType, + IDTokenSignedResponseAlg: m.IDTokenResponseOptions.SigningAlg, + IDTokenEncryptedResponseAlg: m.IDTokenResponseOptions.EncryptionAlg, + IDTokenEncryptedResponseEnc: m.IDTokenResponseOptions.EncryptionEnc, + UserInfoSignedResponseAlg: m.UserInfoResponseOptions.SigningAlg, + UserInfoEncryptedResponseAlg: m.UserInfoResponseOptions.EncryptionAlg, + UserInfoEncryptedResponseEnc: m.UserInfoResponseOptions.EncryptionEnc, + RequestObjectSigningAlg: m.RequestObjectOptions.SigningAlg, + RequestObjectEncryptionAlg: m.RequestObjectOptions.EncryptionAlg, + RequestObjectEncryptionEnc: m.RequestObjectOptions.EncryptionEnc, + TokenEndpointAuthMethod: m.TokenEndpointAuthMethod, + TokenEndpointAuthSigningAlg: m.TokenEndpointAuthSigningAlg, + DefaultMaxAge: m.DefaultMaxAge, + RequireAuthTime: m.RequireAuthTime, + DefaultACRValues: m.DefaultACRValues, + InitiateLoginURI: uriToString(m.InitiateLoginURI), + RequestURIs: urisToStrings(m.RequestURIs), + } +} + +func uriToString(u *url.URL) string { + if u == nil { + return "" + } + return u.String() +} + +func urisToStrings(urls []url.URL) []string { + if len(urls) == 0 { + return nil + } + sli := make([]string, len(urls)) + for i, u := range urls { + sli[i] = u.String() + } + return sli +} + +func emailsToStrings(addrs []mail.Address) []string { + if len(addrs) == 0 { + return nil + } + sli := make([]string, len(addrs)) + for i, addr := range addrs { + sli[i] = addr.String() + } + return sli +} + +// Valid determines if a ClientMetadata conforms with the OIDC specification. +// +// Valid is called by UnmarshalJSON. +// +// NOTE(ericchiang): For development purposes Valid does not mandate 'https' for +// URLs fields where the OIDC spec requires it. This may change in future releases +// of this package. See: https://github.com/coreos/go-oidc/issues/34 +func (m *ClientMetadata) Valid() error { + if len(m.RedirectURIs) == 0 { + return errors.New("zero redirect URLs") + } + + validURI := func(u *url.URL, fieldName string) error { + if u.Host == "" { + return fmt.Errorf("no host for uri field %s", fieldName) + } + if u.Scheme != "http" && u.Scheme != "https" { + return fmt.Errorf("uri field %s scheme is not http or https", fieldName) + } + return nil + } + + uris := []struct { + val *url.URL + name string + }{ + {m.LogoURI, "logo_uri"}, + {m.ClientURI, "client_uri"}, + {m.PolicyURI, "policy_uri"}, + {m.TermsOfServiceURI, "tos_uri"}, + {m.JWKSURI, "jwks_uri"}, + {m.SectorIdentifierURI, "sector_identifier_uri"}, + {m.InitiateLoginURI, "initiate_login_uri"}, + } + + for _, uri := range uris { + if uri.val == nil { + continue + } + if err := validURI(uri.val, uri.name); err != nil { + return err + } + } + + uriLists := []struct { + vals []url.URL + name string + }{ + {m.RedirectURIs, "redirect_uris"}, + {m.RequestURIs, "request_uris"}, + } + for _, list := range uriLists { + for _, uri := range list.vals { + if err := validURI(&uri, list.name); err != nil { + return err + } + } + } + + options := []struct { + option JWAOptions + name string + }{ + {m.IDTokenResponseOptions, "id_token response"}, + {m.UserInfoResponseOptions, "userinfo response"}, + {m.RequestObjectOptions, "request_object"}, + } + for _, option := range options { + if err := option.option.valid(); err != nil { + return fmt.Errorf("invalid JWA values for %s: %v", option.name, err) + } + } + return nil +} + +type ClientRegistrationResponse struct { + ClientID string // Required + ClientSecret string + RegistrationAccessToken string + RegistrationClientURI string + // If IsZero is true, unspecified. + ClientIDIssuedAt time.Time + // Time at which the client_secret will expire. + // If IsZero is true, it will not expire. + ClientSecretExpiresAt time.Time + + ClientMetadata +} + +type encodableClientRegistrationResponse struct { + ClientID string `json:"client_id"` // Required + ClientSecret string `json:"client_secret,omitempty"` + RegistrationAccessToken string `json:"registration_access_token,omitempty"` + RegistrationClientURI string `json:"registration_client_uri,omitempty"` + ClientIDIssuedAt int64 `json:"client_id_issued_at,omitempty"` + // Time at which the client_secret will expire, in seconds since the epoch. + // If 0 it will not expire. + ClientSecretExpiresAt int64 `json:"client_secret_expires_at"` // Required + + encodableClientMetadata +} + +func unixToSec(t time.Time) int64 { + if t.IsZero() { + return 0 + } + return t.Unix() +} + +func (c *ClientRegistrationResponse) MarshalJSON() ([]byte, error) { + e := encodableClientRegistrationResponse{ + ClientID: c.ClientID, + ClientSecret: c.ClientSecret, + RegistrationAccessToken: c.RegistrationAccessToken, + RegistrationClientURI: c.RegistrationClientURI, + ClientIDIssuedAt: unixToSec(c.ClientIDIssuedAt), + ClientSecretExpiresAt: unixToSec(c.ClientSecretExpiresAt), + encodableClientMetadata: c.ClientMetadata.toEncodableStruct(), + } + return json.Marshal(&e) +} + +func secToUnix(sec int64) time.Time { + if sec == 0 { + return time.Time{} + } + return time.Unix(sec, 0) +} + +func (c *ClientRegistrationResponse) UnmarshalJSON(data []byte) error { + var e encodableClientRegistrationResponse + if err := json.Unmarshal(data, &e); err != nil { + return err + } + if e.ClientID == "" { + return errors.New("no client_id in client registration response") + } + metadata, err := e.encodableClientMetadata.toStruct() + if err != nil { + return err + } + *c = ClientRegistrationResponse{ + ClientID: e.ClientID, + ClientSecret: e.ClientSecret, + RegistrationAccessToken: e.RegistrationAccessToken, + RegistrationClientURI: e.RegistrationClientURI, + ClientIDIssuedAt: secToUnix(e.ClientIDIssuedAt), + ClientSecretExpiresAt: secToUnix(e.ClientSecretExpiresAt), + ClientMetadata: metadata, + } + return nil +} + +type ClientConfig struct { + HTTPClient phttp.Client + Credentials ClientCredentials + Scope []string + RedirectURL string + ProviderConfig ProviderConfig + KeySet key.PublicKeySet +} + +func NewClient(cfg ClientConfig) (*Client, error) { + // Allow empty redirect URL in the case where the client + // only needs to verify a given token. + ru, err := url.Parse(cfg.RedirectURL) + if err != nil { + return nil, fmt.Errorf("invalid redirect URL: %v", err) + } + + c := Client{ + credentials: cfg.Credentials, + httpClient: cfg.HTTPClient, + scope: cfg.Scope, + redirectURL: ru.String(), + providerConfig: newProviderConfigRepo(cfg.ProviderConfig), + keySet: cfg.KeySet, + } + + if c.httpClient == nil { + c.httpClient = http.DefaultClient + } + + if c.scope == nil { + c.scope = make([]string, len(DefaultScope)) + copy(c.scope, DefaultScope) + } + + return &c, nil +} + +type Client struct { + httpClient phttp.Client + providerConfig *providerConfigRepo + credentials ClientCredentials + redirectURL string + scope []string + keySet key.PublicKeySet + providerSyncer *ProviderConfigSyncer + + keySetSyncMutex sync.RWMutex + lastKeySetSync time.Time +} + +func (c *Client) Healthy() error { + now := time.Now().UTC() + + cfg := c.providerConfig.Get() + + if cfg.Empty() { + return errors.New("oidc client provider config empty") + } + + if !cfg.ExpiresAt.IsZero() && cfg.ExpiresAt.Before(now) { + return errors.New("oidc client provider config expired") + } + + return nil +} + +func (c *Client) OAuthClient() (*oauth2.Client, error) { + cfg := c.providerConfig.Get() + authMethod, err := chooseAuthMethod(cfg) + if err != nil { + return nil, err + } + + ocfg := oauth2.Config{ + Credentials: oauth2.ClientCredentials(c.credentials), + RedirectURL: c.redirectURL, + AuthURL: cfg.AuthEndpoint.String(), + TokenURL: cfg.TokenEndpoint.String(), + Scope: c.scope, + AuthMethod: authMethod, + } + + return oauth2.NewClient(c.httpClient, ocfg) +} + +func chooseAuthMethod(cfg ProviderConfig) (string, error) { + if len(cfg.TokenEndpointAuthMethodsSupported) == 0 { + return oauth2.AuthMethodClientSecretBasic, nil + } + + for _, authMethod := range cfg.TokenEndpointAuthMethodsSupported { + if _, ok := supportedAuthMethods[authMethod]; ok { + return authMethod, nil + } + } + + return "", errors.New("no supported auth methods") +} + +// SyncProviderConfig starts the provider config syncer +func (c *Client) SyncProviderConfig(discoveryURL string) chan struct{} { + r := NewHTTPProviderConfigGetter(c.httpClient, discoveryURL) + s := NewProviderConfigSyncer(r, c.providerConfig) + stop := s.Run() + s.WaitUntilInitialSync() + return stop +} + +func (c *Client) maybeSyncKeys() error { + tooSoon := func() bool { + return time.Now().UTC().Before(c.lastKeySetSync.Add(keySyncWindow)) + } + + // ignore request to sync keys if a sync operation has been + // attempted too recently + if tooSoon() { + return nil + } + + c.keySetSyncMutex.Lock() + defer c.keySetSyncMutex.Unlock() + + // check again, as another goroutine may have been holding + // the lock while updating the keys + if tooSoon() { + return nil + } + + cfg := c.providerConfig.Get() + r := NewRemotePublicKeyRepo(c.httpClient, cfg.KeysEndpoint.String()) + w := &clientKeyRepo{client: c} + _, err := key.Sync(r, w) + c.lastKeySetSync = time.Now().UTC() + + return err +} + +type clientKeyRepo struct { + client *Client +} + +func (r *clientKeyRepo) Set(ks key.KeySet) error { + pks, ok := ks.(*key.PublicKeySet) + if !ok { + return errors.New("unable to cast to PublicKey") + } + r.client.keySet = *pks + return nil +} + +func (c *Client) ClientCredsToken(scope []string) (jose.JWT, error) { + cfg := c.providerConfig.Get() + + if !cfg.SupportsGrantType(oauth2.GrantTypeClientCreds) { + return jose.JWT{}, fmt.Errorf("%v grant type is not supported", oauth2.GrantTypeClientCreds) + } + + oac, err := c.OAuthClient() + if err != nil { + return jose.JWT{}, err + } + + t, err := oac.ClientCredsToken(scope) + if err != nil { + return jose.JWT{}, err + } + + jwt, err := jose.ParseJWT(t.IDToken) + if err != nil { + return jose.JWT{}, err + } + + return jwt, c.VerifyJWT(jwt) +} + +// ExchangeAuthCode exchanges an OAuth2 auth code for an OIDC JWT ID token. +func (c *Client) ExchangeAuthCode(code string) (jose.JWT, error) { + oac, err := c.OAuthClient() + if err != nil { + return jose.JWT{}, err + } + + t, err := oac.RequestToken(oauth2.GrantTypeAuthCode, code) + if err != nil { + return jose.JWT{}, err + } + + jwt, err := jose.ParseJWT(t.IDToken) + if err != nil { + return jose.JWT{}, err + } + + return jwt, c.VerifyJWT(jwt) +} + +// RefreshToken uses a refresh token to exchange for a new OIDC JWT ID Token. +func (c *Client) RefreshToken(refreshToken string) (jose.JWT, error) { + oac, err := c.OAuthClient() + if err != nil { + return jose.JWT{}, err + } + + t, err := oac.RequestToken(oauth2.GrantTypeRefreshToken, refreshToken) + if err != nil { + return jose.JWT{}, err + } + + jwt, err := jose.ParseJWT(t.IDToken) + if err != nil { + return jose.JWT{}, err + } + + return jwt, c.VerifyJWT(jwt) +} + +func (c *Client) VerifyJWT(jwt jose.JWT) error { + var keysFunc func() []key.PublicKey + if kID, ok := jwt.KeyID(); ok { + keysFunc = c.keysFuncWithID(kID) + } else { + keysFunc = c.keysFuncAll() + } + + v := NewJWTVerifier( + c.providerConfig.Get().Issuer.String(), + c.credentials.ID, + c.maybeSyncKeys, keysFunc) + + return v.Verify(jwt) +} + +// keysFuncWithID returns a function that retrieves at most unexpired +// public key from the Client that matches the provided ID +func (c *Client) keysFuncWithID(kID string) func() []key.PublicKey { + return func() []key.PublicKey { + c.keySetSyncMutex.RLock() + defer c.keySetSyncMutex.RUnlock() + + if c.keySet.ExpiresAt().Before(time.Now()) { + return []key.PublicKey{} + } + + k := c.keySet.Key(kID) + if k == nil { + return []key.PublicKey{} + } + + return []key.PublicKey{*k} + } +} + +// keysFuncAll returns a function that retrieves all unexpired public +// keys from the Client +func (c *Client) keysFuncAll() func() []key.PublicKey { + return func() []key.PublicKey { + c.keySetSyncMutex.RLock() + defer c.keySetSyncMutex.RUnlock() + + if c.keySet.ExpiresAt().Before(time.Now()) { + return []key.PublicKey{} + } + + return c.keySet.Keys() + } +} + +type providerConfigRepo struct { + mu sync.RWMutex + config ProviderConfig // do not access directly, use Get() +} + +func newProviderConfigRepo(pc ProviderConfig) *providerConfigRepo { + return &providerConfigRepo{sync.RWMutex{}, pc} +} + +// returns an error to implement ProviderConfigSetter +func (r *providerConfigRepo) Set(cfg ProviderConfig) error { + r.mu.Lock() + defer r.mu.Unlock() + r.config = cfg + return nil +} + +func (r *providerConfigRepo) Get() ProviderConfig { + r.mu.RLock() + defer r.mu.RUnlock() + return r.config +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/identity.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/identity.go new file mode 100644 index 000000000000..9bfa8e343994 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/identity.go @@ -0,0 +1,44 @@ +package oidc + +import ( + "errors" + "time" + + "github.com/coreos/go-oidc/jose" +) + +type Identity struct { + ID string + Name string + Email string + ExpiresAt time.Time +} + +func IdentityFromClaims(claims jose.Claims) (*Identity, error) { + if claims == nil { + return nil, errors.New("nil claim set") + } + + var ident Identity + var err error + var ok bool + + if ident.ID, ok, err = claims.StringClaim("sub"); err != nil { + return nil, err + } else if !ok { + return nil, errors.New("missing required claim: sub") + } + + if ident.Email, _, err = claims.StringClaim("email"); err != nil { + return nil, err + } + + exp, ok, err := claims.TimeClaim("exp") + if err != nil { + return nil, err + } else if ok { + ident.ExpiresAt = exp + } + + return &ident, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/interface.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/interface.go new file mode 100644 index 000000000000..248cac0b4dff --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/interface.go @@ -0,0 +1,3 @@ +package oidc + +type LoginFunc func(ident Identity, sessionKey string) (redirectURL string, err error) diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/key.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/key.go new file mode 100755 index 000000000000..82a0f567d577 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/key.go @@ -0,0 +1,67 @@ +package oidc + +import ( + "encoding/json" + "errors" + "net/http" + "time" + + phttp "github.com/coreos/go-oidc/http" + "github.com/coreos/go-oidc/jose" + "github.com/coreos/go-oidc/key" +) + +// DefaultPublicKeySetTTL is the default TTL set on the PublicKeySet if no +// Cache-Control header is provided by the JWK Set document endpoint. +const DefaultPublicKeySetTTL = 24 * time.Hour + +// NewRemotePublicKeyRepo is responsible for fetching the JWK Set document. +func NewRemotePublicKeyRepo(hc phttp.Client, ep string) *remotePublicKeyRepo { + return &remotePublicKeyRepo{hc: hc, ep: ep} +} + +type remotePublicKeyRepo struct { + hc phttp.Client + ep string +} + +// Get returns a PublicKeySet fetched from the JWK Set document endpoint. A TTL +// is set on the Key Set to avoid it having to be re-retrieved for every +// encryption event. This TTL is typically controlled by the endpoint returning +// a Cache-Control header, but defaults to 24 hours if no Cache-Control header +// is found. +func (r *remotePublicKeyRepo) Get() (key.KeySet, error) { + req, err := http.NewRequest("GET", r.ep, nil) + if err != nil { + return nil, err + } + + resp, err := r.hc.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + var d struct { + Keys []jose.JWK `json:"keys"` + } + if err := json.NewDecoder(resp.Body).Decode(&d); err != nil { + return nil, err + } + + if len(d.Keys) == 0 { + return nil, errors.New("zero keys in response") + } + + ttl, ok, err := phttp.Cacheable(resp.Header) + if err != nil { + return nil, err + } + if !ok { + ttl = DefaultPublicKeySetTTL + } + + exp := time.Now().UTC().Add(ttl) + ks := key.NewPublicKeySet(d.Keys, exp) + return ks, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/provider.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/provider.go new file mode 100644 index 000000000000..ca2838440b3e --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/provider.go @@ -0,0 +1,690 @@ +package oidc + +import ( + "encoding/json" + "errors" + "fmt" + "log" + "net/http" + "net/url" + "strings" + "sync" + "time" + + "github.com/coreos/pkg/timeutil" + "github.com/jonboulle/clockwork" + + phttp "github.com/coreos/go-oidc/http" + "github.com/coreos/go-oidc/oauth2" +) + +const ( + // Subject Identifier types defined by the OIDC spec. Specifies if the provider + // should provide the same sub claim value to all clients (public) or a unique + // value for each client (pairwise). + // + // See: http://openid.net/specs/openid-connect-core-1_0.html#SubjectIDTypes + SubjectTypePublic = "public" + SubjectTypePairwise = "pairwise" +) + +var ( + // Default values for omitted provider config fields. + // + // Use ProviderConfig's Defaults method to fill a provider config with these values. + DefaultGrantTypesSupported = []string{oauth2.GrantTypeAuthCode, oauth2.GrantTypeImplicit} + DefaultResponseModesSupported = []string{"query", "fragment"} + DefaultTokenEndpointAuthMethodsSupported = []string{oauth2.AuthMethodClientSecretBasic} + DefaultClaimTypesSupported = []string{"normal"} +) + +const ( + MaximumProviderConfigSyncInterval = 24 * time.Hour + MinimumProviderConfigSyncInterval = time.Minute + + discoveryConfigPath = "/.well-known/openid-configuration" +) + +// internally configurable for tests +var minimumProviderConfigSyncInterval = MinimumProviderConfigSyncInterval + +var ( + // Ensure ProviderConfig satisfies these interfaces. + _ json.Marshaler = &ProviderConfig{} + _ json.Unmarshaler = &ProviderConfig{} +) + +// ProviderConfig represents the OpenID Provider Metadata specifying what +// configurations a provider supports. +// +// See: http://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata +type ProviderConfig struct { + Issuer *url.URL // Required + AuthEndpoint *url.URL // Required + TokenEndpoint *url.URL // Required if grant types other than "implicit" are supported + UserInfoEndpoint *url.URL + KeysEndpoint *url.URL // Required + RegistrationEndpoint *url.URL + EndSessionEndpoint *url.URL + CheckSessionIFrame *url.URL + + // Servers MAY choose not to advertise some supported scope values even when this + // parameter is used, although those defined in OpenID Core SHOULD be listed, if supported. + ScopesSupported []string + // OAuth2.0 response types supported. + ResponseTypesSupported []string // Required + // OAuth2.0 response modes supported. + // + // If omitted, defaults to DefaultResponseModesSupported. + ResponseModesSupported []string + // OAuth2.0 grant types supported. + // + // If omitted, defaults to DefaultGrantTypesSupported. + GrantTypesSupported []string + ACRValuesSupported []string + // SubjectTypesSupported specifies strategies for providing values for the sub claim. + SubjectTypesSupported []string // Required + + // JWA signing and encryption algorith values supported for ID tokens. + IDTokenSigningAlgValues []string // Required + IDTokenEncryptionAlgValues []string + IDTokenEncryptionEncValues []string + + // JWA signing and encryption algorith values supported for user info responses. + UserInfoSigningAlgValues []string + UserInfoEncryptionAlgValues []string + UserInfoEncryptionEncValues []string + + // JWA signing and encryption algorith values supported for request objects. + ReqObjSigningAlgValues []string + ReqObjEncryptionAlgValues []string + ReqObjEncryptionEncValues []string + + TokenEndpointAuthMethodsSupported []string + TokenEndpointAuthSigningAlgValuesSupported []string + DisplayValuesSupported []string + ClaimTypesSupported []string + ClaimsSupported []string + ServiceDocs *url.URL + ClaimsLocalsSupported []string + UILocalsSupported []string + ClaimsParameterSupported bool + RequestParameterSupported bool + RequestURIParamaterSupported bool + RequireRequestURIRegistration bool + + Policy *url.URL + TermsOfService *url.URL + + // Not part of the OpenID Provider Metadata + ExpiresAt time.Time +} + +// Defaults returns a shallow copy of ProviderConfig with default +// values replacing omitted fields. +// +// var cfg oidc.ProviderConfig +// // Fill provider config with default values for omitted fields. +// cfg = cfg.Defaults() +// +func (p ProviderConfig) Defaults() ProviderConfig { + setDefault := func(val *[]string, defaultVal []string) { + if len(*val) == 0 { + *val = defaultVal + } + } + setDefault(&p.GrantTypesSupported, DefaultGrantTypesSupported) + setDefault(&p.ResponseModesSupported, DefaultResponseModesSupported) + setDefault(&p.TokenEndpointAuthMethodsSupported, DefaultTokenEndpointAuthMethodsSupported) + setDefault(&p.ClaimTypesSupported, DefaultClaimTypesSupported) + return p +} + +func (p *ProviderConfig) MarshalJSON() ([]byte, error) { + e := p.toEncodableStruct() + return json.Marshal(&e) +} + +func (p *ProviderConfig) UnmarshalJSON(data []byte) error { + var e encodableProviderConfig + if err := json.Unmarshal(data, &e); err != nil { + return err + } + conf, err := e.toStruct() + if err != nil { + return err + } + if err := conf.Valid(); err != nil { + return err + } + *p = conf + return nil +} + +type encodableProviderConfig struct { + Issuer string `json:"issuer"` + AuthEndpoint string `json:"authorization_endpoint"` + TokenEndpoint string `json:"token_endpoint"` + UserInfoEndpoint string `json:"userinfo_endpoint,omitempty"` + KeysEndpoint string `json:"jwks_uri"` + RegistrationEndpoint string `json:"registration_endpoint,omitempty"` + EndSessionEndpoint string `json:"end_session_endpoint,omitempty"` + CheckSessionIFrame string `json:"check_session_iframe,omitempty"` + + // Use 'omitempty' for all slices as per OIDC spec: + // "Claims that return multiple values are represented as JSON arrays. + // Claims with zero elements MUST be omitted from the response." + // http://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationResponse + + ScopesSupported []string `json:"scopes_supported,omitempty"` + ResponseTypesSupported []string `json:"response_types_supported,omitempty"` + ResponseModesSupported []string `json:"response_modes_supported,omitempty"` + GrantTypesSupported []string `json:"grant_types_supported,omitempty"` + ACRValuesSupported []string `json:"acr_values_supported,omitempty"` + SubjectTypesSupported []string `json:"subject_types_supported,omitempty"` + + IDTokenSigningAlgValues []string `json:"id_token_signing_alg_values_supported,omitempty"` + IDTokenEncryptionAlgValues []string `json:"id_token_encryption_alg_values_supported,omitempty"` + IDTokenEncryptionEncValues []string `json:"id_token_encryption_enc_values_supported,omitempty"` + UserInfoSigningAlgValues []string `json:"userinfo_signing_alg_values_supported,omitempty"` + UserInfoEncryptionAlgValues []string `json:"userinfo_encryption_alg_values_supported,omitempty"` + UserInfoEncryptionEncValues []string `json:"userinfo_encryption_enc_values_supported,omitempty"` + ReqObjSigningAlgValues []string `json:"request_object_signing_alg_values_supported,omitempty"` + ReqObjEncryptionAlgValues []string `json:"request_object_encryption_alg_values_supported,omitempty"` + ReqObjEncryptionEncValues []string `json:"request_object_encryption_enc_values_supported,omitempty"` + + TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported,omitempty"` + TokenEndpointAuthSigningAlgValuesSupported []string `json:"token_endpoint_auth_signing_alg_values_supported,omitempty"` + + DisplayValuesSupported []string `json:"display_values_supported,omitempty"` + ClaimTypesSupported []string `json:"claim_types_supported,omitempty"` + ClaimsSupported []string `json:"claims_supported,omitempty"` + ServiceDocs string `json:"service_documentation,omitempty"` + ClaimsLocalsSupported []string `json:"claims_locales_supported,omitempty"` + UILocalsSupported []string `json:"ui_locales_supported,omitempty"` + ClaimsParameterSupported bool `json:"claims_parameter_supported,omitempty"` + RequestParameterSupported bool `json:"request_parameter_supported,omitempty"` + RequestURIParamaterSupported bool `json:"request_uri_parameter_supported,omitempty"` + RequireRequestURIRegistration bool `json:"require_request_uri_registration,omitempty"` + + Policy string `json:"op_policy_uri,omitempty"` + TermsOfService string `json:"op_tos_uri,omitempty"` +} + +func (cfg ProviderConfig) toEncodableStruct() encodableProviderConfig { + return encodableProviderConfig{ + Issuer: uriToString(cfg.Issuer), + AuthEndpoint: uriToString(cfg.AuthEndpoint), + TokenEndpoint: uriToString(cfg.TokenEndpoint), + UserInfoEndpoint: uriToString(cfg.UserInfoEndpoint), + KeysEndpoint: uriToString(cfg.KeysEndpoint), + RegistrationEndpoint: uriToString(cfg.RegistrationEndpoint), + EndSessionEndpoint: uriToString(cfg.EndSessionEndpoint), + CheckSessionIFrame: uriToString(cfg.CheckSessionIFrame), + ScopesSupported: cfg.ScopesSupported, + ResponseTypesSupported: cfg.ResponseTypesSupported, + ResponseModesSupported: cfg.ResponseModesSupported, + GrantTypesSupported: cfg.GrantTypesSupported, + ACRValuesSupported: cfg.ACRValuesSupported, + SubjectTypesSupported: cfg.SubjectTypesSupported, + IDTokenSigningAlgValues: cfg.IDTokenSigningAlgValues, + IDTokenEncryptionAlgValues: cfg.IDTokenEncryptionAlgValues, + IDTokenEncryptionEncValues: cfg.IDTokenEncryptionEncValues, + UserInfoSigningAlgValues: cfg.UserInfoSigningAlgValues, + UserInfoEncryptionAlgValues: cfg.UserInfoEncryptionAlgValues, + UserInfoEncryptionEncValues: cfg.UserInfoEncryptionEncValues, + ReqObjSigningAlgValues: cfg.ReqObjSigningAlgValues, + ReqObjEncryptionAlgValues: cfg.ReqObjEncryptionAlgValues, + ReqObjEncryptionEncValues: cfg.ReqObjEncryptionEncValues, + TokenEndpointAuthMethodsSupported: cfg.TokenEndpointAuthMethodsSupported, + TokenEndpointAuthSigningAlgValuesSupported: cfg.TokenEndpointAuthSigningAlgValuesSupported, + DisplayValuesSupported: cfg.DisplayValuesSupported, + ClaimTypesSupported: cfg.ClaimTypesSupported, + ClaimsSupported: cfg.ClaimsSupported, + ServiceDocs: uriToString(cfg.ServiceDocs), + ClaimsLocalsSupported: cfg.ClaimsLocalsSupported, + UILocalsSupported: cfg.UILocalsSupported, + ClaimsParameterSupported: cfg.ClaimsParameterSupported, + RequestParameterSupported: cfg.RequestParameterSupported, + RequestURIParamaterSupported: cfg.RequestURIParamaterSupported, + RequireRequestURIRegistration: cfg.RequireRequestURIRegistration, + Policy: uriToString(cfg.Policy), + TermsOfService: uriToString(cfg.TermsOfService), + } +} + +func (e encodableProviderConfig) toStruct() (ProviderConfig, error) { + p := stickyErrParser{} + conf := ProviderConfig{ + Issuer: p.parseURI(e.Issuer, "issuer"), + AuthEndpoint: p.parseURI(e.AuthEndpoint, "authorization_endpoint"), + TokenEndpoint: p.parseURI(e.TokenEndpoint, "token_endpoint"), + UserInfoEndpoint: p.parseURI(e.UserInfoEndpoint, "userinfo_endpoint"), + KeysEndpoint: p.parseURI(e.KeysEndpoint, "jwks_uri"), + RegistrationEndpoint: p.parseURI(e.RegistrationEndpoint, "registration_endpoint"), + EndSessionEndpoint: p.parseURI(e.EndSessionEndpoint, "end_session_endpoint"), + CheckSessionIFrame: p.parseURI(e.CheckSessionIFrame, "check_session_iframe"), + ScopesSupported: e.ScopesSupported, + ResponseTypesSupported: e.ResponseTypesSupported, + ResponseModesSupported: e.ResponseModesSupported, + GrantTypesSupported: e.GrantTypesSupported, + ACRValuesSupported: e.ACRValuesSupported, + SubjectTypesSupported: e.SubjectTypesSupported, + IDTokenSigningAlgValues: e.IDTokenSigningAlgValues, + IDTokenEncryptionAlgValues: e.IDTokenEncryptionAlgValues, + IDTokenEncryptionEncValues: e.IDTokenEncryptionEncValues, + UserInfoSigningAlgValues: e.UserInfoSigningAlgValues, + UserInfoEncryptionAlgValues: e.UserInfoEncryptionAlgValues, + UserInfoEncryptionEncValues: e.UserInfoEncryptionEncValues, + ReqObjSigningAlgValues: e.ReqObjSigningAlgValues, + ReqObjEncryptionAlgValues: e.ReqObjEncryptionAlgValues, + ReqObjEncryptionEncValues: e.ReqObjEncryptionEncValues, + TokenEndpointAuthMethodsSupported: e.TokenEndpointAuthMethodsSupported, + TokenEndpointAuthSigningAlgValuesSupported: e.TokenEndpointAuthSigningAlgValuesSupported, + DisplayValuesSupported: e.DisplayValuesSupported, + ClaimTypesSupported: e.ClaimTypesSupported, + ClaimsSupported: e.ClaimsSupported, + ServiceDocs: p.parseURI(e.ServiceDocs, "service_documentation"), + ClaimsLocalsSupported: e.ClaimsLocalsSupported, + UILocalsSupported: e.UILocalsSupported, + ClaimsParameterSupported: e.ClaimsParameterSupported, + RequestParameterSupported: e.RequestParameterSupported, + RequestURIParamaterSupported: e.RequestURIParamaterSupported, + RequireRequestURIRegistration: e.RequireRequestURIRegistration, + Policy: p.parseURI(e.Policy, "op_policy-uri"), + TermsOfService: p.parseURI(e.TermsOfService, "op_tos_uri"), + } + if p.firstErr != nil { + return ProviderConfig{}, p.firstErr + } + return conf, nil +} + +// Empty returns if a ProviderConfig holds no information. +// +// This case generally indicates a ProviderConfigGetter has experienced an error +// and has nothing to report. +func (p ProviderConfig) Empty() bool { + return p.Issuer == nil +} + +func contains(sli []string, ele string) bool { + for _, s := range sli { + if s == ele { + return true + } + } + return false +} + +// Valid determines if a ProviderConfig conforms with the OIDC specification. +// If Valid returns successfully it guarantees required field are non-nil and +// URLs are well formed. +// +// Valid is called by UnmarshalJSON. +// +// NOTE(ericchiang): For development purposes Valid does not mandate 'https' for +// URLs fields where the OIDC spec requires it. This may change in future releases +// of this package. See: https://github.com/coreos/go-oidc/issues/34 +func (p ProviderConfig) Valid() error { + grantTypes := p.GrantTypesSupported + if len(grantTypes) == 0 { + grantTypes = DefaultGrantTypesSupported + } + implicitOnly := true + for _, grantType := range grantTypes { + if grantType != oauth2.GrantTypeImplicit { + implicitOnly = false + break + } + } + + if len(p.SubjectTypesSupported) == 0 { + return errors.New("missing required field subject_types_supported") + } + if len(p.IDTokenSigningAlgValues) == 0 { + return errors.New("missing required field id_token_signing_alg_values_supported") + } + + if len(p.ScopesSupported) != 0 && !contains(p.ScopesSupported, "openid") { + return errors.New("scoped_supported must be unspecified or include 'openid'") + } + + if !contains(p.IDTokenSigningAlgValues, "RS256") { + return errors.New("id_token_signing_alg_values_supported must include 'RS256'") + } + if contains(p.TokenEndpointAuthMethodsSupported, "none") { + return errors.New("token_endpoint_auth_signing_alg_values_supported cannot include 'none'") + } + + uris := []struct { + val *url.URL + name string + required bool + }{ + {p.Issuer, "issuer", true}, + {p.AuthEndpoint, "authorization_endpoint", true}, + {p.TokenEndpoint, "token_endpoint", !implicitOnly}, + {p.UserInfoEndpoint, "userinfo_endpoint", false}, + {p.KeysEndpoint, "jwks_uri", true}, + {p.RegistrationEndpoint, "registration_endpoint", false}, + {p.EndSessionEndpoint, "end_session_endpoint", false}, + {p.CheckSessionIFrame, "check_session_iframe", false}, + {p.ServiceDocs, "service_documentation", false}, + {p.Policy, "op_policy_uri", false}, + {p.TermsOfService, "op_tos_uri", false}, + } + + for _, uri := range uris { + if uri.val == nil { + if !uri.required { + continue + } + return fmt.Errorf("empty value for required uri field %s", uri.name) + } + if uri.val.Host == "" { + return fmt.Errorf("no host for uri field %s", uri.name) + } + if uri.val.Scheme != "http" && uri.val.Scheme != "https" { + return fmt.Errorf("uri field %s schemeis not http or https", uri.name) + } + } + return nil +} + +// Supports determines if provider supports a client given their respective metadata. +func (p ProviderConfig) Supports(c ClientMetadata) error { + if err := p.Valid(); err != nil { + return fmt.Errorf("invalid provider config: %v", err) + } + if err := c.Valid(); err != nil { + return fmt.Errorf("invalid client config: %v", err) + } + + // Fill default values for omitted fields + c = c.Defaults() + p = p.Defaults() + + // Do the supported values list the requested one? + supports := []struct { + supported []string + requested string + name string + }{ + {p.IDTokenSigningAlgValues, c.IDTokenResponseOptions.SigningAlg, "id_token_signed_response_alg"}, + {p.IDTokenEncryptionAlgValues, c.IDTokenResponseOptions.EncryptionAlg, "id_token_encryption_response_alg"}, + {p.IDTokenEncryptionEncValues, c.IDTokenResponseOptions.EncryptionEnc, "id_token_encryption_response_enc"}, + {p.UserInfoSigningAlgValues, c.UserInfoResponseOptions.SigningAlg, "userinfo_signed_response_alg"}, + {p.UserInfoEncryptionAlgValues, c.UserInfoResponseOptions.EncryptionAlg, "userinfo_encryption_response_alg"}, + {p.UserInfoEncryptionEncValues, c.UserInfoResponseOptions.EncryptionEnc, "userinfo_encryption_response_enc"}, + {p.ReqObjSigningAlgValues, c.RequestObjectOptions.SigningAlg, "request_object_signing_alg"}, + {p.ReqObjEncryptionAlgValues, c.RequestObjectOptions.EncryptionAlg, "request_object_encryption_alg"}, + {p.ReqObjEncryptionEncValues, c.RequestObjectOptions.EncryptionEnc, "request_object_encryption_enc"}, + } + for _, field := range supports { + if field.requested == "" { + continue + } + if !contains(field.supported, field.requested) { + return fmt.Errorf("provider does not support requested value for field %s", field.name) + } + } + + stringsEqual := func(s1, s2 string) bool { return s1 == s2 } + + // For lists, are the list of requested values a subset of the supported ones? + supportsAll := []struct { + supported []string + requested []string + name string + // OAuth2.0 response_type can be space separated lists where order doesn't matter. + // For example "id_token token" is the same as "token id_token" + // Support a custom compare method. + comp func(s1, s2 string) bool + }{ + {p.GrantTypesSupported, c.GrantTypes, "grant_types", stringsEqual}, + {p.ResponseTypesSupported, c.ResponseTypes, "response_type", oauth2.ResponseTypesEqual}, + } + for _, field := range supportsAll { + requestLoop: + for _, req := range field.requested { + for _, sup := range field.supported { + if field.comp(req, sup) { + continue requestLoop + } + } + return fmt.Errorf("provider does not support requested value for field %s", field.name) + } + } + + // TODO(ericchiang): Are there more checks we feel comfortable with begin strict about? + + return nil +} + +func (p ProviderConfig) SupportsGrantType(grantType string) bool { + var supported []string + if len(p.GrantTypesSupported) == 0 { + supported = DefaultGrantTypesSupported + } else { + supported = p.GrantTypesSupported + } + + for _, t := range supported { + if t == grantType { + return true + } + } + return false +} + +type ProviderConfigGetter interface { + Get() (ProviderConfig, error) +} + +type ProviderConfigSetter interface { + Set(ProviderConfig) error +} + +type ProviderConfigSyncer struct { + from ProviderConfigGetter + to ProviderConfigSetter + clock clockwork.Clock + + initialSyncDone bool + initialSyncWait sync.WaitGroup +} + +func NewProviderConfigSyncer(from ProviderConfigGetter, to ProviderConfigSetter) *ProviderConfigSyncer { + return &ProviderConfigSyncer{ + from: from, + to: to, + clock: clockwork.NewRealClock(), + } +} + +func (s *ProviderConfigSyncer) Run() chan struct{} { + stop := make(chan struct{}) + + var next pcsStepper + next = &pcsStepNext{aft: time.Duration(0)} + + s.initialSyncWait.Add(1) + go func() { + for { + select { + case <-s.clock.After(next.after()): + next = next.step(s.sync) + case <-stop: + return + } + } + }() + + return stop +} + +func (s *ProviderConfigSyncer) WaitUntilInitialSync() { + s.initialSyncWait.Wait() +} + +func (s *ProviderConfigSyncer) sync() (time.Duration, error) { + cfg, err := s.from.Get() + if err != nil { + return 0, err + } + + if err = s.to.Set(cfg); err != nil { + return 0, fmt.Errorf("error setting provider config: %v", err) + } + + if !s.initialSyncDone { + s.initialSyncWait.Done() + s.initialSyncDone = true + } + + return nextSyncAfter(cfg.ExpiresAt, s.clock), nil +} + +type pcsStepFunc func() (time.Duration, error) + +type pcsStepper interface { + after() time.Duration + step(pcsStepFunc) pcsStepper +} + +type pcsStepNext struct { + aft time.Duration +} + +func (n *pcsStepNext) after() time.Duration { + return n.aft +} + +func (n *pcsStepNext) step(fn pcsStepFunc) (next pcsStepper) { + ttl, err := fn() + if err == nil { + next = &pcsStepNext{aft: ttl} + } else { + next = &pcsStepRetry{aft: time.Second} + log.Printf("go-oidc: provider config sync falied, retyring in %v: %v", next.after(), err) + } + return +} + +type pcsStepRetry struct { + aft time.Duration +} + +func (r *pcsStepRetry) after() time.Duration { + return r.aft +} + +func (r *pcsStepRetry) step(fn pcsStepFunc) (next pcsStepper) { + ttl, err := fn() + if err == nil { + next = &pcsStepNext{aft: ttl} + } else { + next = &pcsStepRetry{aft: timeutil.ExpBackoff(r.aft, time.Minute)} + log.Printf("go-oidc: provider config sync falied, retyring in %v: %v", next.after(), err) + } + return +} + +func nextSyncAfter(exp time.Time, clock clockwork.Clock) time.Duration { + if exp.IsZero() { + return MaximumProviderConfigSyncInterval + } + + t := exp.Sub(clock.Now()) / 2 + if t > MaximumProviderConfigSyncInterval { + t = MaximumProviderConfigSyncInterval + } else if t < minimumProviderConfigSyncInterval { + t = minimumProviderConfigSyncInterval + } + + return t +} + +type httpProviderConfigGetter struct { + hc phttp.Client + issuerURL string + clock clockwork.Clock +} + +func NewHTTPProviderConfigGetter(hc phttp.Client, issuerURL string) *httpProviderConfigGetter { + return &httpProviderConfigGetter{ + hc: hc, + issuerURL: issuerURL, + clock: clockwork.NewRealClock(), + } +} + +func (r *httpProviderConfigGetter) Get() (cfg ProviderConfig, err error) { + // If the Issuer value contains a path component, any terminating / MUST be removed before + // appending /.well-known/openid-configuration. + // https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationRequest + discoveryURL := strings.TrimSuffix(r.issuerURL, "/") + discoveryConfigPath + req, err := http.NewRequest("GET", discoveryURL, nil) + if err != nil { + return + } + + resp, err := r.hc.Do(req) + if err != nil { + return + } + defer resp.Body.Close() + + if err = json.NewDecoder(resp.Body).Decode(&cfg); err != nil { + return + } + + var ttl time.Duration + var ok bool + ttl, ok, err = phttp.Cacheable(resp.Header) + if err != nil { + return + } else if ok { + cfg.ExpiresAt = r.clock.Now().UTC().Add(ttl) + } + + // The issuer value returned MUST be identical to the Issuer URL that was directly used to retrieve the configuration information. + // http://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationValidation + if !urlEqual(cfg.Issuer.String(), r.issuerURL) { + err = fmt.Errorf(`"issuer" in config (%v) does not match provided issuer URL (%v)`, cfg.Issuer, r.issuerURL) + return + } + + return +} + +func FetchProviderConfig(hc phttp.Client, issuerURL string) (ProviderConfig, error) { + if hc == nil { + hc = http.DefaultClient + } + + g := NewHTTPProviderConfigGetter(hc, issuerURL) + return g.Get() +} + +func WaitForProviderConfig(hc phttp.Client, issuerURL string) (pcfg ProviderConfig) { + return waitForProviderConfig(hc, issuerURL, clockwork.NewRealClock()) +} + +func waitForProviderConfig(hc phttp.Client, issuerURL string, clock clockwork.Clock) (pcfg ProviderConfig) { + var sleep time.Duration + var err error + for { + pcfg, err = FetchProviderConfig(hc, issuerURL) + if err == nil { + break + } + + sleep = timeutil.ExpBackoff(sleep, time.Minute) + fmt.Printf("Failed fetching provider config, trying again in %v: %v\n", sleep, err) + time.Sleep(sleep) + } + + return +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/transport.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/transport.go new file mode 100644 index 000000000000..61c926d7fe72 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/transport.go @@ -0,0 +1,88 @@ +package oidc + +import ( + "fmt" + "net/http" + "sync" + + phttp "github.com/coreos/go-oidc/http" + "github.com/coreos/go-oidc/jose" +) + +type TokenRefresher interface { + // Verify checks if the provided token is currently valid or not. + Verify(jose.JWT) error + + // Refresh attempts to authenticate and retrieve a new token. + Refresh() (jose.JWT, error) +} + +type ClientCredsTokenRefresher struct { + Issuer string + OIDCClient *Client +} + +func (c *ClientCredsTokenRefresher) Verify(jwt jose.JWT) (err error) { + _, err = VerifyClientClaims(jwt, c.Issuer) + return +} + +func (c *ClientCredsTokenRefresher) Refresh() (jwt jose.JWT, err error) { + if err = c.OIDCClient.Healthy(); err != nil { + err = fmt.Errorf("unable to authenticate, unhealthy OIDC client: %v", err) + return + } + + jwt, err = c.OIDCClient.ClientCredsToken([]string{"openid"}) + if err != nil { + err = fmt.Errorf("unable to verify auth code with issuer: %v", err) + return + } + + return +} + +type AuthenticatedTransport struct { + TokenRefresher + http.RoundTripper + + mu sync.Mutex + jwt jose.JWT +} + +func (t *AuthenticatedTransport) verifiedJWT() (jose.JWT, error) { + t.mu.Lock() + defer t.mu.Unlock() + + if t.TokenRefresher.Verify(t.jwt) == nil { + return t.jwt, nil + } + + jwt, err := t.TokenRefresher.Refresh() + if err != nil { + return jose.JWT{}, fmt.Errorf("unable to acquire valid JWT: %v", err) + } + + t.jwt = jwt + return t.jwt, nil +} + +// SetJWT sets the JWT held by the Transport. +// This is useful for cases in which you want to set an initial JWT. +func (t *AuthenticatedTransport) SetJWT(jwt jose.JWT) { + t.mu.Lock() + defer t.mu.Unlock() + + t.jwt = jwt +} + +func (t *AuthenticatedTransport) RoundTrip(r *http.Request) (*http.Response, error) { + jwt, err := t.verifiedJWT() + if err != nil { + return nil, err + } + + req := phttp.CopyRequest(r) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", jwt.Encode())) + return t.RoundTripper.RoundTrip(req) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/util.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/util.go new file mode 100644 index 000000000000..f2a5a195e4a3 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/util.go @@ -0,0 +1,109 @@ +package oidc + +import ( + "crypto/rand" + "encoding/base64" + "errors" + "fmt" + "net" + "net/http" + "net/url" + "strings" + "time" + + "github.com/coreos/go-oidc/jose" +) + +// RequestTokenExtractor funcs extract a raw encoded token from a request. +type RequestTokenExtractor func(r *http.Request) (string, error) + +// ExtractBearerToken is a RequestTokenExtractor which extracts a bearer token from a request's +// Authorization header. +func ExtractBearerToken(r *http.Request) (string, error) { + ah := r.Header.Get("Authorization") + if ah == "" { + return "", errors.New("missing Authorization header") + } + + if len(ah) <= 6 || strings.ToUpper(ah[0:6]) != "BEARER" { + return "", errors.New("should be a bearer token") + } + + val := ah[7:] + if len(val) == 0 { + return "", errors.New("bearer token is empty") + } + + return val, nil +} + +// CookieTokenExtractor returns a RequestTokenExtractor which extracts a token from the named cookie in a request. +func CookieTokenExtractor(cookieName string) RequestTokenExtractor { + return func(r *http.Request) (string, error) { + ck, err := r.Cookie(cookieName) + if err != nil { + return "", fmt.Errorf("token cookie not found in request: %v", err) + } + + if ck.Value == "" { + return "", errors.New("token cookie found but is empty") + } + + return ck.Value, nil + } +} + +func NewClaims(iss, sub string, aud interface{}, iat, exp time.Time) jose.Claims { + return jose.Claims{ + // required + "iss": iss, + "sub": sub, + "aud": aud, + "iat": iat.Unix(), + "exp": exp.Unix(), + } +} + +func GenClientID(hostport string) (string, error) { + b, err := randBytes(32) + if err != nil { + return "", err + } + + var host string + if strings.Contains(hostport, ":") { + host, _, err = net.SplitHostPort(hostport) + if err != nil { + return "", err + } + } else { + host = hostport + } + + return fmt.Sprintf("%s@%s", base64.URLEncoding.EncodeToString(b), host), nil +} + +func randBytes(n int) ([]byte, error) { + b := make([]byte, n) + got, err := rand.Read(b) + if err != nil { + return nil, err + } else if n != got { + return nil, errors.New("unable to generate enough random data") + } + return b, nil +} + +// urlEqual checks two urls for equality using only the host and path portions. +func urlEqual(url1, url2 string) bool { + u1, err := url.Parse(url1) + if err != nil { + return false + } + u2, err := url.Parse(url2) + if err != nil { + return false + } + + return strings.ToLower(u1.Host+u1.Path) == strings.ToLower(u2.Host+u2.Path) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/verification.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/verification.go new file mode 100644 index 000000000000..d9c6afa6974d --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/go-oidc/oidc/verification.go @@ -0,0 +1,190 @@ +package oidc + +import ( + "errors" + "fmt" + "time" + + "github.com/jonboulle/clockwork" + + "github.com/coreos/go-oidc/jose" + "github.com/coreos/go-oidc/key" +) + +func VerifySignature(jwt jose.JWT, keys []key.PublicKey) (bool, error) { + jwtBytes := []byte(jwt.Data()) + for _, k := range keys { + v, err := k.Verifier() + if err != nil { + return false, err + } + if v.Verify(jwt.Signature, jwtBytes) == nil { + return true, nil + } + } + return false, nil +} + +// containsString returns true if the given string(needle) is found +// in the string array(haystack). +func containsString(needle string, haystack []string) bool { + for _, v := range haystack { + if v == needle { + return true + } + } + return false +} + +// Verify claims in accordance with OIDC spec +// http://openid.net/specs/openid-connect-basic-1_0.html#IDTokenValidation +func VerifyClaims(jwt jose.JWT, issuer, clientID string) error { + now := time.Now().UTC() + + claims, err := jwt.Claims() + if err != nil { + return err + } + + ident, err := IdentityFromClaims(claims) + if err != nil { + return err + } + + if ident.ExpiresAt.Before(now) { + return errors.New("token is expired") + } + + // iss REQUIRED. Issuer Identifier for the Issuer of the response. + // The iss value is a case sensitive URL using the https scheme that contains scheme, + // host, and optionally, port number and path components and no query or fragment components. + if iss, exists := claims["iss"].(string); exists { + if !urlEqual(iss, issuer) { + return fmt.Errorf("invalid claim value: 'iss'. expected=%s, found=%s.", issuer, iss) + } + } else { + return errors.New("missing claim: 'iss'") + } + + // iat REQUIRED. Time at which the JWT was issued. + // Its value is a JSON number representing the number of seconds from 1970-01-01T0:0:0Z + // as measured in UTC until the date/time. + if _, exists := claims["iat"].(float64); !exists { + return errors.New("missing claim: 'iat'") + } + + // aud REQUIRED. Audience(s) that this ID Token is intended for. + // It MUST contain the OAuth 2.0 client_id of the Relying Party as an audience value. + // It MAY also contain identifiers for other audiences. In the general case, the aud + // value is an array of case sensitive strings. In the common special case when there + // is one audience, the aud value MAY be a single case sensitive string. + if aud, ok, err := claims.StringClaim("aud"); err == nil && ok { + if aud != clientID { + return fmt.Errorf("invalid claims, 'aud' claim and 'client_id' do not match, aud=%s, client_id=%s", aud, clientID) + } + } else if aud, ok, err := claims.StringsClaim("aud"); err == nil && ok { + if !containsString(clientID, aud) { + return fmt.Errorf("invalid claims, cannot find 'client_id' in 'aud' claim, aud=%v, client_id=%s", aud, clientID) + } + } else { + return errors.New("invalid claim value: 'aud' is required, and should be either string or string array") + } + + return nil +} + +// VerifyClientClaims verifies all the required claims are valid for a "client credentials" JWT. +// Returns the client ID if valid, or an error if invalid. +func VerifyClientClaims(jwt jose.JWT, issuer string) (string, error) { + claims, err := jwt.Claims() + if err != nil { + return "", fmt.Errorf("failed to parse JWT claims: %v", err) + } + + iss, ok, err := claims.StringClaim("iss") + if err != nil { + return "", fmt.Errorf("failed to parse 'iss' claim: %v", err) + } else if !ok { + return "", errors.New("missing required 'iss' claim") + } else if !urlEqual(iss, issuer) { + return "", fmt.Errorf("'iss' claim does not match expected issuer, iss=%s", iss) + } + + sub, ok, err := claims.StringClaim("sub") + if err != nil { + return "", fmt.Errorf("failed to parse 'sub' claim: %v", err) + } else if !ok { + return "", errors.New("missing required 'sub' claim") + } + + if aud, ok, err := claims.StringClaim("aud"); err == nil && ok { + if aud != sub { + return "", fmt.Errorf("invalid claims, 'aud' claim and 'sub' claim do not match, aud=%s, sub=%s", aud, sub) + } + } else if aud, ok, err := claims.StringsClaim("aud"); err == nil && ok { + if !containsString(sub, aud) { + return "", fmt.Errorf("invalid claims, cannot find 'sud' in 'aud' claim, aud=%v, sub=%s", aud, sub) + } + } else { + return "", errors.New("invalid claim value: 'aud' is required, and should be either string or string array") + } + + now := time.Now().UTC() + exp, ok, err := claims.TimeClaim("exp") + if err != nil { + return "", fmt.Errorf("failed to parse 'exp' claim: %v", err) + } else if !ok { + return "", errors.New("missing required 'exp' claim") + } else if exp.Before(now) { + return "", fmt.Errorf("token already expired at: %v", exp) + } + + return sub, nil +} + +type JWTVerifier struct { + issuer string + clientID string + syncFunc func() error + keysFunc func() []key.PublicKey + clock clockwork.Clock +} + +func NewJWTVerifier(issuer, clientID string, syncFunc func() error, keysFunc func() []key.PublicKey) JWTVerifier { + return JWTVerifier{ + issuer: issuer, + clientID: clientID, + syncFunc: syncFunc, + keysFunc: keysFunc, + clock: clockwork.NewRealClock(), + } +} + +func (v *JWTVerifier) Verify(jwt jose.JWT) error { + // Verify claims before verifying the signature. This is an optimization to throw out + // tokens we know are invalid without undergoing an expensive signature check and + // possibly a re-sync event. + if err := VerifyClaims(jwt, v.issuer, v.clientID); err != nil { + return fmt.Errorf("oidc: JWT claims invalid: %v", err) + } + + ok, err := VerifySignature(jwt, v.keysFunc()) + if err != nil { + return fmt.Errorf("oidc: JWT signature verification failed: %v", err) + } else if ok { + return nil + } + + if err = v.syncFunc(); err != nil { + return fmt.Errorf("oidc: failed syncing KeySet: %v", err) + } + + ok, err = VerifySignature(jwt, v.keysFunc()) + if err != nil { + return fmt.Errorf("oidc: JWT signature verification failed: %v", err) + } else if !ok { + return errors.New("oidc: unable to verify JWT signature: no matching keys") + } + + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/LICENSE b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/LICENSE new file mode 100644 index 000000000000..e06d2081865a --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/LICENSE @@ -0,0 +1,202 @@ +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. + diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/NOTICE b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/NOTICE new file mode 100644 index 000000000000..b39ddfa5cbde --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/NOTICE @@ -0,0 +1,5 @@ +CoreOS Project +Copyright 2014 CoreOS, Inc + +This product includes software developed at CoreOS, Inc. +(http://www.coreos.com/). diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/health/health.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/health/health.go new file mode 100644 index 000000000000..a1c3610fa5c5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/health/health.go @@ -0,0 +1,127 @@ +package health + +import ( + "expvar" + "fmt" + "log" + "net/http" + + "github.com/coreos/pkg/httputil" +) + +// Checkables should return nil when the thing they are checking is healthy, and an error otherwise. +type Checkable interface { + Healthy() error +} + +// Checker provides a way to make an endpoint which can be probed for system health. +type Checker struct { + // Checks are the Checkables to be checked when probing. + Checks []Checkable + + // Unhealthyhandler is called when one or more of the checks are unhealthy. + // If not provided DefaultUnhealthyHandler is called. + UnhealthyHandler UnhealthyHandler + + // HealthyHandler is called when all checks are healthy. + // If not provided, DefaultHealthyHandler is called. + HealthyHandler http.HandlerFunc +} + +func (c Checker) ServeHTTP(w http.ResponseWriter, r *http.Request) { + unhealthyHandler := c.UnhealthyHandler + if unhealthyHandler == nil { + unhealthyHandler = DefaultUnhealthyHandler + } + + successHandler := c.HealthyHandler + if successHandler == nil { + successHandler = DefaultHealthyHandler + } + + if r.Method != "GET" { + w.Header().Set("Allow", "GET") + w.WriteHeader(http.StatusMethodNotAllowed) + return + } + + if err := Check(c.Checks); err != nil { + unhealthyHandler(w, r, err) + return + } + + successHandler(w, r) +} + +type UnhealthyHandler func(w http.ResponseWriter, r *http.Request, err error) + +type StatusResponse struct { + Status string `json:"status"` + Details *StatusResponseDetails `json:"details,omitempty"` +} + +type StatusResponseDetails struct { + Code int `json:"code,omitempty"` + Message string `json:"message,omitempty"` +} + +func Check(checks []Checkable) (err error) { + errs := []error{} + for _, c := range checks { + if e := c.Healthy(); e != nil { + errs = append(errs, e) + } + } + + switch len(errs) { + case 0: + err = nil + case 1: + err = errs[0] + default: + err = fmt.Errorf("multiple health check failure: %v", errs) + } + + return +} + +func DefaultHealthyHandler(w http.ResponseWriter, r *http.Request) { + err := httputil.WriteJSONResponse(w, http.StatusOK, StatusResponse{ + Status: "ok", + }) + if err != nil { + // TODO(bobbyrullo): replace with logging from new logging pkg, + // once it lands. + log.Printf("Failed to write JSON response: %v", err) + } +} + +func DefaultUnhealthyHandler(w http.ResponseWriter, r *http.Request, err error) { + writeErr := httputil.WriteJSONResponse(w, http.StatusInternalServerError, StatusResponse{ + Status: "error", + Details: &StatusResponseDetails{ + Code: http.StatusInternalServerError, + Message: err.Error(), + }, + }) + if writeErr != nil { + // TODO(bobbyrullo): replace with logging from new logging pkg, + // once it lands. + log.Printf("Failed to write JSON response: %v", err) + } +} + +// ExpvarHandler is copied from https://golang.org/src/expvar/expvar.go, where it's sadly unexported. +func ExpvarHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") + fmt.Fprintf(w, "{\n") + first := true + expvar.Do(func(kv expvar.KeyValue) { + if !first { + fmt.Fprintf(w, ",\n") + } + first = false + fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value) + }) + fmt.Fprintf(w, "\n}\n") +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/httputil/cookie.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/httputil/cookie.go new file mode 100644 index 000000000000..c37a37bb27c7 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/httputil/cookie.go @@ -0,0 +1,21 @@ +package httputil + +import ( + "net/http" + "time" +) + +// DeleteCookies effectively deletes all named cookies +// by wiping all data and setting to expire immediately. +func DeleteCookies(w http.ResponseWriter, cookieNames ...string) { + for _, n := range cookieNames { + c := &http.Cookie{ + Name: n, + Value: "", + Path: "/", + MaxAge: -1, + Expires: time.Time{}, + } + http.SetCookie(w, c) + } +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/httputil/json.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/httputil/json.go new file mode 100644 index 000000000000..0b09235033ff --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/httputil/json.go @@ -0,0 +1,27 @@ +package httputil + +import ( + "encoding/json" + "net/http" +) + +const ( + JSONContentType = "application/json" +) + +func WriteJSONResponse(w http.ResponseWriter, code int, resp interface{}) error { + enc, err := json.Marshal(resp) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return err + } + + w.Header().Set("Content-Type", JSONContentType) + w.WriteHeader(code) + + _, err = w.Write(enc) + if err != nil { + return err + } + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/timeutil/backoff.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/timeutil/backoff.go new file mode 100644 index 000000000000..b34fb49661b6 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/coreos/pkg/timeutil/backoff.go @@ -0,0 +1,15 @@ +package timeutil + +import ( + "time" +) + +func ExpBackoff(prev, max time.Duration) time.Duration { + if prev == 0 { + return time.Second + } + if prev > max/2 { + return max + } + return 2 * prev +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/emicklei/go-restful/swagger/model_builder.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/emicklei/go-restful/swagger/model_builder.go index 3d674cc3dad2..398e83049c44 100644 --- a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/emicklei/go-restful/swagger/model_builder.go +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/emicklei/go-restful/swagger/model_builder.go @@ -395,7 +395,7 @@ func (b modelBuilder) jsonNameOfField(field reflect.StructField) string { return field.Name } -// see also http://json-schema.org/latest/json-schema-testing.html#anchor8 +// see also http://json-schema.org/latest/json-schema-core.html#anchor8 func (b modelBuilder) jsonSchemaType(modelName string) string { schemaMap := map[string]string{ "uint": "integer", diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/LICENSE b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/LICENSE new file mode 100644 index 000000000000..1b1b1921efa6 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/LICENSE @@ -0,0 +1,31 @@ +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/Makefile b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/Makefile new file mode 100644 index 000000000000..e2e0651a934d --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/Makefile @@ -0,0 +1,43 @@ +# Go support for Protocol Buffers - Google's data interchange format +# +# Copyright 2010 The Go Authors. All rights reserved. +# https://github.com/golang/protobuf +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +install: + go install + +test: install generate-test-pbs + go test + + +generate-test-pbs: + make install + make -C testdata + protoc --go_out=Mtestdata/test.proto=github.com/golang/protobuf/proto/testdata,Mgoogle/protobuf/any.proto=github.com/golang/protobuf/ptypes/any:. proto3_proto/proto3.proto + make diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/clone.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/clone.go new file mode 100644 index 000000000000..e392575b353a --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/clone.go @@ -0,0 +1,229 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2011 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Protocol buffer deep copy and merge. +// TODO: RawMessage. + +package proto + +import ( + "log" + "reflect" + "strings" +) + +// Clone returns a deep copy of a protocol buffer. +func Clone(pb Message) Message { + in := reflect.ValueOf(pb) + if in.IsNil() { + return pb + } + + out := reflect.New(in.Type().Elem()) + // out is empty so a merge is a deep copy. + mergeStruct(out.Elem(), in.Elem()) + return out.Interface().(Message) +} + +// Merge merges src into dst. +// Required and optional fields that are set in src will be set to that value in dst. +// Elements of repeated fields will be appended. +// Merge panics if src and dst are not the same type, or if dst is nil. +func Merge(dst, src Message) { + in := reflect.ValueOf(src) + out := reflect.ValueOf(dst) + if out.IsNil() { + panic("proto: nil destination") + } + if in.Type() != out.Type() { + // Explicit test prior to mergeStruct so that mistyped nils will fail + panic("proto: type mismatch") + } + if in.IsNil() { + // Merging nil into non-nil is a quiet no-op + return + } + mergeStruct(out.Elem(), in.Elem()) +} + +func mergeStruct(out, in reflect.Value) { + sprop := GetProperties(in.Type()) + for i := 0; i < in.NumField(); i++ { + f := in.Type().Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + mergeAny(out.Field(i), in.Field(i), false, sprop.Prop[i]) + } + + if emIn, ok := extendable(in.Addr().Interface()); ok { + emOut, _ := extendable(out.Addr().Interface()) + mIn, muIn := emIn.extensionsRead() + if mIn != nil { + mOut := emOut.extensionsWrite() + muIn.Lock() + mergeExtension(mOut, mIn) + muIn.Unlock() + } + } + + uf := in.FieldByName("XXX_unrecognized") + if !uf.IsValid() { + return + } + uin := uf.Bytes() + if len(uin) > 0 { + out.FieldByName("XXX_unrecognized").SetBytes(append([]byte(nil), uin...)) + } +} + +// mergeAny performs a merge between two values of the same type. +// viaPtr indicates whether the values were indirected through a pointer (implying proto2). +// prop is set if this is a struct field (it may be nil). +func mergeAny(out, in reflect.Value, viaPtr bool, prop *Properties) { + if in.Type() == protoMessageType { + if !in.IsNil() { + if out.IsNil() { + out.Set(reflect.ValueOf(Clone(in.Interface().(Message)))) + } else { + Merge(out.Interface().(Message), in.Interface().(Message)) + } + } + return + } + switch in.Kind() { + case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, + reflect.String, reflect.Uint32, reflect.Uint64: + if !viaPtr && isProto3Zero(in) { + return + } + out.Set(in) + case reflect.Interface: + // Probably a oneof field; copy non-nil values. + if in.IsNil() { + return + } + // Allocate destination if it is not set, or set to a different type. + // Otherwise we will merge as normal. + if out.IsNil() || out.Elem().Type() != in.Elem().Type() { + out.Set(reflect.New(in.Elem().Elem().Type())) // interface -> *T -> T -> new(T) + } + mergeAny(out.Elem(), in.Elem(), false, nil) + case reflect.Map: + if in.Len() == 0 { + return + } + if out.IsNil() { + out.Set(reflect.MakeMap(in.Type())) + } + // For maps with value types of *T or []byte we need to deep copy each value. + elemKind := in.Type().Elem().Kind() + for _, key := range in.MapKeys() { + var val reflect.Value + switch elemKind { + case reflect.Ptr: + val = reflect.New(in.Type().Elem().Elem()) + mergeAny(val, in.MapIndex(key), false, nil) + case reflect.Slice: + val = in.MapIndex(key) + val = reflect.ValueOf(append([]byte{}, val.Bytes()...)) + default: + val = in.MapIndex(key) + } + out.SetMapIndex(key, val) + } + case reflect.Ptr: + if in.IsNil() { + return + } + if out.IsNil() { + out.Set(reflect.New(in.Elem().Type())) + } + mergeAny(out.Elem(), in.Elem(), true, nil) + case reflect.Slice: + if in.IsNil() { + return + } + if in.Type().Elem().Kind() == reflect.Uint8 { + // []byte is a scalar bytes field, not a repeated field. + + // Edge case: if this is in a proto3 message, a zero length + // bytes field is considered the zero value, and should not + // be merged. + if prop != nil && prop.proto3 && in.Len() == 0 { + return + } + + // Make a deep copy. + // Append to []byte{} instead of []byte(nil) so that we never end up + // with a nil result. + out.SetBytes(append([]byte{}, in.Bytes()...)) + return + } + n := in.Len() + if out.IsNil() { + out.Set(reflect.MakeSlice(in.Type(), 0, n)) + } + switch in.Type().Elem().Kind() { + case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int32, reflect.Int64, + reflect.String, reflect.Uint32, reflect.Uint64: + out.Set(reflect.AppendSlice(out, in)) + default: + for i := 0; i < n; i++ { + x := reflect.Indirect(reflect.New(in.Type().Elem())) + mergeAny(x, in.Index(i), false, nil) + out.Set(reflect.Append(out, x)) + } + } + case reflect.Struct: + mergeStruct(out, in) + default: + // unknown type, so not a protocol buffer + log.Printf("proto: don't know how to copy %v", in) + } +} + +func mergeExtension(out, in map[int32]Extension) { + for extNum, eIn := range in { + eOut := Extension{desc: eIn.desc} + if eIn.value != nil { + v := reflect.New(reflect.TypeOf(eIn.value)).Elem() + mergeAny(v, reflect.ValueOf(eIn.value), false, nil) + eOut.value = v.Interface() + } + if eIn.enc != nil { + eOut.enc = make([]byte, len(eIn.enc)) + copy(eOut.enc, eIn.enc) + } + + out[extNum] = eOut + } +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/decode.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/decode.go new file mode 100644 index 000000000000..07288a250b47 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/decode.go @@ -0,0 +1,869 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +/* + * Routines for decoding protocol buffer data to construct in-memory representations. + */ + +import ( + "errors" + "fmt" + "io" + "os" + "reflect" +) + +// errOverflow is returned when an integer is too large to be represented. +var errOverflow = errors.New("proto: integer overflow") + +// ErrInternalBadWireType is returned by generated code when an incorrect +// wire type is encountered. It does not get returned to user code. +var ErrInternalBadWireType = errors.New("proto: internal error: bad wiretype for oneof") + +// The fundamental decoders that interpret bytes on the wire. +// Those that take integer types all return uint64 and are +// therefore of type valueDecoder. + +// DecodeVarint reads a varint-encoded integer from the slice. +// It returns the integer and the number of bytes consumed, or +// zero if there is not enough. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func DecodeVarint(buf []byte) (x uint64, n int) { + // x, n already 0 + for shift := uint(0); shift < 64; shift += 7 { + if n >= len(buf) { + return 0, 0 + } + b := uint64(buf[n]) + n++ + x |= (b & 0x7F) << shift + if (b & 0x80) == 0 { + return x, n + } + } + + // The number is too large to represent in a 64-bit value. + return 0, 0 +} + +// DecodeVarint reads a varint-encoded integer from the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) DecodeVarint() (x uint64, err error) { + // x, err already 0 + + i := p.index + l := len(p.buf) + + for shift := uint(0); shift < 64; shift += 7 { + if i >= l { + err = io.ErrUnexpectedEOF + return + } + b := p.buf[i] + i++ + x |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + p.index = i + return + } + } + + // The number is too large to represent in a 64-bit value. + err = errOverflow + return +} + +// DecodeFixed64 reads a 64-bit integer from the Buffer. +// This is the format for the +// fixed64, sfixed64, and double protocol buffer types. +func (p *Buffer) DecodeFixed64() (x uint64, err error) { + // x, err already 0 + i := p.index + 8 + if i < 0 || i > len(p.buf) { + err = io.ErrUnexpectedEOF + return + } + p.index = i + + x = uint64(p.buf[i-8]) + x |= uint64(p.buf[i-7]) << 8 + x |= uint64(p.buf[i-6]) << 16 + x |= uint64(p.buf[i-5]) << 24 + x |= uint64(p.buf[i-4]) << 32 + x |= uint64(p.buf[i-3]) << 40 + x |= uint64(p.buf[i-2]) << 48 + x |= uint64(p.buf[i-1]) << 56 + return +} + +// DecodeFixed32 reads a 32-bit integer from the Buffer. +// This is the format for the +// fixed32, sfixed32, and float protocol buffer types. +func (p *Buffer) DecodeFixed32() (x uint64, err error) { + // x, err already 0 + i := p.index + 4 + if i < 0 || i > len(p.buf) { + err = io.ErrUnexpectedEOF + return + } + p.index = i + + x = uint64(p.buf[i-4]) + x |= uint64(p.buf[i-3]) << 8 + x |= uint64(p.buf[i-2]) << 16 + x |= uint64(p.buf[i-1]) << 24 + return +} + +// DecodeZigzag64 reads a zigzag-encoded 64-bit integer +// from the Buffer. +// This is the format used for the sint64 protocol buffer type. +func (p *Buffer) DecodeZigzag64() (x uint64, err error) { + x, err = p.DecodeVarint() + if err != nil { + return + } + x = (x >> 1) ^ uint64((int64(x&1)<<63)>>63) + return +} + +// DecodeZigzag32 reads a zigzag-encoded 32-bit integer +// from the Buffer. +// This is the format used for the sint32 protocol buffer type. +func (p *Buffer) DecodeZigzag32() (x uint64, err error) { + x, err = p.DecodeVarint() + if err != nil { + return + } + x = uint64((uint32(x) >> 1) ^ uint32((int32(x&1)<<31)>>31)) + return +} + +// These are not ValueDecoders: they produce an array of bytes or a string. +// bytes, embedded messages + +// DecodeRawBytes reads a count-delimited byte buffer from the Buffer. +// This is the format used for the bytes protocol buffer +// type and for embedded messages. +func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error) { + n, err := p.DecodeVarint() + if err != nil { + return nil, err + } + + nb := int(n) + if nb < 0 { + return nil, fmt.Errorf("proto: bad byte length %d", nb) + } + end := p.index + nb + if end < p.index || end > len(p.buf) { + return nil, io.ErrUnexpectedEOF + } + + if !alloc { + // todo: check if can get more uses of alloc=false + buf = p.buf[p.index:end] + p.index += nb + return + } + + buf = make([]byte, nb) + copy(buf, p.buf[p.index:]) + p.index += nb + return +} + +// DecodeStringBytes reads an encoded string from the Buffer. +// This is the format used for the proto2 string type. +func (p *Buffer) DecodeStringBytes() (s string, err error) { + buf, err := p.DecodeRawBytes(false) + if err != nil { + return + } + return string(buf), nil +} + +// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. +// If the protocol buffer has extensions, and the field matches, add it as an extension. +// Otherwise, if the XXX_unrecognized field exists, append the skipped data there. +func (o *Buffer) skipAndSave(t reflect.Type, tag, wire int, base structPointer, unrecField field) error { + oi := o.index + + err := o.skip(t, tag, wire) + if err != nil { + return err + } + + if !unrecField.IsValid() { + return nil + } + + ptr := structPointer_Bytes(base, unrecField) + + // Add the skipped field to struct field + obuf := o.buf + + o.buf = *ptr + o.EncodeVarint(uint64(tag<<3 | wire)) + *ptr = append(o.buf, obuf[oi:o.index]...) + + o.buf = obuf + + return nil +} + +// Skip the next item in the buffer. Its wire type is decoded and presented as an argument. +func (o *Buffer) skip(t reflect.Type, tag, wire int) error { + + var u uint64 + var err error + + switch wire { + case WireVarint: + _, err = o.DecodeVarint() + case WireFixed64: + _, err = o.DecodeFixed64() + case WireBytes: + _, err = o.DecodeRawBytes(false) + case WireFixed32: + _, err = o.DecodeFixed32() + case WireStartGroup: + for { + u, err = o.DecodeVarint() + if err != nil { + break + } + fwire := int(u & 0x7) + if fwire == WireEndGroup { + break + } + ftag := int(u >> 3) + err = o.skip(t, ftag, fwire) + if err != nil { + break + } + } + default: + err = fmt.Errorf("proto: can't skip unknown wire type %d for %s", wire, t) + } + return err +} + +// Unmarshaler is the interface representing objects that can +// unmarshal themselves. The method should reset the receiver before +// decoding starts. The argument points to data that may be +// overwritten, so implementations should not keep references to the +// buffer. +type Unmarshaler interface { + Unmarshal([]byte) error +} + +// Unmarshal parses the protocol buffer representation in buf and places the +// decoded result in pb. If the struct underlying pb does not match +// the data in buf, the results can be unpredictable. +// +// Unmarshal resets pb before starting to unmarshal, so any +// existing data in pb is always removed. Use UnmarshalMerge +// to preserve and append to existing data. +func Unmarshal(buf []byte, pb Message) error { + pb.Reset() + return UnmarshalMerge(buf, pb) +} + +// UnmarshalMerge parses the protocol buffer representation in buf and +// writes the decoded result to pb. If the struct underlying pb does not match +// the data in buf, the results can be unpredictable. +// +// UnmarshalMerge merges into existing data in pb. +// Most code should use Unmarshal instead. +func UnmarshalMerge(buf []byte, pb Message) error { + // If the object can unmarshal itself, let it. + if u, ok := pb.(Unmarshaler); ok { + return u.Unmarshal(buf) + } + return NewBuffer(buf).Unmarshal(pb) +} + +// DecodeMessage reads a count-delimited message from the Buffer. +func (p *Buffer) DecodeMessage(pb Message) error { + enc, err := p.DecodeRawBytes(false) + if err != nil { + return err + } + return NewBuffer(enc).Unmarshal(pb) +} + +// DecodeGroup reads a tag-delimited group from the Buffer. +func (p *Buffer) DecodeGroup(pb Message) error { + typ, base, err := getbase(pb) + if err != nil { + return err + } + return p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), true, base) +} + +// Unmarshal parses the protocol buffer representation in the +// Buffer and places the decoded result in pb. If the struct +// underlying pb does not match the data in the buffer, the results can be +// unpredictable. +func (p *Buffer) Unmarshal(pb Message) error { + // If the object can unmarshal itself, let it. + if u, ok := pb.(Unmarshaler); ok { + err := u.Unmarshal(p.buf[p.index:]) + p.index = len(p.buf) + return err + } + + typ, base, err := getbase(pb) + if err != nil { + return err + } + + err = p.unmarshalType(typ.Elem(), GetProperties(typ.Elem()), false, base) + + if collectStats { + stats.Decode++ + } + + return err +} + +// unmarshalType does the work of unmarshaling a structure. +func (o *Buffer) unmarshalType(st reflect.Type, prop *StructProperties, is_group bool, base structPointer) error { + var state errorState + required, reqFields := prop.reqCount, uint64(0) + + var err error + for err == nil && o.index < len(o.buf) { + oi := o.index + var u uint64 + u, err = o.DecodeVarint() + if err != nil { + break + } + wire := int(u & 0x7) + if wire == WireEndGroup { + if is_group { + return nil // input is satisfied + } + return fmt.Errorf("proto: %s: wiretype end group for non-group", st) + } + tag := int(u >> 3) + if tag <= 0 { + return fmt.Errorf("proto: %s: illegal tag %d (wire type %d)", st, tag, wire) + } + fieldnum, ok := prop.decoderTags.get(tag) + if !ok { + // Maybe it's an extension? + if prop.extendable { + if e, _ := extendable(structPointer_Interface(base, st)); isExtensionField(e, int32(tag)) { + if err = o.skip(st, tag, wire); err == nil { + extmap := e.extensionsWrite() + ext := extmap[int32(tag)] // may be missing + ext.enc = append(ext.enc, o.buf[oi:o.index]...) + extmap[int32(tag)] = ext + } + continue + } + } + // Maybe it's a oneof? + if prop.oneofUnmarshaler != nil { + m := structPointer_Interface(base, st).(Message) + // First return value indicates whether tag is a oneof field. + ok, err = prop.oneofUnmarshaler(m, tag, wire, o) + if err == ErrInternalBadWireType { + // Map the error to something more descriptive. + // Do the formatting here to save generated code space. + err = fmt.Errorf("bad wiretype for oneof field in %T", m) + } + if ok { + continue + } + } + err = o.skipAndSave(st, tag, wire, base, prop.unrecField) + continue + } + p := prop.Prop[fieldnum] + + if p.dec == nil { + fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", st, st.Field(fieldnum).Name) + continue + } + dec := p.dec + if wire != WireStartGroup && wire != p.WireType { + if wire == WireBytes && p.packedDec != nil { + // a packable field + dec = p.packedDec + } else { + err = fmt.Errorf("proto: bad wiretype for field %s.%s: got wiretype %d, want %d", st, st.Field(fieldnum).Name, wire, p.WireType) + continue + } + } + decErr := dec(o, p, base) + if decErr != nil && !state.shouldContinue(decErr, p) { + err = decErr + } + if err == nil && p.Required { + // Successfully decoded a required field. + if tag <= 64 { + // use bitmap for fields 1-64 to catch field reuse. + var mask uint64 = 1 << uint64(tag-1) + if reqFields&mask == 0 { + // new required field + reqFields |= mask + required-- + } + } else { + // This is imprecise. It can be fooled by a required field + // with a tag > 64 that is encoded twice; that's very rare. + // A fully correct implementation would require allocating + // a data structure, which we would like to avoid. + required-- + } + } + } + if err == nil { + if is_group { + return io.ErrUnexpectedEOF + } + if state.err != nil { + return state.err + } + if required > 0 { + // Not enough information to determine the exact field. If we use extra + // CPU, we could determine the field only if the missing required field + // has a tag <= 64 and we check reqFields. + return &RequiredNotSetError{"{Unknown}"} + } + } + return err +} + +// Individual type decoders +// For each, +// u is the decoded value, +// v is a pointer to the field (pointer) in the struct + +// Sizes of the pools to allocate inside the Buffer. +// The goal is modest amortization and allocation +// on at least 16-byte boundaries. +const ( + boolPoolSize = 16 + uint32PoolSize = 8 + uint64PoolSize = 4 +) + +// Decode a bool. +func (o *Buffer) dec_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + if len(o.bools) == 0 { + o.bools = make([]bool, boolPoolSize) + } + o.bools[0] = u != 0 + *structPointer_Bool(base, p.field) = &o.bools[0] + o.bools = o.bools[1:] + return nil +} + +func (o *Buffer) dec_proto3_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + *structPointer_BoolVal(base, p.field) = u != 0 + return nil +} + +// Decode an int32. +func (o *Buffer) dec_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word32_Set(structPointer_Word32(base, p.field), o, uint32(u)) + return nil +} + +func (o *Buffer) dec_proto3_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word32Val_Set(structPointer_Word32Val(base, p.field), uint32(u)) + return nil +} + +// Decode an int64. +func (o *Buffer) dec_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word64_Set(structPointer_Word64(base, p.field), o, u) + return nil +} + +func (o *Buffer) dec_proto3_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + word64Val_Set(structPointer_Word64Val(base, p.field), o, u) + return nil +} + +// Decode a string. +func (o *Buffer) dec_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + *structPointer_String(base, p.field) = &s + return nil +} + +func (o *Buffer) dec_proto3_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + *structPointer_StringVal(base, p.field) = s + return nil +} + +// Decode a slice of bytes ([]byte). +func (o *Buffer) dec_slice_byte(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + *structPointer_Bytes(base, p.field) = b + return nil +} + +// Decode a slice of bools ([]bool). +func (o *Buffer) dec_slice_bool(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + v := structPointer_BoolSlice(base, p.field) + *v = append(*v, u != 0) + return nil +} + +// Decode a slice of bools ([]bool) in packed format. +func (o *Buffer) dec_slice_packed_bool(p *Properties, base structPointer) error { + v := structPointer_BoolSlice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded bools + fin := o.index + nb + if fin < o.index { + return errOverflow + } + + y := *v + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + y = append(y, u != 0) + } + + *v = y + return nil +} + +// Decode a slice of int32s ([]int32). +func (o *Buffer) dec_slice_int32(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + structPointer_Word32Slice(base, p.field).Append(uint32(u)) + return nil +} + +// Decode a slice of int32s ([]int32) in packed format. +func (o *Buffer) dec_slice_packed_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Slice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded int32s + + fin := o.index + nb + if fin < o.index { + return errOverflow + } + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + v.Append(uint32(u)) + } + return nil +} + +// Decode a slice of int64s ([]int64). +func (o *Buffer) dec_slice_int64(p *Properties, base structPointer) error { + u, err := p.valDec(o) + if err != nil { + return err + } + + structPointer_Word64Slice(base, p.field).Append(u) + return nil +} + +// Decode a slice of int64s ([]int64) in packed format. +func (o *Buffer) dec_slice_packed_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Slice(base, p.field) + + nn, err := o.DecodeVarint() + if err != nil { + return err + } + nb := int(nn) // number of bytes of encoded int64s + + fin := o.index + nb + if fin < o.index { + return errOverflow + } + for o.index < fin { + u, err := p.valDec(o) + if err != nil { + return err + } + v.Append(u) + } + return nil +} + +// Decode a slice of strings ([]string). +func (o *Buffer) dec_slice_string(p *Properties, base structPointer) error { + s, err := o.DecodeStringBytes() + if err != nil { + return err + } + v := structPointer_StringSlice(base, p.field) + *v = append(*v, s) + return nil +} + +// Decode a slice of slice of bytes ([][]byte). +func (o *Buffer) dec_slice_slice_byte(p *Properties, base structPointer) error { + b, err := o.DecodeRawBytes(true) + if err != nil { + return err + } + v := structPointer_BytesSlice(base, p.field) + *v = append(*v, b) + return nil +} + +// Decode a map field. +func (o *Buffer) dec_new_map(p *Properties, base structPointer) error { + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + oi := o.index // index at the end of this map entry + o.index -= len(raw) // move buffer back to start of map entry + + mptr := structPointer_NewAt(base, p.field, p.mtype) // *map[K]V + if mptr.Elem().IsNil() { + mptr.Elem().Set(reflect.MakeMap(mptr.Type().Elem())) + } + v := mptr.Elem() // map[K]V + + // Prepare addressable doubly-indirect placeholders for the key and value types. + // See enc_new_map for why. + keyptr := reflect.New(reflect.PtrTo(p.mtype.Key())).Elem() // addressable *K + keybase := toStructPointer(keyptr.Addr()) // **K + + var valbase structPointer + var valptr reflect.Value + switch p.mtype.Elem().Kind() { + case reflect.Slice: + // []byte + var dummy []byte + valptr = reflect.ValueOf(&dummy) // *[]byte + valbase = toStructPointer(valptr) // *[]byte + case reflect.Ptr: + // message; valptr is **Msg; need to allocate the intermediate pointer + valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V + valptr.Set(reflect.New(valptr.Type().Elem())) + valbase = toStructPointer(valptr) + default: + // everything else + valptr = reflect.New(reflect.PtrTo(p.mtype.Elem())).Elem() // addressable *V + valbase = toStructPointer(valptr.Addr()) // **V + } + + // Decode. + // This parses a restricted wire format, namely the encoding of a message + // with two fields. See enc_new_map for the format. + for o.index < oi { + // tagcode for key and value properties are always a single byte + // because they have tags 1 and 2. + tagcode := o.buf[o.index] + o.index++ + switch tagcode { + case p.mkeyprop.tagcode[0]: + if err := p.mkeyprop.dec(o, p.mkeyprop, keybase); err != nil { + return err + } + case p.mvalprop.tagcode[0]: + if err := p.mvalprop.dec(o, p.mvalprop, valbase); err != nil { + return err + } + default: + // TODO: Should we silently skip this instead? + return fmt.Errorf("proto: bad map data tag %d", raw[0]) + } + } + keyelem, valelem := keyptr.Elem(), valptr.Elem() + if !keyelem.IsValid() { + keyelem = reflect.Zero(p.mtype.Key()) + } + if !valelem.IsValid() { + valelem = reflect.Zero(p.mtype.Elem()) + } + + v.SetMapIndex(keyelem, valelem) + return nil +} + +// Decode a group. +func (o *Buffer) dec_struct_group(p *Properties, base structPointer) error { + bas := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(bas) { + // allocate new nested message + bas = toStructPointer(reflect.New(p.stype)) + structPointer_SetStructPointer(base, p.field, bas) + } + return o.unmarshalType(p.stype, p.sprop, true, bas) +} + +// Decode an embedded message. +func (o *Buffer) dec_struct_message(p *Properties, base structPointer) (err error) { + raw, e := o.DecodeRawBytes(false) + if e != nil { + return e + } + + bas := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(bas) { + // allocate new nested message + bas = toStructPointer(reflect.New(p.stype)) + structPointer_SetStructPointer(base, p.field, bas) + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + iv := structPointer_Interface(bas, p.stype) + return iv.(Unmarshaler).Unmarshal(raw) + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, false, bas) + o.buf = obuf + o.index = oi + + return err +} + +// Decode a slice of embedded messages. +func (o *Buffer) dec_slice_struct_message(p *Properties, base structPointer) error { + return o.dec_slice_struct(p, false, base) +} + +// Decode a slice of embedded groups. +func (o *Buffer) dec_slice_struct_group(p *Properties, base structPointer) error { + return o.dec_slice_struct(p, true, base) +} + +// Decode a slice of structs ([]*struct). +func (o *Buffer) dec_slice_struct(p *Properties, is_group bool, base structPointer) error { + v := reflect.New(p.stype) + bas := toStructPointer(v) + structPointer_StructPointerSlice(base, p.field).Append(bas) + + if is_group { + err := o.unmarshalType(p.stype, p.sprop, is_group, bas) + return err + } + + raw, err := o.DecodeRawBytes(false) + if err != nil { + return err + } + + // If the object can unmarshal itself, let it. + if p.isUnmarshaler { + iv := v.Interface() + return iv.(Unmarshaler).Unmarshal(raw) + } + + obuf := o.buf + oi := o.index + o.buf = raw + o.index = 0 + + err = o.unmarshalType(p.stype, p.sprop, is_group, bas) + + o.buf = obuf + o.index = oi + + return err +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/encode.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/encode.go new file mode 100644 index 000000000000..8c1b8fd1f683 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/encode.go @@ -0,0 +1,1363 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +/* + * Routines for encoding data into the wire format for protocol buffers. + */ + +import ( + "errors" + "fmt" + "reflect" + "sort" +) + +// RequiredNotSetError is the error returned if Marshal is called with +// a protocol buffer struct whose required fields have not +// all been initialized. It is also the error returned if Unmarshal is +// called with an encoded protocol buffer that does not include all the +// required fields. +// +// When printed, RequiredNotSetError reports the first unset required field in a +// message. If the field cannot be precisely determined, it is reported as +// "{Unknown}". +type RequiredNotSetError struct { + field string +} + +func (e *RequiredNotSetError) Error() string { + return fmt.Sprintf("proto: required field %q not set", e.field) +} + +var ( + // errRepeatedHasNil is the error returned if Marshal is called with + // a struct with a repeated field containing a nil element. + errRepeatedHasNil = errors.New("proto: repeated field has nil element") + + // errOneofHasNil is the error returned if Marshal is called with + // a struct with a oneof field containing a nil element. + errOneofHasNil = errors.New("proto: oneof field has nil value") + + // ErrNil is the error returned if Marshal is called with nil. + ErrNil = errors.New("proto: Marshal called with nil") + + // ErrTooLarge is the error returned if Marshal is called with a + // message that encodes to >2GB. + ErrTooLarge = errors.New("proto: message encodes to over 2 GB") +) + +// The fundamental encoders that put bytes on the wire. +// Those that take integer types all accept uint64 and are +// therefore of type valueEncoder. + +const maxVarintBytes = 10 // maximum length of a varint + +// maxMarshalSize is the largest allowed size of an encoded protobuf, +// since C++ and Java use signed int32s for the size. +const maxMarshalSize = 1<<31 - 1 + +// EncodeVarint returns the varint encoding of x. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +// Not used by the package itself, but helpful to clients +// wishing to use the same encoding. +func EncodeVarint(x uint64) []byte { + var buf [maxVarintBytes]byte + var n int + for n = 0; x > 127; n++ { + buf[n] = 0x80 | uint8(x&0x7F) + x >>= 7 + } + buf[n] = uint8(x) + n++ + return buf[0:n] +} + +// EncodeVarint writes a varint-encoded integer to the Buffer. +// This is the format for the +// int32, int64, uint32, uint64, bool, and enum +// protocol buffer types. +func (p *Buffer) EncodeVarint(x uint64) error { + for x >= 1<<7 { + p.buf = append(p.buf, uint8(x&0x7f|0x80)) + x >>= 7 + } + p.buf = append(p.buf, uint8(x)) + return nil +} + +// SizeVarint returns the varint encoding size of an integer. +func SizeVarint(x uint64) int { + return sizeVarint(x) +} + +func sizeVarint(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} + +// EncodeFixed64 writes a 64-bit integer to the Buffer. +// This is the format for the +// fixed64, sfixed64, and double protocol buffer types. +func (p *Buffer) EncodeFixed64(x uint64) error { + p.buf = append(p.buf, + uint8(x), + uint8(x>>8), + uint8(x>>16), + uint8(x>>24), + uint8(x>>32), + uint8(x>>40), + uint8(x>>48), + uint8(x>>56)) + return nil +} + +func sizeFixed64(x uint64) int { + return 8 +} + +// EncodeFixed32 writes a 32-bit integer to the Buffer. +// This is the format for the +// fixed32, sfixed32, and float protocol buffer types. +func (p *Buffer) EncodeFixed32(x uint64) error { + p.buf = append(p.buf, + uint8(x), + uint8(x>>8), + uint8(x>>16), + uint8(x>>24)) + return nil +} + +func sizeFixed32(x uint64) int { + return 4 +} + +// EncodeZigzag64 writes a zigzag-encoded 64-bit integer +// to the Buffer. +// This is the format used for the sint64 protocol buffer type. +func (p *Buffer) EncodeZigzag64(x uint64) error { + // use signed number to get arithmetic right shift. + return p.EncodeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +func sizeZigzag64(x uint64) int { + return sizeVarint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} + +// EncodeZigzag32 writes a zigzag-encoded 32-bit integer +// to the Buffer. +// This is the format used for the sint32 protocol buffer type. +func (p *Buffer) EncodeZigzag32(x uint64) error { + // use signed number to get arithmetic right shift. + return p.EncodeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) +} + +func sizeZigzag32(x uint64) int { + return sizeVarint(uint64((uint32(x) << 1) ^ uint32((int32(x) >> 31)))) +} + +// EncodeRawBytes writes a count-delimited byte buffer to the Buffer. +// This is the format used for the bytes protocol buffer +// type and for embedded messages. +func (p *Buffer) EncodeRawBytes(b []byte) error { + p.EncodeVarint(uint64(len(b))) + p.buf = append(p.buf, b...) + return nil +} + +func sizeRawBytes(b []byte) int { + return sizeVarint(uint64(len(b))) + + len(b) +} + +// EncodeStringBytes writes an encoded string to the Buffer. +// This is the format used for the proto2 string type. +func (p *Buffer) EncodeStringBytes(s string) error { + p.EncodeVarint(uint64(len(s))) + p.buf = append(p.buf, s...) + return nil +} + +func sizeStringBytes(s string) int { + return sizeVarint(uint64(len(s))) + + len(s) +} + +// Marshaler is the interface representing objects that can marshal themselves. +type Marshaler interface { + Marshal() ([]byte, error) +} + +// Marshal takes the protocol buffer +// and encodes it into the wire format, returning the data. +func Marshal(pb Message) ([]byte, error) { + // Can the object marshal itself? + if m, ok := pb.(Marshaler); ok { + return m.Marshal() + } + p := NewBuffer(nil) + err := p.Marshal(pb) + var state errorState + if err != nil && !state.shouldContinue(err, nil) { + return nil, err + } + if p.buf == nil && err == nil { + // Return a non-nil slice on success. + return []byte{}, nil + } + return p.buf, err +} + +// EncodeMessage writes the protocol buffer to the Buffer, +// prefixed by a varint-encoded length. +func (p *Buffer) EncodeMessage(pb Message) error { + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return ErrNil + } + if err == nil { + var state errorState + err = p.enc_len_struct(GetProperties(t.Elem()), base, &state) + } + return err +} + +// Marshal takes the protocol buffer +// and encodes it into the wire format, writing the result to the +// Buffer. +func (p *Buffer) Marshal(pb Message) error { + // Can the object marshal itself? + if m, ok := pb.(Marshaler); ok { + data, err := m.Marshal() + if err != nil { + return err + } + p.buf = append(p.buf, data...) + return nil + } + + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return ErrNil + } + if err == nil { + err = p.enc_struct(GetProperties(t.Elem()), base) + } + + if collectStats { + stats.Encode++ + } + + if len(p.buf) > maxMarshalSize { + return ErrTooLarge + } + return err +} + +// Size returns the encoded size of a protocol buffer. +func Size(pb Message) (n int) { + // Can the object marshal itself? If so, Size is slow. + // TODO: add Size to Marshaler, or add a Sizer interface. + if m, ok := pb.(Marshaler); ok { + b, _ := m.Marshal() + return len(b) + } + + t, base, err := getbase(pb) + if structPointer_IsNil(base) { + return 0 + } + if err == nil { + n = size_struct(GetProperties(t.Elem()), base) + } + + if collectStats { + stats.Size++ + } + + return +} + +// Individual type encoders. + +// Encode a bool. +func (o *Buffer) enc_bool(p *Properties, base structPointer) error { + v := *structPointer_Bool(base, p.field) + if v == nil { + return ErrNil + } + x := 0 + if *v { + x = 1 + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_bool(p *Properties, base structPointer) error { + v := *structPointer_BoolVal(base, p.field) + if !v { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, 1) + return nil +} + +func size_bool(p *Properties, base structPointer) int { + v := *structPointer_Bool(base, p.field) + if v == nil { + return 0 + } + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +func size_proto3_bool(p *Properties, base structPointer) int { + v := *structPointer_BoolVal(base, p.field) + if !v && !p.oneof { + return 0 + } + return len(p.tagcode) + 1 // each bool takes exactly one byte +} + +// Encode an int32. +func (o *Buffer) enc_int32(p *Properties, base structPointer) error { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return ErrNil + } + x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_int32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return 0 + } + x := int32(word32_Get(v)) // permit sign extension to use full 64-bit range + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func size_proto3_int32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := int32(word32Val_Get(v)) // permit sign extension to use full 64-bit range + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode a uint32. +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return ErrNil + } + x := word32_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func (o *Buffer) enc_proto3_uint32(p *Properties, base structPointer) error { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, uint64(x)) + return nil +} + +func size_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32(base, p.field) + if word32_IsNil(v) { + return 0 + } + x := word32_Get(v) + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +func size_proto3_uint32(p *Properties, base structPointer) (n int) { + v := structPointer_Word32Val(base, p.field) + x := word32Val_Get(v) + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(uint64(x)) + return +} + +// Encode an int64. +func (o *Buffer) enc_int64(p *Properties, base structPointer) error { + v := structPointer_Word64(base, p.field) + if word64_IsNil(v) { + return ErrNil + } + x := word64_Get(v) + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func (o *Buffer) enc_proto3_int64(p *Properties, base structPointer) error { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + if x == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, x) + return nil +} + +func size_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64(base, p.field) + if word64_IsNil(v) { + return 0 + } + x := word64_Get(v) + n += len(p.tagcode) + n += p.valSize(x) + return +} + +func size_proto3_int64(p *Properties, base structPointer) (n int) { + v := structPointer_Word64Val(base, p.field) + x := word64Val_Get(v) + if x == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += p.valSize(x) + return +} + +// Encode a string. +func (o *Buffer) enc_string(p *Properties, base structPointer) error { + v := *structPointer_String(base, p.field) + if v == nil { + return ErrNil + } + x := *v + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(x) + return nil +} + +func (o *Buffer) enc_proto3_string(p *Properties, base structPointer) error { + v := *structPointer_StringVal(base, p.field) + if v == "" { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(v) + return nil +} + +func size_string(p *Properties, base structPointer) (n int) { + v := *structPointer_String(base, p.field) + if v == nil { + return 0 + } + x := *v + n += len(p.tagcode) + n += sizeStringBytes(x) + return +} + +func size_proto3_string(p *Properties, base structPointer) (n int) { + v := *structPointer_StringVal(base, p.field) + if v == "" && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeStringBytes(v) + return +} + +// All protocol buffer fields are nillable, but be careful. +func isNil(v reflect.Value) bool { + switch v.Kind() { + case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + return v.IsNil() + } + return false +} + +// Encode a message struct. +func (o *Buffer) enc_struct_message(p *Properties, base structPointer) error { + var state errorState + structp := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return ErrNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + return state.err + } + + o.buf = append(o.buf, p.tagcode...) + return o.enc_len_struct(p.sprop, structp, &state) +} + +func size_struct_message(p *Properties, base structPointer) int { + structp := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(structp) { + return 0 + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n0 := len(p.tagcode) + n1 := sizeRawBytes(data) + return n0 + n1 + } + + n0 := len(p.tagcode) + n1 := size_struct(p.sprop, structp) + n2 := sizeVarint(uint64(n1)) // size of encoded length + return n0 + n1 + n2 +} + +// Encode a group struct. +func (o *Buffer) enc_struct_group(p *Properties, base structPointer) error { + var state errorState + b := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(b) { + return ErrNil + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) + err := o.enc_struct(p.sprop, b) + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) + return state.err +} + +func size_struct_group(p *Properties, base structPointer) (n int) { + b := structPointer_GetStructPointer(base, p.field) + if structPointer_IsNil(b) { + return 0 + } + + n += sizeVarint(uint64((p.Tag << 3) | WireStartGroup)) + n += size_struct(p.sprop, b) + n += sizeVarint(uint64((p.Tag << 3) | WireEndGroup)) + return +} + +// Encode a slice of bools ([]bool). +func (o *Buffer) enc_slice_bool(p *Properties, base structPointer) error { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return ErrNil + } + for _, x := range s { + o.buf = append(o.buf, p.tagcode...) + v := uint64(0) + if x { + v = 1 + } + p.valEnc(o, v) + } + return nil +} + +func size_slice_bool(p *Properties, base structPointer) int { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return 0 + } + return l * (len(p.tagcode) + 1) // each bool takes exactly one byte +} + +// Encode a slice of bools ([]bool) in packed format. +func (o *Buffer) enc_slice_packed_bool(p *Properties, base structPointer) error { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(l)) // each bool takes exactly one byte + for _, x := range s { + v := uint64(0) + if x { + v = 1 + } + p.valEnc(o, v) + } + return nil +} + +func size_slice_packed_bool(p *Properties, base structPointer) (n int) { + s := *structPointer_BoolSlice(base, p.field) + l := len(s) + if l == 0 { + return 0 + } + n += len(p.tagcode) + n += sizeVarint(uint64(l)) + n += l // each bool takes exactly one byte + return +} + +// Encode a slice of bytes ([]byte). +func (o *Buffer) enc_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if s == nil { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(s) + return nil +} + +func (o *Buffer) enc_proto3_slice_byte(p *Properties, base structPointer) error { + s := *structPointer_Bytes(base, p.field) + if len(s) == 0 { + return ErrNil + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(s) + return nil +} + +func size_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if s == nil && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeRawBytes(s) + return +} + +func size_proto3_slice_byte(p *Properties, base structPointer) (n int) { + s := *structPointer_Bytes(base, p.field) + if len(s) == 0 && !p.oneof { + return 0 + } + n += len(p.tagcode) + n += sizeRawBytes(s) + return +} + +// Encode a slice of int32s ([]int32). +func (o *Buffer) enc_slice_int32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + p.valEnc(o, uint64(x)) + } + return nil +} + +func size_slice_int32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + n += p.valSize(uint64(x)) + } + return +} + +// Encode a slice of int32s ([]int32) in packed format. +func (o *Buffer) enc_slice_packed_int32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + p.valEnc(buf, uint64(x)) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_int32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + x := int32(s.Index(i)) // permit sign extension to use full 64-bit range + bufSize += p.valSize(uint64(x)) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of uint32s ([]uint32). +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_slice_uint32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + x := s.Index(i) + p.valEnc(o, uint64(x)) + } + return nil +} + +func size_slice_uint32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + x := s.Index(i) + n += p.valSize(uint64(x)) + } + return +} + +// Encode a slice of uint32s ([]uint32) in packed format. +// Exactly the same as int32, except for no sign extension. +func (o *Buffer) enc_slice_packed_uint32(p *Properties, base structPointer) error { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + p.valEnc(buf, uint64(s.Index(i))) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_uint32(p *Properties, base structPointer) (n int) { + s := structPointer_Word32Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + bufSize += p.valSize(uint64(s.Index(i))) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of int64s ([]int64). +func (o *Buffer) enc_slice_int64(p *Properties, base structPointer) error { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + p.valEnc(o, s.Index(i)) + } + return nil +} + +func size_slice_int64(p *Properties, base structPointer) (n int) { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + for i := 0; i < l; i++ { + n += len(p.tagcode) + n += p.valSize(s.Index(i)) + } + return +} + +// Encode a slice of int64s ([]int64) in packed format. +func (o *Buffer) enc_slice_packed_int64(p *Properties, base structPointer) error { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return ErrNil + } + // TODO: Reuse a Buffer. + buf := NewBuffer(nil) + for i := 0; i < l; i++ { + p.valEnc(buf, s.Index(i)) + } + + o.buf = append(o.buf, p.tagcode...) + o.EncodeVarint(uint64(len(buf.buf))) + o.buf = append(o.buf, buf.buf...) + return nil +} + +func size_slice_packed_int64(p *Properties, base structPointer) (n int) { + s := structPointer_Word64Slice(base, p.field) + l := s.Len() + if l == 0 { + return 0 + } + var bufSize int + for i := 0; i < l; i++ { + bufSize += p.valSize(s.Index(i)) + } + + n += len(p.tagcode) + n += sizeVarint(uint64(bufSize)) + n += bufSize + return +} + +// Encode a slice of slice of bytes ([][]byte). +func (o *Buffer) enc_slice_slice_byte(p *Properties, base structPointer) error { + ss := *structPointer_BytesSlice(base, p.field) + l := len(ss) + if l == 0 { + return ErrNil + } + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(ss[i]) + } + return nil +} + +func size_slice_slice_byte(p *Properties, base structPointer) (n int) { + ss := *structPointer_BytesSlice(base, p.field) + l := len(ss) + if l == 0 { + return 0 + } + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + n += sizeRawBytes(ss[i]) + } + return +} + +// Encode a slice of strings ([]string). +func (o *Buffer) enc_slice_string(p *Properties, base structPointer) error { + ss := *structPointer_StringSlice(base, p.field) + l := len(ss) + for i := 0; i < l; i++ { + o.buf = append(o.buf, p.tagcode...) + o.EncodeStringBytes(ss[i]) + } + return nil +} + +func size_slice_string(p *Properties, base structPointer) (n int) { + ss := *structPointer_StringSlice(base, p.field) + l := len(ss) + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + n += sizeStringBytes(ss[i]) + } + return +} + +// Encode a slice of message structs ([]*struct). +func (o *Buffer) enc_slice_struct_message(p *Properties, base structPointer) error { + var state errorState + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + for i := 0; i < l; i++ { + structp := s.Index(i) + if structPointer_IsNil(structp) { + return errRepeatedHasNil + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, err := m.Marshal() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + o.buf = append(o.buf, p.tagcode...) + o.EncodeRawBytes(data) + continue + } + + o.buf = append(o.buf, p.tagcode...) + err := o.enc_len_struct(p.sprop, structp, &state) + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + } + return state.err +} + +func size_slice_struct_message(p *Properties, base structPointer) (n int) { + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + n += l * len(p.tagcode) + for i := 0; i < l; i++ { + structp := s.Index(i) + if structPointer_IsNil(structp) { + return // return the size up to this point + } + + // Can the object marshal itself? + if p.isMarshaler { + m := structPointer_Interface(structp, p.stype).(Marshaler) + data, _ := m.Marshal() + n += len(p.tagcode) + n += sizeRawBytes(data) + continue + } + + n0 := size_struct(p.sprop, structp) + n1 := sizeVarint(uint64(n0)) // size of encoded length + n += n0 + n1 + } + return +} + +// Encode a slice of group structs ([]*struct). +func (o *Buffer) enc_slice_struct_group(p *Properties, base structPointer) error { + var state errorState + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + for i := 0; i < l; i++ { + b := s.Index(i) + if structPointer_IsNil(b) { + return errRepeatedHasNil + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireStartGroup)) + + err := o.enc_struct(p.sprop, b) + + if err != nil && !state.shouldContinue(err, nil) { + if err == ErrNil { + return errRepeatedHasNil + } + return err + } + + o.EncodeVarint(uint64((p.Tag << 3) | WireEndGroup)) + } + return state.err +} + +func size_slice_struct_group(p *Properties, base structPointer) (n int) { + s := structPointer_StructPointerSlice(base, p.field) + l := s.Len() + + n += l * sizeVarint(uint64((p.Tag<<3)|WireStartGroup)) + n += l * sizeVarint(uint64((p.Tag<<3)|WireEndGroup)) + for i := 0; i < l; i++ { + b := s.Index(i) + if structPointer_IsNil(b) { + return // return size up to this point + } + + n += size_struct(p.sprop, b) + } + return +} + +// Encode an extension map. +func (o *Buffer) enc_map(p *Properties, base structPointer) error { + exts := structPointer_ExtMap(base, p.field) + if err := encodeExtensionsMap(*exts); err != nil { + return err + } + + return o.enc_map_body(*exts) +} + +func (o *Buffer) enc_exts(p *Properties, base structPointer) error { + exts := structPointer_Extensions(base, p.field) + if err := encodeExtensions(exts); err != nil { + return err + } + v, _ := exts.extensionsRead() + + return o.enc_map_body(v) +} + +func (o *Buffer) enc_map_body(v map[int32]Extension) error { + // Fast-path for common cases: zero or one extensions. + if len(v) <= 1 { + for _, e := range v { + o.buf = append(o.buf, e.enc...) + } + return nil + } + + // Sort keys to provide a deterministic encoding. + keys := make([]int, 0, len(v)) + for k := range v { + keys = append(keys, int(k)) + } + sort.Ints(keys) + + for _, k := range keys { + o.buf = append(o.buf, v[int32(k)].enc...) + } + return nil +} + +func size_map(p *Properties, base structPointer) int { + v := structPointer_ExtMap(base, p.field) + return extensionsMapSize(*v) +} + +func size_exts(p *Properties, base structPointer) int { + v := structPointer_Extensions(base, p.field) + return extensionsSize(v) +} + +// Encode a map field. +func (o *Buffer) enc_new_map(p *Properties, base structPointer) error { + var state errorState // XXX: or do we need to plumb this through? + + /* + A map defined as + map map_field = N; + is encoded in the same way as + message MapFieldEntry { + key_type key = 1; + value_type value = 2; + } + repeated MapFieldEntry map_field = N; + */ + + v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V + if v.Len() == 0 { + return nil + } + + keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) + + enc := func() error { + if err := p.mkeyprop.enc(o, p.mkeyprop, keybase); err != nil { + return err + } + if err := p.mvalprop.enc(o, p.mvalprop, valbase); err != nil && err != ErrNil { + return err + } + return nil + } + + // Don't sort map keys. It is not required by the spec, and C++ doesn't do it. + for _, key := range v.MapKeys() { + val := v.MapIndex(key) + + keycopy.Set(key) + valcopy.Set(val) + + o.buf = append(o.buf, p.tagcode...) + if err := o.enc_len_thing(enc, &state); err != nil { + return err + } + } + return nil +} + +func size_new_map(p *Properties, base structPointer) int { + v := structPointer_NewAt(base, p.field, p.mtype).Elem() // map[K]V + + keycopy, valcopy, keybase, valbase := mapEncodeScratch(p.mtype) + + n := 0 + for _, key := range v.MapKeys() { + val := v.MapIndex(key) + keycopy.Set(key) + valcopy.Set(val) + + // Tag codes for key and val are the responsibility of the sub-sizer. + keysize := p.mkeyprop.size(p.mkeyprop, keybase) + valsize := p.mvalprop.size(p.mvalprop, valbase) + entry := keysize + valsize + // Add on tag code and length of map entry itself. + n += len(p.tagcode) + sizeVarint(uint64(entry)) + entry + } + return n +} + +// mapEncodeScratch returns a new reflect.Value matching the map's value type, +// and a structPointer suitable for passing to an encoder or sizer. +func mapEncodeScratch(mapType reflect.Type) (keycopy, valcopy reflect.Value, keybase, valbase structPointer) { + // Prepare addressable doubly-indirect placeholders for the key and value types. + // This is needed because the element-type encoders expect **T, but the map iteration produces T. + + keycopy = reflect.New(mapType.Key()).Elem() // addressable K + keyptr := reflect.New(reflect.PtrTo(keycopy.Type())).Elem() // addressable *K + keyptr.Set(keycopy.Addr()) // + keybase = toStructPointer(keyptr.Addr()) // **K + + // Value types are more varied and require special handling. + switch mapType.Elem().Kind() { + case reflect.Slice: + // []byte + var dummy []byte + valcopy = reflect.ValueOf(&dummy).Elem() // addressable []byte + valbase = toStructPointer(valcopy.Addr()) + case reflect.Ptr: + // message; the generated field type is map[K]*Msg (so V is *Msg), + // so we only need one level of indirection. + valcopy = reflect.New(mapType.Elem()).Elem() // addressable V + valbase = toStructPointer(valcopy.Addr()) + default: + // everything else + valcopy = reflect.New(mapType.Elem()).Elem() // addressable V + valptr := reflect.New(reflect.PtrTo(valcopy.Type())).Elem() // addressable *V + valptr.Set(valcopy.Addr()) // + valbase = toStructPointer(valptr.Addr()) // **V + } + return +} + +// Encode a struct. +func (o *Buffer) enc_struct(prop *StructProperties, base structPointer) error { + var state errorState + // Encode fields in tag order so that decoders may use optimizations + // that depend on the ordering. + // https://developers.google.com/protocol-buffers/docs/encoding#order + for _, i := range prop.order { + p := prop.Prop[i] + if p.enc != nil { + err := p.enc(o, p, base) + if err != nil { + if err == ErrNil { + if p.Required && state.err == nil { + state.err = &RequiredNotSetError{p.Name} + } + } else if err == errRepeatedHasNil { + // Give more context to nil values in repeated fields. + return errors.New("repeated field " + p.OrigName + " has nil element") + } else if !state.shouldContinue(err, p) { + return err + } + } + if len(o.buf) > maxMarshalSize { + return ErrTooLarge + } + } + } + + // Do oneof fields. + if prop.oneofMarshaler != nil { + m := structPointer_Interface(base, prop.stype).(Message) + if err := prop.oneofMarshaler(m, o); err == ErrNil { + return errOneofHasNil + } else if err != nil { + return err + } + } + + // Add unrecognized fields at the end. + if prop.unrecField.IsValid() { + v := *structPointer_Bytes(base, prop.unrecField) + if len(o.buf)+len(v) > maxMarshalSize { + return ErrTooLarge + } + if len(v) > 0 { + o.buf = append(o.buf, v...) + } + } + + return state.err +} + +func size_struct(prop *StructProperties, base structPointer) (n int) { + for _, i := range prop.order { + p := prop.Prop[i] + if p.size != nil { + n += p.size(p, base) + } + } + + // Add unrecognized fields at the end. + if prop.unrecField.IsValid() { + v := *structPointer_Bytes(base, prop.unrecField) + n += len(v) + } + + // Factor in any oneof fields. + if prop.oneofSizer != nil { + m := structPointer_Interface(base, prop.stype).(Message) + n += prop.oneofSizer(m) + } + + return +} + +var zeroes [20]byte // longer than any conceivable sizeVarint + +// Encode a struct, preceded by its encoded length (as a varint). +func (o *Buffer) enc_len_struct(prop *StructProperties, base structPointer, state *errorState) error { + return o.enc_len_thing(func() error { return o.enc_struct(prop, base) }, state) +} + +// Encode something, preceded by its encoded length (as a varint). +func (o *Buffer) enc_len_thing(enc func() error, state *errorState) error { + iLen := len(o.buf) + o.buf = append(o.buf, 0, 0, 0, 0) // reserve four bytes for length + iMsg := len(o.buf) + err := enc() + if err != nil && !state.shouldContinue(err, nil) { + return err + } + lMsg := len(o.buf) - iMsg + lLen := sizeVarint(uint64(lMsg)) + switch x := lLen - (iMsg - iLen); { + case x > 0: // actual length is x bytes larger than the space we reserved + // Move msg x bytes right. + o.buf = append(o.buf, zeroes[:x]...) + copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) + case x < 0: // actual length is x bytes smaller than the space we reserved + // Move msg x bytes left. + copy(o.buf[iMsg+x:], o.buf[iMsg:iMsg+lMsg]) + o.buf = o.buf[:len(o.buf)+x] // x is negative + } + // Encode the length in the reserved space. + o.buf = o.buf[:iLen] + o.EncodeVarint(uint64(lMsg)) + o.buf = o.buf[:len(o.buf)+lMsg] + return state.err +} + +// errorState maintains the first error that occurs and updates that error +// with additional context. +type errorState struct { + err error +} + +// shouldContinue reports whether encoding should continue upon encountering the +// given error. If the error is RequiredNotSetError, shouldContinue returns true +// and, if this is the first appearance of that error, remembers it for future +// reporting. +// +// If prop is not nil, it may update any error with additional context about the +// field with the error. +func (s *errorState) shouldContinue(err error, prop *Properties) bool { + // Ignore unset required fields. + reqNotSet, ok := err.(*RequiredNotSetError) + if !ok { + return false + } + if s.err == nil { + if prop != nil { + err = &RequiredNotSetError{prop.Name + "." + reqNotSet.field} + } + s.err = err + } + return true +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/equal.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/equal.go new file mode 100644 index 000000000000..8b16f951c712 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/equal.go @@ -0,0 +1,296 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2011 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Protocol buffer comparison. + +package proto + +import ( + "bytes" + "log" + "reflect" + "strings" +) + +/* +Equal returns true iff protocol buffers a and b are equal. +The arguments must both be pointers to protocol buffer structs. + +Equality is defined in this way: + - Two messages are equal iff they are the same type, + corresponding fields are equal, unknown field sets + are equal, and extensions sets are equal. + - Two set scalar fields are equal iff their values are equal. + If the fields are of a floating-point type, remember that + NaN != x for all x, including NaN. If the message is defined + in a proto3 .proto file, fields are not "set"; specifically, + zero length proto3 "bytes" fields are equal (nil == {}). + - Two repeated fields are equal iff their lengths are the same, + and their corresponding elements are equal (a "bytes" field, + although represented by []byte, is not a repeated field) + - Two unset fields are equal. + - Two unknown field sets are equal if their current + encoded state is equal. + - Two extension sets are equal iff they have corresponding + elements that are pairwise equal. + - Every other combination of things are not equal. + +The return value is undefined if a and b are not protocol buffers. +*/ +func Equal(a, b Message) bool { + if a == nil || b == nil { + return a == b + } + v1, v2 := reflect.ValueOf(a), reflect.ValueOf(b) + if v1.Type() != v2.Type() { + return false + } + if v1.Kind() == reflect.Ptr { + if v1.IsNil() { + return v2.IsNil() + } + if v2.IsNil() { + return false + } + v1, v2 = v1.Elem(), v2.Elem() + } + if v1.Kind() != reflect.Struct { + return false + } + return equalStruct(v1, v2) +} + +// v1 and v2 are known to have the same type. +func equalStruct(v1, v2 reflect.Value) bool { + sprop := GetProperties(v1.Type()) + for i := 0; i < v1.NumField(); i++ { + f := v1.Type().Field(i) + if strings.HasPrefix(f.Name, "XXX_") { + continue + } + f1, f2 := v1.Field(i), v2.Field(i) + if f.Type.Kind() == reflect.Ptr { + if n1, n2 := f1.IsNil(), f2.IsNil(); n1 && n2 { + // both unset + continue + } else if n1 != n2 { + // set/unset mismatch + return false + } + b1, ok := f1.Interface().(raw) + if ok { + b2 := f2.Interface().(raw) + // RawMessage + if !bytes.Equal(b1.Bytes(), b2.Bytes()) { + return false + } + continue + } + f1, f2 = f1.Elem(), f2.Elem() + } + if !equalAny(f1, f2, sprop.Prop[i]) { + return false + } + } + + if em1 := v1.FieldByName("XXX_InternalExtensions"); em1.IsValid() { + em2 := v2.FieldByName("XXX_InternalExtensions") + if !equalExtensions(v1.Type(), em1.Interface().(XXX_InternalExtensions), em2.Interface().(XXX_InternalExtensions)) { + return false + } + } + + if em1 := v1.FieldByName("XXX_extensions"); em1.IsValid() { + em2 := v2.FieldByName("XXX_extensions") + if !equalExtMap(v1.Type(), em1.Interface().(map[int32]Extension), em2.Interface().(map[int32]Extension)) { + return false + } + } + + uf := v1.FieldByName("XXX_unrecognized") + if !uf.IsValid() { + return true + } + + u1 := uf.Bytes() + u2 := v2.FieldByName("XXX_unrecognized").Bytes() + if !bytes.Equal(u1, u2) { + return false + } + + return true +} + +// v1 and v2 are known to have the same type. +// prop may be nil. +func equalAny(v1, v2 reflect.Value, prop *Properties) bool { + if v1.Type() == protoMessageType { + m1, _ := v1.Interface().(Message) + m2, _ := v2.Interface().(Message) + return Equal(m1, m2) + } + switch v1.Kind() { + case reflect.Bool: + return v1.Bool() == v2.Bool() + case reflect.Float32, reflect.Float64: + return v1.Float() == v2.Float() + case reflect.Int32, reflect.Int64: + return v1.Int() == v2.Int() + case reflect.Interface: + // Probably a oneof field; compare the inner values. + n1, n2 := v1.IsNil(), v2.IsNil() + if n1 || n2 { + return n1 == n2 + } + e1, e2 := v1.Elem(), v2.Elem() + if e1.Type() != e2.Type() { + return false + } + return equalAny(e1, e2, nil) + case reflect.Map: + if v1.Len() != v2.Len() { + return false + } + for _, key := range v1.MapKeys() { + val2 := v2.MapIndex(key) + if !val2.IsValid() { + // This key was not found in the second map. + return false + } + if !equalAny(v1.MapIndex(key), val2, nil) { + return false + } + } + return true + case reflect.Ptr: + // Maps may have nil values in them, so check for nil. + if v1.IsNil() && v2.IsNil() { + return true + } + if v1.IsNil() != v2.IsNil() { + return false + } + return equalAny(v1.Elem(), v2.Elem(), prop) + case reflect.Slice: + if v1.Type().Elem().Kind() == reflect.Uint8 { + // short circuit: []byte + + // Edge case: if this is in a proto3 message, a zero length + // bytes field is considered the zero value. + if prop != nil && prop.proto3 && v1.Len() == 0 && v2.Len() == 0 { + return true + } + if v1.IsNil() != v2.IsNil() { + return false + } + return bytes.Equal(v1.Interface().([]byte), v2.Interface().([]byte)) + } + + if v1.Len() != v2.Len() { + return false + } + for i := 0; i < v1.Len(); i++ { + if !equalAny(v1.Index(i), v2.Index(i), prop) { + return false + } + } + return true + case reflect.String: + return v1.Interface().(string) == v2.Interface().(string) + case reflect.Struct: + return equalStruct(v1, v2) + case reflect.Uint32, reflect.Uint64: + return v1.Uint() == v2.Uint() + } + + // unknown type, so not a protocol buffer + log.Printf("proto: don't know how to compare %v", v1) + return false +} + +// base is the struct type that the extensions are based on. +// x1 and x2 are InternalExtensions. +func equalExtensions(base reflect.Type, x1, x2 XXX_InternalExtensions) bool { + em1, _ := x1.extensionsRead() + em2, _ := x2.extensionsRead() + return equalExtMap(base, em1, em2) +} + +func equalExtMap(base reflect.Type, em1, em2 map[int32]Extension) bool { + if len(em1) != len(em2) { + return false + } + + for extNum, e1 := range em1 { + e2, ok := em2[extNum] + if !ok { + return false + } + + m1, m2 := e1.value, e2.value + + if m1 != nil && m2 != nil { + // Both are unencoded. + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { + return false + } + continue + } + + // At least one is encoded. To do a semantically correct comparison + // we need to unmarshal them first. + var desc *ExtensionDesc + if m := extensionMaps[base]; m != nil { + desc = m[extNum] + } + if desc == nil { + log.Printf("proto: don't know how to compare extension %d of %v", extNum, base) + continue + } + var err error + if m1 == nil { + m1, err = decodeExtension(e1.enc, desc) + } + if m2 == nil && err == nil { + m2, err = decodeExtension(e2.enc, desc) + } + if err != nil { + // The encoded form is invalid. + log.Printf("proto: badly encoded extension %d of %v: %v", extNum, base, err) + return false + } + if !equalAny(reflect.ValueOf(m1), reflect.ValueOf(m2), nil) { + return false + } + } + + return true +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/extensions.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/extensions.go new file mode 100644 index 000000000000..9f484f53a3ae --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/extensions.go @@ -0,0 +1,555 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +/* + * Types and routines for supporting protocol buffer extensions. + */ + +import ( + "errors" + "fmt" + "reflect" + "strconv" + "sync" +) + +// ErrMissingExtension is the error returned by GetExtension if the named extension is not in the message. +var ErrMissingExtension = errors.New("proto: missing extension") + +// ExtensionRange represents a range of message extensions for a protocol buffer. +// Used in code generated by the protocol compiler. +type ExtensionRange struct { + Start, End int32 // both inclusive +} + +// extendableProto is an interface implemented by any protocol buffer generated by the current +// proto compiler that may be extended. +type extendableProto interface { + Message + ExtensionRangeArray() []ExtensionRange + extensionsWrite() map[int32]Extension + extensionsRead() (map[int32]Extension, sync.Locker) +} + +// extendableProtoV1 is an interface implemented by a protocol buffer generated by the previous +// version of the proto compiler that may be extended. +type extendableProtoV1 interface { + Message + ExtensionRangeArray() []ExtensionRange + ExtensionMap() map[int32]Extension +} + +// extensionAdapter is a wrapper around extendableProtoV1 that implements extendableProto. +type extensionAdapter struct { + extendableProtoV1 +} + +func (e extensionAdapter) extensionsWrite() map[int32]Extension { + return e.ExtensionMap() +} + +func (e extensionAdapter) extensionsRead() (map[int32]Extension, sync.Locker) { + return e.ExtensionMap(), notLocker{} +} + +// notLocker is a sync.Locker whose Lock and Unlock methods are nops. +type notLocker struct{} + +func (n notLocker) Lock() {} +func (n notLocker) Unlock() {} + +// extendable returns the extendableProto interface for the given generated proto message. +// If the proto message has the old extension format, it returns a wrapper that implements +// the extendableProto interface. +func extendable(p interface{}) (extendableProto, bool) { + if ep, ok := p.(extendableProto); ok { + return ep, ok + } + if ep, ok := p.(extendableProtoV1); ok { + return extensionAdapter{ep}, ok + } + return nil, false +} + +// XXX_InternalExtensions is an internal representation of proto extensions. +// +// Each generated message struct type embeds an anonymous XXX_InternalExtensions field, +// thus gaining the unexported 'extensions' method, which can be called only from the proto package. +// +// The methods of XXX_InternalExtensions are not concurrency safe in general, +// but calls to logically read-only methods such as has and get may be executed concurrently. +type XXX_InternalExtensions struct { + // The struct must be indirect so that if a user inadvertently copies a + // generated message and its embedded XXX_InternalExtensions, they + // avoid the mayhem of a copied mutex. + // + // The mutex serializes all logically read-only operations to p.extensionMap. + // It is up to the client to ensure that write operations to p.extensionMap are + // mutually exclusive with other accesses. + p *struct { + mu sync.Mutex + extensionMap map[int32]Extension + } +} + +// extensionsWrite returns the extension map, creating it on first use. +func (e *XXX_InternalExtensions) extensionsWrite() map[int32]Extension { + if e.p == nil { + e.p = new(struct { + mu sync.Mutex + extensionMap map[int32]Extension + }) + e.p.extensionMap = make(map[int32]Extension) + } + return e.p.extensionMap +} + +// extensionsRead returns the extensions map for read-only use. It may be nil. +// The caller must hold the returned mutex's lock when accessing Elements within the map. +func (e *XXX_InternalExtensions) extensionsRead() (map[int32]Extension, sync.Locker) { + if e.p == nil { + return nil, nil + } + return e.p.extensionMap, &e.p.mu +} + +var extendableProtoType = reflect.TypeOf((*extendableProto)(nil)).Elem() +var extendableProtoV1Type = reflect.TypeOf((*extendableProtoV1)(nil)).Elem() + +// ExtensionDesc represents an extension specification. +// Used in generated code from the protocol compiler. +type ExtensionDesc struct { + ExtendedType Message // nil pointer to the type that is being extended + ExtensionType interface{} // nil pointer to the extension type + Field int32 // field number + Name string // fully-qualified name of extension, for text formatting + Tag string // protobuf tag style +} + +func (ed *ExtensionDesc) repeated() bool { + t := reflect.TypeOf(ed.ExtensionType) + return t.Kind() == reflect.Slice && t.Elem().Kind() != reflect.Uint8 +} + +// Extension represents an extension in a message. +type Extension struct { + // When an extension is stored in a message using SetExtension + // only desc and value are set. When the message is marshaled + // enc will be set to the encoded form of the message. + // + // When a message is unmarshaled and contains extensions, each + // extension will have only enc set. When such an extension is + // accessed using GetExtension (or GetExtensions) desc and value + // will be set. + desc *ExtensionDesc + value interface{} + enc []byte +} + +// SetRawExtension is for testing only. +func SetRawExtension(base Message, id int32, b []byte) { + epb, ok := extendable(base) + if !ok { + return + } + extmap := epb.extensionsWrite() + extmap[id] = Extension{enc: b} +} + +// isExtensionField returns true iff the given field number is in an extension range. +func isExtensionField(pb extendableProto, field int32) bool { + for _, er := range pb.ExtensionRangeArray() { + if er.Start <= field && field <= er.End { + return true + } + } + return false +} + +// checkExtensionTypes checks that the given extension is valid for pb. +func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error { + var pbi interface{} = pb + // Check the extended type. + if ea, ok := pbi.(extensionAdapter); ok { + pbi = ea.extendableProtoV1 + } + if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b { + return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String()) + } + // Check the range. + if !isExtensionField(pb, extension.Field) { + return errors.New("proto: bad extension number; not in declared ranges") + } + return nil +} + +// extPropKey is sufficient to uniquely identify an extension. +type extPropKey struct { + base reflect.Type + field int32 +} + +var extProp = struct { + sync.RWMutex + m map[extPropKey]*Properties +}{ + m: make(map[extPropKey]*Properties), +} + +func extensionProperties(ed *ExtensionDesc) *Properties { + key := extPropKey{base: reflect.TypeOf(ed.ExtendedType), field: ed.Field} + + extProp.RLock() + if prop, ok := extProp.m[key]; ok { + extProp.RUnlock() + return prop + } + extProp.RUnlock() + + extProp.Lock() + defer extProp.Unlock() + // Check again. + if prop, ok := extProp.m[key]; ok { + return prop + } + + prop := new(Properties) + prop.Init(reflect.TypeOf(ed.ExtensionType), "unknown_name", ed.Tag, nil) + extProp.m[key] = prop + return prop +} + +// encode encodes any unmarshaled (unencoded) extensions in e. +func encodeExtensions(e *XXX_InternalExtensions) error { + m, mu := e.extensionsRead() + if m == nil { + return nil // fast path + } + mu.Lock() + defer mu.Unlock() + return encodeExtensionsMap(m) +} + +// encode encodes any unmarshaled (unencoded) extensions in e. +func encodeExtensionsMap(m map[int32]Extension) error { + for k, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + et := reflect.TypeOf(e.desc.ExtensionType) + props := extensionProperties(e.desc) + + p := NewBuffer(nil) + // If e.value has type T, the encoder expects a *struct{ X T }. + // Pass a *T with a zero field and hope it all works out. + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(e.value)) + if err := props.enc(p, props, toStructPointer(x)); err != nil { + return err + } + e.enc = p.buf + m[k] = e + } + return nil +} + +func extensionsSize(e *XXX_InternalExtensions) (n int) { + m, mu := e.extensionsRead() + if m == nil { + return 0 + } + mu.Lock() + defer mu.Unlock() + return extensionsMapSize(m) +} + +func extensionsMapSize(m map[int32]Extension) (n int) { + for _, e := range m { + if e.value == nil || e.desc == nil { + // Extension is only in its encoded form. + n += len(e.enc) + continue + } + + // We don't skip extensions that have an encoded form set, + // because the extension value may have been mutated after + // the last time this function was called. + + et := reflect.TypeOf(e.desc.ExtensionType) + props := extensionProperties(e.desc) + + // If e.value has type T, the encoder expects a *struct{ X T }. + // Pass a *T with a zero field and hope it all works out. + x := reflect.New(et) + x.Elem().Set(reflect.ValueOf(e.value)) + n += props.size(props, toStructPointer(x)) + } + return +} + +// HasExtension returns whether the given extension is present in pb. +func HasExtension(pb Message, extension *ExtensionDesc) bool { + // TODO: Check types, field numbers, etc.? + epb, ok := extendable(pb) + if !ok { + return false + } + extmap, mu := epb.extensionsRead() + if extmap == nil { + return false + } + mu.Lock() + _, ok = extmap[extension.Field] + mu.Unlock() + return ok +} + +// ClearExtension removes the given extension from pb. +func ClearExtension(pb Message, extension *ExtensionDesc) { + epb, ok := extendable(pb) + if !ok { + return + } + // TODO: Check types, field numbers, etc.? + extmap := epb.extensionsWrite() + delete(extmap, extension.Field) +} + +// GetExtension parses and returns the given extension of pb. +// If the extension is not present and has no default value it returns ErrMissingExtension. +func GetExtension(pb Message, extension *ExtensionDesc) (interface{}, error) { + epb, ok := extendable(pb) + if !ok { + return nil, errors.New("proto: not an extendable proto") + } + + if err := checkExtensionTypes(epb, extension); err != nil { + return nil, err + } + + emap, mu := epb.extensionsRead() + if emap == nil { + return defaultExtensionValue(extension) + } + mu.Lock() + defer mu.Unlock() + e, ok := emap[extension.Field] + if !ok { + // defaultExtensionValue returns the default value or + // ErrMissingExtension if there is no default. + return defaultExtensionValue(extension) + } + + if e.value != nil { + // Already decoded. Check the descriptor, though. + if e.desc != extension { + // This shouldn't happen. If it does, it means that + // GetExtension was called twice with two different + // descriptors with the same field number. + return nil, errors.New("proto: descriptor conflict") + } + return e.value, nil + } + + v, err := decodeExtension(e.enc, extension) + if err != nil { + return nil, err + } + + // Remember the decoded version and drop the encoded version. + // That way it is safe to mutate what we return. + e.value = v + e.desc = extension + e.enc = nil + emap[extension.Field] = e + return e.value, nil +} + +// defaultExtensionValue returns the default value for extension. +// If no default for an extension is defined ErrMissingExtension is returned. +func defaultExtensionValue(extension *ExtensionDesc) (interface{}, error) { + t := reflect.TypeOf(extension.ExtensionType) + props := extensionProperties(extension) + + sf, _, err := fieldDefault(t, props) + if err != nil { + return nil, err + } + + if sf == nil || sf.value == nil { + // There is no default value. + return nil, ErrMissingExtension + } + + if t.Kind() != reflect.Ptr { + // We do not need to return a Ptr, we can directly return sf.value. + return sf.value, nil + } + + // We need to return an interface{} that is a pointer to sf.value. + value := reflect.New(t).Elem() + value.Set(reflect.New(value.Type().Elem())) + if sf.kind == reflect.Int32 { + // We may have an int32 or an enum, but the underlying data is int32. + // Since we can't set an int32 into a non int32 reflect.value directly + // set it as a int32. + value.Elem().SetInt(int64(sf.value.(int32))) + } else { + value.Elem().Set(reflect.ValueOf(sf.value)) + } + return value.Interface(), nil +} + +// decodeExtension decodes an extension encoded in b. +func decodeExtension(b []byte, extension *ExtensionDesc) (interface{}, error) { + o := NewBuffer(b) + + t := reflect.TypeOf(extension.ExtensionType) + + props := extensionProperties(extension) + + // t is a pointer to a struct, pointer to basic type or a slice. + // Allocate a "field" to store the pointer/slice itself; the + // pointer/slice will be stored here. We pass + // the address of this field to props.dec. + // This passes a zero field and a *t and lets props.dec + // interpret it as a *struct{ x t }. + value := reflect.New(t).Elem() + + for { + // Discard wire type and field number varint. It isn't needed. + if _, err := o.DecodeVarint(); err != nil { + return nil, err + } + + if err := props.dec(o, props, toStructPointer(value.Addr())); err != nil { + return nil, err + } + + if o.index >= len(o.buf) { + break + } + } + return value.Interface(), nil +} + +// GetExtensions returns a slice of the extensions present in pb that are also listed in es. +// The returned slice has the same length as es; missing extensions will appear as nil elements. +func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) { + epb, ok := extendable(pb) + if !ok { + return nil, errors.New("proto: not an extendable proto") + } + extensions = make([]interface{}, len(es)) + for i, e := range es { + extensions[i], err = GetExtension(epb, e) + if err == ErrMissingExtension { + err = nil + } + if err != nil { + return + } + } + return +} + +// SetExtension sets the specified extension of pb to the specified value. +func SetExtension(pb Message, extension *ExtensionDesc, value interface{}) error { + epb, ok := extendable(pb) + if !ok { + return errors.New("proto: not an extendable proto") + } + if err := checkExtensionTypes(epb, extension); err != nil { + return err + } + typ := reflect.TypeOf(extension.ExtensionType) + if typ != reflect.TypeOf(value) { + return errors.New("proto: bad extension value type") + } + // nil extension values need to be caught early, because the + // encoder can't distinguish an ErrNil due to a nil extension + // from an ErrNil due to a missing field. Extensions are + // always optional, so the encoder would just swallow the error + // and drop all the extensions from the encoded message. + if reflect.ValueOf(value).IsNil() { + return fmt.Errorf("proto: SetExtension called with nil value of type %T", value) + } + + extmap := epb.extensionsWrite() + extmap[extension.Field] = Extension{desc: extension, value: value} + return nil +} + +// ClearAllExtensions clears all extensions from pb. +func ClearAllExtensions(pb Message) { + epb, ok := extendable(pb) + if !ok { + return + } + m := epb.extensionsWrite() + for k := range m { + delete(m, k) + } +} + +// A global registry of extensions. +// The generated code will register the generated descriptors by calling RegisterExtension. + +var extensionMaps = make(map[reflect.Type]map[int32]*ExtensionDesc) + +// RegisterExtension is called from the generated code. +func RegisterExtension(desc *ExtensionDesc) { + st := reflect.TypeOf(desc.ExtendedType).Elem() + m := extensionMaps[st] + if m == nil { + m = make(map[int32]*ExtensionDesc) + extensionMaps[st] = m + } + if _, ok := m[desc.Field]; ok { + panic("proto: duplicate extension registered: " + st.String() + " " + strconv.Itoa(int(desc.Field))) + } + m[desc.Field] = desc +} + +// RegisteredExtensions returns a map of the registered extensions of a +// protocol buffer struct, indexed by the extension number. +// The argument pb should be a nil pointer to the struct type. +func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc { + return extensionMaps[reflect.TypeOf(pb).Elem()] +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/lib.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/lib.go new file mode 100644 index 000000000000..170b8e87d2e4 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/lib.go @@ -0,0 +1,898 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/* +Package proto converts data structures to and from the wire format of +protocol buffers. It works in concert with the Go source code generated +for .proto files by the protocol compiler. + +A summary of the properties of the protocol buffer interface +for a protocol buffer variable v: + + - Names are turned from camel_case to CamelCase for export. + - There are no methods on v to set fields; just treat + them as structure fields. + - There are getters that return a field's value if set, + and return the field's default value if unset. + The getters work even if the receiver is a nil message. + - The zero value for a struct is its correct initialization state. + All desired fields must be set before marshaling. + - A Reset() method will restore a protobuf struct to its zero state. + - Non-repeated fields are pointers to the values; nil means unset. + That is, optional or required field int32 f becomes F *int32. + - Repeated fields are slices. + - Helper functions are available to aid the setting of fields. + msg.Foo = proto.String("hello") // set field + - Constants are defined to hold the default values of all fields that + have them. They have the form Default_StructName_FieldName. + Because the getter methods handle defaulted values, + direct use of these constants should be rare. + - Enums are given type names and maps from names to values. + Enum values are prefixed by the enclosing message's name, or by the + enum's type name if it is a top-level enum. Enum types have a String + method, and a Enum method to assist in message construction. + - Nested messages, groups and enums have type names prefixed with the name of + the surrounding message type. + - Extensions are given descriptor names that start with E_, + followed by an underscore-delimited list of the nested messages + that contain it (if any) followed by the CamelCased name of the + extension field itself. HasExtension, ClearExtension, GetExtension + and SetExtension are functions for manipulating extensions. + - Oneof field sets are given a single field in their message, + with distinguished wrapper types for each possible field value. + - Marshal and Unmarshal are functions to encode and decode the wire format. + +When the .proto file specifies `syntax="proto3"`, there are some differences: + + - Non-repeated fields of non-message type are values instead of pointers. + - Getters are only generated for message and oneof fields. + - Enum types do not get an Enum method. + +The simplest way to describe this is to see an example. +Given file test.proto, containing + + package example; + + enum FOO { X = 17; } + + message Test { + required string label = 1; + optional int32 type = 2 [default=77]; + repeated int64 reps = 3; + optional group OptionalGroup = 4 { + required string RequiredField = 5; + } + oneof union { + int32 number = 6; + string name = 7; + } + } + +The resulting file, test.pb.go, is: + + package example + + import proto "github.com/golang/protobuf/proto" + import math "math" + + type FOO int32 + const ( + FOO_X FOO = 17 + ) + var FOO_name = map[int32]string{ + 17: "X", + } + var FOO_value = map[string]int32{ + "X": 17, + } + + func (x FOO) Enum() *FOO { + p := new(FOO) + *p = x + return p + } + func (x FOO) String() string { + return proto.EnumName(FOO_name, int32(x)) + } + func (x *FOO) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(FOO_value, data) + if err != nil { + return err + } + *x = FOO(value) + return nil + } + + type Test struct { + Label *string `protobuf:"bytes,1,req,name=label" json:"label,omitempty"` + Type *int32 `protobuf:"varint,2,opt,name=type,def=77" json:"type,omitempty"` + Reps []int64 `protobuf:"varint,3,rep,name=reps" json:"reps,omitempty"` + Optionalgroup *Test_OptionalGroup `protobuf:"group,4,opt,name=OptionalGroup" json:"optionalgroup,omitempty"` + // Types that are valid to be assigned to Union: + // *Test_Number + // *Test_Name + Union isTest_Union `protobuf_oneof:"union"` + XXX_unrecognized []byte `json:"-"` + } + func (m *Test) Reset() { *m = Test{} } + func (m *Test) String() string { return proto.CompactTextString(m) } + func (*Test) ProtoMessage() {} + + type isTest_Union interface { + isTest_Union() + } + + type Test_Number struct { + Number int32 `protobuf:"varint,6,opt,name=number"` + } + type Test_Name struct { + Name string `protobuf:"bytes,7,opt,name=name"` + } + + func (*Test_Number) isTest_Union() {} + func (*Test_Name) isTest_Union() {} + + func (m *Test) GetUnion() isTest_Union { + if m != nil { + return m.Union + } + return nil + } + const Default_Test_Type int32 = 77 + + func (m *Test) GetLabel() string { + if m != nil && m.Label != nil { + return *m.Label + } + return "" + } + + func (m *Test) GetType() int32 { + if m != nil && m.Type != nil { + return *m.Type + } + return Default_Test_Type + } + + func (m *Test) GetOptionalgroup() *Test_OptionalGroup { + if m != nil { + return m.Optionalgroup + } + return nil + } + + type Test_OptionalGroup struct { + RequiredField *string `protobuf:"bytes,5,req" json:"RequiredField,omitempty"` + } + func (m *Test_OptionalGroup) Reset() { *m = Test_OptionalGroup{} } + func (m *Test_OptionalGroup) String() string { return proto.CompactTextString(m) } + + func (m *Test_OptionalGroup) GetRequiredField() string { + if m != nil && m.RequiredField != nil { + return *m.RequiredField + } + return "" + } + + func (m *Test) GetNumber() int32 { + if x, ok := m.GetUnion().(*Test_Number); ok { + return x.Number + } + return 0 + } + + func (m *Test) GetName() string { + if x, ok := m.GetUnion().(*Test_Name); ok { + return x.Name + } + return "" + } + + func init() { + proto.RegisterEnum("example.FOO", FOO_name, FOO_value) + } + +To create and play with a Test object: + + package main + + import ( + "log" + + "github.com/golang/protobuf/proto" + pb "./example.pb" + ) + + func main() { + test := &pb.Test{ + Label: proto.String("hello"), + Type: proto.Int32(17), + Reps: []int64{1, 2, 3}, + Optionalgroup: &pb.Test_OptionalGroup{ + RequiredField: proto.String("good bye"), + }, + Union: &pb.Test_Name{"fred"}, + } + data, err := proto.Marshal(test) + if err != nil { + log.Fatal("marshaling error: ", err) + } + newTest := &pb.Test{} + err = proto.Unmarshal(data, newTest) + if err != nil { + log.Fatal("unmarshaling error: ", err) + } + // Now test and newTest contain the same data. + if test.GetLabel() != newTest.GetLabel() { + log.Fatalf("data mismatch %q != %q", test.GetLabel(), newTest.GetLabel()) + } + // Use a type switch to determine which oneof was set. + switch u := test.Union.(type) { + case *pb.Test_Number: // u.Number contains the number. + case *pb.Test_Name: // u.Name contains the string. + } + // etc. + } +*/ +package proto + +import ( + "encoding/json" + "fmt" + "log" + "reflect" + "sort" + "strconv" + "sync" +) + +// Message is implemented by generated protocol buffer messages. +type Message interface { + Reset() + String() string + ProtoMessage() +} + +// Stats records allocation details about the protocol buffer encoders +// and decoders. Useful for tuning the library itself. +type Stats struct { + Emalloc uint64 // mallocs in encode + Dmalloc uint64 // mallocs in decode + Encode uint64 // number of encodes + Decode uint64 // number of decodes + Chit uint64 // number of cache hits + Cmiss uint64 // number of cache misses + Size uint64 // number of sizes +} + +// Set to true to enable stats collection. +const collectStats = false + +var stats Stats + +// GetStats returns a copy of the global Stats structure. +func GetStats() Stats { return stats } + +// A Buffer is a buffer manager for marshaling and unmarshaling +// protocol buffers. It may be reused between invocations to +// reduce memory usage. It is not necessary to use a Buffer; +// the global functions Marshal and Unmarshal create a +// temporary Buffer and are fine for most applications. +type Buffer struct { + buf []byte // encode/decode byte stream + index int // write point + + // pools of basic types to amortize allocation. + bools []bool + uint32s []uint32 + uint64s []uint64 + + // extra pools, only used with pointer_reflect.go + int32s []int32 + int64s []int64 + float32s []float32 + float64s []float64 +} + +// NewBuffer allocates a new Buffer and initializes its internal data to +// the contents of the argument slice. +func NewBuffer(e []byte) *Buffer { + return &Buffer{buf: e} +} + +// Reset resets the Buffer, ready for marshaling a new protocol buffer. +func (p *Buffer) Reset() { + p.buf = p.buf[0:0] // for reading/writing + p.index = 0 // for reading +} + +// SetBuf replaces the internal buffer with the slice, +// ready for unmarshaling the contents of the slice. +func (p *Buffer) SetBuf(s []byte) { + p.buf = s + p.index = 0 +} + +// Bytes returns the contents of the Buffer. +func (p *Buffer) Bytes() []byte { return p.buf } + +/* + * Helper routines for simplifying the creation of optional fields of basic type. + */ + +// Bool is a helper routine that allocates a new bool value +// to store v and returns a pointer to it. +func Bool(v bool) *bool { + return &v +} + +// Int32 is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it. +func Int32(v int32) *int32 { + return &v +} + +// Int is a helper routine that allocates a new int32 value +// to store v and returns a pointer to it, but unlike Int32 +// its argument value is an int. +func Int(v int) *int32 { + p := new(int32) + *p = int32(v) + return p +} + +// Int64 is a helper routine that allocates a new int64 value +// to store v and returns a pointer to it. +func Int64(v int64) *int64 { + return &v +} + +// Float32 is a helper routine that allocates a new float32 value +// to store v and returns a pointer to it. +func Float32(v float32) *float32 { + return &v +} + +// Float64 is a helper routine that allocates a new float64 value +// to store v and returns a pointer to it. +func Float64(v float64) *float64 { + return &v +} + +// Uint32 is a helper routine that allocates a new uint32 value +// to store v and returns a pointer to it. +func Uint32(v uint32) *uint32 { + return &v +} + +// Uint64 is a helper routine that allocates a new uint64 value +// to store v and returns a pointer to it. +func Uint64(v uint64) *uint64 { + return &v +} + +// String is a helper routine that allocates a new string value +// to store v and returns a pointer to it. +func String(v string) *string { + return &v +} + +// EnumName is a helper function to simplify printing protocol buffer enums +// by name. Given an enum map and a value, it returns a useful string. +func EnumName(m map[int32]string, v int32) string { + s, ok := m[v] + if ok { + return s + } + return strconv.Itoa(int(v)) +} + +// UnmarshalJSONEnum is a helper function to simplify recovering enum int values +// from their JSON-encoded representation. Given a map from the enum's symbolic +// names to its int values, and a byte buffer containing the JSON-encoded +// value, it returns an int32 that can be cast to the enum type by the caller. +// +// The function can deal with both JSON representations, numeric and symbolic. +func UnmarshalJSONEnum(m map[string]int32, data []byte, enumName string) (int32, error) { + if data[0] == '"' { + // New style: enums are strings. + var repr string + if err := json.Unmarshal(data, &repr); err != nil { + return -1, err + } + val, ok := m[repr] + if !ok { + return 0, fmt.Errorf("unrecognized enum %s value %q", enumName, repr) + } + return val, nil + } + // Old style: enums are ints. + var val int32 + if err := json.Unmarshal(data, &val); err != nil { + return 0, fmt.Errorf("cannot unmarshal %#q into enum %s", data, enumName) + } + return val, nil +} + +// DebugPrint dumps the encoded data in b in a debugging format with a header +// including the string s. Used in testing but made available for general debugging. +func (p *Buffer) DebugPrint(s string, b []byte) { + var u uint64 + + obuf := p.buf + index := p.index + p.buf = b + p.index = 0 + depth := 0 + + fmt.Printf("\n--- %s ---\n", s) + +out: + for { + for i := 0; i < depth; i++ { + fmt.Print(" ") + } + + index := p.index + if index == len(p.buf) { + break + } + + op, err := p.DecodeVarint() + if err != nil { + fmt.Printf("%3d: fetching op err %v\n", index, err) + break out + } + tag := op >> 3 + wire := op & 7 + + switch wire { + default: + fmt.Printf("%3d: t=%3d unknown wire=%d\n", + index, tag, wire) + break out + + case WireBytes: + var r []byte + + r, err = p.DecodeRawBytes(false) + if err != nil { + break out + } + fmt.Printf("%3d: t=%3d bytes [%d]", index, tag, len(r)) + if len(r) <= 6 { + for i := 0; i < len(r); i++ { + fmt.Printf(" %.2x", r[i]) + } + } else { + for i := 0; i < 3; i++ { + fmt.Printf(" %.2x", r[i]) + } + fmt.Printf(" ..") + for i := len(r) - 3; i < len(r); i++ { + fmt.Printf(" %.2x", r[i]) + } + } + fmt.Printf("\n") + + case WireFixed32: + u, err = p.DecodeFixed32() + if err != nil { + fmt.Printf("%3d: t=%3d fix32 err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d fix32 %d\n", index, tag, u) + + case WireFixed64: + u, err = p.DecodeFixed64() + if err != nil { + fmt.Printf("%3d: t=%3d fix64 err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d fix64 %d\n", index, tag, u) + + case WireVarint: + u, err = p.DecodeVarint() + if err != nil { + fmt.Printf("%3d: t=%3d varint err %v\n", index, tag, err) + break out + } + fmt.Printf("%3d: t=%3d varint %d\n", index, tag, u) + + case WireStartGroup: + fmt.Printf("%3d: t=%3d start\n", index, tag) + depth++ + + case WireEndGroup: + depth-- + fmt.Printf("%3d: t=%3d end\n", index, tag) + } + } + + if depth != 0 { + fmt.Printf("%3d: start-end not balanced %d\n", p.index, depth) + } + fmt.Printf("\n") + + p.buf = obuf + p.index = index +} + +// SetDefaults sets unset protocol buffer fields to their default values. +// It only modifies fields that are both unset and have defined defaults. +// It recursively sets default values in any non-nil sub-messages. +func SetDefaults(pb Message) { + setDefaults(reflect.ValueOf(pb), true, false) +} + +// v is a pointer to a struct. +func setDefaults(v reflect.Value, recur, zeros bool) { + v = v.Elem() + + defaultMu.RLock() + dm, ok := defaults[v.Type()] + defaultMu.RUnlock() + if !ok { + dm = buildDefaultMessage(v.Type()) + defaultMu.Lock() + defaults[v.Type()] = dm + defaultMu.Unlock() + } + + for _, sf := range dm.scalars { + f := v.Field(sf.index) + if !f.IsNil() { + // field already set + continue + } + dv := sf.value + if dv == nil && !zeros { + // no explicit default, and don't want to set zeros + continue + } + fptr := f.Addr().Interface() // **T + // TODO: Consider batching the allocations we do here. + switch sf.kind { + case reflect.Bool: + b := new(bool) + if dv != nil { + *b = dv.(bool) + } + *(fptr.(**bool)) = b + case reflect.Float32: + f := new(float32) + if dv != nil { + *f = dv.(float32) + } + *(fptr.(**float32)) = f + case reflect.Float64: + f := new(float64) + if dv != nil { + *f = dv.(float64) + } + *(fptr.(**float64)) = f + case reflect.Int32: + // might be an enum + if ft := f.Type(); ft != int32PtrType { + // enum + f.Set(reflect.New(ft.Elem())) + if dv != nil { + f.Elem().SetInt(int64(dv.(int32))) + } + } else { + // int32 field + i := new(int32) + if dv != nil { + *i = dv.(int32) + } + *(fptr.(**int32)) = i + } + case reflect.Int64: + i := new(int64) + if dv != nil { + *i = dv.(int64) + } + *(fptr.(**int64)) = i + case reflect.String: + s := new(string) + if dv != nil { + *s = dv.(string) + } + *(fptr.(**string)) = s + case reflect.Uint8: + // exceptional case: []byte + var b []byte + if dv != nil { + db := dv.([]byte) + b = make([]byte, len(db)) + copy(b, db) + } else { + b = []byte{} + } + *(fptr.(*[]byte)) = b + case reflect.Uint32: + u := new(uint32) + if dv != nil { + *u = dv.(uint32) + } + *(fptr.(**uint32)) = u + case reflect.Uint64: + u := new(uint64) + if dv != nil { + *u = dv.(uint64) + } + *(fptr.(**uint64)) = u + default: + log.Printf("proto: can't set default for field %v (sf.kind=%v)", f, sf.kind) + } + } + + for _, ni := range dm.nested { + f := v.Field(ni) + // f is *T or []*T or map[T]*T + switch f.Kind() { + case reflect.Ptr: + if f.IsNil() { + continue + } + setDefaults(f, recur, zeros) + + case reflect.Slice: + for i := 0; i < f.Len(); i++ { + e := f.Index(i) + if e.IsNil() { + continue + } + setDefaults(e, recur, zeros) + } + + case reflect.Map: + for _, k := range f.MapKeys() { + e := f.MapIndex(k) + if e.IsNil() { + continue + } + setDefaults(e, recur, zeros) + } + } + } +} + +var ( + // defaults maps a protocol buffer struct type to a slice of the fields, + // with its scalar fields set to their proto-declared non-zero default values. + defaultMu sync.RWMutex + defaults = make(map[reflect.Type]defaultMessage) + + int32PtrType = reflect.TypeOf((*int32)(nil)) +) + +// defaultMessage represents information about the default values of a message. +type defaultMessage struct { + scalars []scalarField + nested []int // struct field index of nested messages +} + +type scalarField struct { + index int // struct field index + kind reflect.Kind // element type (the T in *T or []T) + value interface{} // the proto-declared default value, or nil +} + +// t is a struct type. +func buildDefaultMessage(t reflect.Type) (dm defaultMessage) { + sprop := GetProperties(t) + for _, prop := range sprop.Prop { + fi, ok := sprop.decoderTags.get(prop.Tag) + if !ok { + // XXX_unrecognized + continue + } + ft := t.Field(fi).Type + + sf, nested, err := fieldDefault(ft, prop) + switch { + case err != nil: + log.Print(err) + case nested: + dm.nested = append(dm.nested, fi) + case sf != nil: + sf.index = fi + dm.scalars = append(dm.scalars, *sf) + } + } + + return dm +} + +// fieldDefault returns the scalarField for field type ft. +// sf will be nil if the field can not have a default. +// nestedMessage will be true if this is a nested message. +// Note that sf.index is not set on return. +func fieldDefault(ft reflect.Type, prop *Properties) (sf *scalarField, nestedMessage bool, err error) { + var canHaveDefault bool + switch ft.Kind() { + case reflect.Ptr: + if ft.Elem().Kind() == reflect.Struct { + nestedMessage = true + } else { + canHaveDefault = true // proto2 scalar field + } + + case reflect.Slice: + switch ft.Elem().Kind() { + case reflect.Ptr: + nestedMessage = true // repeated message + case reflect.Uint8: + canHaveDefault = true // bytes field + } + + case reflect.Map: + if ft.Elem().Kind() == reflect.Ptr { + nestedMessage = true // map with message values + } + } + + if !canHaveDefault { + if nestedMessage { + return nil, true, nil + } + return nil, false, nil + } + + // We now know that ft is a pointer or slice. + sf = &scalarField{kind: ft.Elem().Kind()} + + // scalar fields without defaults + if !prop.HasDefault { + return sf, false, nil + } + + // a scalar field: either *T or []byte + switch ft.Elem().Kind() { + case reflect.Bool: + x, err := strconv.ParseBool(prop.Default) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default bool %q: %v", prop.Default, err) + } + sf.value = x + case reflect.Float32: + x, err := strconv.ParseFloat(prop.Default, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default float32 %q: %v", prop.Default, err) + } + sf.value = float32(x) + case reflect.Float64: + x, err := strconv.ParseFloat(prop.Default, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default float64 %q: %v", prop.Default, err) + } + sf.value = x + case reflect.Int32: + x, err := strconv.ParseInt(prop.Default, 10, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default int32 %q: %v", prop.Default, err) + } + sf.value = int32(x) + case reflect.Int64: + x, err := strconv.ParseInt(prop.Default, 10, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default int64 %q: %v", prop.Default, err) + } + sf.value = x + case reflect.String: + sf.value = prop.Default + case reflect.Uint8: + // []byte (not *uint8) + sf.value = []byte(prop.Default) + case reflect.Uint32: + x, err := strconv.ParseUint(prop.Default, 10, 32) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default uint32 %q: %v", prop.Default, err) + } + sf.value = uint32(x) + case reflect.Uint64: + x, err := strconv.ParseUint(prop.Default, 10, 64) + if err != nil { + return nil, false, fmt.Errorf("proto: bad default uint64 %q: %v", prop.Default, err) + } + sf.value = x + default: + return nil, false, fmt.Errorf("proto: unhandled def kind %v", ft.Elem().Kind()) + } + + return sf, false, nil +} + +// Map fields may have key types of non-float scalars, strings and enums. +// The easiest way to sort them in some deterministic order is to use fmt. +// If this turns out to be inefficient we can always consider other options, +// such as doing a Schwartzian transform. + +func mapKeys(vs []reflect.Value) sort.Interface { + s := mapKeySorter{ + vs: vs, + // default Less function: textual comparison + less: func(a, b reflect.Value) bool { + return fmt.Sprint(a.Interface()) < fmt.Sprint(b.Interface()) + }, + } + + // Type specialization per https://developers.google.com/protocol-buffers/docs/proto#maps; + // numeric keys are sorted numerically. + if len(vs) == 0 { + return s + } + switch vs[0].Kind() { + case reflect.Int32, reflect.Int64: + s.less = func(a, b reflect.Value) bool { return a.Int() < b.Int() } + case reflect.Uint32, reflect.Uint64: + s.less = func(a, b reflect.Value) bool { return a.Uint() < b.Uint() } + } + + return s +} + +type mapKeySorter struct { + vs []reflect.Value + less func(a, b reflect.Value) bool +} + +func (s mapKeySorter) Len() int { return len(s.vs) } +func (s mapKeySorter) Swap(i, j int) { s.vs[i], s.vs[j] = s.vs[j], s.vs[i] } +func (s mapKeySorter) Less(i, j int) bool { + return s.less(s.vs[i], s.vs[j]) +} + +// isProto3Zero reports whether v is a zero proto3 value. +func isProto3Zero(v reflect.Value) bool { + switch v.Kind() { + case reflect.Bool: + return !v.Bool() + case reflect.Int32, reflect.Int64: + return v.Int() == 0 + case reflect.Uint32, reflect.Uint64: + return v.Uint() == 0 + case reflect.Float32, reflect.Float64: + return v.Float() == 0 + case reflect.String: + return v.String() == "" + } + return false +} + +// ProtoPackageIsVersion2 is referenced from generated protocol buffer files +// to assert that that code is compatible with this version of the proto package. +const ProtoPackageIsVersion2 = true + +// ProtoPackageIsVersion1 is referenced from generated protocol buffer files +// to assert that that code is compatible with this version of the proto package. +const ProtoPackageIsVersion1 = true diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/message_set.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/message_set.go new file mode 100644 index 000000000000..fd982decd66e --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/message_set.go @@ -0,0 +1,311 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +/* + * Support for message sets. + */ + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "reflect" + "sort" +) + +// errNoMessageTypeID occurs when a protocol buffer does not have a message type ID. +// A message type ID is required for storing a protocol buffer in a message set. +var errNoMessageTypeID = errors.New("proto does not have a message type ID") + +// The first two types (_MessageSet_Item and messageSet) +// model what the protocol compiler produces for the following protocol message: +// message MessageSet { +// repeated group Item = 1 { +// required int32 type_id = 2; +// required string message = 3; +// }; +// } +// That is the MessageSet wire format. We can't use a proto to generate these +// because that would introduce a circular dependency between it and this package. + +type _MessageSet_Item struct { + TypeId *int32 `protobuf:"varint,2,req,name=type_id"` + Message []byte `protobuf:"bytes,3,req,name=message"` +} + +type messageSet struct { + Item []*_MessageSet_Item `protobuf:"group,1,rep"` + XXX_unrecognized []byte + // TODO: caching? +} + +// Make sure messageSet is a Message. +var _ Message = (*messageSet)(nil) + +// messageTypeIder is an interface satisfied by a protocol buffer type +// that may be stored in a MessageSet. +type messageTypeIder interface { + MessageTypeId() int32 +} + +func (ms *messageSet) find(pb Message) *_MessageSet_Item { + mti, ok := pb.(messageTypeIder) + if !ok { + return nil + } + id := mti.MessageTypeId() + for _, item := range ms.Item { + if *item.TypeId == id { + return item + } + } + return nil +} + +func (ms *messageSet) Has(pb Message) bool { + if ms.find(pb) != nil { + return true + } + return false +} + +func (ms *messageSet) Unmarshal(pb Message) error { + if item := ms.find(pb); item != nil { + return Unmarshal(item.Message, pb) + } + if _, ok := pb.(messageTypeIder); !ok { + return errNoMessageTypeID + } + return nil // TODO: return error instead? +} + +func (ms *messageSet) Marshal(pb Message) error { + msg, err := Marshal(pb) + if err != nil { + return err + } + if item := ms.find(pb); item != nil { + // reuse existing item + item.Message = msg + return nil + } + + mti, ok := pb.(messageTypeIder) + if !ok { + return errNoMessageTypeID + } + + mtid := mti.MessageTypeId() + ms.Item = append(ms.Item, &_MessageSet_Item{ + TypeId: &mtid, + Message: msg, + }) + return nil +} + +func (ms *messageSet) Reset() { *ms = messageSet{} } +func (ms *messageSet) String() string { return CompactTextString(ms) } +func (*messageSet) ProtoMessage() {} + +// Support for the message_set_wire_format message option. + +func skipVarint(buf []byte) []byte { + i := 0 + for ; buf[i]&0x80 != 0; i++ { + } + return buf[i+1:] +} + +// MarshalMessageSet encodes the extension map represented by m in the message set wire format. +// It is called by generated Marshal methods on protocol buffer messages with the message_set_wire_format option. +func MarshalMessageSet(exts interface{}) ([]byte, error) { + var m map[int32]Extension + switch exts := exts.(type) { + case *XXX_InternalExtensions: + if err := encodeExtensions(exts); err != nil { + return nil, err + } + m, _ = exts.extensionsRead() + case map[int32]Extension: + if err := encodeExtensionsMap(exts); err != nil { + return nil, err + } + m = exts + default: + return nil, errors.New("proto: not an extension map") + } + + // Sort extension IDs to provide a deterministic encoding. + // See also enc_map in encode.go. + ids := make([]int, 0, len(m)) + for id := range m { + ids = append(ids, int(id)) + } + sort.Ints(ids) + + ms := &messageSet{Item: make([]*_MessageSet_Item, 0, len(m))} + for _, id := range ids { + e := m[int32(id)] + // Remove the wire type and field number varint, as well as the length varint. + msg := skipVarint(skipVarint(e.enc)) + + ms.Item = append(ms.Item, &_MessageSet_Item{ + TypeId: Int32(int32(id)), + Message: msg, + }) + } + return Marshal(ms) +} + +// UnmarshalMessageSet decodes the extension map encoded in buf in the message set wire format. +// It is called by generated Unmarshal methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSet(buf []byte, exts interface{}) error { + var m map[int32]Extension + switch exts := exts.(type) { + case *XXX_InternalExtensions: + m = exts.extensionsWrite() + case map[int32]Extension: + m = exts + default: + return errors.New("proto: not an extension map") + } + + ms := new(messageSet) + if err := Unmarshal(buf, ms); err != nil { + return err + } + for _, item := range ms.Item { + id := *item.TypeId + msg := item.Message + + // Restore wire type and field number varint, plus length varint. + // Be careful to preserve duplicate items. + b := EncodeVarint(uint64(id)<<3 | WireBytes) + if ext, ok := m[id]; ok { + // Existing data; rip off the tag and length varint + // so we join the new data correctly. + // We can assume that ext.enc is set because we are unmarshaling. + o := ext.enc[len(b):] // skip wire type and field number + _, n := DecodeVarint(o) // calculate length of length varint + o = o[n:] // skip length varint + msg = append(o, msg...) // join old data and new data + } + b = append(b, EncodeVarint(uint64(len(msg)))...) + b = append(b, msg...) + + m[id] = Extension{enc: b} + } + return nil +} + +// MarshalMessageSetJSON encodes the extension map represented by m in JSON format. +// It is called by generated MarshalJSON methods on protocol buffer messages with the message_set_wire_format option. +func MarshalMessageSetJSON(exts interface{}) ([]byte, error) { + var m map[int32]Extension + switch exts := exts.(type) { + case *XXX_InternalExtensions: + m, _ = exts.extensionsRead() + case map[int32]Extension: + m = exts + default: + return nil, errors.New("proto: not an extension map") + } + var b bytes.Buffer + b.WriteByte('{') + + // Process the map in key order for deterministic output. + ids := make([]int32, 0, len(m)) + for id := range m { + ids = append(ids, id) + } + sort.Sort(int32Slice(ids)) // int32Slice defined in text.go + + for i, id := range ids { + ext := m[id] + if i > 0 { + b.WriteByte(',') + } + + msd, ok := messageSetMap[id] + if !ok { + // Unknown type; we can't render it, so skip it. + continue + } + fmt.Fprintf(&b, `"[%s]":`, msd.name) + + x := ext.value + if x == nil { + x = reflect.New(msd.t.Elem()).Interface() + if err := Unmarshal(ext.enc, x.(Message)); err != nil { + return nil, err + } + } + d, err := json.Marshal(x) + if err != nil { + return nil, err + } + b.Write(d) + } + b.WriteByte('}') + return b.Bytes(), nil +} + +// UnmarshalMessageSetJSON decodes the extension map encoded in buf in JSON format. +// It is called by generated UnmarshalJSON methods on protocol buffer messages with the message_set_wire_format option. +func UnmarshalMessageSetJSON(buf []byte, exts interface{}) error { + // Common-case fast path. + if len(buf) == 0 || bytes.Equal(buf, []byte("{}")) { + return nil + } + + // This is fairly tricky, and it's not clear that it is needed. + return errors.New("TODO: UnmarshalMessageSetJSON not yet implemented") +} + +// A global registry of types that can be used in a MessageSet. + +var messageSetMap = make(map[int32]messageSetDesc) + +type messageSetDesc struct { + t reflect.Type // pointer to struct + name string +} + +// RegisterMessageSetType is called from the generated code. +func RegisterMessageSetType(m Message, fieldNum int32, name string) { + messageSetMap[fieldNum] = messageSetDesc{ + t: reflect.TypeOf(m), + name: name, + } +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/pointer_reflect.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/pointer_reflect.go new file mode 100644 index 000000000000..fb512e2e16dc --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/pointer_reflect.go @@ -0,0 +1,484 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2012 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +build appengine js + +// This file contains an implementation of proto field accesses using package reflect. +// It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can +// be used on App Engine. + +package proto + +import ( + "math" + "reflect" +) + +// A structPointer is a pointer to a struct. +type structPointer struct { + v reflect.Value +} + +// toStructPointer returns a structPointer equivalent to the given reflect value. +// The reflect value must itself be a pointer to a struct. +func toStructPointer(v reflect.Value) structPointer { + return structPointer{v} +} + +// IsNil reports whether p is nil. +func structPointer_IsNil(p structPointer) bool { + return p.v.IsNil() +} + +// Interface returns the struct pointer as an interface value. +func structPointer_Interface(p structPointer, _ reflect.Type) interface{} { + return p.v.Interface() +} + +// A field identifies a field in a struct, accessible from a structPointer. +// In this implementation, a field is identified by the sequence of field indices +// passed to reflect's FieldByIndex. +type field []int + +// toField returns a field equivalent to the given reflect field. +func toField(f *reflect.StructField) field { + return f.Index +} + +// invalidField is an invalid field identifier. +var invalidField = field(nil) + +// IsValid reports whether the field identifier is valid. +func (f field) IsValid() bool { return f != nil } + +// field returns the given field in the struct as a reflect value. +func structPointer_field(p structPointer, f field) reflect.Value { + // Special case: an extension map entry with a value of type T + // passes a *T to the struct-handling code with a zero field, + // expecting that it will be treated as equivalent to *struct{ X T }, + // which has the same memory layout. We have to handle that case + // specially, because reflect will panic if we call FieldByIndex on a + // non-struct. + if f == nil { + return p.v.Elem() + } + + return p.v.Elem().FieldByIndex(f) +} + +// ifield returns the given field in the struct as an interface value. +func structPointer_ifield(p structPointer, f field) interface{} { + return structPointer_field(p, f).Addr().Interface() +} + +// Bytes returns the address of a []byte field in the struct. +func structPointer_Bytes(p structPointer, f field) *[]byte { + return structPointer_ifield(p, f).(*[]byte) +} + +// BytesSlice returns the address of a [][]byte field in the struct. +func structPointer_BytesSlice(p structPointer, f field) *[][]byte { + return structPointer_ifield(p, f).(*[][]byte) +} + +// Bool returns the address of a *bool field in the struct. +func structPointer_Bool(p structPointer, f field) **bool { + return structPointer_ifield(p, f).(**bool) +} + +// BoolVal returns the address of a bool field in the struct. +func structPointer_BoolVal(p structPointer, f field) *bool { + return structPointer_ifield(p, f).(*bool) +} + +// BoolSlice returns the address of a []bool field in the struct. +func structPointer_BoolSlice(p structPointer, f field) *[]bool { + return structPointer_ifield(p, f).(*[]bool) +} + +// String returns the address of a *string field in the struct. +func structPointer_String(p structPointer, f field) **string { + return structPointer_ifield(p, f).(**string) +} + +// StringVal returns the address of a string field in the struct. +func structPointer_StringVal(p structPointer, f field) *string { + return structPointer_ifield(p, f).(*string) +} + +// StringSlice returns the address of a []string field in the struct. +func structPointer_StringSlice(p structPointer, f field) *[]string { + return structPointer_ifield(p, f).(*[]string) +} + +// Extensions returns the address of an extension map field in the struct. +func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions { + return structPointer_ifield(p, f).(*XXX_InternalExtensions) +} + +// ExtMap returns the address of an extension map field in the struct. +func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { + return structPointer_ifield(p, f).(*map[int32]Extension) +} + +// NewAt returns the reflect.Value for a pointer to a field in the struct. +func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { + return structPointer_field(p, f).Addr() +} + +// SetStructPointer writes a *struct field in the struct. +func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { + structPointer_field(p, f).Set(q.v) +} + +// GetStructPointer reads a *struct field in the struct. +func structPointer_GetStructPointer(p structPointer, f field) structPointer { + return structPointer{structPointer_field(p, f)} +} + +// StructPointerSlice the address of a []*struct field in the struct. +func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice { + return structPointerSlice{structPointer_field(p, f)} +} + +// A structPointerSlice represents the address of a slice of pointers to structs +// (themselves messages or groups). That is, v.Type() is *[]*struct{...}. +type structPointerSlice struct { + v reflect.Value +} + +func (p structPointerSlice) Len() int { return p.v.Len() } +func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} } +func (p structPointerSlice) Append(q structPointer) { + p.v.Set(reflect.Append(p.v, q.v)) +} + +var ( + int32Type = reflect.TypeOf(int32(0)) + uint32Type = reflect.TypeOf(uint32(0)) + float32Type = reflect.TypeOf(float32(0)) + int64Type = reflect.TypeOf(int64(0)) + uint64Type = reflect.TypeOf(uint64(0)) + float64Type = reflect.TypeOf(float64(0)) +) + +// A word32 represents a field of type *int32, *uint32, *float32, or *enum. +// That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable. +type word32 struct { + v reflect.Value +} + +// IsNil reports whether p is nil. +func word32_IsNil(p word32) bool { + return p.v.IsNil() +} + +// Set sets p to point at a newly allocated word with bits set to x. +func word32_Set(p word32, o *Buffer, x uint32) { + t := p.v.Type().Elem() + switch t { + case int32Type: + if len(o.int32s) == 0 { + o.int32s = make([]int32, uint32PoolSize) + } + o.int32s[0] = int32(x) + p.v.Set(reflect.ValueOf(&o.int32s[0])) + o.int32s = o.int32s[1:] + return + case uint32Type: + if len(o.uint32s) == 0 { + o.uint32s = make([]uint32, uint32PoolSize) + } + o.uint32s[0] = x + p.v.Set(reflect.ValueOf(&o.uint32s[0])) + o.uint32s = o.uint32s[1:] + return + case float32Type: + if len(o.float32s) == 0 { + o.float32s = make([]float32, uint32PoolSize) + } + o.float32s[0] = math.Float32frombits(x) + p.v.Set(reflect.ValueOf(&o.float32s[0])) + o.float32s = o.float32s[1:] + return + } + + // must be enum + p.v.Set(reflect.New(t)) + p.v.Elem().SetInt(int64(int32(x))) +} + +// Get gets the bits pointed at by p, as a uint32. +func word32_Get(p word32) uint32 { + elem := p.v.Elem() + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32(p structPointer, f field) word32 { + return word32{structPointer_field(p, f)} +} + +// A word32Val represents a field of type int32, uint32, float32, or enum. +// That is, v.Type() is int32, uint32, float32, or enum and v is assignable. +type word32Val struct { + v reflect.Value +} + +// Set sets *p to x. +func word32Val_Set(p word32Val, x uint32) { + switch p.v.Type() { + case int32Type: + p.v.SetInt(int64(x)) + return + case uint32Type: + p.v.SetUint(uint64(x)) + return + case float32Type: + p.v.SetFloat(float64(math.Float32frombits(x))) + return + } + + // must be enum + p.v.SetInt(int64(int32(x))) +} + +// Get gets the bits pointed at by p, as a uint32. +func word32Val_Get(p word32Val) uint32 { + elem := p.v + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct. +func structPointer_Word32Val(p structPointer, f field) word32Val { + return word32Val{structPointer_field(p, f)} +} + +// A word32Slice is a slice of 32-bit values. +// That is, v.Type() is []int32, []uint32, []float32, or []enum. +type word32Slice struct { + v reflect.Value +} + +func (p word32Slice) Append(x uint32) { + n, m := p.v.Len(), p.v.Cap() + if n < m { + p.v.SetLen(n + 1) + } else { + t := p.v.Type().Elem() + p.v.Set(reflect.Append(p.v, reflect.Zero(t))) + } + elem := p.v.Index(n) + switch elem.Kind() { + case reflect.Int32: + elem.SetInt(int64(int32(x))) + case reflect.Uint32: + elem.SetUint(uint64(x)) + case reflect.Float32: + elem.SetFloat(float64(math.Float32frombits(x))) + } +} + +func (p word32Slice) Len() int { + return p.v.Len() +} + +func (p word32Slice) Index(i int) uint32 { + elem := p.v.Index(i) + switch elem.Kind() { + case reflect.Int32: + return uint32(elem.Int()) + case reflect.Uint32: + return uint32(elem.Uint()) + case reflect.Float32: + return math.Float32bits(float32(elem.Float())) + } + panic("unreachable") +} + +// Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct. +func structPointer_Word32Slice(p structPointer, f field) word32Slice { + return word32Slice{structPointer_field(p, f)} +} + +// word64 is like word32 but for 64-bit values. +type word64 struct { + v reflect.Value +} + +func word64_Set(p word64, o *Buffer, x uint64) { + t := p.v.Type().Elem() + switch t { + case int64Type: + if len(o.int64s) == 0 { + o.int64s = make([]int64, uint64PoolSize) + } + o.int64s[0] = int64(x) + p.v.Set(reflect.ValueOf(&o.int64s[0])) + o.int64s = o.int64s[1:] + return + case uint64Type: + if len(o.uint64s) == 0 { + o.uint64s = make([]uint64, uint64PoolSize) + } + o.uint64s[0] = x + p.v.Set(reflect.ValueOf(&o.uint64s[0])) + o.uint64s = o.uint64s[1:] + return + case float64Type: + if len(o.float64s) == 0 { + o.float64s = make([]float64, uint64PoolSize) + } + o.float64s[0] = math.Float64frombits(x) + p.v.Set(reflect.ValueOf(&o.float64s[0])) + o.float64s = o.float64s[1:] + return + } + panic("unreachable") +} + +func word64_IsNil(p word64) bool { + return p.v.IsNil() +} + +func word64_Get(p word64) uint64 { + elem := p.v.Elem() + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return elem.Uint() + case reflect.Float64: + return math.Float64bits(elem.Float()) + } + panic("unreachable") +} + +func structPointer_Word64(p structPointer, f field) word64 { + return word64{structPointer_field(p, f)} +} + +// word64Val is like word32Val but for 64-bit values. +type word64Val struct { + v reflect.Value +} + +func word64Val_Set(p word64Val, o *Buffer, x uint64) { + switch p.v.Type() { + case int64Type: + p.v.SetInt(int64(x)) + return + case uint64Type: + p.v.SetUint(x) + return + case float64Type: + p.v.SetFloat(math.Float64frombits(x)) + return + } + panic("unreachable") +} + +func word64Val_Get(p word64Val) uint64 { + elem := p.v + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return elem.Uint() + case reflect.Float64: + return math.Float64bits(elem.Float()) + } + panic("unreachable") +} + +func structPointer_Word64Val(p structPointer, f field) word64Val { + return word64Val{structPointer_field(p, f)} +} + +type word64Slice struct { + v reflect.Value +} + +func (p word64Slice) Append(x uint64) { + n, m := p.v.Len(), p.v.Cap() + if n < m { + p.v.SetLen(n + 1) + } else { + t := p.v.Type().Elem() + p.v.Set(reflect.Append(p.v, reflect.Zero(t))) + } + elem := p.v.Index(n) + switch elem.Kind() { + case reflect.Int64: + elem.SetInt(int64(int64(x))) + case reflect.Uint64: + elem.SetUint(uint64(x)) + case reflect.Float64: + elem.SetFloat(float64(math.Float64frombits(x))) + } +} + +func (p word64Slice) Len() int { + return p.v.Len() +} + +func (p word64Slice) Index(i int) uint64 { + elem := p.v.Index(i) + switch elem.Kind() { + case reflect.Int64: + return uint64(elem.Int()) + case reflect.Uint64: + return uint64(elem.Uint()) + case reflect.Float64: + return math.Float64bits(float64(elem.Float())) + } + panic("unreachable") +} + +func structPointer_Word64Slice(p structPointer, f field) word64Slice { + return word64Slice{structPointer_field(p, f)} +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/pointer_unsafe.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/pointer_unsafe.go new file mode 100644 index 000000000000..6b5567d47cd3 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/pointer_unsafe.go @@ -0,0 +1,270 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2012 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// +build !appengine,!js + +// This file contains the implementation of the proto field accesses using package unsafe. + +package proto + +import ( + "reflect" + "unsafe" +) + +// NOTE: These type_Foo functions would more idiomatically be methods, +// but Go does not allow methods on pointer types, and we must preserve +// some pointer type for the garbage collector. We use these +// funcs with clunky names as our poor approximation to methods. +// +// An alternative would be +// type structPointer struct { p unsafe.Pointer } +// but that does not registerize as well. + +// A structPointer is a pointer to a struct. +type structPointer unsafe.Pointer + +// toStructPointer returns a structPointer equivalent to the given reflect value. +func toStructPointer(v reflect.Value) structPointer { + return structPointer(unsafe.Pointer(v.Pointer())) +} + +// IsNil reports whether p is nil. +func structPointer_IsNil(p structPointer) bool { + return p == nil +} + +// Interface returns the struct pointer, assumed to have element type t, +// as an interface value. +func structPointer_Interface(p structPointer, t reflect.Type) interface{} { + return reflect.NewAt(t, unsafe.Pointer(p)).Interface() +} + +// A field identifies a field in a struct, accessible from a structPointer. +// In this implementation, a field is identified by its byte offset from the start of the struct. +type field uintptr + +// toField returns a field equivalent to the given reflect field. +func toField(f *reflect.StructField) field { + return field(f.Offset) +} + +// invalidField is an invalid field identifier. +const invalidField = ^field(0) + +// IsValid reports whether the field identifier is valid. +func (f field) IsValid() bool { + return f != ^field(0) +} + +// Bytes returns the address of a []byte field in the struct. +func structPointer_Bytes(p structPointer, f field) *[]byte { + return (*[]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BytesSlice returns the address of a [][]byte field in the struct. +func structPointer_BytesSlice(p structPointer, f field) *[][]byte { + return (*[][]byte)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// Bool returns the address of a *bool field in the struct. +func structPointer_Bool(p structPointer, f field) **bool { + return (**bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BoolVal returns the address of a bool field in the struct. +func structPointer_BoolVal(p structPointer, f field) *bool { + return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// BoolSlice returns the address of a []bool field in the struct. +func structPointer_BoolSlice(p structPointer, f field) *[]bool { + return (*[]bool)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// String returns the address of a *string field in the struct. +func structPointer_String(p structPointer, f field) **string { + return (**string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StringVal returns the address of a string field in the struct. +func structPointer_StringVal(p structPointer, f field) *string { + return (*string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StringSlice returns the address of a []string field in the struct. +func structPointer_StringSlice(p structPointer, f field) *[]string { + return (*[]string)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// ExtMap returns the address of an extension map field in the struct. +func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions { + return (*XXX_InternalExtensions)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { + return (*map[int32]Extension)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// NewAt returns the reflect.Value for a pointer to a field in the struct. +func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { + return reflect.NewAt(typ, unsafe.Pointer(uintptr(p)+uintptr(f))) +} + +// SetStructPointer writes a *struct field in the struct. +func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { + *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) = q +} + +// GetStructPointer reads a *struct field in the struct. +func structPointer_GetStructPointer(p structPointer, f field) structPointer { + return *(*structPointer)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// StructPointerSlice the address of a []*struct field in the struct. +func structPointer_StructPointerSlice(p structPointer, f field) *structPointerSlice { + return (*structPointerSlice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// A structPointerSlice represents a slice of pointers to structs (themselves submessages or groups). +type structPointerSlice []structPointer + +func (v *structPointerSlice) Len() int { return len(*v) } +func (v *structPointerSlice) Index(i int) structPointer { return (*v)[i] } +func (v *structPointerSlice) Append(p structPointer) { *v = append(*v, p) } + +// A word32 is the address of a "pointer to 32-bit value" field. +type word32 **uint32 + +// IsNil reports whether *v is nil. +func word32_IsNil(p word32) bool { + return *p == nil +} + +// Set sets *v to point at a newly allocated word set to x. +func word32_Set(p word32, o *Buffer, x uint32) { + if len(o.uint32s) == 0 { + o.uint32s = make([]uint32, uint32PoolSize) + } + o.uint32s[0] = x + *p = &o.uint32s[0] + o.uint32s = o.uint32s[1:] +} + +// Get gets the value pointed at by *v. +func word32_Get(p word32) uint32 { + return **p +} + +// Word32 returns the address of a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32(p structPointer, f field) word32 { + return word32((**uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// A word32Val is the address of a 32-bit value field. +type word32Val *uint32 + +// Set sets *p to x. +func word32Val_Set(p word32Val, x uint32) { + *p = x +} + +// Get gets the value pointed at by p. +func word32Val_Get(p word32Val) uint32 { + return *p +} + +// Word32Val returns the address of a *int32, *uint32, *float32, or *enum field in the struct. +func structPointer_Word32Val(p structPointer, f field) word32Val { + return word32Val((*uint32)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// A word32Slice is a slice of 32-bit values. +type word32Slice []uint32 + +func (v *word32Slice) Append(x uint32) { *v = append(*v, x) } +func (v *word32Slice) Len() int { return len(*v) } +func (v *word32Slice) Index(i int) uint32 { return (*v)[i] } + +// Word32Slice returns the address of a []int32, []uint32, []float32, or []enum field in the struct. +func structPointer_Word32Slice(p structPointer, f field) *word32Slice { + return (*word32Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} + +// word64 is like word32 but for 64-bit values. +type word64 **uint64 + +func word64_Set(p word64, o *Buffer, x uint64) { + if len(o.uint64s) == 0 { + o.uint64s = make([]uint64, uint64PoolSize) + } + o.uint64s[0] = x + *p = &o.uint64s[0] + o.uint64s = o.uint64s[1:] +} + +func word64_IsNil(p word64) bool { + return *p == nil +} + +func word64_Get(p word64) uint64 { + return **p +} + +func structPointer_Word64(p structPointer, f field) word64 { + return word64((**uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// word64Val is like word32Val but for 64-bit values. +type word64Val *uint64 + +func word64Val_Set(p word64Val, o *Buffer, x uint64) { + *p = x +} + +func word64Val_Get(p word64Val) uint64 { + return *p +} + +func structPointer_Word64Val(p structPointer, f field) word64Val { + return word64Val((*uint64)(unsafe.Pointer(uintptr(p) + uintptr(f)))) +} + +// word64Slice is like word32Slice but for 64-bit values. +type word64Slice []uint64 + +func (v *word64Slice) Append(x uint64) { *v = append(*v, x) } +func (v *word64Slice) Len() int { return len(*v) } +func (v *word64Slice) Index(i int) uint64 { return (*v)[i] } + +func structPointer_Word64Slice(p structPointer, f field) *word64Slice { + return (*word64Slice)(unsafe.Pointer(uintptr(p) + uintptr(f))) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/properties.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/properties.go new file mode 100644 index 000000000000..69ddda8d4ba0 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/properties.go @@ -0,0 +1,864 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +/* + * Routines for encoding data into the wire format for protocol buffers. + */ + +import ( + "fmt" + "log" + "os" + "reflect" + "sort" + "strconv" + "strings" + "sync" +) + +const debug bool = false + +// Constants that identify the encoding of a value on the wire. +const ( + WireVarint = 0 + WireFixed64 = 1 + WireBytes = 2 + WireStartGroup = 3 + WireEndGroup = 4 + WireFixed32 = 5 +) + +const startSize = 10 // initial slice/string sizes + +// Encoders are defined in encode.go +// An encoder outputs the full representation of a field, including its +// tag and encoder type. +type encoder func(p *Buffer, prop *Properties, base structPointer) error + +// A valueEncoder encodes a single integer in a particular encoding. +type valueEncoder func(o *Buffer, x uint64) error + +// Sizers are defined in encode.go +// A sizer returns the encoded size of a field, including its tag and encoder +// type. +type sizer func(prop *Properties, base structPointer) int + +// A valueSizer returns the encoded size of a single integer in a particular +// encoding. +type valueSizer func(x uint64) int + +// Decoders are defined in decode.go +// A decoder creates a value from its wire representation. +// Unrecognized subelements are saved in unrec. +type decoder func(p *Buffer, prop *Properties, base structPointer) error + +// A valueDecoder decodes a single integer in a particular encoding. +type valueDecoder func(o *Buffer) (x uint64, err error) + +// A oneofMarshaler does the marshaling for all oneof fields in a message. +type oneofMarshaler func(Message, *Buffer) error + +// A oneofUnmarshaler does the unmarshaling for a oneof field in a message. +type oneofUnmarshaler func(Message, int, int, *Buffer) (bool, error) + +// A oneofSizer does the sizing for all oneof fields in a message. +type oneofSizer func(Message) int + +// tagMap is an optimization over map[int]int for typical protocol buffer +// use-cases. Encoded protocol buffers are often in tag order with small tag +// numbers. +type tagMap struct { + fastTags []int + slowTags map[int]int +} + +// tagMapFastLimit is the upper bound on the tag number that will be stored in +// the tagMap slice rather than its map. +const tagMapFastLimit = 1024 + +func (p *tagMap) get(t int) (int, bool) { + if t > 0 && t < tagMapFastLimit { + if t >= len(p.fastTags) { + return 0, false + } + fi := p.fastTags[t] + return fi, fi >= 0 + } + fi, ok := p.slowTags[t] + return fi, ok +} + +func (p *tagMap) put(t int, fi int) { + if t > 0 && t < tagMapFastLimit { + for len(p.fastTags) < t+1 { + p.fastTags = append(p.fastTags, -1) + } + p.fastTags[t] = fi + return + } + if p.slowTags == nil { + p.slowTags = make(map[int]int) + } + p.slowTags[t] = fi +} + +// StructProperties represents properties for all the fields of a struct. +// decoderTags and decoderOrigNames should only be used by the decoder. +type StructProperties struct { + Prop []*Properties // properties for each field + reqCount int // required count + decoderTags tagMap // map from proto tag to struct field number + decoderOrigNames map[string]int // map from original name to struct field number + order []int // list of struct field numbers in tag order + unrecField field // field id of the XXX_unrecognized []byte field + extendable bool // is this an extendable proto + + oneofMarshaler oneofMarshaler + oneofUnmarshaler oneofUnmarshaler + oneofSizer oneofSizer + stype reflect.Type + + // OneofTypes contains information about the oneof fields in this message. + // It is keyed by the original name of a field. + OneofTypes map[string]*OneofProperties +} + +// OneofProperties represents information about a specific field in a oneof. +type OneofProperties struct { + Type reflect.Type // pointer to generated struct type for this oneof field + Field int // struct field number of the containing oneof in the message + Prop *Properties +} + +// Implement the sorting interface so we can sort the fields in tag order, as recommended by the spec. +// See encode.go, (*Buffer).enc_struct. + +func (sp *StructProperties) Len() int { return len(sp.order) } +func (sp *StructProperties) Less(i, j int) bool { + return sp.Prop[sp.order[i]].Tag < sp.Prop[sp.order[j]].Tag +} +func (sp *StructProperties) Swap(i, j int) { sp.order[i], sp.order[j] = sp.order[j], sp.order[i] } + +// Properties represents the protocol-specific behavior of a single struct field. +type Properties struct { + Name string // name of the field, for error messages + OrigName string // original name before protocol compiler (always set) + JSONName string // name to use for JSON; determined by protoc + Wire string + WireType int + Tag int + Required bool + Optional bool + Repeated bool + Packed bool // relevant for repeated primitives only + Enum string // set for enum types only + proto3 bool // whether this is known to be a proto3 field; set for []byte only + oneof bool // whether this is a oneof field + + Default string // default value + HasDefault bool // whether an explicit default was provided + def_uint64 uint64 + + enc encoder + valEnc valueEncoder // set for bool and numeric types only + field field + tagcode []byte // encoding of EncodeVarint((Tag<<3)|WireType) + tagbuf [8]byte + stype reflect.Type // set for struct types only + sprop *StructProperties // set for struct types only + isMarshaler bool + isUnmarshaler bool + + mtype reflect.Type // set for map types only + mkeyprop *Properties // set for map types only + mvalprop *Properties // set for map types only + + size sizer + valSize valueSizer // set for bool and numeric types only + + dec decoder + valDec valueDecoder // set for bool and numeric types only + + // If this is a packable field, this will be the decoder for the packed version of the field. + packedDec decoder +} + +// String formats the properties in the protobuf struct field tag style. +func (p *Properties) String() string { + s := p.Wire + s = "," + s += strconv.Itoa(p.Tag) + if p.Required { + s += ",req" + } + if p.Optional { + s += ",opt" + } + if p.Repeated { + s += ",rep" + } + if p.Packed { + s += ",packed" + } + s += ",name=" + p.OrigName + if p.JSONName != p.OrigName { + s += ",json=" + p.JSONName + } + if p.proto3 { + s += ",proto3" + } + if p.oneof { + s += ",oneof" + } + if len(p.Enum) > 0 { + s += ",enum=" + p.Enum + } + if p.HasDefault { + s += ",def=" + p.Default + } + return s +} + +// Parse populates p by parsing a string in the protobuf struct field tag style. +func (p *Properties) Parse(s string) { + // "bytes,49,opt,name=foo,def=hello!" + fields := strings.Split(s, ",") // breaks def=, but handled below. + if len(fields) < 2 { + fmt.Fprintf(os.Stderr, "proto: tag has too few fields: %q\n", s) + return + } + + p.Wire = fields[0] + switch p.Wire { + case "varint": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeVarint + p.valDec = (*Buffer).DecodeVarint + p.valSize = sizeVarint + case "fixed32": + p.WireType = WireFixed32 + p.valEnc = (*Buffer).EncodeFixed32 + p.valDec = (*Buffer).DecodeFixed32 + p.valSize = sizeFixed32 + case "fixed64": + p.WireType = WireFixed64 + p.valEnc = (*Buffer).EncodeFixed64 + p.valDec = (*Buffer).DecodeFixed64 + p.valSize = sizeFixed64 + case "zigzag32": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeZigzag32 + p.valDec = (*Buffer).DecodeZigzag32 + p.valSize = sizeZigzag32 + case "zigzag64": + p.WireType = WireVarint + p.valEnc = (*Buffer).EncodeZigzag64 + p.valDec = (*Buffer).DecodeZigzag64 + p.valSize = sizeZigzag64 + case "bytes", "group": + p.WireType = WireBytes + // no numeric converter for non-numeric types + default: + fmt.Fprintf(os.Stderr, "proto: tag has unknown wire type: %q\n", s) + return + } + + var err error + p.Tag, err = strconv.Atoi(fields[1]) + if err != nil { + return + } + + for i := 2; i < len(fields); i++ { + f := fields[i] + switch { + case f == "req": + p.Required = true + case f == "opt": + p.Optional = true + case f == "rep": + p.Repeated = true + case f == "packed": + p.Packed = true + case strings.HasPrefix(f, "name="): + p.OrigName = f[5:] + case strings.HasPrefix(f, "json="): + p.JSONName = f[5:] + case strings.HasPrefix(f, "enum="): + p.Enum = f[5:] + case f == "proto3": + p.proto3 = true + case f == "oneof": + p.oneof = true + case strings.HasPrefix(f, "def="): + p.HasDefault = true + p.Default = f[4:] // rest of string + if i+1 < len(fields) { + // Commas aren't escaped, and def is always last. + p.Default += "," + strings.Join(fields[i+1:], ",") + break + } + } + } +} + +func logNoSliceEnc(t1, t2 reflect.Type) { + fmt.Fprintf(os.Stderr, "proto: no slice oenc for %T = []%T\n", t1, t2) +} + +var protoMessageType = reflect.TypeOf((*Message)(nil)).Elem() + +// Initialize the fields for encoding and decoding. +func (p *Properties) setEncAndDec(typ reflect.Type, f *reflect.StructField, lockGetProp bool) { + p.enc = nil + p.dec = nil + p.size = nil + + switch t1 := typ; t1.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no coders for %v\n", t1) + + // proto3 scalar types + + case reflect.Bool: + p.enc = (*Buffer).enc_proto3_bool + p.dec = (*Buffer).dec_proto3_bool + p.size = size_proto3_bool + case reflect.Int32: + p.enc = (*Buffer).enc_proto3_int32 + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_proto3_int32 + case reflect.Uint32: + p.enc = (*Buffer).enc_proto3_uint32 + p.dec = (*Buffer).dec_proto3_int32 // can reuse + p.size = size_proto3_uint32 + case reflect.Int64, reflect.Uint64: + p.enc = (*Buffer).enc_proto3_int64 + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_proto3_int64 + case reflect.Float32: + p.enc = (*Buffer).enc_proto3_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int32 + p.size = size_proto3_uint32 + case reflect.Float64: + p.enc = (*Buffer).enc_proto3_int64 // can just treat them as bits + p.dec = (*Buffer).dec_proto3_int64 + p.size = size_proto3_int64 + case reflect.String: + p.enc = (*Buffer).enc_proto3_string + p.dec = (*Buffer).dec_proto3_string + p.size = size_proto3_string + + case reflect.Ptr: + switch t2 := t1.Elem(); t2.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no encoder function for %v -> %v\n", t1, t2) + break + case reflect.Bool: + p.enc = (*Buffer).enc_bool + p.dec = (*Buffer).dec_bool + p.size = size_bool + case reflect.Int32: + p.enc = (*Buffer).enc_int32 + p.dec = (*Buffer).dec_int32 + p.size = size_int32 + case reflect.Uint32: + p.enc = (*Buffer).enc_uint32 + p.dec = (*Buffer).dec_int32 // can reuse + p.size = size_uint32 + case reflect.Int64, reflect.Uint64: + p.enc = (*Buffer).enc_int64 + p.dec = (*Buffer).dec_int64 + p.size = size_int64 + case reflect.Float32: + p.enc = (*Buffer).enc_uint32 // can just treat them as bits + p.dec = (*Buffer).dec_int32 + p.size = size_uint32 + case reflect.Float64: + p.enc = (*Buffer).enc_int64 // can just treat them as bits + p.dec = (*Buffer).dec_int64 + p.size = size_int64 + case reflect.String: + p.enc = (*Buffer).enc_string + p.dec = (*Buffer).dec_string + p.size = size_string + case reflect.Struct: + p.stype = t1.Elem() + p.isMarshaler = isMarshaler(t1) + p.isUnmarshaler = isUnmarshaler(t1) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_struct_message + p.dec = (*Buffer).dec_struct_message + p.size = size_struct_message + } else { + p.enc = (*Buffer).enc_struct_group + p.dec = (*Buffer).dec_struct_group + p.size = size_struct_group + } + } + + case reflect.Slice: + switch t2 := t1.Elem(); t2.Kind() { + default: + logNoSliceEnc(t1, t2) + break + case reflect.Bool: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_bool + p.size = size_slice_packed_bool + } else { + p.enc = (*Buffer).enc_slice_bool + p.size = size_slice_bool + } + p.dec = (*Buffer).dec_slice_bool + p.packedDec = (*Buffer).dec_slice_packed_bool + case reflect.Int32: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int32 + p.size = size_slice_packed_int32 + } else { + p.enc = (*Buffer).enc_slice_int32 + p.size = size_slice_int32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case reflect.Uint32: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_uint32 + p.size = size_slice_packed_uint32 + } else { + p.enc = (*Buffer).enc_slice_uint32 + p.size = size_slice_uint32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case reflect.Int64, reflect.Uint64: + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int64 + p.size = size_slice_packed_int64 + } else { + p.enc = (*Buffer).enc_slice_int64 + p.size = size_slice_int64 + } + p.dec = (*Buffer).dec_slice_int64 + p.packedDec = (*Buffer).dec_slice_packed_int64 + case reflect.Uint8: + p.dec = (*Buffer).dec_slice_byte + if p.proto3 { + p.enc = (*Buffer).enc_proto3_slice_byte + p.size = size_proto3_slice_byte + } else { + p.enc = (*Buffer).enc_slice_byte + p.size = size_slice_byte + } + case reflect.Float32, reflect.Float64: + switch t2.Bits() { + case 32: + // can just treat them as bits + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_uint32 + p.size = size_slice_packed_uint32 + } else { + p.enc = (*Buffer).enc_slice_uint32 + p.size = size_slice_uint32 + } + p.dec = (*Buffer).dec_slice_int32 + p.packedDec = (*Buffer).dec_slice_packed_int32 + case 64: + // can just treat them as bits + if p.Packed { + p.enc = (*Buffer).enc_slice_packed_int64 + p.size = size_slice_packed_int64 + } else { + p.enc = (*Buffer).enc_slice_int64 + p.size = size_slice_int64 + } + p.dec = (*Buffer).dec_slice_int64 + p.packedDec = (*Buffer).dec_slice_packed_int64 + default: + logNoSliceEnc(t1, t2) + break + } + case reflect.String: + p.enc = (*Buffer).enc_slice_string + p.dec = (*Buffer).dec_slice_string + p.size = size_slice_string + case reflect.Ptr: + switch t3 := t2.Elem(); t3.Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no ptr oenc for %T -> %T -> %T\n", t1, t2, t3) + break + case reflect.Struct: + p.stype = t2.Elem() + p.isMarshaler = isMarshaler(t2) + p.isUnmarshaler = isUnmarshaler(t2) + if p.Wire == "bytes" { + p.enc = (*Buffer).enc_slice_struct_message + p.dec = (*Buffer).dec_slice_struct_message + p.size = size_slice_struct_message + } else { + p.enc = (*Buffer).enc_slice_struct_group + p.dec = (*Buffer).dec_slice_struct_group + p.size = size_slice_struct_group + } + } + case reflect.Slice: + switch t2.Elem().Kind() { + default: + fmt.Fprintf(os.Stderr, "proto: no slice elem oenc for %T -> %T -> %T\n", t1, t2, t2.Elem()) + break + case reflect.Uint8: + p.enc = (*Buffer).enc_slice_slice_byte + p.dec = (*Buffer).dec_slice_slice_byte + p.size = size_slice_slice_byte + } + } + + case reflect.Map: + p.enc = (*Buffer).enc_new_map + p.dec = (*Buffer).dec_new_map + p.size = size_new_map + + p.mtype = t1 + p.mkeyprop = &Properties{} + p.mkeyprop.init(reflect.PtrTo(p.mtype.Key()), "Key", f.Tag.Get("protobuf_key"), nil, lockGetProp) + p.mvalprop = &Properties{} + vtype := p.mtype.Elem() + if vtype.Kind() != reflect.Ptr && vtype.Kind() != reflect.Slice { + // The value type is not a message (*T) or bytes ([]byte), + // so we need encoders for the pointer to this type. + vtype = reflect.PtrTo(vtype) + } + p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) + } + + // precalculate tag code + wire := p.WireType + if p.Packed { + wire = WireBytes + } + x := uint32(p.Tag)<<3 | uint32(wire) + i := 0 + for i = 0; x > 127; i++ { + p.tagbuf[i] = 0x80 | uint8(x&0x7F) + x >>= 7 + } + p.tagbuf[i] = uint8(x) + p.tagcode = p.tagbuf[0 : i+1] + + if p.stype != nil { + if lockGetProp { + p.sprop = GetProperties(p.stype) + } else { + p.sprop = getPropertiesLocked(p.stype) + } + } +} + +var ( + marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() + unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() +) + +// isMarshaler reports whether type t implements Marshaler. +func isMarshaler(t reflect.Type) bool { + // We're checking for (likely) pointer-receiver methods + // so if t is not a pointer, something is very wrong. + // The calls above only invoke isMarshaler on pointer types. + if t.Kind() != reflect.Ptr { + panic("proto: misuse of isMarshaler") + } + return t.Implements(marshalerType) +} + +// isUnmarshaler reports whether type t implements Unmarshaler. +func isUnmarshaler(t reflect.Type) bool { + // We're checking for (likely) pointer-receiver methods + // so if t is not a pointer, something is very wrong. + // The calls above only invoke isUnmarshaler on pointer types. + if t.Kind() != reflect.Ptr { + panic("proto: misuse of isUnmarshaler") + } + return t.Implements(unmarshalerType) +} + +// Init populates the properties from a protocol buffer struct tag. +func (p *Properties) Init(typ reflect.Type, name, tag string, f *reflect.StructField) { + p.init(typ, name, tag, f, true) +} + +func (p *Properties) init(typ reflect.Type, name, tag string, f *reflect.StructField, lockGetProp bool) { + // "bytes,49,opt,def=hello!" + p.Name = name + p.OrigName = name + if f != nil { + p.field = toField(f) + } + if tag == "" { + return + } + p.Parse(tag) + p.setEncAndDec(typ, f, lockGetProp) +} + +var ( + propertiesMu sync.RWMutex + propertiesMap = make(map[reflect.Type]*StructProperties) +) + +// GetProperties returns the list of properties for the type represented by t. +// t must represent a generated struct type of a protocol message. +func GetProperties(t reflect.Type) *StructProperties { + if t.Kind() != reflect.Struct { + panic("proto: type must have kind struct") + } + + // Most calls to GetProperties in a long-running program will be + // retrieving details for types we have seen before. + propertiesMu.RLock() + sprop, ok := propertiesMap[t] + propertiesMu.RUnlock() + if ok { + if collectStats { + stats.Chit++ + } + return sprop + } + + propertiesMu.Lock() + sprop = getPropertiesLocked(t) + propertiesMu.Unlock() + return sprop +} + +// getPropertiesLocked requires that propertiesMu is held. +func getPropertiesLocked(t reflect.Type) *StructProperties { + if prop, ok := propertiesMap[t]; ok { + if collectStats { + stats.Chit++ + } + return prop + } + if collectStats { + stats.Cmiss++ + } + + prop := new(StructProperties) + // in case of recursive protos, fill this in now. + propertiesMap[t] = prop + + // build properties + prop.extendable = reflect.PtrTo(t).Implements(extendableProtoType) || + reflect.PtrTo(t).Implements(extendableProtoV1Type) + prop.unrecField = invalidField + prop.Prop = make([]*Properties, t.NumField()) + prop.order = make([]int, t.NumField()) + + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + p := new(Properties) + name := f.Name + p.init(f.Type, name, f.Tag.Get("protobuf"), &f, false) + + if f.Name == "XXX_InternalExtensions" { // special case + p.enc = (*Buffer).enc_exts + p.dec = nil // not needed + p.size = size_exts + } else if f.Name == "XXX_extensions" { // special case + p.enc = (*Buffer).enc_map + p.dec = nil // not needed + p.size = size_map + } else if f.Name == "XXX_unrecognized" { // special case + prop.unrecField = toField(&f) + } + oneof := f.Tag.Get("protobuf_oneof") // special case + if oneof != "" { + // Oneof fields don't use the traditional protobuf tag. + p.OrigName = oneof + } + prop.Prop[i] = p + prop.order[i] = i + if debug { + print(i, " ", f.Name, " ", t.String(), " ") + if p.Tag > 0 { + print(p.String()) + } + print("\n") + } + if p.enc == nil && !strings.HasPrefix(f.Name, "XXX_") && oneof == "" { + fmt.Fprintln(os.Stderr, "proto: no encoder for", f.Name, f.Type.String(), "[GetProperties]") + } + } + + // Re-order prop.order. + sort.Sort(prop) + + type oneofMessage interface { + XXX_OneofFuncs() (func(Message, *Buffer) error, func(Message, int, int, *Buffer) (bool, error), func(Message) int, []interface{}) + } + if om, ok := reflect.Zero(reflect.PtrTo(t)).Interface().(oneofMessage); ok { + var oots []interface{} + prop.oneofMarshaler, prop.oneofUnmarshaler, prop.oneofSizer, oots = om.XXX_OneofFuncs() + prop.stype = t + + // Interpret oneof metadata. + prop.OneofTypes = make(map[string]*OneofProperties) + for _, oot := range oots { + oop := &OneofProperties{ + Type: reflect.ValueOf(oot).Type(), // *T + Prop: new(Properties), + } + sft := oop.Type.Elem().Field(0) + oop.Prop.Name = sft.Name + oop.Prop.Parse(sft.Tag.Get("protobuf")) + // There will be exactly one interface field that + // this new value is assignable to. + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + if f.Type.Kind() != reflect.Interface { + continue + } + if !oop.Type.AssignableTo(f.Type) { + continue + } + oop.Field = i + break + } + prop.OneofTypes[oop.Prop.OrigName] = oop + } + } + + // build required counts + // build tags + reqCount := 0 + prop.decoderOrigNames = make(map[string]int) + for i, p := range prop.Prop { + if strings.HasPrefix(p.Name, "XXX_") { + // Internal fields should not appear in tags/origNames maps. + // They are handled specially when encoding and decoding. + continue + } + if p.Required { + reqCount++ + } + prop.decoderTags.put(p.Tag, i) + prop.decoderOrigNames[p.OrigName] = i + } + prop.reqCount = reqCount + + return prop +} + +// Return the Properties object for the x[0]'th field of the structure. +func propByIndex(t reflect.Type, x []int) *Properties { + if len(x) != 1 { + fmt.Fprintf(os.Stderr, "proto: field index dimension %d (not 1) for type %s\n", len(x), t) + return nil + } + prop := GetProperties(t) + return prop.Prop[x[0]] +} + +// Get the address and type of a pointer to a struct from an interface. +func getbase(pb Message) (t reflect.Type, b structPointer, err error) { + if pb == nil { + err = ErrNil + return + } + // get the reflect type of the pointer to the struct. + t = reflect.TypeOf(pb) + // get the address of the struct. + value := reflect.ValueOf(pb) + b = toStructPointer(value) + return +} + +// A global registry of enum types. +// The generated code will register the generated maps by calling RegisterEnum. + +var enumValueMaps = make(map[string]map[string]int32) + +// RegisterEnum is called from the generated code to install the enum descriptor +// maps into the global table to aid parsing text format protocol buffers. +func RegisterEnum(typeName string, unusedNameMap map[int32]string, valueMap map[string]int32) { + if _, ok := enumValueMaps[typeName]; ok { + panic("proto: duplicate enum registered: " + typeName) + } + enumValueMaps[typeName] = valueMap +} + +// EnumValueMap returns the mapping from names to integers of the +// enum type enumType, or a nil if not found. +func EnumValueMap(enumType string) map[string]int32 { + return enumValueMaps[enumType] +} + +// A registry of all linked message types. +// The string is a fully-qualified proto name ("pkg.Message"). +var ( + protoTypes = make(map[string]reflect.Type) + revProtoTypes = make(map[reflect.Type]string) +) + +// RegisterType is called from generated code and maps from the fully qualified +// proto name to the type (pointer to struct) of the protocol buffer. +func RegisterType(x Message, name string) { + if _, ok := protoTypes[name]; ok { + // TODO: Some day, make this a panic. + log.Printf("proto: duplicate proto type registered: %s", name) + return + } + t := reflect.TypeOf(x) + protoTypes[name] = t + revProtoTypes[t] = name +} + +// MessageName returns the fully-qualified proto name for the given message type. +func MessageName(x Message) string { return revProtoTypes[reflect.TypeOf(x)] } + +// MessageType returns the message type (pointer to struct) for a named message. +func MessageType(name string) reflect.Type { return protoTypes[name] } + +// A registry of all linked proto files. +var ( + protoFiles = make(map[string][]byte) // file name => fileDescriptor +) + +// RegisterFile is called from generated code and maps from the +// full file name of a .proto file to its compressed FileDescriptorProto. +func RegisterFile(filename string, fileDescriptor []byte) { + protoFiles[filename] = fileDescriptor +} + +// FileDescriptor returns the compressed FileDescriptorProto for a .proto file. +func FileDescriptor(filename string) []byte { return protoFiles[filename] } diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/text.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/text.go new file mode 100644 index 000000000000..8214ce326b54 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/text.go @@ -0,0 +1,854 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +// Functions for writing the text protocol buffer format. + +import ( + "bufio" + "bytes" + "encoding" + "errors" + "fmt" + "io" + "log" + "math" + "reflect" + "sort" + "strings" +) + +var ( + newline = []byte("\n") + spaces = []byte(" ") + gtNewline = []byte(">\n") + endBraceNewline = []byte("}\n") + backslashN = []byte{'\\', 'n'} + backslashR = []byte{'\\', 'r'} + backslashT = []byte{'\\', 't'} + backslashDQ = []byte{'\\', '"'} + backslashBS = []byte{'\\', '\\'} + posInf = []byte("inf") + negInf = []byte("-inf") + nan = []byte("nan") +) + +type writer interface { + io.Writer + WriteByte(byte) error +} + +// textWriter is an io.Writer that tracks its indentation level. +type textWriter struct { + ind int + complete bool // if the current position is a complete line + compact bool // whether to write out as a one-liner + w writer +} + +func (w *textWriter) WriteString(s string) (n int, err error) { + if !strings.Contains(s, "\n") { + if !w.compact && w.complete { + w.writeIndent() + } + w.complete = false + return io.WriteString(w.w, s) + } + // WriteString is typically called without newlines, so this + // codepath and its copy are rare. We copy to avoid + // duplicating all of Write's logic here. + return w.Write([]byte(s)) +} + +func (w *textWriter) Write(p []byte) (n int, err error) { + newlines := bytes.Count(p, newline) + if newlines == 0 { + if !w.compact && w.complete { + w.writeIndent() + } + n, err = w.w.Write(p) + w.complete = false + return n, err + } + + frags := bytes.SplitN(p, newline, newlines+1) + if w.compact { + for i, frag := range frags { + if i > 0 { + if err := w.w.WriteByte(' '); err != nil { + return n, err + } + n++ + } + nn, err := w.w.Write(frag) + n += nn + if err != nil { + return n, err + } + } + return n, nil + } + + for i, frag := range frags { + if w.complete { + w.writeIndent() + } + nn, err := w.w.Write(frag) + n += nn + if err != nil { + return n, err + } + if i+1 < len(frags) { + if err := w.w.WriteByte('\n'); err != nil { + return n, err + } + n++ + } + } + w.complete = len(frags[len(frags)-1]) == 0 + return n, nil +} + +func (w *textWriter) WriteByte(c byte) error { + if w.compact && c == '\n' { + c = ' ' + } + if !w.compact && w.complete { + w.writeIndent() + } + err := w.w.WriteByte(c) + w.complete = c == '\n' + return err +} + +func (w *textWriter) indent() { w.ind++ } + +func (w *textWriter) unindent() { + if w.ind == 0 { + log.Printf("proto: textWriter unindented too far") + return + } + w.ind-- +} + +func writeName(w *textWriter, props *Properties) error { + if _, err := w.WriteString(props.OrigName); err != nil { + return err + } + if props.Wire != "group" { + return w.WriteByte(':') + } + return nil +} + +// raw is the interface satisfied by RawMessage. +type raw interface { + Bytes() []byte +} + +func requiresQuotes(u string) bool { + // When type URL contains any characters except [0-9A-Za-z./\-]*, it must be quoted. + for _, ch := range u { + switch { + case ch == '.' || ch == '/' || ch == '_': + continue + case '0' <= ch && ch <= '9': + continue + case 'A' <= ch && ch <= 'Z': + continue + case 'a' <= ch && ch <= 'z': + continue + default: + return true + } + } + return false +} + +// isAny reports whether sv is a google.protobuf.Any message +func isAny(sv reflect.Value) bool { + type wkt interface { + XXX_WellKnownType() string + } + t, ok := sv.Addr().Interface().(wkt) + return ok && t.XXX_WellKnownType() == "Any" +} + +// writeProto3Any writes an expanded google.protobuf.Any message. +// +// It returns (false, nil) if sv value can't be unmarshaled (e.g. because +// required messages are not linked in). +// +// It returns (true, error) when sv was written in expanded format or an error +// was encountered. +func (tm *TextMarshaler) writeProto3Any(w *textWriter, sv reflect.Value) (bool, error) { + turl := sv.FieldByName("TypeUrl") + val := sv.FieldByName("Value") + if !turl.IsValid() || !val.IsValid() { + return true, errors.New("proto: invalid google.protobuf.Any message") + } + + b, ok := val.Interface().([]byte) + if !ok { + return true, errors.New("proto: invalid google.protobuf.Any message") + } + + parts := strings.Split(turl.String(), "/") + mt := MessageType(parts[len(parts)-1]) + if mt == nil { + return false, nil + } + m := reflect.New(mt.Elem()) + if err := Unmarshal(b, m.Interface().(Message)); err != nil { + return false, nil + } + w.Write([]byte("[")) + u := turl.String() + if requiresQuotes(u) { + writeString(w, u) + } else { + w.Write([]byte(u)) + } + if w.compact { + w.Write([]byte("]:<")) + } else { + w.Write([]byte("]: <\n")) + w.ind++ + } + if err := tm.writeStruct(w, m.Elem()); err != nil { + return true, err + } + if w.compact { + w.Write([]byte("> ")) + } else { + w.ind-- + w.Write([]byte(">\n")) + } + return true, nil +} + +func (tm *TextMarshaler) writeStruct(w *textWriter, sv reflect.Value) error { + if tm.ExpandAny && isAny(sv) { + if canExpand, err := tm.writeProto3Any(w, sv); canExpand { + return err + } + } + st := sv.Type() + sprops := GetProperties(st) + for i := 0; i < sv.NumField(); i++ { + fv := sv.Field(i) + props := sprops.Prop[i] + name := st.Field(i).Name + + if strings.HasPrefix(name, "XXX_") { + // There are two XXX_ fields: + // XXX_unrecognized []byte + // XXX_extensions map[int32]proto.Extension + // The first is handled here; + // the second is handled at the bottom of this function. + if name == "XXX_unrecognized" && !fv.IsNil() { + if err := writeUnknownStruct(w, fv.Interface().([]byte)); err != nil { + return err + } + } + continue + } + if fv.Kind() == reflect.Ptr && fv.IsNil() { + // Field not filled in. This could be an optional field or + // a required field that wasn't filled in. Either way, there + // isn't anything we can show for it. + continue + } + if fv.Kind() == reflect.Slice && fv.IsNil() { + // Repeated field that is empty, or a bytes field that is unused. + continue + } + + if props.Repeated && fv.Kind() == reflect.Slice { + // Repeated field. + for j := 0; j < fv.Len(); j++ { + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + v := fv.Index(j) + if v.Kind() == reflect.Ptr && v.IsNil() { + // A nil message in a repeated field is not valid, + // but we can handle that more gracefully than panicking. + if _, err := w.Write([]byte("\n")); err != nil { + return err + } + continue + } + if err := tm.writeAny(w, v, props); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + continue + } + if fv.Kind() == reflect.Map { + // Map fields are rendered as a repeated struct with key/value fields. + keys := fv.MapKeys() + sort.Sort(mapKeys(keys)) + for _, key := range keys { + val := fv.MapIndex(key) + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + // open struct + if err := w.WriteByte('<'); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + // key + if _, err := w.WriteString("key:"); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := tm.writeAny(w, key, props.mkeyprop); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + // nil values aren't legal, but we can avoid panicking because of them. + if val.Kind() != reflect.Ptr || !val.IsNil() { + // value + if _, err := w.WriteString("value:"); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := tm.writeAny(w, val, props.mvalprop); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + // close struct + w.unindent() + if err := w.WriteByte('>'); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + } + continue + } + if props.proto3 && fv.Kind() == reflect.Slice && fv.Len() == 0 { + // empty bytes field + continue + } + if fv.Kind() != reflect.Ptr && fv.Kind() != reflect.Slice { + // proto3 non-repeated scalar field; skip if zero value + if isProto3Zero(fv) { + continue + } + } + + if fv.Kind() == reflect.Interface { + // Check if it is a oneof. + if st.Field(i).Tag.Get("protobuf_oneof") != "" { + // fv is nil, or holds a pointer to generated struct. + // That generated struct has exactly one field, + // which has a protobuf struct tag. + if fv.IsNil() { + continue + } + inner := fv.Elem().Elem() // interface -> *T -> T + tag := inner.Type().Field(0).Tag.Get("protobuf") + props = new(Properties) // Overwrite the outer props var, but not its pointee. + props.Parse(tag) + // Write the value in the oneof, not the oneof itself. + fv = inner.Field(0) + + // Special case to cope with malformed messages gracefully: + // If the value in the oneof is a nil pointer, don't panic + // in writeAny. + if fv.Kind() == reflect.Ptr && fv.IsNil() { + // Use errors.New so writeAny won't render quotes. + msg := errors.New("/* nil */") + fv = reflect.ValueOf(&msg).Elem() + } + } + } + + if err := writeName(w, props); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if b, ok := fv.Interface().(raw); ok { + if err := writeRaw(w, b.Bytes()); err != nil { + return err + } + continue + } + + // Enums have a String method, so writeAny will work fine. + if err := tm.writeAny(w, fv, props); err != nil { + return err + } + + if err := w.WriteByte('\n'); err != nil { + return err + } + } + + // Extensions (the XXX_extensions field). + pv := sv.Addr() + if _, ok := extendable(pv.Interface()); ok { + if err := tm.writeExtensions(w, pv); err != nil { + return err + } + } + + return nil +} + +// writeRaw writes an uninterpreted raw message. +func writeRaw(w *textWriter, b []byte) error { + if err := w.WriteByte('<'); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + if err := writeUnknownStruct(w, b); err != nil { + return err + } + w.unindent() + if err := w.WriteByte('>'); err != nil { + return err + } + return nil +} + +// writeAny writes an arbitrary field. +func (tm *TextMarshaler) writeAny(w *textWriter, v reflect.Value, props *Properties) error { + v = reflect.Indirect(v) + + // Floats have special cases. + if v.Kind() == reflect.Float32 || v.Kind() == reflect.Float64 { + x := v.Float() + var b []byte + switch { + case math.IsInf(x, 1): + b = posInf + case math.IsInf(x, -1): + b = negInf + case math.IsNaN(x): + b = nan + } + if b != nil { + _, err := w.Write(b) + return err + } + // Other values are handled below. + } + + // We don't attempt to serialise every possible value type; only those + // that can occur in protocol buffers. + switch v.Kind() { + case reflect.Slice: + // Should only be a []byte; repeated fields are handled in writeStruct. + if err := writeString(w, string(v.Bytes())); err != nil { + return err + } + case reflect.String: + if err := writeString(w, v.String()); err != nil { + return err + } + case reflect.Struct: + // Required/optional group/message. + var bra, ket byte = '<', '>' + if props != nil && props.Wire == "group" { + bra, ket = '{', '}' + } + if err := w.WriteByte(bra); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte('\n'); err != nil { + return err + } + } + w.indent() + if etm, ok := v.Interface().(encoding.TextMarshaler); ok { + text, err := etm.MarshalText() + if err != nil { + return err + } + if _, err = w.Write(text); err != nil { + return err + } + } else if err := tm.writeStruct(w, v); err != nil { + return err + } + w.unindent() + if err := w.WriteByte(ket); err != nil { + return err + } + default: + _, err := fmt.Fprint(w, v.Interface()) + return err + } + return nil +} + +// equivalent to C's isprint. +func isprint(c byte) bool { + return c >= 0x20 && c < 0x7f +} + +// writeString writes a string in the protocol buffer text format. +// It is similar to strconv.Quote except we don't use Go escape sequences, +// we treat the string as a byte sequence, and we use octal escapes. +// These differences are to maintain interoperability with the other +// languages' implementations of the text format. +func writeString(w *textWriter, s string) error { + // use WriteByte here to get any needed indent + if err := w.WriteByte('"'); err != nil { + return err + } + // Loop over the bytes, not the runes. + for i := 0; i < len(s); i++ { + var err error + // Divergence from C++: we don't escape apostrophes. + // There's no need to escape them, and the C++ parser + // copes with a naked apostrophe. + switch c := s[i]; c { + case '\n': + _, err = w.w.Write(backslashN) + case '\r': + _, err = w.w.Write(backslashR) + case '\t': + _, err = w.w.Write(backslashT) + case '"': + _, err = w.w.Write(backslashDQ) + case '\\': + _, err = w.w.Write(backslashBS) + default: + if isprint(c) { + err = w.w.WriteByte(c) + } else { + _, err = fmt.Fprintf(w.w, "\\%03o", c) + } + } + if err != nil { + return err + } + } + return w.WriteByte('"') +} + +func writeUnknownStruct(w *textWriter, data []byte) (err error) { + if !w.compact { + if _, err := fmt.Fprintf(w, "/* %d unknown bytes */\n", len(data)); err != nil { + return err + } + } + b := NewBuffer(data) + for b.index < len(b.buf) { + x, err := b.DecodeVarint() + if err != nil { + _, err := fmt.Fprintf(w, "/* %v */\n", err) + return err + } + wire, tag := x&7, x>>3 + if wire == WireEndGroup { + w.unindent() + if _, err := w.Write(endBraceNewline); err != nil { + return err + } + continue + } + if _, err := fmt.Fprint(w, tag); err != nil { + return err + } + if wire != WireStartGroup { + if err := w.WriteByte(':'); err != nil { + return err + } + } + if !w.compact || wire == WireStartGroup { + if err := w.WriteByte(' '); err != nil { + return err + } + } + switch wire { + case WireBytes: + buf, e := b.DecodeRawBytes(false) + if e == nil { + _, err = fmt.Fprintf(w, "%q", buf) + } else { + _, err = fmt.Fprintf(w, "/* %v */", e) + } + case WireFixed32: + x, err = b.DecodeFixed32() + err = writeUnknownInt(w, x, err) + case WireFixed64: + x, err = b.DecodeFixed64() + err = writeUnknownInt(w, x, err) + case WireStartGroup: + err = w.WriteByte('{') + w.indent() + case WireVarint: + x, err = b.DecodeVarint() + err = writeUnknownInt(w, x, err) + default: + _, err = fmt.Fprintf(w, "/* unknown wire type %d */", wire) + } + if err != nil { + return err + } + if err = w.WriteByte('\n'); err != nil { + return err + } + } + return nil +} + +func writeUnknownInt(w *textWriter, x uint64, err error) error { + if err == nil { + _, err = fmt.Fprint(w, x) + } else { + _, err = fmt.Fprintf(w, "/* %v */", err) + } + return err +} + +type int32Slice []int32 + +func (s int32Slice) Len() int { return len(s) } +func (s int32Slice) Less(i, j int) bool { return s[i] < s[j] } +func (s int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } + +// writeExtensions writes all the extensions in pv. +// pv is assumed to be a pointer to a protocol message struct that is extendable. +func (tm *TextMarshaler) writeExtensions(w *textWriter, pv reflect.Value) error { + emap := extensionMaps[pv.Type().Elem()] + ep, _ := extendable(pv.Interface()) + + // Order the extensions by ID. + // This isn't strictly necessary, but it will give us + // canonical output, which will also make testing easier. + m, mu := ep.extensionsRead() + if m == nil { + return nil + } + mu.Lock() + ids := make([]int32, 0, len(m)) + for id := range m { + ids = append(ids, id) + } + sort.Sort(int32Slice(ids)) + mu.Unlock() + + for _, extNum := range ids { + ext := m[extNum] + var desc *ExtensionDesc + if emap != nil { + desc = emap[extNum] + } + if desc == nil { + // Unknown extension. + if err := writeUnknownStruct(w, ext.enc); err != nil { + return err + } + continue + } + + pb, err := GetExtension(ep, desc) + if err != nil { + return fmt.Errorf("failed getting extension: %v", err) + } + + // Repeated extensions will appear as a slice. + if !desc.repeated() { + if err := tm.writeExtension(w, desc.Name, pb); err != nil { + return err + } + } else { + v := reflect.ValueOf(pb) + for i := 0; i < v.Len(); i++ { + if err := tm.writeExtension(w, desc.Name, v.Index(i).Interface()); err != nil { + return err + } + } + } + } + return nil +} + +func (tm *TextMarshaler) writeExtension(w *textWriter, name string, pb interface{}) error { + if _, err := fmt.Fprintf(w, "[%s]:", name); err != nil { + return err + } + if !w.compact { + if err := w.WriteByte(' '); err != nil { + return err + } + } + if err := tm.writeAny(w, reflect.ValueOf(pb), nil); err != nil { + return err + } + if err := w.WriteByte('\n'); err != nil { + return err + } + return nil +} + +func (w *textWriter) writeIndent() { + if !w.complete { + return + } + remain := w.ind * 2 + for remain > 0 { + n := remain + if n > len(spaces) { + n = len(spaces) + } + w.w.Write(spaces[:n]) + remain -= n + } + w.complete = false +} + +// TextMarshaler is a configurable text format marshaler. +type TextMarshaler struct { + Compact bool // use compact text format (one line). + ExpandAny bool // expand google.protobuf.Any messages of known types +} + +// Marshal writes a given protocol buffer in text format. +// The only errors returned are from w. +func (tm *TextMarshaler) Marshal(w io.Writer, pb Message) error { + val := reflect.ValueOf(pb) + if pb == nil || val.IsNil() { + w.Write([]byte("")) + return nil + } + var bw *bufio.Writer + ww, ok := w.(writer) + if !ok { + bw = bufio.NewWriter(w) + ww = bw + } + aw := &textWriter{ + w: ww, + complete: true, + compact: tm.Compact, + } + + if etm, ok := pb.(encoding.TextMarshaler); ok { + text, err := etm.MarshalText() + if err != nil { + return err + } + if _, err = aw.Write(text); err != nil { + return err + } + if bw != nil { + return bw.Flush() + } + return nil + } + // Dereference the received pointer so we don't have outer < and >. + v := reflect.Indirect(val) + if err := tm.writeStruct(aw, v); err != nil { + return err + } + if bw != nil { + return bw.Flush() + } + return nil +} + +// Text is the same as Marshal, but returns the string directly. +func (tm *TextMarshaler) Text(pb Message) string { + var buf bytes.Buffer + tm.Marshal(&buf, pb) + return buf.String() +} + +var ( + defaultTextMarshaler = TextMarshaler{} + compactTextMarshaler = TextMarshaler{Compact: true} +) + +// TODO: consider removing some of the Marshal functions below. + +// MarshalText writes a given protocol buffer in text format. +// The only errors returned are from w. +func MarshalText(w io.Writer, pb Message) error { return defaultTextMarshaler.Marshal(w, pb) } + +// MarshalTextString is the same as MarshalText, but returns the string directly. +func MarshalTextString(pb Message) string { return defaultTextMarshaler.Text(pb) } + +// CompactText writes a given protocol buffer in compact text format (one line). +func CompactText(w io.Writer, pb Message) error { return compactTextMarshaler.Marshal(w, pb) } + +// CompactTextString is the same as CompactText, but returns the string directly. +func CompactTextString(pb Message) string { return compactTextMarshaler.Text(pb) } diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/text_parser.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/text_parser.go new file mode 100644 index 000000000000..0b8c59f746eb --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/golang/protobuf/proto/text_parser.go @@ -0,0 +1,880 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +// Functions for parsing the Text protocol buffer format. +// TODO: message sets. + +import ( + "encoding" + "errors" + "fmt" + "reflect" + "strconv" + "strings" + "unicode/utf8" +) + +type ParseError struct { + Message string + Line int // 1-based line number + Offset int // 0-based byte offset from start of input +} + +func (p *ParseError) Error() string { + if p.Line == 1 { + // show offset only for first line + return fmt.Sprintf("line 1.%d: %v", p.Offset, p.Message) + } + return fmt.Sprintf("line %d: %v", p.Line, p.Message) +} + +type token struct { + value string + err *ParseError + line int // line number + offset int // byte number from start of input, not start of line + unquoted string // the unquoted version of value, if it was a quoted string +} + +func (t *token) String() string { + if t.err == nil { + return fmt.Sprintf("%q (line=%d, offset=%d)", t.value, t.line, t.offset) + } + return fmt.Sprintf("parse error: %v", t.err) +} + +type textParser struct { + s string // remaining input + done bool // whether the parsing is finished (success or error) + backed bool // whether back() was called + offset, line int + cur token +} + +func newTextParser(s string) *textParser { + p := new(textParser) + p.s = s + p.line = 1 + p.cur.line = 1 + return p +} + +func (p *textParser) errorf(format string, a ...interface{}) *ParseError { + pe := &ParseError{fmt.Sprintf(format, a...), p.cur.line, p.cur.offset} + p.cur.err = pe + p.done = true + return pe +} + +// Numbers and identifiers are matched by [-+._A-Za-z0-9] +func isIdentOrNumberChar(c byte) bool { + switch { + case 'A' <= c && c <= 'Z', 'a' <= c && c <= 'z': + return true + case '0' <= c && c <= '9': + return true + } + switch c { + case '-', '+', '.', '_': + return true + } + return false +} + +func isWhitespace(c byte) bool { + switch c { + case ' ', '\t', '\n', '\r': + return true + } + return false +} + +func isQuote(c byte) bool { + switch c { + case '"', '\'': + return true + } + return false +} + +func (p *textParser) skipWhitespace() { + i := 0 + for i < len(p.s) && (isWhitespace(p.s[i]) || p.s[i] == '#') { + if p.s[i] == '#' { + // comment; skip to end of line or input + for i < len(p.s) && p.s[i] != '\n' { + i++ + } + if i == len(p.s) { + break + } + } + if p.s[i] == '\n' { + p.line++ + } + i++ + } + p.offset += i + p.s = p.s[i:len(p.s)] + if len(p.s) == 0 { + p.done = true + } +} + +func (p *textParser) advance() { + // Skip whitespace + p.skipWhitespace() + if p.done { + return + } + + // Start of non-whitespace + p.cur.err = nil + p.cur.offset, p.cur.line = p.offset, p.line + p.cur.unquoted = "" + switch p.s[0] { + case '<', '>', '{', '}', ':', '[', ']', ';', ',', '/': + // Single symbol + p.cur.value, p.s = p.s[0:1], p.s[1:len(p.s)] + case '"', '\'': + // Quoted string + i := 1 + for i < len(p.s) && p.s[i] != p.s[0] && p.s[i] != '\n' { + if p.s[i] == '\\' && i+1 < len(p.s) { + // skip escaped char + i++ + } + i++ + } + if i >= len(p.s) || p.s[i] != p.s[0] { + p.errorf("unmatched quote") + return + } + unq, err := unquoteC(p.s[1:i], rune(p.s[0])) + if err != nil { + p.errorf("invalid quoted string %s: %v", p.s[0:i+1], err) + return + } + p.cur.value, p.s = p.s[0:i+1], p.s[i+1:len(p.s)] + p.cur.unquoted = unq + default: + i := 0 + for i < len(p.s) && isIdentOrNumberChar(p.s[i]) { + i++ + } + if i == 0 { + p.errorf("unexpected byte %#x", p.s[0]) + return + } + p.cur.value, p.s = p.s[0:i], p.s[i:len(p.s)] + } + p.offset += len(p.cur.value) +} + +var ( + errBadUTF8 = errors.New("proto: bad UTF-8") + errBadHex = errors.New("proto: bad hexadecimal") +) + +func unquoteC(s string, quote rune) (string, error) { + // This is based on C++'s tokenizer.cc. + // Despite its name, this is *not* parsing C syntax. + // For instance, "\0" is an invalid quoted string. + + // Avoid allocation in trivial cases. + simple := true + for _, r := range s { + if r == '\\' || r == quote { + simple = false + break + } + } + if simple { + return s, nil + } + + buf := make([]byte, 0, 3*len(s)/2) + for len(s) > 0 { + r, n := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && n == 1 { + return "", errBadUTF8 + } + s = s[n:] + if r != '\\' { + if r < utf8.RuneSelf { + buf = append(buf, byte(r)) + } else { + buf = append(buf, string(r)...) + } + continue + } + + ch, tail, err := unescape(s) + if err != nil { + return "", err + } + buf = append(buf, ch...) + s = tail + } + return string(buf), nil +} + +func unescape(s string) (ch string, tail string, err error) { + r, n := utf8.DecodeRuneInString(s) + if r == utf8.RuneError && n == 1 { + return "", "", errBadUTF8 + } + s = s[n:] + switch r { + case 'a': + return "\a", s, nil + case 'b': + return "\b", s, nil + case 'f': + return "\f", s, nil + case 'n': + return "\n", s, nil + case 'r': + return "\r", s, nil + case 't': + return "\t", s, nil + case 'v': + return "\v", s, nil + case '?': + return "?", s, nil // trigraph workaround + case '\'', '"', '\\': + return string(r), s, nil + case '0', '1', '2', '3', '4', '5', '6', '7', 'x', 'X': + if len(s) < 2 { + return "", "", fmt.Errorf(`\%c requires 2 following digits`, r) + } + base := 8 + ss := s[:2] + s = s[2:] + if r == 'x' || r == 'X' { + base = 16 + } else { + ss = string(r) + ss + } + i, err := strconv.ParseUint(ss, base, 8) + if err != nil { + return "", "", err + } + return string([]byte{byte(i)}), s, nil + case 'u', 'U': + n := 4 + if r == 'U' { + n = 8 + } + if len(s) < n { + return "", "", fmt.Errorf(`\%c requires %d digits`, r, n) + } + + bs := make([]byte, n/2) + for i := 0; i < n; i += 2 { + a, ok1 := unhex(s[i]) + b, ok2 := unhex(s[i+1]) + if !ok1 || !ok2 { + return "", "", errBadHex + } + bs[i/2] = a<<4 | b + } + s = s[n:] + return string(bs), s, nil + } + return "", "", fmt.Errorf(`unknown escape \%c`, r) +} + +// Adapted from src/pkg/strconv/quote.go. +func unhex(b byte) (v byte, ok bool) { + switch { + case '0' <= b && b <= '9': + return b - '0', true + case 'a' <= b && b <= 'f': + return b - 'a' + 10, true + case 'A' <= b && b <= 'F': + return b - 'A' + 10, true + } + return 0, false +} + +// Back off the parser by one token. Can only be done between calls to next(). +// It makes the next advance() a no-op. +func (p *textParser) back() { p.backed = true } + +// Advances the parser and returns the new current token. +func (p *textParser) next() *token { + if p.backed || p.done { + p.backed = false + return &p.cur + } + p.advance() + if p.done { + p.cur.value = "" + } else if len(p.cur.value) > 0 && isQuote(p.cur.value[0]) { + // Look for multiple quoted strings separated by whitespace, + // and concatenate them. + cat := p.cur + for { + p.skipWhitespace() + if p.done || !isQuote(p.s[0]) { + break + } + p.advance() + if p.cur.err != nil { + return &p.cur + } + cat.value += " " + p.cur.value + cat.unquoted += p.cur.unquoted + } + p.done = false // parser may have seen EOF, but we want to return cat + p.cur = cat + } + return &p.cur +} + +func (p *textParser) consumeToken(s string) error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != s { + p.back() + return p.errorf("expected %q, found %q", s, tok.value) + } + return nil +} + +// Return a RequiredNotSetError indicating which required field was not set. +func (p *textParser) missingRequiredFieldError(sv reflect.Value) *RequiredNotSetError { + st := sv.Type() + sprops := GetProperties(st) + for i := 0; i < st.NumField(); i++ { + if !isNil(sv.Field(i)) { + continue + } + + props := sprops.Prop[i] + if props.Required { + return &RequiredNotSetError{fmt.Sprintf("%v.%v", st, props.OrigName)} + } + } + return &RequiredNotSetError{fmt.Sprintf("%v.", st)} // should not happen +} + +// Returns the index in the struct for the named field, as well as the parsed tag properties. +func structFieldByName(sprops *StructProperties, name string) (int, *Properties, bool) { + i, ok := sprops.decoderOrigNames[name] + if ok { + return i, sprops.Prop[i], true + } + return -1, nil, false +} + +// Consume a ':' from the input stream (if the next token is a colon), +// returning an error if a colon is needed but not present. +func (p *textParser) checkForColon(props *Properties, typ reflect.Type) *ParseError { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != ":" { + // Colon is optional when the field is a group or message. + needColon := true + switch props.Wire { + case "group": + needColon = false + case "bytes": + // A "bytes" field is either a message, a string, or a repeated field; + // those three become *T, *string and []T respectively, so we can check for + // this field being a pointer to a non-string. + if typ.Kind() == reflect.Ptr { + // *T or *string + if typ.Elem().Kind() == reflect.String { + break + } + } else if typ.Kind() == reflect.Slice { + // []T or []*T + if typ.Elem().Kind() != reflect.Ptr { + break + } + } else if typ.Kind() == reflect.String { + // The proto3 exception is for a string field, + // which requires a colon. + break + } + needColon = false + } + if needColon { + return p.errorf("expected ':', found %q", tok.value) + } + p.back() + } + return nil +} + +func (p *textParser) readStruct(sv reflect.Value, terminator string) error { + st := sv.Type() + sprops := GetProperties(st) + reqCount := sprops.reqCount + var reqFieldErr error + fieldSet := make(map[string]bool) + // A struct is a sequence of "name: value", terminated by one of + // '>' or '}', or the end of the input. A name may also be + // "[extension]" or "[type/url]". + // + // The whole struct can also be an expanded Any message, like: + // [type/url] < ... struct contents ... > + for { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == terminator { + break + } + if tok.value == "[" { + // Looks like an extension or an Any. + // + // TODO: Check whether we need to handle + // namespace rooted names (e.g. ".something.Foo"). + extName, err := p.consumeExtName() + if err != nil { + return err + } + + if s := strings.LastIndex(extName, "/"); s >= 0 { + // If it contains a slash, it's an Any type URL. + messageName := extName[s+1:] + mt := MessageType(messageName) + if mt == nil { + return p.errorf("unrecognized message %q in google.protobuf.Any", messageName) + } + tok = p.next() + if tok.err != nil { + return tok.err + } + // consume an optional colon + if tok.value == ":" { + tok = p.next() + if tok.err != nil { + return tok.err + } + } + var terminator string + switch tok.value { + case "<": + terminator = ">" + case "{": + terminator = "}" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + v := reflect.New(mt.Elem()) + if pe := p.readStruct(v.Elem(), terminator); pe != nil { + return pe + } + b, err := Marshal(v.Interface().(Message)) + if err != nil { + return p.errorf("failed to marshal message of type %q: %v", messageName, err) + } + sv.FieldByName("TypeUrl").SetString(extName) + sv.FieldByName("Value").SetBytes(b) + continue + } + + var desc *ExtensionDesc + // This could be faster, but it's functional. + // TODO: Do something smarter than a linear scan. + for _, d := range RegisteredExtensions(reflect.New(st).Interface().(Message)) { + if d.Name == extName { + desc = d + break + } + } + if desc == nil { + return p.errorf("unrecognized extension %q", extName) + } + + props := &Properties{} + props.Parse(desc.Tag) + + typ := reflect.TypeOf(desc.ExtensionType) + if err := p.checkForColon(props, typ); err != nil { + return err + } + + rep := desc.repeated() + + // Read the extension structure, and set it in + // the value we're constructing. + var ext reflect.Value + if !rep { + ext = reflect.New(typ).Elem() + } else { + ext = reflect.New(typ.Elem()).Elem() + } + if err := p.readAny(ext, props); err != nil { + if _, ok := err.(*RequiredNotSetError); !ok { + return err + } + reqFieldErr = err + } + ep := sv.Addr().Interface().(Message) + if !rep { + SetExtension(ep, desc, ext.Interface()) + } else { + old, err := GetExtension(ep, desc) + var sl reflect.Value + if err == nil { + sl = reflect.ValueOf(old) // existing slice + } else { + sl = reflect.MakeSlice(typ, 0, 1) + } + sl = reflect.Append(sl, ext) + SetExtension(ep, desc, sl.Interface()) + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + continue + } + + // This is a normal, non-extension field. + name := tok.value + var dst reflect.Value + fi, props, ok := structFieldByName(sprops, name) + if ok { + dst = sv.Field(fi) + } else if oop, ok := sprops.OneofTypes[name]; ok { + // It is a oneof. + props = oop.Prop + nv := reflect.New(oop.Type.Elem()) + dst = nv.Elem().Field(0) + sv.Field(oop.Field).Set(nv) + } + if !dst.IsValid() { + return p.errorf("unknown field name %q in %v", name, st) + } + + if dst.Kind() == reflect.Map { + // Consume any colon. + if err := p.checkForColon(props, dst.Type()); err != nil { + return err + } + + // Construct the map if it doesn't already exist. + if dst.IsNil() { + dst.Set(reflect.MakeMap(dst.Type())) + } + key := reflect.New(dst.Type().Key()).Elem() + val := reflect.New(dst.Type().Elem()).Elem() + + // The map entry should be this sequence of tokens: + // < key : KEY value : VALUE > + // However, implementations may omit key or value, and technically + // we should support them in any order. See b/28924776 for a time + // this went wrong. + + tok := p.next() + var terminator string + switch tok.value { + case "<": + terminator = ">" + case "{": + terminator = "}" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + for { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == terminator { + break + } + switch tok.value { + case "key": + if err := p.consumeToken(":"); err != nil { + return err + } + if err := p.readAny(key, props.mkeyprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + case "value": + if err := p.checkForColon(props.mvalprop, dst.Type().Elem()); err != nil { + return err + } + if err := p.readAny(val, props.mvalprop); err != nil { + return err + } + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + default: + p.back() + return p.errorf(`expected "key", "value", or %q, found %q`, terminator, tok.value) + } + } + + dst.SetMapIndex(key, val) + continue + } + + // Check that it's not already set if it's not a repeated field. + if !props.Repeated && fieldSet[name] { + return p.errorf("non-repeated field %q was repeated", name) + } + + if err := p.checkForColon(props, dst.Type()); err != nil { + return err + } + + // Parse into the field. + fieldSet[name] = true + if err := p.readAny(dst, props); err != nil { + if _, ok := err.(*RequiredNotSetError); !ok { + return err + } + reqFieldErr = err + } + if props.Required { + reqCount-- + } + + if err := p.consumeOptionalSeparator(); err != nil { + return err + } + + } + + if reqCount > 0 { + return p.missingRequiredFieldError(sv) + } + return reqFieldErr +} + +// consumeExtName consumes extension name or expanded Any type URL and the +// following ']'. It returns the name or URL consumed. +func (p *textParser) consumeExtName() (string, error) { + tok := p.next() + if tok.err != nil { + return "", tok.err + } + + // If extension name or type url is quoted, it's a single token. + if len(tok.value) > 2 && isQuote(tok.value[0]) && tok.value[len(tok.value)-1] == tok.value[0] { + name, err := unquoteC(tok.value[1:len(tok.value)-1], rune(tok.value[0])) + if err != nil { + return "", err + } + return name, p.consumeToken("]") + } + + // Consume everything up to "]" + var parts []string + for tok.value != "]" { + parts = append(parts, tok.value) + tok = p.next() + if tok.err != nil { + return "", p.errorf("unrecognized type_url or extension name: %s", tok.err) + } + } + return strings.Join(parts, ""), nil +} + +// consumeOptionalSeparator consumes an optional semicolon or comma. +// It is used in readStruct to provide backward compatibility. +func (p *textParser) consumeOptionalSeparator() error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value != ";" && tok.value != "," { + p.back() + } + return nil +} + +func (p *textParser) readAny(v reflect.Value, props *Properties) error { + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == "" { + return p.errorf("unexpected EOF") + } + + switch fv := v; fv.Kind() { + case reflect.Slice: + at := v.Type() + if at.Elem().Kind() == reflect.Uint8 { + // Special case for []byte + if tok.value[0] != '"' && tok.value[0] != '\'' { + // Deliberately written out here, as the error after + // this switch statement would write "invalid []byte: ...", + // which is not as user-friendly. + return p.errorf("invalid string: %v", tok.value) + } + bytes := []byte(tok.unquoted) + fv.Set(reflect.ValueOf(bytes)) + return nil + } + // Repeated field. + if tok.value == "[" { + // Repeated field with list notation, like [1,2,3]. + for { + fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) + err := p.readAny(fv.Index(fv.Len()-1), props) + if err != nil { + return err + } + tok := p.next() + if tok.err != nil { + return tok.err + } + if tok.value == "]" { + break + } + if tok.value != "," { + return p.errorf("Expected ']' or ',' found %q", tok.value) + } + } + return nil + } + // One value of the repeated field. + p.back() + fv.Set(reflect.Append(fv, reflect.New(at.Elem()).Elem())) + return p.readAny(fv.Index(fv.Len()-1), props) + case reflect.Bool: + // Either "true", "false", 1 or 0. + switch tok.value { + case "true", "1": + fv.SetBool(true) + return nil + case "false", "0": + fv.SetBool(false) + return nil + } + case reflect.Float32, reflect.Float64: + v := tok.value + // Ignore 'f' for compatibility with output generated by C++, but don't + // remove 'f' when the value is "-inf" or "inf". + if strings.HasSuffix(v, "f") && tok.value != "-inf" && tok.value != "inf" { + v = v[:len(v)-1] + } + if f, err := strconv.ParseFloat(v, fv.Type().Bits()); err == nil { + fv.SetFloat(f) + return nil + } + case reflect.Int32: + if x, err := strconv.ParseInt(tok.value, 0, 32); err == nil { + fv.SetInt(x) + return nil + } + + if len(props.Enum) == 0 { + break + } + m, ok := enumValueMaps[props.Enum] + if !ok { + break + } + x, ok := m[tok.value] + if !ok { + break + } + fv.SetInt(int64(x)) + return nil + case reflect.Int64: + if x, err := strconv.ParseInt(tok.value, 0, 64); err == nil { + fv.SetInt(x) + return nil + } + + case reflect.Ptr: + // A basic field (indirected through pointer), or a repeated message/group + p.back() + fv.Set(reflect.New(fv.Type().Elem())) + return p.readAny(fv.Elem(), props) + case reflect.String: + if tok.value[0] == '"' || tok.value[0] == '\'' { + fv.SetString(tok.unquoted) + return nil + } + case reflect.Struct: + var terminator string + switch tok.value { + case "{": + terminator = "}" + case "<": + terminator = ">" + default: + return p.errorf("expected '{' or '<', found %q", tok.value) + } + // TODO: Handle nested messages which implement encoding.TextUnmarshaler. + return p.readStruct(fv, terminator) + case reflect.Uint32: + if x, err := strconv.ParseUint(tok.value, 0, 32); err == nil { + fv.SetUint(uint64(x)) + return nil + } + case reflect.Uint64: + if x, err := strconv.ParseUint(tok.value, 0, 64); err == nil { + fv.SetUint(x) + return nil + } + } + return p.errorf("invalid %v: %v", v.Type(), tok.value) +} + +// UnmarshalText reads a protocol buffer in Text format. UnmarshalText resets pb +// before starting to unmarshal, so any existing data in pb is always removed. +// If a required field is not set and no other error occurs, +// UnmarshalText returns *RequiredNotSetError. +func UnmarshalText(s string, pb Message) error { + if um, ok := pb.(encoding.TextUnmarshaler); ok { + err := um.UnmarshalText([]byte(s)) + return err + } + pb.Reset() + v := reflect.ValueOf(pb) + if pe := newTextParser(s).readStruct(v.Elem(), ""); pe != nil { + return pe + } + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/.gitignore b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/.gitignore new file mode 100644 index 000000000000..010c242bd8a9 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/.gitignore @@ -0,0 +1,25 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test + +*.swp diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/LICENSE b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/LICENSE new file mode 100644 index 000000000000..5c304d1a4a7b --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/LICENSE @@ -0,0 +1,201 @@ +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. diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/clockwork.go b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/clockwork.go new file mode 100644 index 000000000000..4b6918b522a7 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/github.com/jonboulle/clockwork/clockwork.go @@ -0,0 +1,161 @@ +package clockwork + +import ( + "sync" + "time" +) + +// Clock provides an interface that packages can use instead of directly +// using the time module, so that chronology-related behavior can be tested +type Clock interface { + After(d time.Duration) <-chan time.Time + Sleep(d time.Duration) + Now() time.Time +} + +// FakeClock provides an interface for a clock which can be +// manually advanced through time +type FakeClock interface { + Clock + // Advance advances the FakeClock to a new point in time, ensuring any existing + // sleepers are notified appropriately before returning + Advance(d time.Duration) + // BlockUntil will block until the FakeClock has the given number of + // sleepers (callers of Sleep or After) + BlockUntil(n int) +} + +// NewRealClock returns a Clock which simply delegates calls to the actual time +// package; it should be used by packages in production. +func NewRealClock() Clock { + return &realClock{} +} + +// NewFakeClock returns a FakeClock implementation which can be +// manually advanced through time for testing. +func NewFakeClock() FakeClock { + return &fakeClock{ + l: sync.RWMutex{}, + } +} + +type realClock struct{} + +func (rc *realClock) After(d time.Duration) <-chan time.Time { + return time.After(d) +} + +func (rc *realClock) Sleep(d time.Duration) { + time.Sleep(d) +} + +func (rc *realClock) Now() time.Time { + return time.Now() +} + +type fakeClock struct { + sleepers []*sleeper + blockers []*blocker + time time.Time + + l sync.RWMutex +} + +// sleeper represents a caller of After or Sleep +type sleeper struct { + until time.Time + done chan time.Time +} + +// blocker represents a caller of BlockUntil +type blocker struct { + count int + ch chan struct{} +} + +// After mimics time.After; it waits for the given duration to elapse on the +// fakeClock, then sends the current time on the returned channel. +func (fc *fakeClock) After(d time.Duration) <-chan time.Time { + fc.l.Lock() + defer fc.l.Unlock() + now := fc.time + done := make(chan time.Time, 1) + if d.Nanoseconds() == 0 { + // special case - trigger immediately + done <- now + } else { + // otherwise, add to the set of sleepers + s := &sleeper{ + until: now.Add(d), + done: done, + } + fc.sleepers = append(fc.sleepers, s) + // and notify any blockers + fc.blockers = notifyBlockers(fc.blockers, len(fc.sleepers)) + } + return done +} + +// notifyBlockers notifies all the blockers waiting until the +// given number of sleepers are waiting on the fakeClock. It +// returns an updated slice of blockers (i.e. those still waiting) +func notifyBlockers(blockers []*blocker, count int) (newBlockers []*blocker) { + for _, b := range blockers { + if b.count == count { + close(b.ch) + } else { + newBlockers = append(newBlockers, b) + } + } + return +} + +// Sleep blocks until the given duration has passed on the fakeClock +func (fc *fakeClock) Sleep(d time.Duration) { + <-fc.After(d) +} + +// Time returns the current time of the fakeClock +func (fc *fakeClock) Now() time.Time { + fc.l.Lock() + defer fc.l.Unlock() + return fc.time +} + +// Advance advances fakeClock to a new point in time, ensuring channels from any +// previous invocations of After are notified appropriately before returning +func (fc *fakeClock) Advance(d time.Duration) { + fc.l.Lock() + defer fc.l.Unlock() + end := fc.time.Add(d) + var newSleepers []*sleeper + for _, s := range fc.sleepers { + if end.Sub(s.until) >= 0 { + s.done <- end + } else { + newSleepers = append(newSleepers, s) + } + } + fc.sleepers = newSleepers + fc.blockers = notifyBlockers(fc.blockers, len(fc.sleepers)) + fc.time = end +} + +// BlockUntil will block until the fakeClock has the given number of sleepers +// (callers of Sleep or After) +func (fc *fakeClock) BlockUntil(n int) { + fc.l.Lock() + // Fast path: current number of sleepers is what we're looking for + if len(fc.sleepers) == n { + fc.l.Unlock() + return + } + // Otherwise, set up a new blocker + b := &blocker{ + count: n, + ch: make(chan struct{}), + } + fc.blockers = append(fc.blockers, b) + fc.l.Unlock() + <-b.ch +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go new file mode 100644 index 000000000000..f31d88273674 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go @@ -0,0 +1,64 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.7 + +// Package ctxhttp provides helper functions for performing context-aware HTTP requests. +package ctxhttp + +import ( + "io" + "net/http" + "net/url" + "strings" + + "golang.org/x/net/context" +) + +// Do sends an HTTP request with the provided http.Client and returns +// an HTTP response. +// +// If the client is nil, http.DefaultClient is used. +// +// The provided ctx must be non-nil. If it is canceled or times out, +// ctx.Err() will be returned. +func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { + if client == nil { + client = http.DefaultClient + } + return client.Do(req.WithContext(ctx)) +} + +// Get issues a GET request via the Do function. +func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error) { + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return nil, err + } + return Do(ctx, client, req) +} + +// Head issues a HEAD request via the Do function. +func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error) { + req, err := http.NewRequest("HEAD", url, nil) + if err != nil { + return nil, err + } + return Do(ctx, client, req) +} + +// Post issues a POST request via the Do function. +func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error) { + req, err := http.NewRequest("POST", url, body) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", bodyType) + return Do(ctx, client, req) +} + +// PostForm issues a POST request via the Do function. +func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { + return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go new file mode 100644 index 000000000000..7564b203276a --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go @@ -0,0 +1,147 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.7 + +package ctxhttp + +import ( + "io" + "net/http" + "net/url" + "strings" + + "golang.org/x/net/context" +) + +func nop() {} + +var ( + testHookContextDoneBeforeHeaders = nop + testHookDoReturned = nop + testHookDidBodyClose = nop +) + +// Do sends an HTTP request with the provided http.Client and returns an HTTP response. +// If the client is nil, http.DefaultClient is used. +// If the context is canceled or times out, ctx.Err() will be returned. +func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { + if client == nil { + client = http.DefaultClient + } + + // TODO(djd): Respect any existing value of req.Cancel. + cancel := make(chan struct{}) + req.Cancel = cancel + + type responseAndError struct { + resp *http.Response + err error + } + result := make(chan responseAndError, 1) + + // Make local copies of test hooks closed over by goroutines below. + // Prevents data races in tests. + testHookDoReturned := testHookDoReturned + testHookDidBodyClose := testHookDidBodyClose + + go func() { + resp, err := client.Do(req) + testHookDoReturned() + result <- responseAndError{resp, err} + }() + + var resp *http.Response + + select { + case <-ctx.Done(): + testHookContextDoneBeforeHeaders() + close(cancel) + // Clean up after the goroutine calling client.Do: + go func() { + if r := <-result; r.resp != nil { + testHookDidBodyClose() + r.resp.Body.Close() + } + }() + return nil, ctx.Err() + case r := <-result: + var err error + resp, err = r.resp, r.err + if err != nil { + return resp, err + } + } + + c := make(chan struct{}) + go func() { + select { + case <-ctx.Done(): + close(cancel) + case <-c: + // The response's Body is closed. + } + }() + resp.Body = ¬ifyingReader{resp.Body, c} + + return resp, nil +} + +// Get issues a GET request via the Do function. +func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error) { + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return nil, err + } + return Do(ctx, client, req) +} + +// Head issues a HEAD request via the Do function. +func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error) { + req, err := http.NewRequest("HEAD", url, nil) + if err != nil { + return nil, err + } + return Do(ctx, client, req) +} + +// Post issues a POST request via the Do function. +func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error) { + req, err := http.NewRequest("POST", url, body) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", bodyType) + return Do(ctx, client, req) +} + +// PostForm issues a POST request via the Do function. +func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { + return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) +} + +// notifyingReader is an io.ReadCloser that closes the notify channel after +// Close is called or a Read fails on the underlying ReadCloser. +type notifyingReader struct { + io.ReadCloser + notify chan<- struct{} +} + +func (r *notifyingReader) Read(p []byte) (int, error) { + n, err := r.ReadCloser.Read(p) + if err != nil && r.notify != nil { + close(r.notify) + r.notify = nil + } + return n, err +} + +func (r *notifyingReader) Close() error { + err := r.ReadCloser.Close() + if r.notify != nil { + close(r.notify) + r.notify = nil + } + return err +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/AUTHORS b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/AUTHORS new file mode 100644 index 000000000000..15167cd746c5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/AUTHORS @@ -0,0 +1,3 @@ +# This source code refers to The Go Authors for copyright purposes. +# The master list of authors is in the main Go distribution, +# visible at http://tip.golang.org/AUTHORS. diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/CONTRIBUTING.md b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/CONTRIBUTING.md new file mode 100644 index 000000000000..46aa2b12dda8 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# Contributing to Go + +Go is an open source project. + +It is the work of hundreds of contributors. We appreciate your help! + + +## Filing issues + +When [filing an issue](https://github.com/golang/oauth2/issues), make sure to answer these five questions: + +1. What version of Go are you using (`go version`)? +2. What operating system and processor architecture are you using? +3. What did you do? +4. What did you expect to see? +5. What did you see instead? + +General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. +The gophers there will answer or ask you to file an issue if you've tripped over a bug. + +## Contributing code + +Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) +before sending patches. + +**We do not accept GitHub pull requests** +(we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). + +Unless otherwise noted, the Go source files are distributed under +the BSD-style license found in the LICENSE file. + diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/CONTRIBUTORS b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/CONTRIBUTORS new file mode 100644 index 000000000000..1c4577e96806 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/CONTRIBUTORS @@ -0,0 +1,3 @@ +# This source code was written by the Go contributors. +# The master list of contributors is in the main Go distribution, +# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/LICENSE b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/LICENSE new file mode 100644 index 000000000000..d02f24fd5288 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2009 The oauth2 Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/client_appengine.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/client_appengine.go new file mode 100644 index 000000000000..8962c49d1deb --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/client_appengine.go @@ -0,0 +1,25 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build appengine + +// App Engine hooks. + +package oauth2 + +import ( + "net/http" + + "golang.org/x/net/context" + "golang.org/x/oauth2/internal" + "google.golang.org/appengine/urlfetch" +) + +func init() { + internal.RegisterContextClientFunc(contextClientAppEngine) +} + +func contextClientAppEngine(ctx context.Context) (*http.Client, error) { + return urlfetch.Client(ctx), nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appengine.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appengine.go new file mode 100644 index 000000000000..dc993efb5e10 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appengine.go @@ -0,0 +1,86 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package google + +import ( + "sort" + "strings" + "sync" + "time" + + "golang.org/x/net/context" + "golang.org/x/oauth2" +) + +// Set at init time by appenginevm_hook.go. If true, we are on App Engine Managed VMs. +var appengineVM bool + +// Set at init time by appengine_hook.go. If nil, we're not on App Engine. +var appengineTokenFunc func(c context.Context, scopes ...string) (token string, expiry time.Time, err error) + +// AppEngineTokenSource returns a token source that fetches tokens +// issued to the current App Engine application's service account. +// If you are implementing a 3-legged OAuth 2.0 flow on App Engine +// that involves user accounts, see oauth2.Config instead. +// +// The provided context must have come from appengine.NewContext. +func AppEngineTokenSource(ctx context.Context, scope ...string) oauth2.TokenSource { + if appengineTokenFunc == nil { + panic("google: AppEngineTokenSource can only be used on App Engine.") + } + scopes := append([]string{}, scope...) + sort.Strings(scopes) + return &appEngineTokenSource{ + ctx: ctx, + scopes: scopes, + key: strings.Join(scopes, " "), + } +} + +// aeTokens helps the fetched tokens to be reused until their expiration. +var ( + aeTokensMu sync.Mutex + aeTokens = make(map[string]*tokenLock) // key is space-separated scopes +) + +type tokenLock struct { + mu sync.Mutex // guards t; held while fetching or updating t + t *oauth2.Token +} + +type appEngineTokenSource struct { + ctx context.Context + scopes []string + key string // to aeTokens map; space-separated scopes +} + +func (ts *appEngineTokenSource) Token() (*oauth2.Token, error) { + if appengineTokenFunc == nil { + panic("google: AppEngineTokenSource can only be used on App Engine.") + } + + aeTokensMu.Lock() + tok, ok := aeTokens[ts.key] + if !ok { + tok = &tokenLock{} + aeTokens[ts.key] = tok + } + aeTokensMu.Unlock() + + tok.mu.Lock() + defer tok.mu.Unlock() + if tok.t.Valid() { + return tok.t, nil + } + access, exp, err := appengineTokenFunc(ts.ctx, ts.scopes...) + if err != nil { + return nil, err + } + tok.t = &oauth2.Token{ + AccessToken: access, + Expiry: exp, + } + return tok.t, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appengine_hook.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appengine_hook.go new file mode 100644 index 000000000000..4f42c8b34354 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appengine_hook.go @@ -0,0 +1,13 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build appengine + +package google + +import "google.golang.org/appengine" + +func init() { + appengineTokenFunc = appengine.AccessToken +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appenginevm_hook.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appenginevm_hook.go new file mode 100644 index 000000000000..633611cc3a01 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/appenginevm_hook.go @@ -0,0 +1,14 @@ +// Copyright 2015 The oauth2 Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build appenginevm + +package google + +import "google.golang.org/appengine" + +func init() { + appengineVM = true + appengineTokenFunc = appengine.AccessToken +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/default.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/default.go new file mode 100644 index 000000000000..565d731c45b0 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/default.go @@ -0,0 +1,155 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package google + +import ( + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "net/http" + "os" + "path/filepath" + "runtime" + + "cloud.google.com/go/compute/metadata" + "golang.org/x/net/context" + "golang.org/x/oauth2" + "golang.org/x/oauth2/jwt" +) + +// DefaultClient returns an HTTP Client that uses the +// DefaultTokenSource to obtain authentication credentials. +// +// This client should be used when developing services +// that run on Google App Engine or Google Compute Engine +// and use "Application Default Credentials." +// +// For more details, see: +// https://developers.google.com/accounts/docs/application-default-credentials +// +func DefaultClient(ctx context.Context, scope ...string) (*http.Client, error) { + ts, err := DefaultTokenSource(ctx, scope...) + if err != nil { + return nil, err + } + return oauth2.NewClient(ctx, ts), nil +} + +// DefaultTokenSource is a token source that uses +// "Application Default Credentials". +// +// It looks for credentials in the following places, +// preferring the first location found: +// +// 1. A JSON file whose path is specified by the +// GOOGLE_APPLICATION_CREDENTIALS environment variable. +// 2. A JSON file in a location known to the gcloud command-line tool. +// On Windows, this is %APPDATA%/gcloud/application_default_credentials.json. +// On other systems, $HOME/.config/gcloud/application_default_credentials.json. +// 3. On Google App Engine it uses the appengine.AccessToken function. +// 4. On Google Compute Engine and Google App Engine Managed VMs, it fetches +// credentials from the metadata server. +// (In this final case any provided scopes are ignored.) +// +// For more details, see: +// https://developers.google.com/accounts/docs/application-default-credentials +// +func DefaultTokenSource(ctx context.Context, scope ...string) (oauth2.TokenSource, error) { + // First, try the environment variable. + const envVar = "GOOGLE_APPLICATION_CREDENTIALS" + if filename := os.Getenv(envVar); filename != "" { + ts, err := tokenSourceFromFile(ctx, filename, scope) + if err != nil { + return nil, fmt.Errorf("google: error getting credentials using %v environment variable: %v", envVar, err) + } + return ts, nil + } + + // Second, try a well-known file. + filename := wellKnownFile() + _, err := os.Stat(filename) + if err == nil { + ts, err2 := tokenSourceFromFile(ctx, filename, scope) + if err2 == nil { + return ts, nil + } + err = err2 + } else if os.IsNotExist(err) { + err = nil // ignore this error + } + if err != nil { + return nil, fmt.Errorf("google: error getting credentials using well-known file (%v): %v", filename, err) + } + + // Third, if we're on Google App Engine use those credentials. + if appengineTokenFunc != nil && !appengineVM { + return AppEngineTokenSource(ctx, scope...), nil + } + + // Fourth, if we're on Google Compute Engine use the metadata server. + if metadata.OnGCE() { + return ComputeTokenSource(""), nil + } + + // None are found; return helpful error. + const url = "https://developers.google.com/accounts/docs/application-default-credentials" + return nil, fmt.Errorf("google: could not find default credentials. See %v for more information.", url) +} + +func wellKnownFile() string { + const f = "application_default_credentials.json" + if runtime.GOOS == "windows" { + return filepath.Join(os.Getenv("APPDATA"), "gcloud", f) + } + return filepath.Join(guessUnixHomeDir(), ".config", "gcloud", f) +} + +func tokenSourceFromFile(ctx context.Context, filename string, scopes []string) (oauth2.TokenSource, error) { + b, err := ioutil.ReadFile(filename) + if err != nil { + return nil, err + } + var d struct { + // Common fields + Type string + ClientID string `json:"client_id"` + + // User Credential fields + ClientSecret string `json:"client_secret"` + RefreshToken string `json:"refresh_token"` + + // Service Account fields + ClientEmail string `json:"client_email"` + PrivateKeyID string `json:"private_key_id"` + PrivateKey string `json:"private_key"` + } + if err := json.Unmarshal(b, &d); err != nil { + return nil, err + } + switch d.Type { + case "authorized_user": + cfg := &oauth2.Config{ + ClientID: d.ClientID, + ClientSecret: d.ClientSecret, + Scopes: append([]string{}, scopes...), // copy + Endpoint: Endpoint, + } + tok := &oauth2.Token{RefreshToken: d.RefreshToken} + return cfg.TokenSource(ctx, tok), nil + case "service_account": + cfg := &jwt.Config{ + Email: d.ClientEmail, + PrivateKey: []byte(d.PrivateKey), + Scopes: append([]string{}, scopes...), // copy + TokenURL: JWTTokenURL, + } + return cfg.TokenSource(ctx), nil + case "": + return nil, errors.New("missing 'type' field in credentials") + default: + return nil, fmt.Errorf("unknown credential type: %q", d.Type) + } +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/google.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/google.go new file mode 100644 index 000000000000..4f7352762b34 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/google.go @@ -0,0 +1,153 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package google provides support for making OAuth2 authorized and +// authenticated HTTP requests to Google APIs. +// It supports the Web server flow, client-side credentials, service accounts, +// Google Compute Engine service accounts, and Google App Engine service +// accounts. +// +// For more information, please read +// https://developers.google.com/accounts/docs/OAuth2 +// and +// https://developers.google.com/accounts/docs/application-default-credentials. +package google + +import ( + "encoding/json" + "errors" + "fmt" + "strings" + "time" + + "cloud.google.com/go/compute/metadata" + "golang.org/x/oauth2" + "golang.org/x/oauth2/jwt" +) + +// Endpoint is Google's OAuth 2.0 endpoint. +var Endpoint = oauth2.Endpoint{ + AuthURL: "https://accounts.google.com/o/oauth2/auth", + TokenURL: "https://accounts.google.com/o/oauth2/token", +} + +// JWTTokenURL is Google's OAuth 2.0 token URL to use with the JWT flow. +const JWTTokenURL = "https://accounts.google.com/o/oauth2/token" + +// ConfigFromJSON uses a Google Developers Console client_credentials.json +// file to construct a config. +// client_credentials.json can be downloaded from +// https://console.developers.google.com, under "Credentials". Download the Web +// application credentials in the JSON format and provide the contents of the +// file as jsonKey. +func ConfigFromJSON(jsonKey []byte, scope ...string) (*oauth2.Config, error) { + type cred struct { + ClientID string `json:"client_id"` + ClientSecret string `json:"client_secret"` + RedirectURIs []string `json:"redirect_uris"` + AuthURI string `json:"auth_uri"` + TokenURI string `json:"token_uri"` + } + var j struct { + Web *cred `json:"web"` + Installed *cred `json:"installed"` + } + if err := json.Unmarshal(jsonKey, &j); err != nil { + return nil, err + } + var c *cred + switch { + case j.Web != nil: + c = j.Web + case j.Installed != nil: + c = j.Installed + default: + return nil, fmt.Errorf("oauth2/google: no credentials found") + } + if len(c.RedirectURIs) < 1 { + return nil, errors.New("oauth2/google: missing redirect URL in the client_credentials.json") + } + return &oauth2.Config{ + ClientID: c.ClientID, + ClientSecret: c.ClientSecret, + RedirectURL: c.RedirectURIs[0], + Scopes: scope, + Endpoint: oauth2.Endpoint{ + AuthURL: c.AuthURI, + TokenURL: c.TokenURI, + }, + }, nil +} + +// JWTConfigFromJSON uses a Google Developers service account JSON key file to read +// the credentials that authorize and authenticate the requests. +// Create a service account on "Credentials" for your project at +// https://console.developers.google.com to download a JSON key file. +func JWTConfigFromJSON(jsonKey []byte, scope ...string) (*jwt.Config, error) { + var key struct { + Email string `json:"client_email"` + PrivateKey string `json:"private_key"` + PrivateKeyID string `json:"private_key_id"` + TokenURL string `json:"token_uri"` + } + if err := json.Unmarshal(jsonKey, &key); err != nil { + return nil, err + } + config := &jwt.Config{ + Email: key.Email, + PrivateKey: []byte(key.PrivateKey), + PrivateKeyID: key.PrivateKeyID, + Scopes: scope, + TokenURL: key.TokenURL, + } + if config.TokenURL == "" { + config.TokenURL = JWTTokenURL + } + return config, nil +} + +// ComputeTokenSource returns a token source that fetches access tokens +// from Google Compute Engine (GCE)'s metadata server. It's only valid to use +// this token source if your program is running on a GCE instance. +// If no account is specified, "default" is used. +// Further information about retrieving access tokens from the GCE metadata +// server can be found at https://cloud.google.com/compute/docs/authentication. +func ComputeTokenSource(account string) oauth2.TokenSource { + return oauth2.ReuseTokenSource(nil, computeSource{account: account}) +} + +type computeSource struct { + account string +} + +func (cs computeSource) Token() (*oauth2.Token, error) { + if !metadata.OnGCE() { + return nil, errors.New("oauth2/google: can't get a token from the metadata service; not running on GCE") + } + acct := cs.account + if acct == "" { + acct = "default" + } + tokenJSON, err := metadata.Get("instance/service-accounts/" + acct + "/token") + if err != nil { + return nil, err + } + var res struct { + AccessToken string `json:"access_token"` + ExpiresInSec int `json:"expires_in"` + TokenType string `json:"token_type"` + } + err = json.NewDecoder(strings.NewReader(tokenJSON)).Decode(&res) + if err != nil { + return nil, fmt.Errorf("oauth2/google: invalid token JSON from metadata: %v", err) + } + if res.ExpiresInSec == 0 || res.AccessToken == "" { + return nil, fmt.Errorf("oauth2/google: incomplete token received from metadata") + } + return &oauth2.Token{ + AccessToken: res.AccessToken, + TokenType: res.TokenType, + Expiry: time.Now().Add(time.Duration(res.ExpiresInSec) * time.Second), + }, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/jwt.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/jwt.go new file mode 100644 index 000000000000..b0fdb3a888ac --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/jwt.go @@ -0,0 +1,74 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package google + +import ( + "crypto/rsa" + "fmt" + "time" + + "golang.org/x/oauth2" + "golang.org/x/oauth2/internal" + "golang.org/x/oauth2/jws" +) + +// JWTAccessTokenSourceFromJSON uses a Google Developers service account JSON +// key file to read the credentials that authorize and authenticate the +// requests, and returns a TokenSource that does not use any OAuth2 flow but +// instead creates a JWT and sends that as the access token. +// The audience is typically a URL that specifies the scope of the credentials. +// +// Note that this is not a standard OAuth flow, but rather an +// optimization supported by a few Google services. +// Unless you know otherwise, you should use JWTConfigFromJSON instead. +func JWTAccessTokenSourceFromJSON(jsonKey []byte, audience string) (oauth2.TokenSource, error) { + cfg, err := JWTConfigFromJSON(jsonKey) + if err != nil { + return nil, fmt.Errorf("google: could not parse JSON key: %v", err) + } + pk, err := internal.ParseKey(cfg.PrivateKey) + if err != nil { + return nil, fmt.Errorf("google: could not parse key: %v", err) + } + ts := &jwtAccessTokenSource{ + email: cfg.Email, + audience: audience, + pk: pk, + pkID: cfg.PrivateKeyID, + } + tok, err := ts.Token() + if err != nil { + return nil, err + } + return oauth2.ReuseTokenSource(tok, ts), nil +} + +type jwtAccessTokenSource struct { + email, audience string + pk *rsa.PrivateKey + pkID string +} + +func (ts *jwtAccessTokenSource) Token() (*oauth2.Token, error) { + iat := time.Now() + exp := iat.Add(time.Hour) + cs := &jws.ClaimSet{ + Iss: ts.email, + Sub: ts.email, + Aud: ts.audience, + Iat: iat.Unix(), + Exp: exp.Unix(), + } + hdr := &jws.Header{ + Algorithm: "RS256", + Typ: "JWT", + KeyID: string(ts.pkID), + } + msg, err := jws.Encode(hdr, cs, ts.pk) + if err != nil { + return nil, fmt.Errorf("google: could not encode JWT: %v", err) + } + return &oauth2.Token{AccessToken: msg, TokenType: "Bearer", Expiry: exp}, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/sdk.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/sdk.go new file mode 100644 index 000000000000..d29a3bb9bbc5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/google/sdk.go @@ -0,0 +1,168 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package google + +import ( + "encoding/json" + "errors" + "fmt" + "net/http" + "os" + "os/user" + "path/filepath" + "runtime" + "strings" + "time" + + "golang.org/x/net/context" + "golang.org/x/oauth2" + "golang.org/x/oauth2/internal" +) + +type sdkCredentials struct { + Data []struct { + Credential struct { + ClientID string `json:"client_id"` + ClientSecret string `json:"client_secret"` + AccessToken string `json:"access_token"` + RefreshToken string `json:"refresh_token"` + TokenExpiry *time.Time `json:"token_expiry"` + } `json:"credential"` + Key struct { + Account string `json:"account"` + Scope string `json:"scope"` + } `json:"key"` + } +} + +// An SDKConfig provides access to tokens from an account already +// authorized via the Google Cloud SDK. +type SDKConfig struct { + conf oauth2.Config + initialToken *oauth2.Token +} + +// NewSDKConfig creates an SDKConfig for the given Google Cloud SDK +// account. If account is empty, the account currently active in +// Google Cloud SDK properties is used. +// Google Cloud SDK credentials must be created by running `gcloud auth` +// before using this function. +// The Google Cloud SDK is available at https://cloud.google.com/sdk/. +func NewSDKConfig(account string) (*SDKConfig, error) { + configPath, err := sdkConfigPath() + if err != nil { + return nil, fmt.Errorf("oauth2/google: error getting SDK config path: %v", err) + } + credentialsPath := filepath.Join(configPath, "credentials") + f, err := os.Open(credentialsPath) + if err != nil { + return nil, fmt.Errorf("oauth2/google: failed to load SDK credentials: %v", err) + } + defer f.Close() + + var c sdkCredentials + if err := json.NewDecoder(f).Decode(&c); err != nil { + return nil, fmt.Errorf("oauth2/google: failed to decode SDK credentials from %q: %v", credentialsPath, err) + } + if len(c.Data) == 0 { + return nil, fmt.Errorf("oauth2/google: no credentials found in %q, run `gcloud auth login` to create one", credentialsPath) + } + if account == "" { + propertiesPath := filepath.Join(configPath, "properties") + f, err := os.Open(propertiesPath) + if err != nil { + return nil, fmt.Errorf("oauth2/google: failed to load SDK properties: %v", err) + } + defer f.Close() + ini, err := internal.ParseINI(f) + if err != nil { + return nil, fmt.Errorf("oauth2/google: failed to parse SDK properties %q: %v", propertiesPath, err) + } + core, ok := ini["core"] + if !ok { + return nil, fmt.Errorf("oauth2/google: failed to find [core] section in %v", ini) + } + active, ok := core["account"] + if !ok { + return nil, fmt.Errorf("oauth2/google: failed to find %q attribute in %v", "account", core) + } + account = active + } + + for _, d := range c.Data { + if account == "" || d.Key.Account == account { + if d.Credential.AccessToken == "" && d.Credential.RefreshToken == "" { + return nil, fmt.Errorf("oauth2/google: no token available for account %q", account) + } + var expiry time.Time + if d.Credential.TokenExpiry != nil { + expiry = *d.Credential.TokenExpiry + } + return &SDKConfig{ + conf: oauth2.Config{ + ClientID: d.Credential.ClientID, + ClientSecret: d.Credential.ClientSecret, + Scopes: strings.Split(d.Key.Scope, " "), + Endpoint: Endpoint, + RedirectURL: "oob", + }, + initialToken: &oauth2.Token{ + AccessToken: d.Credential.AccessToken, + RefreshToken: d.Credential.RefreshToken, + Expiry: expiry, + }, + }, nil + } + } + return nil, fmt.Errorf("oauth2/google: no such credentials for account %q", account) +} + +// Client returns an HTTP client using Google Cloud SDK credentials to +// authorize requests. The token will auto-refresh as necessary. The +// underlying http.RoundTripper will be obtained using the provided +// context. The returned client and its Transport should not be +// modified. +func (c *SDKConfig) Client(ctx context.Context) *http.Client { + return &http.Client{ + Transport: &oauth2.Transport{ + Source: c.TokenSource(ctx), + }, + } +} + +// TokenSource returns an oauth2.TokenSource that retrieve tokens from +// Google Cloud SDK credentials using the provided context. +// It will returns the current access token stored in the credentials, +// and refresh it when it expires, but it won't update the credentials +// with the new access token. +func (c *SDKConfig) TokenSource(ctx context.Context) oauth2.TokenSource { + return c.conf.TokenSource(ctx, c.initialToken) +} + +// Scopes are the OAuth 2.0 scopes the current account is authorized for. +func (c *SDKConfig) Scopes() []string { + return c.conf.Scopes +} + +// sdkConfigPath tries to guess where the gcloud config is located. +// It can be overridden during tests. +var sdkConfigPath = func() (string, error) { + if runtime.GOOS == "windows" { + return filepath.Join(os.Getenv("APPDATA"), "gcloud"), nil + } + homeDir := guessUnixHomeDir() + if homeDir == "" { + return "", errors.New("unable to get current user home directory: os/user lookup failed; $HOME is empty") + } + return filepath.Join(homeDir, ".config", "gcloud"), nil +} + +func guessUnixHomeDir() string { + usr, err := user.Current() + if err == nil { + return usr.HomeDir + } + return os.Getenv("HOME") +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/oauth2.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/oauth2.go new file mode 100644 index 000000000000..fbe1028d64e5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/oauth2.go @@ -0,0 +1,76 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package internal contains support packages for oauth2 package. +package internal + +import ( + "bufio" + "crypto/rsa" + "crypto/x509" + "encoding/pem" + "errors" + "fmt" + "io" + "strings" +) + +// ParseKey converts the binary contents of a private key file +// to an *rsa.PrivateKey. It detects whether the private key is in a +// PEM container or not. If so, it extracts the the private key +// from PEM container before conversion. It only supports PEM +// containers with no passphrase. +func ParseKey(key []byte) (*rsa.PrivateKey, error) { + block, _ := pem.Decode(key) + if block != nil { + key = block.Bytes + } + parsedKey, err := x509.ParsePKCS8PrivateKey(key) + if err != nil { + parsedKey, err = x509.ParsePKCS1PrivateKey(key) + if err != nil { + return nil, fmt.Errorf("private key should be a PEM or plain PKSC1 or PKCS8; parse error: %v", err) + } + } + parsed, ok := parsedKey.(*rsa.PrivateKey) + if !ok { + return nil, errors.New("private key is invalid") + } + return parsed, nil +} + +func ParseINI(ini io.Reader) (map[string]map[string]string, error) { + result := map[string]map[string]string{ + "": map[string]string{}, // root section + } + scanner := bufio.NewScanner(ini) + currentSection := "" + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if strings.HasPrefix(line, ";") { + // comment. + continue + } + if strings.HasPrefix(line, "[") && strings.HasSuffix(line, "]") { + currentSection = strings.TrimSpace(line[1 : len(line)-1]) + result[currentSection] = map[string]string{} + continue + } + parts := strings.SplitN(line, "=", 2) + if len(parts) == 2 && parts[0] != "" { + result[currentSection][strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) + } + } + if err := scanner.Err(); err != nil { + return nil, fmt.Errorf("error scanning ini: %v", err) + } + return result, nil +} + +func CondVal(v string) []string { + if v == "" { + return nil + } + return []string{v} +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/token.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/token.go new file mode 100644 index 000000000000..18328a0dcf2e --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/token.go @@ -0,0 +1,225 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package internal contains support packages for oauth2 package. +package internal + +import ( + "encoding/json" + "fmt" + "io" + "io/ioutil" + "mime" + "net/http" + "net/url" + "strconv" + "strings" + "time" + + "golang.org/x/net/context" +) + +// Token represents the crendentials used to authorize +// the requests to access protected resources on the OAuth 2.0 +// provider's backend. +// +// This type is a mirror of oauth2.Token and exists to break +// an otherwise-circular dependency. Other internal packages +// should convert this Token into an oauth2.Token before use. +type Token struct { + // AccessToken is the token that authorizes and authenticates + // the requests. + AccessToken string + + // TokenType is the type of token. + // The Type method returns either this or "Bearer", the default. + TokenType string + + // RefreshToken is a token that's used by the application + // (as opposed to the user) to refresh the access token + // if it expires. + RefreshToken string + + // Expiry is the optional expiration time of the access token. + // + // If zero, TokenSource implementations will reuse the same + // token forever and RefreshToken or equivalent + // mechanisms for that TokenSource will not be used. + Expiry time.Time + + // Raw optionally contains extra metadata from the server + // when updating a token. + Raw interface{} +} + +// tokenJSON is the struct representing the HTTP response from OAuth2 +// providers returning a token in JSON form. +type tokenJSON struct { + AccessToken string `json:"access_token"` + TokenType string `json:"token_type"` + RefreshToken string `json:"refresh_token"` + ExpiresIn expirationTime `json:"expires_in"` // at least PayPal returns string, while most return number + Expires expirationTime `json:"expires"` // broken Facebook spelling of expires_in +} + +func (e *tokenJSON) expiry() (t time.Time) { + if v := e.ExpiresIn; v != 0 { + return time.Now().Add(time.Duration(v) * time.Second) + } + if v := e.Expires; v != 0 { + return time.Now().Add(time.Duration(v) * time.Second) + } + return +} + +type expirationTime int32 + +func (e *expirationTime) UnmarshalJSON(b []byte) error { + var n json.Number + err := json.Unmarshal(b, &n) + if err != nil { + return err + } + i, err := n.Int64() + if err != nil { + return err + } + *e = expirationTime(i) + return nil +} + +var brokenAuthHeaderProviders = []string{ + "https://accounts.google.com/", + "https://api.dropbox.com/", + "https://api.dropboxapi.com/", + "https://api.instagram.com/", + "https://api.netatmo.net/", + "https://api.odnoklassniki.ru/", + "https://api.pushbullet.com/", + "https://api.soundcloud.com/", + "https://api.twitch.tv/", + "https://app.box.com/", + "https://connect.stripe.com/", + "https://login.microsoftonline.com/", + "https://login.salesforce.com/", + "https://oauth.sandbox.trainingpeaks.com/", + "https://oauth.trainingpeaks.com/", + "https://oauth.vk.com/", + "https://openapi.baidu.com/", + "https://slack.com/", + "https://test-sandbox.auth.corp.google.com", + "https://test.salesforce.com/", + "https://user.gini.net/", + "https://www.douban.com/", + "https://www.googleapis.com/", + "https://www.linkedin.com/", + "https://www.strava.com/oauth/", + "https://www.wunderlist.com/oauth/", + "https://api.patreon.com/", +} + +func RegisterBrokenAuthHeaderProvider(tokenURL string) { + brokenAuthHeaderProviders = append(brokenAuthHeaderProviders, tokenURL) +} + +// providerAuthHeaderWorks reports whether the OAuth2 server identified by the tokenURL +// implements the OAuth2 spec correctly +// See https://code.google.com/p/goauth2/issues/detail?id=31 for background. +// In summary: +// - Reddit only accepts client secret in the Authorization header +// - Dropbox accepts either it in URL param or Auth header, but not both. +// - Google only accepts URL param (not spec compliant?), not Auth header +// - Stripe only accepts client secret in Auth header with Bearer method, not Basic +func providerAuthHeaderWorks(tokenURL string) bool { + for _, s := range brokenAuthHeaderProviders { + if strings.HasPrefix(tokenURL, s) { + // Some sites fail to implement the OAuth2 spec fully. + return false + } + } + + // Assume the provider implements the spec properly + // otherwise. We can add more exceptions as they're + // discovered. We will _not_ be adding configurable hooks + // to this package to let users select server bugs. + return true +} + +func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string, v url.Values) (*Token, error) { + hc, err := ContextClient(ctx) + if err != nil { + return nil, err + } + v.Set("client_id", clientID) + bustedAuth := !providerAuthHeaderWorks(tokenURL) + if bustedAuth && clientSecret != "" { + v.Set("client_secret", clientSecret) + } + req, err := http.NewRequest("POST", tokenURL, strings.NewReader(v.Encode())) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + if !bustedAuth { + req.SetBasicAuth(clientID, clientSecret) + } + r, err := hc.Do(req) + if err != nil { + return nil, err + } + defer r.Body.Close() + body, err := ioutil.ReadAll(io.LimitReader(r.Body, 1<<20)) + if err != nil { + return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err) + } + if code := r.StatusCode; code < 200 || code > 299 { + return nil, fmt.Errorf("oauth2: cannot fetch token: %v\nResponse: %s", r.Status, body) + } + + var token *Token + content, _, _ := mime.ParseMediaType(r.Header.Get("Content-Type")) + switch content { + case "application/x-www-form-urlencoded", "text/plain": + vals, err := url.ParseQuery(string(body)) + if err != nil { + return nil, err + } + token = &Token{ + AccessToken: vals.Get("access_token"), + TokenType: vals.Get("token_type"), + RefreshToken: vals.Get("refresh_token"), + Raw: vals, + } + e := vals.Get("expires_in") + if e == "" { + // TODO(jbd): Facebook's OAuth2 implementation is broken and + // returns expires_in field in expires. Remove the fallback to expires, + // when Facebook fixes their implementation. + e = vals.Get("expires") + } + expires, _ := strconv.Atoi(e) + if expires != 0 { + token.Expiry = time.Now().Add(time.Duration(expires) * time.Second) + } + default: + var tj tokenJSON + if err = json.Unmarshal(body, &tj); err != nil { + return nil, err + } + token = &Token{ + AccessToken: tj.AccessToken, + TokenType: tj.TokenType, + RefreshToken: tj.RefreshToken, + Expiry: tj.expiry(), + Raw: make(map[string]interface{}), + } + json.Unmarshal(body, &token.Raw) // no error checks for optional fields + } + // Don't overwrite `RefreshToken` with an empty value + // if this was a token refreshing request. + if token.RefreshToken == "" { + token.RefreshToken = v.Get("refresh_token") + } + return token, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/transport.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/transport.go new file mode 100644 index 000000000000..f1f173e345db --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/internal/transport.go @@ -0,0 +1,69 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package internal contains support packages for oauth2 package. +package internal + +import ( + "net/http" + + "golang.org/x/net/context" +) + +// HTTPClient is the context key to use with golang.org/x/net/context's +// WithValue function to associate an *http.Client value with a context. +var HTTPClient ContextKey + +// ContextKey is just an empty struct. It exists so HTTPClient can be +// an immutable public variable with a unique type. It's immutable +// because nobody else can create a ContextKey, being unexported. +type ContextKey struct{} + +// ContextClientFunc is a func which tries to return an *http.Client +// given a Context value. If it returns an error, the search stops +// with that error. If it returns (nil, nil), the search continues +// down the list of registered funcs. +type ContextClientFunc func(context.Context) (*http.Client, error) + +var contextClientFuncs []ContextClientFunc + +func RegisterContextClientFunc(fn ContextClientFunc) { + contextClientFuncs = append(contextClientFuncs, fn) +} + +func ContextClient(ctx context.Context) (*http.Client, error) { + if ctx != nil { + if hc, ok := ctx.Value(HTTPClient).(*http.Client); ok { + return hc, nil + } + } + for _, fn := range contextClientFuncs { + c, err := fn(ctx) + if err != nil { + return nil, err + } + if c != nil { + return c, nil + } + } + return http.DefaultClient, nil +} + +func ContextTransport(ctx context.Context) http.RoundTripper { + hc, err := ContextClient(ctx) + // This is a rare error case (somebody using nil on App Engine). + if err != nil { + return ErrorTransport{err} + } + return hc.Transport +} + +// ErrorTransport returns the specified error on RoundTrip. +// This RoundTripper should be used in rare error cases where +// error handling can be postponed to response handling time. +type ErrorTransport struct{ Err error } + +func (t ErrorTransport) RoundTrip(*http.Request) (*http.Response, error) { + return nil, t.Err +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/jws/jws.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/jws/jws.go new file mode 100644 index 000000000000..8bcecb46ba5f --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/jws/jws.go @@ -0,0 +1,182 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package jws provides a partial implementation +// of JSON Web Signature encoding and decoding. +// It exists to support the golang.org/x/oauth2 package. +// +// See RFC 7515. +// +// Deprecated: this package is not intended for public use and might be +// removed in the future. It exists for internal use only. +// Please switch to another JWS package or copy this package into your own +// source tree. +package jws + +import ( + "bytes" + "crypto" + "crypto/rand" + "crypto/rsa" + "crypto/sha256" + "encoding/base64" + "encoding/json" + "errors" + "fmt" + "strings" + "time" +) + +// ClaimSet contains information about the JWT signature including the +// permissions being requested (scopes), the target of the token, the issuer, +// the time the token was issued, and the lifetime of the token. +type ClaimSet struct { + Iss string `json:"iss"` // email address of the client_id of the application making the access token request + Scope string `json:"scope,omitempty"` // space-delimited list of the permissions the application requests + Aud string `json:"aud"` // descriptor of the intended target of the assertion (Optional). + Exp int64 `json:"exp"` // the expiration time of the assertion (seconds since Unix epoch) + Iat int64 `json:"iat"` // the time the assertion was issued (seconds since Unix epoch) + Typ string `json:"typ,omitempty"` // token type (Optional). + + // Email for which the application is requesting delegated access (Optional). + Sub string `json:"sub,omitempty"` + + // The old name of Sub. Client keeps setting Prn to be + // complaint with legacy OAuth 2.0 providers. (Optional) + Prn string `json:"prn,omitempty"` + + // See http://tools.ietf.org/html/draft-jones-json-web-token-10#section-4.3 + // This array is marshalled using custom code (see (c *ClaimSet) encode()). + PrivateClaims map[string]interface{} `json:"-"` +} + +func (c *ClaimSet) encode() (string, error) { + // Reverting time back for machines whose time is not perfectly in sync. + // If client machine's time is in the future according + // to Google servers, an access token will not be issued. + now := time.Now().Add(-10 * time.Second) + if c.Iat == 0 { + c.Iat = now.Unix() + } + if c.Exp == 0 { + c.Exp = now.Add(time.Hour).Unix() + } + if c.Exp < c.Iat { + return "", fmt.Errorf("jws: invalid Exp = %v; must be later than Iat = %v", c.Exp, c.Iat) + } + + b, err := json.Marshal(c) + if err != nil { + return "", err + } + + if len(c.PrivateClaims) == 0 { + return base64.RawURLEncoding.EncodeToString(b), nil + } + + // Marshal private claim set and then append it to b. + prv, err := json.Marshal(c.PrivateClaims) + if err != nil { + return "", fmt.Errorf("jws: invalid map of private claims %v", c.PrivateClaims) + } + + // Concatenate public and private claim JSON objects. + if !bytes.HasSuffix(b, []byte{'}'}) { + return "", fmt.Errorf("jws: invalid JSON %s", b) + } + if !bytes.HasPrefix(prv, []byte{'{'}) { + return "", fmt.Errorf("jws: invalid JSON %s", prv) + } + b[len(b)-1] = ',' // Replace closing curly brace with a comma. + b = append(b, prv[1:]...) // Append private claims. + return base64.RawURLEncoding.EncodeToString(b), nil +} + +// Header represents the header for the signed JWS payloads. +type Header struct { + // The algorithm used for signature. + Algorithm string `json:"alg"` + + // Represents the token type. + Typ string `json:"typ"` + + // The optional hint of which key is being used. + KeyID string `json:"kid,omitempty"` +} + +func (h *Header) encode() (string, error) { + b, err := json.Marshal(h) + if err != nil { + return "", err + } + return base64.RawURLEncoding.EncodeToString(b), nil +} + +// Decode decodes a claim set from a JWS payload. +func Decode(payload string) (*ClaimSet, error) { + // decode returned id token to get expiry + s := strings.Split(payload, ".") + if len(s) < 2 { + // TODO(jbd): Provide more context about the error. + return nil, errors.New("jws: invalid token received") + } + decoded, err := base64.RawURLEncoding.DecodeString(s[1]) + if err != nil { + return nil, err + } + c := &ClaimSet{} + err = json.NewDecoder(bytes.NewBuffer(decoded)).Decode(c) + return c, err +} + +// Signer returns a signature for the given data. +type Signer func(data []byte) (sig []byte, err error) + +// EncodeWithSigner encodes a header and claim set with the provided signer. +func EncodeWithSigner(header *Header, c *ClaimSet, sg Signer) (string, error) { + head, err := header.encode() + if err != nil { + return "", err + } + cs, err := c.encode() + if err != nil { + return "", err + } + ss := fmt.Sprintf("%s.%s", head, cs) + sig, err := sg([]byte(ss)) + if err != nil { + return "", err + } + return fmt.Sprintf("%s.%s", ss, base64.RawURLEncoding.EncodeToString(sig)), nil +} + +// Encode encodes a signed JWS with provided header and claim set. +// This invokes EncodeWithSigner using crypto/rsa.SignPKCS1v15 with the given RSA private key. +func Encode(header *Header, c *ClaimSet, key *rsa.PrivateKey) (string, error) { + sg := func(data []byte) (sig []byte, err error) { + h := sha256.New() + h.Write(data) + return rsa.SignPKCS1v15(rand.Reader, key, crypto.SHA256, h.Sum(nil)) + } + return EncodeWithSigner(header, c, sg) +} + +// Verify tests whether the provided JWT token's signature was produced by the private key +// associated with the supplied public key. +func Verify(token string, key *rsa.PublicKey) error { + parts := strings.Split(token, ".") + if len(parts) != 3 { + return errors.New("jws: invalid token received, token must have 3 parts") + } + + signedContent := parts[0] + "." + parts[1] + signatureString, err := base64.RawURLEncoding.DecodeString(parts[2]) + if err != nil { + return err + } + + h := sha256.New() + h.Write([]byte(signedContent)) + return rsa.VerifyPKCS1v15(key, crypto.SHA256, h.Sum(nil), []byte(signatureString)) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/jwt/jwt.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/jwt/jwt.go new file mode 100644 index 000000000000..f4b9523e6e4c --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/jwt/jwt.go @@ -0,0 +1,157 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package jwt implements the OAuth 2.0 JSON Web Token flow, commonly +// known as "two-legged OAuth 2.0". +// +// See: https://tools.ietf.org/html/draft-ietf-oauth-jwt-bearer-12 +package jwt + +import ( + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "net/url" + "strings" + "time" + + "golang.org/x/net/context" + "golang.org/x/oauth2" + "golang.org/x/oauth2/internal" + "golang.org/x/oauth2/jws" +) + +var ( + defaultGrantType = "urn:ietf:params:oauth:grant-type:jwt-bearer" + defaultHeader = &jws.Header{Algorithm: "RS256", Typ: "JWT"} +) + +// Config is the configuration for using JWT to fetch tokens, +// commonly known as "two-legged OAuth 2.0". +type Config struct { + // Email is the OAuth client identifier used when communicating with + // the configured OAuth provider. + Email string + + // PrivateKey contains the contents of an RSA private key or the + // contents of a PEM file that contains a private key. The provided + // private key is used to sign JWT payloads. + // PEM containers with a passphrase are not supported. + // Use the following command to convert a PKCS 12 file into a PEM. + // + // $ openssl pkcs12 -in key.p12 -out key.pem -nodes + // + PrivateKey []byte + + // PrivateKeyID contains an optional hint indicating which key is being + // used. + PrivateKeyID string + + // Subject is the optional user to impersonate. + Subject string + + // Scopes optionally specifies a list of requested permission scopes. + Scopes []string + + // TokenURL is the endpoint required to complete the 2-legged JWT flow. + TokenURL string + + // Expires optionally specifies how long the token is valid for. + Expires time.Duration +} + +// TokenSource returns a JWT TokenSource using the configuration +// in c and the HTTP client from the provided context. +func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource { + return oauth2.ReuseTokenSource(nil, jwtSource{ctx, c}) +} + +// Client returns an HTTP client wrapping the context's +// HTTP transport and adding Authorization headers with tokens +// obtained from c. +// +// The returned client and its Transport should not be modified. +func (c *Config) Client(ctx context.Context) *http.Client { + return oauth2.NewClient(ctx, c.TokenSource(ctx)) +} + +// jwtSource is a source that always does a signed JWT request for a token. +// It should typically be wrapped with a reuseTokenSource. +type jwtSource struct { + ctx context.Context + conf *Config +} + +func (js jwtSource) Token() (*oauth2.Token, error) { + pk, err := internal.ParseKey(js.conf.PrivateKey) + if err != nil { + return nil, err + } + hc := oauth2.NewClient(js.ctx, nil) + claimSet := &jws.ClaimSet{ + Iss: js.conf.Email, + Scope: strings.Join(js.conf.Scopes, " "), + Aud: js.conf.TokenURL, + } + if subject := js.conf.Subject; subject != "" { + claimSet.Sub = subject + // prn is the old name of sub. Keep setting it + // to be compatible with legacy OAuth 2.0 providers. + claimSet.Prn = subject + } + if t := js.conf.Expires; t > 0 { + claimSet.Exp = time.Now().Add(t).Unix() + } + payload, err := jws.Encode(defaultHeader, claimSet, pk) + if err != nil { + return nil, err + } + v := url.Values{} + v.Set("grant_type", defaultGrantType) + v.Set("assertion", payload) + resp, err := hc.PostForm(js.conf.TokenURL, v) + if err != nil { + return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err) + } + defer resp.Body.Close() + body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20)) + if err != nil { + return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err) + } + if c := resp.StatusCode; c < 200 || c > 299 { + return nil, fmt.Errorf("oauth2: cannot fetch token: %v\nResponse: %s", resp.Status, body) + } + // tokenRes is the JSON response body. + var tokenRes struct { + AccessToken string `json:"access_token"` + TokenType string `json:"token_type"` + IDToken string `json:"id_token"` + ExpiresIn int64 `json:"expires_in"` // relative seconds from now + } + if err := json.Unmarshal(body, &tokenRes); err != nil { + return nil, fmt.Errorf("oauth2: cannot fetch token: %v", err) + } + token := &oauth2.Token{ + AccessToken: tokenRes.AccessToken, + TokenType: tokenRes.TokenType, + } + raw := make(map[string]interface{}) + json.Unmarshal(body, &raw) // no error checks for optional fields + token = token.WithExtra(raw) + + if secs := tokenRes.ExpiresIn; secs > 0 { + token.Expiry = time.Now().Add(time.Duration(secs) * time.Second) + } + if v := tokenRes.IDToken; v != "" { + // decode returned id token to get expiry + claimSet, err := jws.Decode(v) + if err != nil { + return nil, fmt.Errorf("oauth2: error decoding JWT token: %v", err) + } + token.Expiry = time.Unix(claimSet.Exp, 0) + } + return token, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/oauth2.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/oauth2.go new file mode 100644 index 000000000000..798edc809fb5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/oauth2.go @@ -0,0 +1,341 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package oauth2 provides support for making +// OAuth2 authorized and authenticated HTTP requests. +// It can additionally grant authorization with Bearer JWT. +package oauth2 + +import ( + "bytes" + "errors" + "net/http" + "net/url" + "strings" + "sync" + + "golang.org/x/net/context" + "golang.org/x/oauth2/internal" +) + +// NoContext is the default context you should supply if not using +// your own context.Context (see https://golang.org/x/net/context). +// +// Deprecated: Use context.Background() or context.TODO() instead. +var NoContext = context.TODO() + +// RegisterBrokenAuthHeaderProvider registers an OAuth2 server +// identified by the tokenURL prefix as an OAuth2 implementation +// which doesn't support the HTTP Basic authentication +// scheme to authenticate with the authorization server. +// Once a server is registered, credentials (client_id and client_secret) +// will be passed as query parameters rather than being present +// in the Authorization header. +// See https://code.google.com/p/goauth2/issues/detail?id=31 for background. +func RegisterBrokenAuthHeaderProvider(tokenURL string) { + internal.RegisterBrokenAuthHeaderProvider(tokenURL) +} + +// Config describes a typical 3-legged OAuth2 flow, with both the +// client application information and the server's endpoint URLs. +// For the client credentials 2-legged OAuth2 flow, see the clientcredentials +// package (https://golang.org/x/oauth2/clientcredentials). +type Config struct { + // ClientID is the application's ID. + ClientID string + + // ClientSecret is the application's secret. + ClientSecret string + + // Endpoint contains the resource server's token endpoint + // URLs. These are constants specific to each server and are + // often available via site-specific packages, such as + // google.Endpoint or github.Endpoint. + Endpoint Endpoint + + // RedirectURL is the URL to redirect users going through + // the OAuth flow, after the resource owner's URLs. + RedirectURL string + + // Scope specifies optional requested permissions. + Scopes []string +} + +// A TokenSource is anything that can return a token. +type TokenSource interface { + // Token returns a token or an error. + // Token must be safe for concurrent use by multiple goroutines. + // The returned Token must not be modified. + Token() (*Token, error) +} + +// Endpoint contains the OAuth 2.0 provider's authorization and token +// endpoint URLs. +type Endpoint struct { + AuthURL string + TokenURL string +} + +var ( + // AccessTypeOnline and AccessTypeOffline are options passed + // to the Options.AuthCodeURL method. They modify the + // "access_type" field that gets sent in the URL returned by + // AuthCodeURL. + // + // Online is the default if neither is specified. If your + // application needs to refresh access tokens when the user + // is not present at the browser, then use offline. This will + // result in your application obtaining a refresh token the + // first time your application exchanges an authorization + // code for a user. + AccessTypeOnline AuthCodeOption = SetAuthURLParam("access_type", "online") + AccessTypeOffline AuthCodeOption = SetAuthURLParam("access_type", "offline") + + // ApprovalForce forces the users to view the consent dialog + // and confirm the permissions request at the URL returned + // from AuthCodeURL, even if they've already done so. + ApprovalForce AuthCodeOption = SetAuthURLParam("approval_prompt", "force") +) + +// An AuthCodeOption is passed to Config.AuthCodeURL. +type AuthCodeOption interface { + setValue(url.Values) +} + +type setParam struct{ k, v string } + +func (p setParam) setValue(m url.Values) { m.Set(p.k, p.v) } + +// SetAuthURLParam builds an AuthCodeOption which passes key/value parameters +// to a provider's authorization endpoint. +func SetAuthURLParam(key, value string) AuthCodeOption { + return setParam{key, value} +} + +// AuthCodeURL returns a URL to OAuth 2.0 provider's consent page +// that asks for permissions for the required scopes explicitly. +// +// State is a token to protect the user from CSRF attacks. You must +// always provide a non-zero string and validate that it matches the +// the state query parameter on your redirect callback. +// See http://tools.ietf.org/html/rfc6749#section-10.12 for more info. +// +// Opts may include AccessTypeOnline or AccessTypeOffline, as well +// as ApprovalForce. +func (c *Config) AuthCodeURL(state string, opts ...AuthCodeOption) string { + var buf bytes.Buffer + buf.WriteString(c.Endpoint.AuthURL) + v := url.Values{ + "response_type": {"code"}, + "client_id": {c.ClientID}, + "redirect_uri": internal.CondVal(c.RedirectURL), + "scope": internal.CondVal(strings.Join(c.Scopes, " ")), + "state": internal.CondVal(state), + } + for _, opt := range opts { + opt.setValue(v) + } + if strings.Contains(c.Endpoint.AuthURL, "?") { + buf.WriteByte('&') + } else { + buf.WriteByte('?') + } + buf.WriteString(v.Encode()) + return buf.String() +} + +// PasswordCredentialsToken converts a resource owner username and password +// pair into a token. +// +// Per the RFC, this grant type should only be used "when there is a high +// degree of trust between the resource owner and the client (e.g., the client +// is part of the device operating system or a highly privileged application), +// and when other authorization grant types are not available." +// See https://tools.ietf.org/html/rfc6749#section-4.3 for more info. +// +// The HTTP client to use is derived from the context. +// If nil, http.DefaultClient is used. +func (c *Config) PasswordCredentialsToken(ctx context.Context, username, password string) (*Token, error) { + return retrieveToken(ctx, c, url.Values{ + "grant_type": {"password"}, + "username": {username}, + "password": {password}, + "scope": internal.CondVal(strings.Join(c.Scopes, " ")), + }) +} + +// Exchange converts an authorization code into a token. +// +// It is used after a resource provider redirects the user back +// to the Redirect URI (the URL obtained from AuthCodeURL). +// +// The HTTP client to use is derived from the context. +// If a client is not provided via the context, http.DefaultClient is used. +// +// The code will be in the *http.Request.FormValue("code"). Before +// calling Exchange, be sure to validate FormValue("state"). +func (c *Config) Exchange(ctx context.Context, code string) (*Token, error) { + return retrieveToken(ctx, c, url.Values{ + "grant_type": {"authorization_code"}, + "code": {code}, + "redirect_uri": internal.CondVal(c.RedirectURL), + "scope": internal.CondVal(strings.Join(c.Scopes, " ")), + }) +} + +// Client returns an HTTP client using the provided token. +// The token will auto-refresh as necessary. The underlying +// HTTP transport will be obtained using the provided context. +// The returned client and its Transport should not be modified. +func (c *Config) Client(ctx context.Context, t *Token) *http.Client { + return NewClient(ctx, c.TokenSource(ctx, t)) +} + +// TokenSource returns a TokenSource that returns t until t expires, +// automatically refreshing it as necessary using the provided context. +// +// Most users will use Config.Client instead. +func (c *Config) TokenSource(ctx context.Context, t *Token) TokenSource { + tkr := &tokenRefresher{ + ctx: ctx, + conf: c, + } + if t != nil { + tkr.refreshToken = t.RefreshToken + } + return &reuseTokenSource{ + t: t, + new: tkr, + } +} + +// tokenRefresher is a TokenSource that makes "grant_type"=="refresh_token" +// HTTP requests to renew a token using a RefreshToken. +type tokenRefresher struct { + ctx context.Context // used to get HTTP requests + conf *Config + refreshToken string +} + +// WARNING: Token is not safe for concurrent access, as it +// updates the tokenRefresher's refreshToken field. +// Within this package, it is used by reuseTokenSource which +// synchronizes calls to this method with its own mutex. +func (tf *tokenRefresher) Token() (*Token, error) { + if tf.refreshToken == "" { + return nil, errors.New("oauth2: token expired and refresh token is not set") + } + + tk, err := retrieveToken(tf.ctx, tf.conf, url.Values{ + "grant_type": {"refresh_token"}, + "refresh_token": {tf.refreshToken}, + }) + + if err != nil { + return nil, err + } + if tf.refreshToken != tk.RefreshToken { + tf.refreshToken = tk.RefreshToken + } + return tk, err +} + +// reuseTokenSource is a TokenSource that holds a single token in memory +// and validates its expiry before each call to retrieve it with +// Token. If it's expired, it will be auto-refreshed using the +// new TokenSource. +type reuseTokenSource struct { + new TokenSource // called when t is expired. + + mu sync.Mutex // guards t + t *Token +} + +// Token returns the current token if it's still valid, else will +// refresh the current token (using r.Context for HTTP client +// information) and return the new one. +func (s *reuseTokenSource) Token() (*Token, error) { + s.mu.Lock() + defer s.mu.Unlock() + if s.t.Valid() { + return s.t, nil + } + t, err := s.new.Token() + if err != nil { + return nil, err + } + s.t = t + return t, nil +} + +// StaticTokenSource returns a TokenSource that always returns the same token. +// Because the provided token t is never refreshed, StaticTokenSource is only +// useful for tokens that never expire. +func StaticTokenSource(t *Token) TokenSource { + return staticTokenSource{t} +} + +// staticTokenSource is a TokenSource that always returns the same Token. +type staticTokenSource struct { + t *Token +} + +func (s staticTokenSource) Token() (*Token, error) { + return s.t, nil +} + +// HTTPClient is the context key to use with golang.org/x/net/context's +// WithValue function to associate an *http.Client value with a context. +var HTTPClient internal.ContextKey + +// NewClient creates an *http.Client from a Context and TokenSource. +// The returned client is not valid beyond the lifetime of the context. +// +// As a special case, if src is nil, a non-OAuth2 client is returned +// using the provided context. This exists to support related OAuth2 +// packages. +func NewClient(ctx context.Context, src TokenSource) *http.Client { + if src == nil { + c, err := internal.ContextClient(ctx) + if err != nil { + return &http.Client{Transport: internal.ErrorTransport{Err: err}} + } + return c + } + return &http.Client{ + Transport: &Transport{ + Base: internal.ContextTransport(ctx), + Source: ReuseTokenSource(nil, src), + }, + } +} + +// ReuseTokenSource returns a TokenSource which repeatedly returns the +// same token as long as it's valid, starting with t. +// When its cached token is invalid, a new token is obtained from src. +// +// ReuseTokenSource is typically used to reuse tokens from a cache +// (such as a file on disk) between runs of a program, rather than +// obtaining new tokens unnecessarily. +// +// The initial token t may be nil, in which case the TokenSource is +// wrapped in a caching version if it isn't one already. This also +// means it's always safe to wrap ReuseTokenSource around any other +// TokenSource without adverse effects. +func ReuseTokenSource(t *Token, src TokenSource) TokenSource { + // Don't wrap a reuseTokenSource in itself. That would work, + // but cause an unnecessary number of mutex operations. + // Just build the equivalent one. + if rt, ok := src.(*reuseTokenSource); ok { + if t == nil { + // Just use it directly. + return rt + } + src = rt.new + } + return &reuseTokenSource{ + t: t, + new: src, + } +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/token.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/token.go new file mode 100644 index 000000000000..7a3167f15b04 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/token.go @@ -0,0 +1,158 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package oauth2 + +import ( + "net/http" + "net/url" + "strconv" + "strings" + "time" + + "golang.org/x/net/context" + "golang.org/x/oauth2/internal" +) + +// expiryDelta determines how earlier a token should be considered +// expired than its actual expiration time. It is used to avoid late +// expirations due to client-server time mismatches. +const expiryDelta = 10 * time.Second + +// Token represents the crendentials used to authorize +// the requests to access protected resources on the OAuth 2.0 +// provider's backend. +// +// Most users of this package should not access fields of Token +// directly. They're exported mostly for use by related packages +// implementing derivative OAuth2 flows. +type Token struct { + // AccessToken is the token that authorizes and authenticates + // the requests. + AccessToken string `json:"access_token"` + + // TokenType is the type of token. + // The Type method returns either this or "Bearer", the default. + TokenType string `json:"token_type,omitempty"` + + // RefreshToken is a token that's used by the application + // (as opposed to the user) to refresh the access token + // if it expires. + RefreshToken string `json:"refresh_token,omitempty"` + + // Expiry is the optional expiration time of the access token. + // + // If zero, TokenSource implementations will reuse the same + // token forever and RefreshToken or equivalent + // mechanisms for that TokenSource will not be used. + Expiry time.Time `json:"expiry,omitempty"` + + // raw optionally contains extra metadata from the server + // when updating a token. + raw interface{} +} + +// Type returns t.TokenType if non-empty, else "Bearer". +func (t *Token) Type() string { + if strings.EqualFold(t.TokenType, "bearer") { + return "Bearer" + } + if strings.EqualFold(t.TokenType, "mac") { + return "MAC" + } + if strings.EqualFold(t.TokenType, "basic") { + return "Basic" + } + if t.TokenType != "" { + return t.TokenType + } + return "Bearer" +} + +// SetAuthHeader sets the Authorization header to r using the access +// token in t. +// +// This method is unnecessary when using Transport or an HTTP Client +// returned by this package. +func (t *Token) SetAuthHeader(r *http.Request) { + r.Header.Set("Authorization", t.Type()+" "+t.AccessToken) +} + +// WithExtra returns a new Token that's a clone of t, but using the +// provided raw extra map. This is only intended for use by packages +// implementing derivative OAuth2 flows. +func (t *Token) WithExtra(extra interface{}) *Token { + t2 := new(Token) + *t2 = *t + t2.raw = extra + return t2 +} + +// Extra returns an extra field. +// Extra fields are key-value pairs returned by the server as a +// part of the token retrieval response. +func (t *Token) Extra(key string) interface{} { + if raw, ok := t.raw.(map[string]interface{}); ok { + return raw[key] + } + + vals, ok := t.raw.(url.Values) + if !ok { + return nil + } + + v := vals.Get(key) + switch s := strings.TrimSpace(v); strings.Count(s, ".") { + case 0: // Contains no "."; try to parse as int + if i, err := strconv.ParseInt(s, 10, 64); err == nil { + return i + } + case 1: // Contains a single "."; try to parse as float + if f, err := strconv.ParseFloat(s, 64); err == nil { + return f + } + } + + return v +} + +// expired reports whether the token is expired. +// t must be non-nil. +func (t *Token) expired() bool { + if t.Expiry.IsZero() { + return false + } + return t.Expiry.Add(-expiryDelta).Before(time.Now()) +} + +// Valid reports whether t is non-nil, has an AccessToken, and is not expired. +func (t *Token) Valid() bool { + return t != nil && t.AccessToken != "" && !t.expired() +} + +// tokenFromInternal maps an *internal.Token struct into +// a *Token struct. +func tokenFromInternal(t *internal.Token) *Token { + if t == nil { + return nil + } + return &Token{ + AccessToken: t.AccessToken, + TokenType: t.TokenType, + RefreshToken: t.RefreshToken, + Expiry: t.Expiry, + raw: t.Raw, + } +} + +// retrieveToken takes a *Config and uses that to retrieve an *internal.Token. +// This token is then mapped from *internal.Token into an *oauth2.Token which is returned along +// with an error.. +func retrieveToken(ctx context.Context, c *Config, v url.Values) (*Token, error) { + tk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endpoint.TokenURL, v) + if err != nil { + return nil, err + } + return tokenFromInternal(tk), nil +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/transport.go b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/transport.go new file mode 100644 index 000000000000..92ac7e2531f4 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/golang.org/x/oauth2/transport.go @@ -0,0 +1,132 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package oauth2 + +import ( + "errors" + "io" + "net/http" + "sync" +) + +// Transport is an http.RoundTripper that makes OAuth 2.0 HTTP requests, +// wrapping a base RoundTripper and adding an Authorization header +// with a token from the supplied Sources. +// +// Transport is a low-level mechanism. Most code will use the +// higher-level Config.Client method instead. +type Transport struct { + // Source supplies the token to add to outgoing requests' + // Authorization headers. + Source TokenSource + + // Base is the base RoundTripper used to make HTTP requests. + // If nil, http.DefaultTransport is used. + Base http.RoundTripper + + mu sync.Mutex // guards modReq + modReq map[*http.Request]*http.Request // original -> modified +} + +// RoundTrip authorizes and authenticates the request with an +// access token. If no token exists or token is expired, +// tries to refresh/fetch a new token. +func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { + if t.Source == nil { + return nil, errors.New("oauth2: Transport's Source is nil") + } + token, err := t.Source.Token() + if err != nil { + return nil, err + } + + req2 := cloneRequest(req) // per RoundTripper contract + token.SetAuthHeader(req2) + t.setModReq(req, req2) + res, err := t.base().RoundTrip(req2) + if err != nil { + t.setModReq(req, nil) + return nil, err + } + res.Body = &onEOFReader{ + rc: res.Body, + fn: func() { t.setModReq(req, nil) }, + } + return res, nil +} + +// CancelRequest cancels an in-flight request by closing its connection. +func (t *Transport) CancelRequest(req *http.Request) { + type canceler interface { + CancelRequest(*http.Request) + } + if cr, ok := t.base().(canceler); ok { + t.mu.Lock() + modReq := t.modReq[req] + delete(t.modReq, req) + t.mu.Unlock() + cr.CancelRequest(modReq) + } +} + +func (t *Transport) base() http.RoundTripper { + if t.Base != nil { + return t.Base + } + return http.DefaultTransport +} + +func (t *Transport) setModReq(orig, mod *http.Request) { + t.mu.Lock() + defer t.mu.Unlock() + if t.modReq == nil { + t.modReq = make(map[*http.Request]*http.Request) + } + if mod == nil { + delete(t.modReq, orig) + } else { + t.modReq[orig] = mod + } +} + +// cloneRequest returns a clone of the provided *http.Request. +// The clone is a shallow copy of the struct and its Header map. +func cloneRequest(r *http.Request) *http.Request { + // shallow copy of the struct + r2 := new(http.Request) + *r2 = *r + // deep copy of the Header + r2.Header = make(http.Header, len(r.Header)) + for k, s := range r.Header { + r2.Header[k] = append([]string(nil), s...) + } + return r2 +} + +type onEOFReader struct { + rc io.ReadCloser + fn func() +} + +func (r *onEOFReader) Read(p []byte) (n int, err error) { + n, err = r.rc.Read(p) + if err == io.EOF { + r.runFunc() + } + return +} + +func (r *onEOFReader) Close() error { + err := r.rc.Close() + r.runFunc() + return err +} + +func (r *onEOFReader) runFunc() { + if fn := r.fn; fn != nil { + fn() + r.fn = nil + } +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/LICENSE b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/LICENSE new file mode 100644 index 000000000000..d64569567334 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/LICENSE @@ -0,0 +1,202 @@ + + 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. diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/appengine.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/appengine.go new file mode 100644 index 000000000000..8865c49a5f5e --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/appengine.go @@ -0,0 +1,112 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// Package appengine provides basic functionality for Google App Engine. +// +// For more information on how to write Go apps for Google App Engine, see: +// https://cloud.google.com/appengine/docs/go/ +package appengine + +import ( + "net/http" + + "github.com/golang/protobuf/proto" + "golang.org/x/net/context" + + "google.golang.org/appengine/internal" +) + +// The gophers party all night; the rabbits provide the beats. + +// Main is the principal entry point for an app running in App Engine. +// +// On App Engine Flexible it installs a trivial health checker if one isn't +// already registered, and starts listening on port 8080 (overridden by the +// $PORT environment variable). +// +// See https://cloud.google.com/appengine/docs/flexible/custom-runtimes#health_check_requests +// for details on how to do your own health checking. +// +// Main is not yet supported on App Engine Standard. +// +// Main never returns. +// +// Main is designed so that the app's main package looks like this: +// +// package main +// +// import ( +// "google.golang.org/appengine" +// +// _ "myapp/package0" +// _ "myapp/package1" +// ) +// +// func main() { +// appengine.Main() +// } +// +// The "myapp/packageX" packages are expected to register HTTP handlers +// in their init functions. +func Main() { + internal.Main() +} + +// IsDevAppServer reports whether the App Engine app is running in the +// development App Server. +func IsDevAppServer() bool { + return internal.IsDevAppServer() +} + +// NewContext returns a context for an in-flight HTTP request. +// This function is cheap. +func NewContext(req *http.Request) context.Context { + return WithContext(context.Background(), req) +} + +// WithContext returns a copy of the parent context +// and associates it with an in-flight HTTP request. +// This function is cheap. +func WithContext(parent context.Context, req *http.Request) context.Context { + return internal.WithContext(parent, req) +} + +// TODO(dsymonds): Add a Call function here? Otherwise other packages can't access internal.Call. + +// BlobKey is a key for a blobstore blob. +// +// Conceptually, this type belongs in the blobstore package, but it lives in +// the appengine package to avoid a circular dependency: blobstore depends on +// datastore, and datastore needs to refer to the BlobKey type. +type BlobKey string + +// GeoPoint represents a location as latitude/longitude in degrees. +type GeoPoint struct { + Lat, Lng float64 +} + +// Valid returns whether a GeoPoint is within [-90, 90] latitude and [-180, 180] longitude. +func (g GeoPoint) Valid() bool { + return -90 <= g.Lat && g.Lat <= 90 && -180 <= g.Lng && g.Lng <= 180 +} + +// APICallFunc defines a function type for handling an API call. +// See WithCallOverride. +type APICallFunc func(ctx context.Context, service, method string, in, out proto.Message) error + +// WithAPICallFunc returns a copy of the parent context +// that will cause API calls to invoke f instead of their normal operation. +// +// This is intended for advanced users only. +func WithAPICallFunc(ctx context.Context, f APICallFunc) context.Context { + return internal.WithCallOverride(ctx, internal.CallOverrideFunc(f)) +} + +// APICall performs an API call. +// +// This is not intended for general use; it is exported for use in conjunction +// with WithAPICallFunc. +func APICall(ctx context.Context, service, method string, in, out proto.Message) error { + return internal.Call(ctx, service, method, in, out) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/appengine_vm.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/appengine_vm.go new file mode 100644 index 000000000000..f4b645aad3be --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/appengine_vm.go @@ -0,0 +1,20 @@ +// Copyright 2015 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build !appengine + +package appengine + +import ( + "golang.org/x/net/context" + + "google.golang.org/appengine/internal" +) + +// BackgroundContext returns a context not associated with a request. +// This should only be used when not servicing a request. +// This only works in App Engine "flexible environment". +func BackgroundContext() context.Context { + return internal.BackgroundContext() +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/errors.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/errors.go new file mode 100644 index 000000000000..16d0772e2a46 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/errors.go @@ -0,0 +1,46 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// This file provides error functions for common API failure modes. + +package appengine + +import ( + "fmt" + + "google.golang.org/appengine/internal" +) + +// IsOverQuota reports whether err represents an API call failure +// due to insufficient available quota. +func IsOverQuota(err error) bool { + callErr, ok := err.(*internal.CallError) + return ok && callErr.Code == 4 +} + +// MultiError is returned by batch operations when there are errors with +// particular elements. Errors will be in a one-to-one correspondence with +// the input elements; successful elements will have a nil entry. +type MultiError []error + +func (m MultiError) Error() string { + s, n := "", 0 + for _, e := range m { + if e != nil { + if n == 0 { + s = e.Error() + } + n++ + } + } + switch n { + case 0: + return "(0 errors)" + case 1: + return s + case 2: + return s + " (and 1 other error)" + } + return fmt.Sprintf("%s (and %d other errors)", s, n-1) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/identity.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/identity.go new file mode 100644 index 000000000000..b8dcf8f36198 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/identity.go @@ -0,0 +1,142 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package appengine + +import ( + "time" + + "golang.org/x/net/context" + + "google.golang.org/appengine/internal" + pb "google.golang.org/appengine/internal/app_identity" + modpb "google.golang.org/appengine/internal/modules" +) + +// AppID returns the application ID for the current application. +// The string will be a plain application ID (e.g. "appid"), with a +// domain prefix for custom domain deployments (e.g. "example.com:appid"). +func AppID(c context.Context) string { return internal.AppID(c) } + +// DefaultVersionHostname returns the standard hostname of the default version +// of the current application (e.g. "my-app.appspot.com"). This is suitable for +// use in constructing URLs. +func DefaultVersionHostname(c context.Context) string { + return internal.DefaultVersionHostname(c) +} + +// ModuleName returns the module name of the current instance. +func ModuleName(c context.Context) string { + return internal.ModuleName(c) +} + +// ModuleHostname returns a hostname of a module instance. +// If module is the empty string, it refers to the module of the current instance. +// If version is empty, it refers to the version of the current instance if valid, +// or the default version of the module of the current instance. +// If instance is empty, ModuleHostname returns the load-balancing hostname. +func ModuleHostname(c context.Context, module, version, instance string) (string, error) { + req := &modpb.GetHostnameRequest{} + if module != "" { + req.Module = &module + } + if version != "" { + req.Version = &version + } + if instance != "" { + req.Instance = &instance + } + res := &modpb.GetHostnameResponse{} + if err := internal.Call(c, "modules", "GetHostname", req, res); err != nil { + return "", err + } + return *res.Hostname, nil +} + +// VersionID returns the version ID for the current application. +// It will be of the form "X.Y", where X is specified in app.yaml, +// and Y is a number generated when each version of the app is uploaded. +// It does not include a module name. +func VersionID(c context.Context) string { return internal.VersionID(c) } + +// InstanceID returns a mostly-unique identifier for this instance. +func InstanceID() string { return internal.InstanceID() } + +// Datacenter returns an identifier for the datacenter that the instance is running in. +func Datacenter(c context.Context) string { return internal.Datacenter(c) } + +// ServerSoftware returns the App Engine release version. +// In production, it looks like "Google App Engine/X.Y.Z". +// In the development appserver, it looks like "Development/X.Y". +func ServerSoftware() string { return internal.ServerSoftware() } + +// RequestID returns a string that uniquely identifies the request. +func RequestID(c context.Context) string { return internal.RequestID(c) } + +// AccessToken generates an OAuth2 access token for the specified scopes on +// behalf of service account of this application. This token will expire after +// the returned time. +func AccessToken(c context.Context, scopes ...string) (token string, expiry time.Time, err error) { + req := &pb.GetAccessTokenRequest{Scope: scopes} + res := &pb.GetAccessTokenResponse{} + + err = internal.Call(c, "app_identity_service", "GetAccessToken", req, res) + if err != nil { + return "", time.Time{}, err + } + return res.GetAccessToken(), time.Unix(res.GetExpirationTime(), 0), nil +} + +// Certificate represents a public certificate for the app. +type Certificate struct { + KeyName string + Data []byte // PEM-encoded X.509 certificate +} + +// PublicCertificates retrieves the public certificates for the app. +// They can be used to verify a signature returned by SignBytes. +func PublicCertificates(c context.Context) ([]Certificate, error) { + req := &pb.GetPublicCertificateForAppRequest{} + res := &pb.GetPublicCertificateForAppResponse{} + if err := internal.Call(c, "app_identity_service", "GetPublicCertificatesForApp", req, res); err != nil { + return nil, err + } + var cs []Certificate + for _, pc := range res.PublicCertificateList { + cs = append(cs, Certificate{ + KeyName: pc.GetKeyName(), + Data: []byte(pc.GetX509CertificatePem()), + }) + } + return cs, nil +} + +// ServiceAccount returns a string representing the service account name, in +// the form of an email address (typically app_id@appspot.gserviceaccount.com). +func ServiceAccount(c context.Context) (string, error) { + req := &pb.GetServiceAccountNameRequest{} + res := &pb.GetServiceAccountNameResponse{} + + err := internal.Call(c, "app_identity_service", "GetServiceAccountName", req, res) + if err != nil { + return "", err + } + return res.GetServiceAccountName(), err +} + +// SignBytes signs bytes using a private key unique to your application. +func SignBytes(c context.Context, bytes []byte) (keyName string, signature []byte, err error) { + req := &pb.SignForAppRequest{BytesToSign: bytes} + res := &pb.SignForAppResponse{} + + if err := internal.Call(c, "app_identity_service", "SignForApp", req, res); err != nil { + return "", nil, err + } + return res.GetKeyName(), res.GetSignatureBytes(), nil +} + +func init() { + internal.RegisterErrorCodeMap("app_identity_service", pb.AppIdentityServiceError_ErrorCode_name) + internal.RegisterErrorCodeMap("modules", modpb.ModulesServiceError_ErrorCode_name) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api.go new file mode 100644 index 000000000000..ec5aa59b39b5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api.go @@ -0,0 +1,646 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build !appengine + +package internal + +import ( + "bytes" + "errors" + "fmt" + "io/ioutil" + "log" + "net" + "net/http" + "net/url" + "os" + "runtime" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" + + "github.com/golang/protobuf/proto" + netcontext "golang.org/x/net/context" + + basepb "google.golang.org/appengine/internal/base" + logpb "google.golang.org/appengine/internal/log" + remotepb "google.golang.org/appengine/internal/remote_api" +) + +const ( + apiPath = "/rpc_http" +) + +var ( + // Incoming headers. + ticketHeader = http.CanonicalHeaderKey("X-AppEngine-API-Ticket") + dapperHeader = http.CanonicalHeaderKey("X-Google-DapperTraceInfo") + traceHeader = http.CanonicalHeaderKey("X-Cloud-Trace-Context") + curNamespaceHeader = http.CanonicalHeaderKey("X-AppEngine-Current-Namespace") + userIPHeader = http.CanonicalHeaderKey("X-AppEngine-User-IP") + remoteAddrHeader = http.CanonicalHeaderKey("X-AppEngine-Remote-Addr") + + // Outgoing headers. + apiEndpointHeader = http.CanonicalHeaderKey("X-Google-RPC-Service-Endpoint") + apiEndpointHeaderValue = []string{"app-engine-apis"} + apiMethodHeader = http.CanonicalHeaderKey("X-Google-RPC-Service-Method") + apiMethodHeaderValue = []string{"/VMRemoteAPI.CallRemoteAPI"} + apiDeadlineHeader = http.CanonicalHeaderKey("X-Google-RPC-Service-Deadline") + apiContentType = http.CanonicalHeaderKey("Content-Type") + apiContentTypeValue = []string{"application/octet-stream"} + logFlushHeader = http.CanonicalHeaderKey("X-AppEngine-Log-Flush-Count") + + apiHTTPClient = &http.Client{ + Transport: &http.Transport{ + Proxy: http.ProxyFromEnvironment, + Dial: limitDial, + }, + } +) + +func apiURL() *url.URL { + host, port := "appengine.googleapis.internal", "10001" + if h := os.Getenv("API_HOST"); h != "" { + host = h + } + if p := os.Getenv("API_PORT"); p != "" { + port = p + } + return &url.URL{ + Scheme: "http", + Host: host + ":" + port, + Path: apiPath, + } +} + +func handleHTTP(w http.ResponseWriter, r *http.Request) { + c := &context{ + req: r, + outHeader: w.Header(), + apiURL: apiURL(), + } + stopFlushing := make(chan int) + + ctxs.Lock() + ctxs.m[r] = c + ctxs.Unlock() + defer func() { + ctxs.Lock() + delete(ctxs.m, r) + ctxs.Unlock() + }() + + // Patch up RemoteAddr so it looks reasonable. + if addr := r.Header.Get(userIPHeader); addr != "" { + r.RemoteAddr = addr + } else if addr = r.Header.Get(remoteAddrHeader); addr != "" { + r.RemoteAddr = addr + } else { + // Should not normally reach here, but pick a sensible default anyway. + r.RemoteAddr = "127.0.0.1" + } + // The address in the headers will most likely be of these forms: + // 123.123.123.123 + // 2001:db8::1 + // net/http.Request.RemoteAddr is specified to be in "IP:port" form. + if _, _, err := net.SplitHostPort(r.RemoteAddr); err != nil { + // Assume the remote address is only a host; add a default port. + r.RemoteAddr = net.JoinHostPort(r.RemoteAddr, "80") + } + + // Start goroutine responsible for flushing app logs. + // This is done after adding c to ctx.m (and stopped before removing it) + // because flushing logs requires making an API call. + go c.logFlusher(stopFlushing) + + executeRequestSafely(c, r) + c.outHeader = nil // make sure header changes aren't respected any more + + stopFlushing <- 1 // any logging beyond this point will be dropped + + // Flush any pending logs asynchronously. + c.pendingLogs.Lock() + flushes := c.pendingLogs.flushes + if len(c.pendingLogs.lines) > 0 { + flushes++ + } + c.pendingLogs.Unlock() + go c.flushLog(false) + w.Header().Set(logFlushHeader, strconv.Itoa(flushes)) + + // Avoid nil Write call if c.Write is never called. + if c.outCode != 0 { + w.WriteHeader(c.outCode) + } + if c.outBody != nil { + w.Write(c.outBody) + } +} + +func executeRequestSafely(c *context, r *http.Request) { + defer func() { + if x := recover(); x != nil { + logf(c, 4, "%s", renderPanic(x)) // 4 == critical + c.outCode = 500 + } + }() + + http.DefaultServeMux.ServeHTTP(c, r) +} + +func renderPanic(x interface{}) string { + buf := make([]byte, 16<<10) // 16 KB should be plenty + buf = buf[:runtime.Stack(buf, false)] + + // Remove the first few stack frames: + // this func + // the recover closure in the caller + // That will root the stack trace at the site of the panic. + const ( + skipStart = "internal.renderPanic" + skipFrames = 2 + ) + start := bytes.Index(buf, []byte(skipStart)) + p := start + for i := 0; i < skipFrames*2 && p+1 < len(buf); i++ { + p = bytes.IndexByte(buf[p+1:], '\n') + p + 1 + if p < 0 { + break + } + } + if p >= 0 { + // buf[start:p+1] is the block to remove. + // Copy buf[p+1:] over buf[start:] and shrink buf. + copy(buf[start:], buf[p+1:]) + buf = buf[:len(buf)-(p+1-start)] + } + + // Add panic heading. + head := fmt.Sprintf("panic: %v\n\n", x) + if len(head) > len(buf) { + // Extremely unlikely to happen. + return head + } + copy(buf[len(head):], buf) + copy(buf, head) + + return string(buf) +} + +var ctxs = struct { + sync.Mutex + m map[*http.Request]*context + bg *context // background context, lazily initialized + // dec is used by tests to decorate the netcontext.Context returned + // for a given request. This allows tests to add overrides (such as + // WithAppIDOverride) to the context. The map is nil outside tests. + dec map[*http.Request]func(netcontext.Context) netcontext.Context +}{ + m: make(map[*http.Request]*context), +} + +// context represents the context of an in-flight HTTP request. +// It implements the appengine.Context and http.ResponseWriter interfaces. +type context struct { + req *http.Request + + outCode int + outHeader http.Header + outBody []byte + + pendingLogs struct { + sync.Mutex + lines []*logpb.UserAppLogLine + flushes int + } + + apiURL *url.URL +} + +var contextKey = "holds a *context" + +func fromContext(ctx netcontext.Context) *context { + c, _ := ctx.Value(&contextKey).(*context) + return c +} + +func withContext(parent netcontext.Context, c *context) netcontext.Context { + ctx := netcontext.WithValue(parent, &contextKey, c) + if ns := c.req.Header.Get(curNamespaceHeader); ns != "" { + ctx = withNamespace(ctx, ns) + } + return ctx +} + +func toContext(c *context) netcontext.Context { + return withContext(netcontext.Background(), c) +} + +func IncomingHeaders(ctx netcontext.Context) http.Header { + if c := fromContext(ctx); c != nil { + return c.req.Header + } + return nil +} + +func WithContext(parent netcontext.Context, req *http.Request) netcontext.Context { + ctxs.Lock() + c := ctxs.m[req] + d := ctxs.dec[req] + ctxs.Unlock() + + if d != nil { + parent = d(parent) + } + + if c == nil { + // Someone passed in an http.Request that is not in-flight. + // We panic here rather than panicking at a later point + // so that stack traces will be more sensible. + log.Panic("appengine: NewContext passed an unknown http.Request") + } + return withContext(parent, c) +} + +func BackgroundContext() netcontext.Context { + ctxs.Lock() + defer ctxs.Unlock() + + if ctxs.bg != nil { + return toContext(ctxs.bg) + } + + // Compute background security ticket. + appID := partitionlessAppID() + escAppID := strings.Replace(strings.Replace(appID, ":", "_", -1), ".", "_", -1) + majVersion := VersionID(nil) + if i := strings.Index(majVersion, "."); i > 0 { + majVersion = majVersion[:i] + } + ticket := fmt.Sprintf("%s/%s.%s.%s", escAppID, ModuleName(nil), majVersion, InstanceID()) + + ctxs.bg = &context{ + req: &http.Request{ + Header: http.Header{ + ticketHeader: []string{ticket}, + }, + }, + apiURL: apiURL(), + } + + // TODO(dsymonds): Wire up the shutdown handler to do a final flush. + go ctxs.bg.logFlusher(make(chan int)) + + return toContext(ctxs.bg) +} + +// RegisterTestRequest registers the HTTP request req for testing, such that +// any API calls are sent to the provided URL. It returns a closure to delete +// the registration. +// It should only be used by aetest package. +func RegisterTestRequest(req *http.Request, apiURL *url.URL, decorate func(netcontext.Context) netcontext.Context) func() { + c := &context{ + req: req, + apiURL: apiURL, + } + ctxs.Lock() + defer ctxs.Unlock() + if _, ok := ctxs.m[req]; ok { + log.Panic("req already associated with context") + } + if _, ok := ctxs.dec[req]; ok { + log.Panic("req already associated with context") + } + if ctxs.dec == nil { + ctxs.dec = make(map[*http.Request]func(netcontext.Context) netcontext.Context) + } + ctxs.m[req] = c + ctxs.dec[req] = decorate + + return func() { + ctxs.Lock() + delete(ctxs.m, req) + delete(ctxs.dec, req) + ctxs.Unlock() + } +} + +var errTimeout = &CallError{ + Detail: "Deadline exceeded", + Code: int32(remotepb.RpcError_CANCELLED), + Timeout: true, +} + +func (c *context) Header() http.Header { return c.outHeader } + +// Copied from $GOROOT/src/pkg/net/http/transfer.go. Some response status +// codes do not permit a response body (nor response entity headers such as +// Content-Length, Content-Type, etc). +func bodyAllowedForStatus(status int) bool { + switch { + case status >= 100 && status <= 199: + return false + case status == 204: + return false + case status == 304: + return false + } + return true +} + +func (c *context) Write(b []byte) (int, error) { + if c.outCode == 0 { + c.WriteHeader(http.StatusOK) + } + if len(b) > 0 && !bodyAllowedForStatus(c.outCode) { + return 0, http.ErrBodyNotAllowed + } + c.outBody = append(c.outBody, b...) + return len(b), nil +} + +func (c *context) WriteHeader(code int) { + if c.outCode != 0 { + logf(c, 3, "WriteHeader called multiple times on request.") // error level + return + } + c.outCode = code +} + +func (c *context) post(body []byte, timeout time.Duration) (b []byte, err error) { + hreq := &http.Request{ + Method: "POST", + URL: c.apiURL, + Header: http.Header{ + apiEndpointHeader: apiEndpointHeaderValue, + apiMethodHeader: apiMethodHeaderValue, + apiContentType: apiContentTypeValue, + apiDeadlineHeader: []string{strconv.FormatFloat(timeout.Seconds(), 'f', -1, 64)}, + }, + Body: ioutil.NopCloser(bytes.NewReader(body)), + ContentLength: int64(len(body)), + Host: c.apiURL.Host, + } + if info := c.req.Header.Get(dapperHeader); info != "" { + hreq.Header.Set(dapperHeader, info) + } + if info := c.req.Header.Get(traceHeader); info != "" { + hreq.Header.Set(traceHeader, info) + } + + tr := apiHTTPClient.Transport.(*http.Transport) + + var timedOut int32 // atomic; set to 1 if timed out + t := time.AfterFunc(timeout, func() { + atomic.StoreInt32(&timedOut, 1) + tr.CancelRequest(hreq) + }) + defer t.Stop() + defer func() { + // Check if timeout was exceeded. + if atomic.LoadInt32(&timedOut) != 0 { + err = errTimeout + } + }() + + hresp, err := apiHTTPClient.Do(hreq) + if err != nil { + return nil, &CallError{ + Detail: fmt.Sprintf("service bridge HTTP failed: %v", err), + Code: int32(remotepb.RpcError_UNKNOWN), + } + } + defer hresp.Body.Close() + hrespBody, err := ioutil.ReadAll(hresp.Body) + if hresp.StatusCode != 200 { + return nil, &CallError{ + Detail: fmt.Sprintf("service bridge returned HTTP %d (%q)", hresp.StatusCode, hrespBody), + Code: int32(remotepb.RpcError_UNKNOWN), + } + } + if err != nil { + return nil, &CallError{ + Detail: fmt.Sprintf("service bridge response bad: %v", err), + Code: int32(remotepb.RpcError_UNKNOWN), + } + } + return hrespBody, nil +} + +func Call(ctx netcontext.Context, service, method string, in, out proto.Message) error { + if ns := NamespaceFromContext(ctx); ns != "" { + if fn, ok := NamespaceMods[service]; ok { + fn(in, ns) + } + } + + if f, ctx, ok := callOverrideFromContext(ctx); ok { + return f(ctx, service, method, in, out) + } + + // Handle already-done contexts quickly. + select { + case <-ctx.Done(): + return ctx.Err() + default: + } + + c := fromContext(ctx) + if c == nil { + // Give a good error message rather than a panic lower down. + return errors.New("not an App Engine context") + } + + // Apply transaction modifications if we're in a transaction. + if t := transactionFromContext(ctx); t != nil { + if t.finished { + return errors.New("transaction context has expired") + } + applyTransaction(in, &t.transaction) + } + + // Default RPC timeout is 60s. + timeout := 60 * time.Second + if deadline, ok := ctx.Deadline(); ok { + timeout = deadline.Sub(time.Now()) + } + + data, err := proto.Marshal(in) + if err != nil { + return err + } + + ticket := c.req.Header.Get(ticketHeader) + req := &remotepb.Request{ + ServiceName: &service, + Method: &method, + Request: data, + RequestId: &ticket, + } + hreqBody, err := proto.Marshal(req) + if err != nil { + return err + } + + hrespBody, err := c.post(hreqBody, timeout) + if err != nil { + return err + } + + res := &remotepb.Response{} + if err := proto.Unmarshal(hrespBody, res); err != nil { + return err + } + if res.RpcError != nil { + ce := &CallError{ + Detail: res.RpcError.GetDetail(), + Code: *res.RpcError.Code, + } + switch remotepb.RpcError_ErrorCode(ce.Code) { + case remotepb.RpcError_CANCELLED, remotepb.RpcError_DEADLINE_EXCEEDED: + ce.Timeout = true + } + return ce + } + if res.ApplicationError != nil { + return &APIError{ + Service: *req.ServiceName, + Detail: res.ApplicationError.GetDetail(), + Code: *res.ApplicationError.Code, + } + } + if res.Exception != nil || res.JavaException != nil { + // This shouldn't happen, but let's be defensive. + return &CallError{ + Detail: "service bridge returned exception", + Code: int32(remotepb.RpcError_UNKNOWN), + } + } + return proto.Unmarshal(res.Response, out) +} + +func (c *context) Request() *http.Request { + return c.req +} + +func (c *context) addLogLine(ll *logpb.UserAppLogLine) { + // Truncate long log lines. + // TODO(dsymonds): Check if this is still necessary. + const lim = 8 << 10 + if len(*ll.Message) > lim { + suffix := fmt.Sprintf("...(length %d)", len(*ll.Message)) + ll.Message = proto.String((*ll.Message)[:lim-len(suffix)] + suffix) + } + + c.pendingLogs.Lock() + c.pendingLogs.lines = append(c.pendingLogs.lines, ll) + c.pendingLogs.Unlock() +} + +var logLevelName = map[int64]string{ + 0: "DEBUG", + 1: "INFO", + 2: "WARNING", + 3: "ERROR", + 4: "CRITICAL", +} + +func logf(c *context, level int64, format string, args ...interface{}) { + s := fmt.Sprintf(format, args...) + s = strings.TrimRight(s, "\n") // Remove any trailing newline characters. + c.addLogLine(&logpb.UserAppLogLine{ + TimestampUsec: proto.Int64(time.Now().UnixNano() / 1e3), + Level: &level, + Message: &s, + }) + log.Print(logLevelName[level] + ": " + s) +} + +// flushLog attempts to flush any pending logs to the appserver. +// It should not be called concurrently. +func (c *context) flushLog(force bool) (flushed bool) { + c.pendingLogs.Lock() + // Grab up to 30 MB. We can get away with up to 32 MB, but let's be cautious. + n, rem := 0, 30<<20 + for ; n < len(c.pendingLogs.lines); n++ { + ll := c.pendingLogs.lines[n] + // Each log line will require about 3 bytes of overhead. + nb := proto.Size(ll) + 3 + if nb > rem { + break + } + rem -= nb + } + lines := c.pendingLogs.lines[:n] + c.pendingLogs.lines = c.pendingLogs.lines[n:] + c.pendingLogs.Unlock() + + if len(lines) == 0 && !force { + // Nothing to flush. + return false + } + + rescueLogs := false + defer func() { + if rescueLogs { + c.pendingLogs.Lock() + c.pendingLogs.lines = append(lines, c.pendingLogs.lines...) + c.pendingLogs.Unlock() + } + }() + + buf, err := proto.Marshal(&logpb.UserAppLogGroup{ + LogLine: lines, + }) + if err != nil { + log.Printf("internal.flushLog: marshaling UserAppLogGroup: %v", err) + rescueLogs = true + return false + } + + req := &logpb.FlushRequest{ + Logs: buf, + } + res := &basepb.VoidProto{} + c.pendingLogs.Lock() + c.pendingLogs.flushes++ + c.pendingLogs.Unlock() + if err := Call(toContext(c), "logservice", "Flush", req, res); err != nil { + log.Printf("internal.flushLog: Flush RPC: %v", err) + rescueLogs = true + return false + } + return true +} + +const ( + // Log flushing parameters. + flushInterval = 1 * time.Second + forceFlushInterval = 60 * time.Second +) + +func (c *context) logFlusher(stop <-chan int) { + lastFlush := time.Now() + tick := time.NewTicker(flushInterval) + for { + select { + case <-stop: + // Request finished. + tick.Stop() + return + case <-tick.C: + force := time.Now().Sub(lastFlush) > forceFlushInterval + if c.flushLog(force) { + lastFlush = time.Now() + } + } + } +} + +func ContextForTesting(req *http.Request) netcontext.Context { + return toContext(&context{req: req}) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api_classic.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api_classic.go new file mode 100644 index 000000000000..597f66e6ea2d --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api_classic.go @@ -0,0 +1,159 @@ +// Copyright 2015 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build appengine + +package internal + +import ( + "errors" + "fmt" + "net/http" + "time" + + "appengine" + "appengine_internal" + basepb "appengine_internal/base" + + "github.com/golang/protobuf/proto" + netcontext "golang.org/x/net/context" +) + +var contextKey = "holds an appengine.Context" + +func fromContext(ctx netcontext.Context) appengine.Context { + c, _ := ctx.Value(&contextKey).(appengine.Context) + return c +} + +// This is only for classic App Engine adapters. +func ClassicContextFromContext(ctx netcontext.Context) appengine.Context { + return fromContext(ctx) +} + +func withContext(parent netcontext.Context, c appengine.Context) netcontext.Context { + ctx := netcontext.WithValue(parent, &contextKey, c) + + s := &basepb.StringProto{} + c.Call("__go__", "GetNamespace", &basepb.VoidProto{}, s, nil) + if ns := s.GetValue(); ns != "" { + ctx = NamespacedContext(ctx, ns) + } + + return ctx +} + +func IncomingHeaders(ctx netcontext.Context) http.Header { + if c := fromContext(ctx); c != nil { + if req, ok := c.Request().(*http.Request); ok { + return req.Header + } + } + return nil +} + +func WithContext(parent netcontext.Context, req *http.Request) netcontext.Context { + c := appengine.NewContext(req) + return withContext(parent, c) +} + +type testingContext struct { + appengine.Context + + req *http.Request +} + +func (t *testingContext) FullyQualifiedAppID() string { return "dev~testcontext" } +func (t *testingContext) Call(service, method string, _, _ appengine_internal.ProtoMessage, _ *appengine_internal.CallOptions) error { + if service == "__go__" && method == "GetNamespace" { + return nil + } + return fmt.Errorf("testingContext: unsupported Call") +} +func (t *testingContext) Request() interface{} { return t.req } + +func ContextForTesting(req *http.Request) netcontext.Context { + return withContext(netcontext.Background(), &testingContext{req: req}) +} + +func Call(ctx netcontext.Context, service, method string, in, out proto.Message) error { + if ns := NamespaceFromContext(ctx); ns != "" { + if fn, ok := NamespaceMods[service]; ok { + fn(in, ns) + } + } + + if f, ctx, ok := callOverrideFromContext(ctx); ok { + return f(ctx, service, method, in, out) + } + + // Handle already-done contexts quickly. + select { + case <-ctx.Done(): + return ctx.Err() + default: + } + + c := fromContext(ctx) + if c == nil { + // Give a good error message rather than a panic lower down. + return errors.New("not an App Engine context") + } + + // Apply transaction modifications if we're in a transaction. + if t := transactionFromContext(ctx); t != nil { + if t.finished { + return errors.New("transaction context has expired") + } + applyTransaction(in, &t.transaction) + } + + var opts *appengine_internal.CallOptions + if d, ok := ctx.Deadline(); ok { + opts = &appengine_internal.CallOptions{ + Timeout: d.Sub(time.Now()), + } + } + + err := c.Call(service, method, in, out, opts) + switch v := err.(type) { + case *appengine_internal.APIError: + return &APIError{ + Service: v.Service, + Detail: v.Detail, + Code: v.Code, + } + case *appengine_internal.CallError: + return &CallError{ + Detail: v.Detail, + Code: v.Code, + Timeout: v.Timeout, + } + } + return err +} + +func handleHTTP(w http.ResponseWriter, r *http.Request) { + panic("handleHTTP called; this should be impossible") +} + +func logf(c appengine.Context, level int64, format string, args ...interface{}) { + var fn func(format string, args ...interface{}) + switch level { + case 0: + fn = c.Debugf + case 1: + fn = c.Infof + case 2: + fn = c.Warningf + case 3: + fn = c.Errorf + case 4: + fn = c.Criticalf + default: + // This shouldn't happen. + fn = c.Criticalf + } + fn(format, args...) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api_common.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api_common.go new file mode 100644 index 000000000000..2db33a774bc6 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/api_common.go @@ -0,0 +1,86 @@ +// Copyright 2015 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +import ( + "github.com/golang/protobuf/proto" + netcontext "golang.org/x/net/context" +) + +type CallOverrideFunc func(ctx netcontext.Context, service, method string, in, out proto.Message) error + +var callOverrideKey = "holds []CallOverrideFunc" + +func WithCallOverride(ctx netcontext.Context, f CallOverrideFunc) netcontext.Context { + // We avoid appending to any existing call override + // so we don't risk overwriting a popped stack below. + var cofs []CallOverrideFunc + if uf, ok := ctx.Value(&callOverrideKey).([]CallOverrideFunc); ok { + cofs = append(cofs, uf...) + } + cofs = append(cofs, f) + return netcontext.WithValue(ctx, &callOverrideKey, cofs) +} + +func callOverrideFromContext(ctx netcontext.Context) (CallOverrideFunc, netcontext.Context, bool) { + cofs, _ := ctx.Value(&callOverrideKey).([]CallOverrideFunc) + if len(cofs) == 0 { + return nil, nil, false + } + // We found a list of overrides; grab the last, and reconstitute a + // context that will hide it. + f := cofs[len(cofs)-1] + ctx = netcontext.WithValue(ctx, &callOverrideKey, cofs[:len(cofs)-1]) + return f, ctx, true +} + +type logOverrideFunc func(level int64, format string, args ...interface{}) + +var logOverrideKey = "holds a logOverrideFunc" + +func WithLogOverride(ctx netcontext.Context, f logOverrideFunc) netcontext.Context { + return netcontext.WithValue(ctx, &logOverrideKey, f) +} + +var appIDOverrideKey = "holds a string, being the full app ID" + +func WithAppIDOverride(ctx netcontext.Context, appID string) netcontext.Context { + return netcontext.WithValue(ctx, &appIDOverrideKey, appID) +} + +var namespaceKey = "holds the namespace string" + +func withNamespace(ctx netcontext.Context, ns string) netcontext.Context { + return netcontext.WithValue(ctx, &namespaceKey, ns) +} + +func NamespaceFromContext(ctx netcontext.Context) string { + // If there's no namespace, return the empty string. + ns, _ := ctx.Value(&namespaceKey).(string) + return ns +} + +// FullyQualifiedAppID returns the fully-qualified application ID. +// This may contain a partition prefix (e.g. "s~" for High Replication apps), +// or a domain prefix (e.g. "example.com:"). +func FullyQualifiedAppID(ctx netcontext.Context) string { + if id, ok := ctx.Value(&appIDOverrideKey).(string); ok { + return id + } + return fullyQualifiedAppID(ctx) +} + +func Logf(ctx netcontext.Context, level int64, format string, args ...interface{}) { + if f, ok := ctx.Value(&logOverrideKey).(logOverrideFunc); ok { + f(level, format, args...) + return + } + logf(fromContext(ctx), level, format, args...) +} + +// NamespacedContext wraps a Context to support namespaces. +func NamespacedContext(ctx netcontext.Context, namespace string) netcontext.Context { + return withNamespace(ctx, namespace) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_id.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_id.go new file mode 100644 index 000000000000..11df8c07b538 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_id.go @@ -0,0 +1,28 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +import ( + "strings" +) + +func parseFullAppID(appid string) (partition, domain, displayID string) { + if i := strings.Index(appid, "~"); i != -1 { + partition, appid = appid[:i], appid[i+1:] + } + if i := strings.Index(appid, ":"); i != -1 { + domain, appid = appid[:i], appid[i+1:] + } + return partition, domain, appid +} + +// appID returns "appid" or "domain.com:appid". +func appID(fullAppID string) string { + _, dom, dis := parseFullAppID(fullAppID) + if dom != "" { + return dom + ":" + dis + } + return dis +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.pb.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.pb.go new file mode 100644 index 000000000000..87d9701b8df9 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.pb.go @@ -0,0 +1,296 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/app_identity/app_identity_service.proto +// DO NOT EDIT! + +/* +Package app_identity is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/app_identity/app_identity_service.proto + +It has these top-level messages: + AppIdentityServiceError + SignForAppRequest + SignForAppResponse + GetPublicCertificateForAppRequest + PublicCertificate + GetPublicCertificateForAppResponse + GetServiceAccountNameRequest + GetServiceAccountNameResponse + GetAccessTokenRequest + GetAccessTokenResponse + GetDefaultGcsBucketNameRequest + GetDefaultGcsBucketNameResponse +*/ +package app_identity + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type AppIdentityServiceError_ErrorCode int32 + +const ( + AppIdentityServiceError_SUCCESS AppIdentityServiceError_ErrorCode = 0 + AppIdentityServiceError_UNKNOWN_SCOPE AppIdentityServiceError_ErrorCode = 9 + AppIdentityServiceError_BLOB_TOO_LARGE AppIdentityServiceError_ErrorCode = 1000 + AppIdentityServiceError_DEADLINE_EXCEEDED AppIdentityServiceError_ErrorCode = 1001 + AppIdentityServiceError_NOT_A_VALID_APP AppIdentityServiceError_ErrorCode = 1002 + AppIdentityServiceError_UNKNOWN_ERROR AppIdentityServiceError_ErrorCode = 1003 + AppIdentityServiceError_NOT_ALLOWED AppIdentityServiceError_ErrorCode = 1005 + AppIdentityServiceError_NOT_IMPLEMENTED AppIdentityServiceError_ErrorCode = 1006 +) + +var AppIdentityServiceError_ErrorCode_name = map[int32]string{ + 0: "SUCCESS", + 9: "UNKNOWN_SCOPE", + 1000: "BLOB_TOO_LARGE", + 1001: "DEADLINE_EXCEEDED", + 1002: "NOT_A_VALID_APP", + 1003: "UNKNOWN_ERROR", + 1005: "NOT_ALLOWED", + 1006: "NOT_IMPLEMENTED", +} +var AppIdentityServiceError_ErrorCode_value = map[string]int32{ + "SUCCESS": 0, + "UNKNOWN_SCOPE": 9, + "BLOB_TOO_LARGE": 1000, + "DEADLINE_EXCEEDED": 1001, + "NOT_A_VALID_APP": 1002, + "UNKNOWN_ERROR": 1003, + "NOT_ALLOWED": 1005, + "NOT_IMPLEMENTED": 1006, +} + +func (x AppIdentityServiceError_ErrorCode) Enum() *AppIdentityServiceError_ErrorCode { + p := new(AppIdentityServiceError_ErrorCode) + *p = x + return p +} +func (x AppIdentityServiceError_ErrorCode) String() string { + return proto.EnumName(AppIdentityServiceError_ErrorCode_name, int32(x)) +} +func (x *AppIdentityServiceError_ErrorCode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(AppIdentityServiceError_ErrorCode_value, data, "AppIdentityServiceError_ErrorCode") + if err != nil { + return err + } + *x = AppIdentityServiceError_ErrorCode(value) + return nil +} + +type AppIdentityServiceError struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *AppIdentityServiceError) Reset() { *m = AppIdentityServiceError{} } +func (m *AppIdentityServiceError) String() string { return proto.CompactTextString(m) } +func (*AppIdentityServiceError) ProtoMessage() {} + +type SignForAppRequest struct { + BytesToSign []byte `protobuf:"bytes,1,opt,name=bytes_to_sign" json:"bytes_to_sign,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SignForAppRequest) Reset() { *m = SignForAppRequest{} } +func (m *SignForAppRequest) String() string { return proto.CompactTextString(m) } +func (*SignForAppRequest) ProtoMessage() {} + +func (m *SignForAppRequest) GetBytesToSign() []byte { + if m != nil { + return m.BytesToSign + } + return nil +} + +type SignForAppResponse struct { + KeyName *string `protobuf:"bytes,1,opt,name=key_name" json:"key_name,omitempty"` + SignatureBytes []byte `protobuf:"bytes,2,opt,name=signature_bytes" json:"signature_bytes,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SignForAppResponse) Reset() { *m = SignForAppResponse{} } +func (m *SignForAppResponse) String() string { return proto.CompactTextString(m) } +func (*SignForAppResponse) ProtoMessage() {} + +func (m *SignForAppResponse) GetKeyName() string { + if m != nil && m.KeyName != nil { + return *m.KeyName + } + return "" +} + +func (m *SignForAppResponse) GetSignatureBytes() []byte { + if m != nil { + return m.SignatureBytes + } + return nil +} + +type GetPublicCertificateForAppRequest struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetPublicCertificateForAppRequest) Reset() { *m = GetPublicCertificateForAppRequest{} } +func (m *GetPublicCertificateForAppRequest) String() string { return proto.CompactTextString(m) } +func (*GetPublicCertificateForAppRequest) ProtoMessage() {} + +type PublicCertificate struct { + KeyName *string `protobuf:"bytes,1,opt,name=key_name" json:"key_name,omitempty"` + X509CertificatePem *string `protobuf:"bytes,2,opt,name=x509_certificate_pem" json:"x509_certificate_pem,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PublicCertificate) Reset() { *m = PublicCertificate{} } +func (m *PublicCertificate) String() string { return proto.CompactTextString(m) } +func (*PublicCertificate) ProtoMessage() {} + +func (m *PublicCertificate) GetKeyName() string { + if m != nil && m.KeyName != nil { + return *m.KeyName + } + return "" +} + +func (m *PublicCertificate) GetX509CertificatePem() string { + if m != nil && m.X509CertificatePem != nil { + return *m.X509CertificatePem + } + return "" +} + +type GetPublicCertificateForAppResponse struct { + PublicCertificateList []*PublicCertificate `protobuf:"bytes,1,rep,name=public_certificate_list" json:"public_certificate_list,omitempty"` + MaxClientCacheTimeInSecond *int64 `protobuf:"varint,2,opt,name=max_client_cache_time_in_second" json:"max_client_cache_time_in_second,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetPublicCertificateForAppResponse) Reset() { *m = GetPublicCertificateForAppResponse{} } +func (m *GetPublicCertificateForAppResponse) String() string { return proto.CompactTextString(m) } +func (*GetPublicCertificateForAppResponse) ProtoMessage() {} + +func (m *GetPublicCertificateForAppResponse) GetPublicCertificateList() []*PublicCertificate { + if m != nil { + return m.PublicCertificateList + } + return nil +} + +func (m *GetPublicCertificateForAppResponse) GetMaxClientCacheTimeInSecond() int64 { + if m != nil && m.MaxClientCacheTimeInSecond != nil { + return *m.MaxClientCacheTimeInSecond + } + return 0 +} + +type GetServiceAccountNameRequest struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetServiceAccountNameRequest) Reset() { *m = GetServiceAccountNameRequest{} } +func (m *GetServiceAccountNameRequest) String() string { return proto.CompactTextString(m) } +func (*GetServiceAccountNameRequest) ProtoMessage() {} + +type GetServiceAccountNameResponse struct { + ServiceAccountName *string `protobuf:"bytes,1,opt,name=service_account_name" json:"service_account_name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetServiceAccountNameResponse) Reset() { *m = GetServiceAccountNameResponse{} } +func (m *GetServiceAccountNameResponse) String() string { return proto.CompactTextString(m) } +func (*GetServiceAccountNameResponse) ProtoMessage() {} + +func (m *GetServiceAccountNameResponse) GetServiceAccountName() string { + if m != nil && m.ServiceAccountName != nil { + return *m.ServiceAccountName + } + return "" +} + +type GetAccessTokenRequest struct { + Scope []string `protobuf:"bytes,1,rep,name=scope" json:"scope,omitempty"` + ServiceAccountId *int64 `protobuf:"varint,2,opt,name=service_account_id" json:"service_account_id,omitempty"` + ServiceAccountName *string `protobuf:"bytes,3,opt,name=service_account_name" json:"service_account_name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetAccessTokenRequest) Reset() { *m = GetAccessTokenRequest{} } +func (m *GetAccessTokenRequest) String() string { return proto.CompactTextString(m) } +func (*GetAccessTokenRequest) ProtoMessage() {} + +func (m *GetAccessTokenRequest) GetScope() []string { + if m != nil { + return m.Scope + } + return nil +} + +func (m *GetAccessTokenRequest) GetServiceAccountId() int64 { + if m != nil && m.ServiceAccountId != nil { + return *m.ServiceAccountId + } + return 0 +} + +func (m *GetAccessTokenRequest) GetServiceAccountName() string { + if m != nil && m.ServiceAccountName != nil { + return *m.ServiceAccountName + } + return "" +} + +type GetAccessTokenResponse struct { + AccessToken *string `protobuf:"bytes,1,opt,name=access_token" json:"access_token,omitempty"` + ExpirationTime *int64 `protobuf:"varint,2,opt,name=expiration_time" json:"expiration_time,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetAccessTokenResponse) Reset() { *m = GetAccessTokenResponse{} } +func (m *GetAccessTokenResponse) String() string { return proto.CompactTextString(m) } +func (*GetAccessTokenResponse) ProtoMessage() {} + +func (m *GetAccessTokenResponse) GetAccessToken() string { + if m != nil && m.AccessToken != nil { + return *m.AccessToken + } + return "" +} + +func (m *GetAccessTokenResponse) GetExpirationTime() int64 { + if m != nil && m.ExpirationTime != nil { + return *m.ExpirationTime + } + return 0 +} + +type GetDefaultGcsBucketNameRequest struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetDefaultGcsBucketNameRequest) Reset() { *m = GetDefaultGcsBucketNameRequest{} } +func (m *GetDefaultGcsBucketNameRequest) String() string { return proto.CompactTextString(m) } +func (*GetDefaultGcsBucketNameRequest) ProtoMessage() {} + +type GetDefaultGcsBucketNameResponse struct { + DefaultGcsBucketName *string `protobuf:"bytes,1,opt,name=default_gcs_bucket_name" json:"default_gcs_bucket_name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetDefaultGcsBucketNameResponse) Reset() { *m = GetDefaultGcsBucketNameResponse{} } +func (m *GetDefaultGcsBucketNameResponse) String() string { return proto.CompactTextString(m) } +func (*GetDefaultGcsBucketNameResponse) ProtoMessage() {} + +func (m *GetDefaultGcsBucketNameResponse) GetDefaultGcsBucketName() string { + if m != nil && m.DefaultGcsBucketName != nil { + return *m.DefaultGcsBucketName + } + return "" +} + +func init() { +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.proto b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.proto new file mode 100644 index 000000000000..19610ca5b753 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.proto @@ -0,0 +1,64 @@ +syntax = "proto2"; +option go_package = "app_identity"; + +package appengine; + +message AppIdentityServiceError { + enum ErrorCode { + SUCCESS = 0; + UNKNOWN_SCOPE = 9; + BLOB_TOO_LARGE = 1000; + DEADLINE_EXCEEDED = 1001; + NOT_A_VALID_APP = 1002; + UNKNOWN_ERROR = 1003; + NOT_ALLOWED = 1005; + NOT_IMPLEMENTED = 1006; + } +} + +message SignForAppRequest { + optional bytes bytes_to_sign = 1; +} + +message SignForAppResponse { + optional string key_name = 1; + optional bytes signature_bytes = 2; +} + +message GetPublicCertificateForAppRequest { +} + +message PublicCertificate { + optional string key_name = 1; + optional string x509_certificate_pem = 2; +} + +message GetPublicCertificateForAppResponse { + repeated PublicCertificate public_certificate_list = 1; + optional int64 max_client_cache_time_in_second = 2; +} + +message GetServiceAccountNameRequest { +} + +message GetServiceAccountNameResponse { + optional string service_account_name = 1; +} + +message GetAccessTokenRequest { + repeated string scope = 1; + optional int64 service_account_id = 2; + optional string service_account_name = 3; +} + +message GetAccessTokenResponse { + optional string access_token = 1; + optional int64 expiration_time = 2; +} + +message GetDefaultGcsBucketNameRequest { +} + +message GetDefaultGcsBucketNameResponse { + optional string default_gcs_bucket_name = 1; +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/base/api_base.pb.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/base/api_base.pb.go new file mode 100644 index 000000000000..36a195650a95 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/base/api_base.pb.go @@ -0,0 +1,133 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/base/api_base.proto +// DO NOT EDIT! + +/* +Package base is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/base/api_base.proto + +It has these top-level messages: + StringProto + Integer32Proto + Integer64Proto + BoolProto + DoubleProto + BytesProto + VoidProto +*/ +package base + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type StringProto struct { + Value *string `protobuf:"bytes,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *StringProto) Reset() { *m = StringProto{} } +func (m *StringProto) String() string { return proto.CompactTextString(m) } +func (*StringProto) ProtoMessage() {} + +func (m *StringProto) GetValue() string { + if m != nil && m.Value != nil { + return *m.Value + } + return "" +} + +type Integer32Proto struct { + Value *int32 `protobuf:"varint,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Integer32Proto) Reset() { *m = Integer32Proto{} } +func (m *Integer32Proto) String() string { return proto.CompactTextString(m) } +func (*Integer32Proto) ProtoMessage() {} + +func (m *Integer32Proto) GetValue() int32 { + if m != nil && m.Value != nil { + return *m.Value + } + return 0 +} + +type Integer64Proto struct { + Value *int64 `protobuf:"varint,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Integer64Proto) Reset() { *m = Integer64Proto{} } +func (m *Integer64Proto) String() string { return proto.CompactTextString(m) } +func (*Integer64Proto) ProtoMessage() {} + +func (m *Integer64Proto) GetValue() int64 { + if m != nil && m.Value != nil { + return *m.Value + } + return 0 +} + +type BoolProto struct { + Value *bool `protobuf:"varint,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *BoolProto) Reset() { *m = BoolProto{} } +func (m *BoolProto) String() string { return proto.CompactTextString(m) } +func (*BoolProto) ProtoMessage() {} + +func (m *BoolProto) GetValue() bool { + if m != nil && m.Value != nil { + return *m.Value + } + return false +} + +type DoubleProto struct { + Value *float64 `protobuf:"fixed64,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DoubleProto) Reset() { *m = DoubleProto{} } +func (m *DoubleProto) String() string { return proto.CompactTextString(m) } +func (*DoubleProto) ProtoMessage() {} + +func (m *DoubleProto) GetValue() float64 { + if m != nil && m.Value != nil { + return *m.Value + } + return 0 +} + +type BytesProto struct { + Value []byte `protobuf:"bytes,1,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *BytesProto) Reset() { *m = BytesProto{} } +func (m *BytesProto) String() string { return proto.CompactTextString(m) } +func (*BytesProto) ProtoMessage() {} + +func (m *BytesProto) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +type VoidProto struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *VoidProto) Reset() { *m = VoidProto{} } +func (m *VoidProto) String() string { return proto.CompactTextString(m) } +func (*VoidProto) ProtoMessage() {} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/base/api_base.proto b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/base/api_base.proto new file mode 100644 index 000000000000..56cd7a3cad05 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/base/api_base.proto @@ -0,0 +1,33 @@ +// Built-in base types for API calls. Primarily useful as return types. + +syntax = "proto2"; +option go_package = "base"; + +package appengine.base; + +message StringProto { + required string value = 1; +} + +message Integer32Proto { + required int32 value = 1; +} + +message Integer64Proto { + required int64 value = 1; +} + +message BoolProto { + required bool value = 1; +} + +message DoubleProto { + required double value = 1; +} + +message BytesProto { + required bytes value = 1 [ctype=CORD]; +} + +message VoidProto { +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go new file mode 100644 index 000000000000..8613cb7311af --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go @@ -0,0 +1,2778 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/datastore/datastore_v3.proto +// DO NOT EDIT! + +/* +Package datastore is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/datastore/datastore_v3.proto + +It has these top-level messages: + Action + PropertyValue + Property + Path + Reference + User + EntityProto + CompositeProperty + Index + CompositeIndex + IndexPostfix + IndexPosition + Snapshot + InternalHeader + Transaction + Query + CompiledQuery + CompiledCursor + Cursor + Error + Cost + GetRequest + GetResponse + PutRequest + PutResponse + TouchRequest + TouchResponse + DeleteRequest + DeleteResponse + NextRequest + QueryResult + AllocateIdsRequest + AllocateIdsResponse + CompositeIndices + AddActionsRequest + AddActionsResponse + BeginTransactionRequest + CommitResponse +*/ +package datastore + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type Property_Meaning int32 + +const ( + Property_NO_MEANING Property_Meaning = 0 + Property_BLOB Property_Meaning = 14 + Property_TEXT Property_Meaning = 15 + Property_BYTESTRING Property_Meaning = 16 + Property_ATOM_CATEGORY Property_Meaning = 1 + Property_ATOM_LINK Property_Meaning = 2 + Property_ATOM_TITLE Property_Meaning = 3 + Property_ATOM_CONTENT Property_Meaning = 4 + Property_ATOM_SUMMARY Property_Meaning = 5 + Property_ATOM_AUTHOR Property_Meaning = 6 + Property_GD_WHEN Property_Meaning = 7 + Property_GD_EMAIL Property_Meaning = 8 + Property_GEORSS_POINT Property_Meaning = 9 + Property_GD_IM Property_Meaning = 10 + Property_GD_PHONENUMBER Property_Meaning = 11 + Property_GD_POSTALADDRESS Property_Meaning = 12 + Property_GD_RATING Property_Meaning = 13 + Property_BLOBKEY Property_Meaning = 17 + Property_ENTITY_PROTO Property_Meaning = 19 + Property_INDEX_VALUE Property_Meaning = 18 +) + +var Property_Meaning_name = map[int32]string{ + 0: "NO_MEANING", + 14: "BLOB", + 15: "TEXT", + 16: "BYTESTRING", + 1: "ATOM_CATEGORY", + 2: "ATOM_LINK", + 3: "ATOM_TITLE", + 4: "ATOM_CONTENT", + 5: "ATOM_SUMMARY", + 6: "ATOM_AUTHOR", + 7: "GD_WHEN", + 8: "GD_EMAIL", + 9: "GEORSS_POINT", + 10: "GD_IM", + 11: "GD_PHONENUMBER", + 12: "GD_POSTALADDRESS", + 13: "GD_RATING", + 17: "BLOBKEY", + 19: "ENTITY_PROTO", + 18: "INDEX_VALUE", +} +var Property_Meaning_value = map[string]int32{ + "NO_MEANING": 0, + "BLOB": 14, + "TEXT": 15, + "BYTESTRING": 16, + "ATOM_CATEGORY": 1, + "ATOM_LINK": 2, + "ATOM_TITLE": 3, + "ATOM_CONTENT": 4, + "ATOM_SUMMARY": 5, + "ATOM_AUTHOR": 6, + "GD_WHEN": 7, + "GD_EMAIL": 8, + "GEORSS_POINT": 9, + "GD_IM": 10, + "GD_PHONENUMBER": 11, + "GD_POSTALADDRESS": 12, + "GD_RATING": 13, + "BLOBKEY": 17, + "ENTITY_PROTO": 19, + "INDEX_VALUE": 18, +} + +func (x Property_Meaning) Enum() *Property_Meaning { + p := new(Property_Meaning) + *p = x + return p +} +func (x Property_Meaning) String() string { + return proto.EnumName(Property_Meaning_name, int32(x)) +} +func (x *Property_Meaning) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Property_Meaning_value, data, "Property_Meaning") + if err != nil { + return err + } + *x = Property_Meaning(value) + return nil +} + +type Property_FtsTokenizationOption int32 + +const ( + Property_HTML Property_FtsTokenizationOption = 1 + Property_ATOM Property_FtsTokenizationOption = 2 +) + +var Property_FtsTokenizationOption_name = map[int32]string{ + 1: "HTML", + 2: "ATOM", +} +var Property_FtsTokenizationOption_value = map[string]int32{ + "HTML": 1, + "ATOM": 2, +} + +func (x Property_FtsTokenizationOption) Enum() *Property_FtsTokenizationOption { + p := new(Property_FtsTokenizationOption) + *p = x + return p +} +func (x Property_FtsTokenizationOption) String() string { + return proto.EnumName(Property_FtsTokenizationOption_name, int32(x)) +} +func (x *Property_FtsTokenizationOption) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Property_FtsTokenizationOption_value, data, "Property_FtsTokenizationOption") + if err != nil { + return err + } + *x = Property_FtsTokenizationOption(value) + return nil +} + +type EntityProto_Kind int32 + +const ( + EntityProto_GD_CONTACT EntityProto_Kind = 1 + EntityProto_GD_EVENT EntityProto_Kind = 2 + EntityProto_GD_MESSAGE EntityProto_Kind = 3 +) + +var EntityProto_Kind_name = map[int32]string{ + 1: "GD_CONTACT", + 2: "GD_EVENT", + 3: "GD_MESSAGE", +} +var EntityProto_Kind_value = map[string]int32{ + "GD_CONTACT": 1, + "GD_EVENT": 2, + "GD_MESSAGE": 3, +} + +func (x EntityProto_Kind) Enum() *EntityProto_Kind { + p := new(EntityProto_Kind) + *p = x + return p +} +func (x EntityProto_Kind) String() string { + return proto.EnumName(EntityProto_Kind_name, int32(x)) +} +func (x *EntityProto_Kind) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(EntityProto_Kind_value, data, "EntityProto_Kind") + if err != nil { + return err + } + *x = EntityProto_Kind(value) + return nil +} + +type Index_Property_Direction int32 + +const ( + Index_Property_ASCENDING Index_Property_Direction = 1 + Index_Property_DESCENDING Index_Property_Direction = 2 +) + +var Index_Property_Direction_name = map[int32]string{ + 1: "ASCENDING", + 2: "DESCENDING", +} +var Index_Property_Direction_value = map[string]int32{ + "ASCENDING": 1, + "DESCENDING": 2, +} + +func (x Index_Property_Direction) Enum() *Index_Property_Direction { + p := new(Index_Property_Direction) + *p = x + return p +} +func (x Index_Property_Direction) String() string { + return proto.EnumName(Index_Property_Direction_name, int32(x)) +} +func (x *Index_Property_Direction) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Index_Property_Direction_value, data, "Index_Property_Direction") + if err != nil { + return err + } + *x = Index_Property_Direction(value) + return nil +} + +type CompositeIndex_State int32 + +const ( + CompositeIndex_WRITE_ONLY CompositeIndex_State = 1 + CompositeIndex_READ_WRITE CompositeIndex_State = 2 + CompositeIndex_DELETED CompositeIndex_State = 3 + CompositeIndex_ERROR CompositeIndex_State = 4 +) + +var CompositeIndex_State_name = map[int32]string{ + 1: "WRITE_ONLY", + 2: "READ_WRITE", + 3: "DELETED", + 4: "ERROR", +} +var CompositeIndex_State_value = map[string]int32{ + "WRITE_ONLY": 1, + "READ_WRITE": 2, + "DELETED": 3, + "ERROR": 4, +} + +func (x CompositeIndex_State) Enum() *CompositeIndex_State { + p := new(CompositeIndex_State) + *p = x + return p +} +func (x CompositeIndex_State) String() string { + return proto.EnumName(CompositeIndex_State_name, int32(x)) +} +func (x *CompositeIndex_State) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(CompositeIndex_State_value, data, "CompositeIndex_State") + if err != nil { + return err + } + *x = CompositeIndex_State(value) + return nil +} + +type Snapshot_Status int32 + +const ( + Snapshot_INACTIVE Snapshot_Status = 0 + Snapshot_ACTIVE Snapshot_Status = 1 +) + +var Snapshot_Status_name = map[int32]string{ + 0: "INACTIVE", + 1: "ACTIVE", +} +var Snapshot_Status_value = map[string]int32{ + "INACTIVE": 0, + "ACTIVE": 1, +} + +func (x Snapshot_Status) Enum() *Snapshot_Status { + p := new(Snapshot_Status) + *p = x + return p +} +func (x Snapshot_Status) String() string { + return proto.EnumName(Snapshot_Status_name, int32(x)) +} +func (x *Snapshot_Status) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Snapshot_Status_value, data, "Snapshot_Status") + if err != nil { + return err + } + *x = Snapshot_Status(value) + return nil +} + +type Query_Hint int32 + +const ( + Query_ORDER_FIRST Query_Hint = 1 + Query_ANCESTOR_FIRST Query_Hint = 2 + Query_FILTER_FIRST Query_Hint = 3 +) + +var Query_Hint_name = map[int32]string{ + 1: "ORDER_FIRST", + 2: "ANCESTOR_FIRST", + 3: "FILTER_FIRST", +} +var Query_Hint_value = map[string]int32{ + "ORDER_FIRST": 1, + "ANCESTOR_FIRST": 2, + "FILTER_FIRST": 3, +} + +func (x Query_Hint) Enum() *Query_Hint { + p := new(Query_Hint) + *p = x + return p +} +func (x Query_Hint) String() string { + return proto.EnumName(Query_Hint_name, int32(x)) +} +func (x *Query_Hint) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Query_Hint_value, data, "Query_Hint") + if err != nil { + return err + } + *x = Query_Hint(value) + return nil +} + +type Query_Filter_Operator int32 + +const ( + Query_Filter_LESS_THAN Query_Filter_Operator = 1 + Query_Filter_LESS_THAN_OR_EQUAL Query_Filter_Operator = 2 + Query_Filter_GREATER_THAN Query_Filter_Operator = 3 + Query_Filter_GREATER_THAN_OR_EQUAL Query_Filter_Operator = 4 + Query_Filter_EQUAL Query_Filter_Operator = 5 + Query_Filter_IN Query_Filter_Operator = 6 + Query_Filter_EXISTS Query_Filter_Operator = 7 +) + +var Query_Filter_Operator_name = map[int32]string{ + 1: "LESS_THAN", + 2: "LESS_THAN_OR_EQUAL", + 3: "GREATER_THAN", + 4: "GREATER_THAN_OR_EQUAL", + 5: "EQUAL", + 6: "IN", + 7: "EXISTS", +} +var Query_Filter_Operator_value = map[string]int32{ + "LESS_THAN": 1, + "LESS_THAN_OR_EQUAL": 2, + "GREATER_THAN": 3, + "GREATER_THAN_OR_EQUAL": 4, + "EQUAL": 5, + "IN": 6, + "EXISTS": 7, +} + +func (x Query_Filter_Operator) Enum() *Query_Filter_Operator { + p := new(Query_Filter_Operator) + *p = x + return p +} +func (x Query_Filter_Operator) String() string { + return proto.EnumName(Query_Filter_Operator_name, int32(x)) +} +func (x *Query_Filter_Operator) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Query_Filter_Operator_value, data, "Query_Filter_Operator") + if err != nil { + return err + } + *x = Query_Filter_Operator(value) + return nil +} + +type Query_Order_Direction int32 + +const ( + Query_Order_ASCENDING Query_Order_Direction = 1 + Query_Order_DESCENDING Query_Order_Direction = 2 +) + +var Query_Order_Direction_name = map[int32]string{ + 1: "ASCENDING", + 2: "DESCENDING", +} +var Query_Order_Direction_value = map[string]int32{ + "ASCENDING": 1, + "DESCENDING": 2, +} + +func (x Query_Order_Direction) Enum() *Query_Order_Direction { + p := new(Query_Order_Direction) + *p = x + return p +} +func (x Query_Order_Direction) String() string { + return proto.EnumName(Query_Order_Direction_name, int32(x)) +} +func (x *Query_Order_Direction) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Query_Order_Direction_value, data, "Query_Order_Direction") + if err != nil { + return err + } + *x = Query_Order_Direction(value) + return nil +} + +type Error_ErrorCode int32 + +const ( + Error_BAD_REQUEST Error_ErrorCode = 1 + Error_CONCURRENT_TRANSACTION Error_ErrorCode = 2 + Error_INTERNAL_ERROR Error_ErrorCode = 3 + Error_NEED_INDEX Error_ErrorCode = 4 + Error_TIMEOUT Error_ErrorCode = 5 + Error_PERMISSION_DENIED Error_ErrorCode = 6 + Error_BIGTABLE_ERROR Error_ErrorCode = 7 + Error_COMMITTED_BUT_STILL_APPLYING Error_ErrorCode = 8 + Error_CAPABILITY_DISABLED Error_ErrorCode = 9 + Error_TRY_ALTERNATE_BACKEND Error_ErrorCode = 10 + Error_SAFE_TIME_TOO_OLD Error_ErrorCode = 11 +) + +var Error_ErrorCode_name = map[int32]string{ + 1: "BAD_REQUEST", + 2: "CONCURRENT_TRANSACTION", + 3: "INTERNAL_ERROR", + 4: "NEED_INDEX", + 5: "TIMEOUT", + 6: "PERMISSION_DENIED", + 7: "BIGTABLE_ERROR", + 8: "COMMITTED_BUT_STILL_APPLYING", + 9: "CAPABILITY_DISABLED", + 10: "TRY_ALTERNATE_BACKEND", + 11: "SAFE_TIME_TOO_OLD", +} +var Error_ErrorCode_value = map[string]int32{ + "BAD_REQUEST": 1, + "CONCURRENT_TRANSACTION": 2, + "INTERNAL_ERROR": 3, + "NEED_INDEX": 4, + "TIMEOUT": 5, + "PERMISSION_DENIED": 6, + "BIGTABLE_ERROR": 7, + "COMMITTED_BUT_STILL_APPLYING": 8, + "CAPABILITY_DISABLED": 9, + "TRY_ALTERNATE_BACKEND": 10, + "SAFE_TIME_TOO_OLD": 11, +} + +func (x Error_ErrorCode) Enum() *Error_ErrorCode { + p := new(Error_ErrorCode) + *p = x + return p +} +func (x Error_ErrorCode) String() string { + return proto.EnumName(Error_ErrorCode_name, int32(x)) +} +func (x *Error_ErrorCode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(Error_ErrorCode_value, data, "Error_ErrorCode") + if err != nil { + return err + } + *x = Error_ErrorCode(value) + return nil +} + +type PutRequest_AutoIdPolicy int32 + +const ( + PutRequest_CURRENT PutRequest_AutoIdPolicy = 0 + PutRequest_SEQUENTIAL PutRequest_AutoIdPolicy = 1 +) + +var PutRequest_AutoIdPolicy_name = map[int32]string{ + 0: "CURRENT", + 1: "SEQUENTIAL", +} +var PutRequest_AutoIdPolicy_value = map[string]int32{ + "CURRENT": 0, + "SEQUENTIAL": 1, +} + +func (x PutRequest_AutoIdPolicy) Enum() *PutRequest_AutoIdPolicy { + p := new(PutRequest_AutoIdPolicy) + *p = x + return p +} +func (x PutRequest_AutoIdPolicy) String() string { + return proto.EnumName(PutRequest_AutoIdPolicy_name, int32(x)) +} +func (x *PutRequest_AutoIdPolicy) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(PutRequest_AutoIdPolicy_value, data, "PutRequest_AutoIdPolicy") + if err != nil { + return err + } + *x = PutRequest_AutoIdPolicy(value) + return nil +} + +type Action struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *Action) Reset() { *m = Action{} } +func (m *Action) String() string { return proto.CompactTextString(m) } +func (*Action) ProtoMessage() {} + +type PropertyValue struct { + Int64Value *int64 `protobuf:"varint,1,opt,name=int64Value" json:"int64Value,omitempty"` + BooleanValue *bool `protobuf:"varint,2,opt,name=booleanValue" json:"booleanValue,omitempty"` + StringValue *string `protobuf:"bytes,3,opt,name=stringValue" json:"stringValue,omitempty"` + DoubleValue *float64 `protobuf:"fixed64,4,opt,name=doubleValue" json:"doubleValue,omitempty"` + Pointvalue *PropertyValue_PointValue `protobuf:"group,5,opt,name=PointValue" json:"pointvalue,omitempty"` + Uservalue *PropertyValue_UserValue `protobuf:"group,8,opt,name=UserValue" json:"uservalue,omitempty"` + Referencevalue *PropertyValue_ReferenceValue `protobuf:"group,12,opt,name=ReferenceValue" json:"referencevalue,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PropertyValue) Reset() { *m = PropertyValue{} } +func (m *PropertyValue) String() string { return proto.CompactTextString(m) } +func (*PropertyValue) ProtoMessage() {} + +func (m *PropertyValue) GetInt64Value() int64 { + if m != nil && m.Int64Value != nil { + return *m.Int64Value + } + return 0 +} + +func (m *PropertyValue) GetBooleanValue() bool { + if m != nil && m.BooleanValue != nil { + return *m.BooleanValue + } + return false +} + +func (m *PropertyValue) GetStringValue() string { + if m != nil && m.StringValue != nil { + return *m.StringValue + } + return "" +} + +func (m *PropertyValue) GetDoubleValue() float64 { + if m != nil && m.DoubleValue != nil { + return *m.DoubleValue + } + return 0 +} + +func (m *PropertyValue) GetPointvalue() *PropertyValue_PointValue { + if m != nil { + return m.Pointvalue + } + return nil +} + +func (m *PropertyValue) GetUservalue() *PropertyValue_UserValue { + if m != nil { + return m.Uservalue + } + return nil +} + +func (m *PropertyValue) GetReferencevalue() *PropertyValue_ReferenceValue { + if m != nil { + return m.Referencevalue + } + return nil +} + +type PropertyValue_PointValue struct { + X *float64 `protobuf:"fixed64,6,req,name=x" json:"x,omitempty"` + Y *float64 `protobuf:"fixed64,7,req,name=y" json:"y,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PropertyValue_PointValue) Reset() { *m = PropertyValue_PointValue{} } +func (m *PropertyValue_PointValue) String() string { return proto.CompactTextString(m) } +func (*PropertyValue_PointValue) ProtoMessage() {} + +func (m *PropertyValue_PointValue) GetX() float64 { + if m != nil && m.X != nil { + return *m.X + } + return 0 +} + +func (m *PropertyValue_PointValue) GetY() float64 { + if m != nil && m.Y != nil { + return *m.Y + } + return 0 +} + +type PropertyValue_UserValue struct { + Email *string `protobuf:"bytes,9,req,name=email" json:"email,omitempty"` + AuthDomain *string `protobuf:"bytes,10,req,name=auth_domain" json:"auth_domain,omitempty"` + Nickname *string `protobuf:"bytes,11,opt,name=nickname" json:"nickname,omitempty"` + FederatedIdentity *string `protobuf:"bytes,21,opt,name=federated_identity" json:"federated_identity,omitempty"` + FederatedProvider *string `protobuf:"bytes,22,opt,name=federated_provider" json:"federated_provider,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PropertyValue_UserValue) Reset() { *m = PropertyValue_UserValue{} } +func (m *PropertyValue_UserValue) String() string { return proto.CompactTextString(m) } +func (*PropertyValue_UserValue) ProtoMessage() {} + +func (m *PropertyValue_UserValue) GetEmail() string { + if m != nil && m.Email != nil { + return *m.Email + } + return "" +} + +func (m *PropertyValue_UserValue) GetAuthDomain() string { + if m != nil && m.AuthDomain != nil { + return *m.AuthDomain + } + return "" +} + +func (m *PropertyValue_UserValue) GetNickname() string { + if m != nil && m.Nickname != nil { + return *m.Nickname + } + return "" +} + +func (m *PropertyValue_UserValue) GetFederatedIdentity() string { + if m != nil && m.FederatedIdentity != nil { + return *m.FederatedIdentity + } + return "" +} + +func (m *PropertyValue_UserValue) GetFederatedProvider() string { + if m != nil && m.FederatedProvider != nil { + return *m.FederatedProvider + } + return "" +} + +type PropertyValue_ReferenceValue struct { + App *string `protobuf:"bytes,13,req,name=app" json:"app,omitempty"` + NameSpace *string `protobuf:"bytes,20,opt,name=name_space" json:"name_space,omitempty"` + Pathelement []*PropertyValue_ReferenceValue_PathElement `protobuf:"group,14,rep,name=PathElement" json:"pathelement,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PropertyValue_ReferenceValue) Reset() { *m = PropertyValue_ReferenceValue{} } +func (m *PropertyValue_ReferenceValue) String() string { return proto.CompactTextString(m) } +func (*PropertyValue_ReferenceValue) ProtoMessage() {} + +func (m *PropertyValue_ReferenceValue) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +func (m *PropertyValue_ReferenceValue) GetNameSpace() string { + if m != nil && m.NameSpace != nil { + return *m.NameSpace + } + return "" +} + +func (m *PropertyValue_ReferenceValue) GetPathelement() []*PropertyValue_ReferenceValue_PathElement { + if m != nil { + return m.Pathelement + } + return nil +} + +type PropertyValue_ReferenceValue_PathElement struct { + Type *string `protobuf:"bytes,15,req,name=type" json:"type,omitempty"` + Id *int64 `protobuf:"varint,16,opt,name=id" json:"id,omitempty"` + Name *string `protobuf:"bytes,17,opt,name=name" json:"name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PropertyValue_ReferenceValue_PathElement) Reset() { + *m = PropertyValue_ReferenceValue_PathElement{} +} +func (m *PropertyValue_ReferenceValue_PathElement) String() string { return proto.CompactTextString(m) } +func (*PropertyValue_ReferenceValue_PathElement) ProtoMessage() {} + +func (m *PropertyValue_ReferenceValue_PathElement) GetType() string { + if m != nil && m.Type != nil { + return *m.Type + } + return "" +} + +func (m *PropertyValue_ReferenceValue_PathElement) GetId() int64 { + if m != nil && m.Id != nil { + return *m.Id + } + return 0 +} + +func (m *PropertyValue_ReferenceValue_PathElement) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +type Property struct { + Meaning *Property_Meaning `protobuf:"varint,1,opt,name=meaning,enum=appengine.Property_Meaning,def=0" json:"meaning,omitempty"` + MeaningUri *string `protobuf:"bytes,2,opt,name=meaning_uri" json:"meaning_uri,omitempty"` + Name *string `protobuf:"bytes,3,req,name=name" json:"name,omitempty"` + Value *PropertyValue `protobuf:"bytes,5,req,name=value" json:"value,omitempty"` + Multiple *bool `protobuf:"varint,4,req,name=multiple" json:"multiple,omitempty"` + Searchable *bool `protobuf:"varint,6,opt,name=searchable,def=0" json:"searchable,omitempty"` + FtsTokenizationOption *Property_FtsTokenizationOption `protobuf:"varint,8,opt,name=fts_tokenization_option,enum=appengine.Property_FtsTokenizationOption" json:"fts_tokenization_option,omitempty"` + Locale *string `protobuf:"bytes,9,opt,name=locale,def=en" json:"locale,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Property) Reset() { *m = Property{} } +func (m *Property) String() string { return proto.CompactTextString(m) } +func (*Property) ProtoMessage() {} + +const Default_Property_Meaning Property_Meaning = Property_NO_MEANING +const Default_Property_Searchable bool = false +const Default_Property_Locale string = "en" + +func (m *Property) GetMeaning() Property_Meaning { + if m != nil && m.Meaning != nil { + return *m.Meaning + } + return Default_Property_Meaning +} + +func (m *Property) GetMeaningUri() string { + if m != nil && m.MeaningUri != nil { + return *m.MeaningUri + } + return "" +} + +func (m *Property) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *Property) GetValue() *PropertyValue { + if m != nil { + return m.Value + } + return nil +} + +func (m *Property) GetMultiple() bool { + if m != nil && m.Multiple != nil { + return *m.Multiple + } + return false +} + +func (m *Property) GetSearchable() bool { + if m != nil && m.Searchable != nil { + return *m.Searchable + } + return Default_Property_Searchable +} + +func (m *Property) GetFtsTokenizationOption() Property_FtsTokenizationOption { + if m != nil && m.FtsTokenizationOption != nil { + return *m.FtsTokenizationOption + } + return Property_HTML +} + +func (m *Property) GetLocale() string { + if m != nil && m.Locale != nil { + return *m.Locale + } + return Default_Property_Locale +} + +type Path struct { + Element []*Path_Element `protobuf:"group,1,rep,name=Element" json:"element,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Path) Reset() { *m = Path{} } +func (m *Path) String() string { return proto.CompactTextString(m) } +func (*Path) ProtoMessage() {} + +func (m *Path) GetElement() []*Path_Element { + if m != nil { + return m.Element + } + return nil +} + +type Path_Element struct { + Type *string `protobuf:"bytes,2,req,name=type" json:"type,omitempty"` + Id *int64 `protobuf:"varint,3,opt,name=id" json:"id,omitempty"` + Name *string `protobuf:"bytes,4,opt,name=name" json:"name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Path_Element) Reset() { *m = Path_Element{} } +func (m *Path_Element) String() string { return proto.CompactTextString(m) } +func (*Path_Element) ProtoMessage() {} + +func (m *Path_Element) GetType() string { + if m != nil && m.Type != nil { + return *m.Type + } + return "" +} + +func (m *Path_Element) GetId() int64 { + if m != nil && m.Id != nil { + return *m.Id + } + return 0 +} + +func (m *Path_Element) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +type Reference struct { + App *string `protobuf:"bytes,13,req,name=app" json:"app,omitempty"` + NameSpace *string `protobuf:"bytes,20,opt,name=name_space" json:"name_space,omitempty"` + Path *Path `protobuf:"bytes,14,req,name=path" json:"path,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Reference) Reset() { *m = Reference{} } +func (m *Reference) String() string { return proto.CompactTextString(m) } +func (*Reference) ProtoMessage() {} + +func (m *Reference) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +func (m *Reference) GetNameSpace() string { + if m != nil && m.NameSpace != nil { + return *m.NameSpace + } + return "" +} + +func (m *Reference) GetPath() *Path { + if m != nil { + return m.Path + } + return nil +} + +type User struct { + Email *string `protobuf:"bytes,1,req,name=email" json:"email,omitempty"` + AuthDomain *string `protobuf:"bytes,2,req,name=auth_domain" json:"auth_domain,omitempty"` + Nickname *string `protobuf:"bytes,3,opt,name=nickname" json:"nickname,omitempty"` + FederatedIdentity *string `protobuf:"bytes,6,opt,name=federated_identity" json:"federated_identity,omitempty"` + FederatedProvider *string `protobuf:"bytes,7,opt,name=federated_provider" json:"federated_provider,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *User) Reset() { *m = User{} } +func (m *User) String() string { return proto.CompactTextString(m) } +func (*User) ProtoMessage() {} + +func (m *User) GetEmail() string { + if m != nil && m.Email != nil { + return *m.Email + } + return "" +} + +func (m *User) GetAuthDomain() string { + if m != nil && m.AuthDomain != nil { + return *m.AuthDomain + } + return "" +} + +func (m *User) GetNickname() string { + if m != nil && m.Nickname != nil { + return *m.Nickname + } + return "" +} + +func (m *User) GetFederatedIdentity() string { + if m != nil && m.FederatedIdentity != nil { + return *m.FederatedIdentity + } + return "" +} + +func (m *User) GetFederatedProvider() string { + if m != nil && m.FederatedProvider != nil { + return *m.FederatedProvider + } + return "" +} + +type EntityProto struct { + Key *Reference `protobuf:"bytes,13,req,name=key" json:"key,omitempty"` + EntityGroup *Path `protobuf:"bytes,16,req,name=entity_group" json:"entity_group,omitempty"` + Owner *User `protobuf:"bytes,17,opt,name=owner" json:"owner,omitempty"` + Kind *EntityProto_Kind `protobuf:"varint,4,opt,name=kind,enum=appengine.EntityProto_Kind" json:"kind,omitempty"` + KindUri *string `protobuf:"bytes,5,opt,name=kind_uri" json:"kind_uri,omitempty"` + Property []*Property `protobuf:"bytes,14,rep,name=property" json:"property,omitempty"` + RawProperty []*Property `protobuf:"bytes,15,rep,name=raw_property" json:"raw_property,omitempty"` + Rank *int32 `protobuf:"varint,18,opt,name=rank" json:"rank,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *EntityProto) Reset() { *m = EntityProto{} } +func (m *EntityProto) String() string { return proto.CompactTextString(m) } +func (*EntityProto) ProtoMessage() {} + +func (m *EntityProto) GetKey() *Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *EntityProto) GetEntityGroup() *Path { + if m != nil { + return m.EntityGroup + } + return nil +} + +func (m *EntityProto) GetOwner() *User { + if m != nil { + return m.Owner + } + return nil +} + +func (m *EntityProto) GetKind() EntityProto_Kind { + if m != nil && m.Kind != nil { + return *m.Kind + } + return EntityProto_GD_CONTACT +} + +func (m *EntityProto) GetKindUri() string { + if m != nil && m.KindUri != nil { + return *m.KindUri + } + return "" +} + +func (m *EntityProto) GetProperty() []*Property { + if m != nil { + return m.Property + } + return nil +} + +func (m *EntityProto) GetRawProperty() []*Property { + if m != nil { + return m.RawProperty + } + return nil +} + +func (m *EntityProto) GetRank() int32 { + if m != nil && m.Rank != nil { + return *m.Rank + } + return 0 +} + +type CompositeProperty struct { + IndexId *int64 `protobuf:"varint,1,req,name=index_id" json:"index_id,omitempty"` + Value []string `protobuf:"bytes,2,rep,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompositeProperty) Reset() { *m = CompositeProperty{} } +func (m *CompositeProperty) String() string { return proto.CompactTextString(m) } +func (*CompositeProperty) ProtoMessage() {} + +func (m *CompositeProperty) GetIndexId() int64 { + if m != nil && m.IndexId != nil { + return *m.IndexId + } + return 0 +} + +func (m *CompositeProperty) GetValue() []string { + if m != nil { + return m.Value + } + return nil +} + +type Index struct { + EntityType *string `protobuf:"bytes,1,req,name=entity_type" json:"entity_type,omitempty"` + Ancestor *bool `protobuf:"varint,5,req,name=ancestor" json:"ancestor,omitempty"` + Property []*Index_Property `protobuf:"group,2,rep,name=Property" json:"property,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Index) Reset() { *m = Index{} } +func (m *Index) String() string { return proto.CompactTextString(m) } +func (*Index) ProtoMessage() {} + +func (m *Index) GetEntityType() string { + if m != nil && m.EntityType != nil { + return *m.EntityType + } + return "" +} + +func (m *Index) GetAncestor() bool { + if m != nil && m.Ancestor != nil { + return *m.Ancestor + } + return false +} + +func (m *Index) GetProperty() []*Index_Property { + if m != nil { + return m.Property + } + return nil +} + +type Index_Property struct { + Name *string `protobuf:"bytes,3,req,name=name" json:"name,omitempty"` + Direction *Index_Property_Direction `protobuf:"varint,4,opt,name=direction,enum=appengine.Index_Property_Direction,def=1" json:"direction,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Index_Property) Reset() { *m = Index_Property{} } +func (m *Index_Property) String() string { return proto.CompactTextString(m) } +func (*Index_Property) ProtoMessage() {} + +const Default_Index_Property_Direction Index_Property_Direction = Index_Property_ASCENDING + +func (m *Index_Property) GetName() string { + if m != nil && m.Name != nil { + return *m.Name + } + return "" +} + +func (m *Index_Property) GetDirection() Index_Property_Direction { + if m != nil && m.Direction != nil { + return *m.Direction + } + return Default_Index_Property_Direction +} + +type CompositeIndex struct { + AppId *string `protobuf:"bytes,1,req,name=app_id" json:"app_id,omitempty"` + Id *int64 `protobuf:"varint,2,req,name=id" json:"id,omitempty"` + Definition *Index `protobuf:"bytes,3,req,name=definition" json:"definition,omitempty"` + State *CompositeIndex_State `protobuf:"varint,4,req,name=state,enum=appengine.CompositeIndex_State" json:"state,omitempty"` + OnlyUseIfRequired *bool `protobuf:"varint,6,opt,name=only_use_if_required,def=0" json:"only_use_if_required,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompositeIndex) Reset() { *m = CompositeIndex{} } +func (m *CompositeIndex) String() string { return proto.CompactTextString(m) } +func (*CompositeIndex) ProtoMessage() {} + +const Default_CompositeIndex_OnlyUseIfRequired bool = false + +func (m *CompositeIndex) GetAppId() string { + if m != nil && m.AppId != nil { + return *m.AppId + } + return "" +} + +func (m *CompositeIndex) GetId() int64 { + if m != nil && m.Id != nil { + return *m.Id + } + return 0 +} + +func (m *CompositeIndex) GetDefinition() *Index { + if m != nil { + return m.Definition + } + return nil +} + +func (m *CompositeIndex) GetState() CompositeIndex_State { + if m != nil && m.State != nil { + return *m.State + } + return CompositeIndex_WRITE_ONLY +} + +func (m *CompositeIndex) GetOnlyUseIfRequired() bool { + if m != nil && m.OnlyUseIfRequired != nil { + return *m.OnlyUseIfRequired + } + return Default_CompositeIndex_OnlyUseIfRequired +} + +type IndexPostfix struct { + IndexValue []*IndexPostfix_IndexValue `protobuf:"bytes,1,rep,name=index_value" json:"index_value,omitempty"` + Key *Reference `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"` + Before *bool `protobuf:"varint,3,opt,name=before,def=1" json:"before,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *IndexPostfix) Reset() { *m = IndexPostfix{} } +func (m *IndexPostfix) String() string { return proto.CompactTextString(m) } +func (*IndexPostfix) ProtoMessage() {} + +const Default_IndexPostfix_Before bool = true + +func (m *IndexPostfix) GetIndexValue() []*IndexPostfix_IndexValue { + if m != nil { + return m.IndexValue + } + return nil +} + +func (m *IndexPostfix) GetKey() *Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *IndexPostfix) GetBefore() bool { + if m != nil && m.Before != nil { + return *m.Before + } + return Default_IndexPostfix_Before +} + +type IndexPostfix_IndexValue struct { + PropertyName *string `protobuf:"bytes,1,req,name=property_name" json:"property_name,omitempty"` + Value *PropertyValue `protobuf:"bytes,2,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *IndexPostfix_IndexValue) Reset() { *m = IndexPostfix_IndexValue{} } +func (m *IndexPostfix_IndexValue) String() string { return proto.CompactTextString(m) } +func (*IndexPostfix_IndexValue) ProtoMessage() {} + +func (m *IndexPostfix_IndexValue) GetPropertyName() string { + if m != nil && m.PropertyName != nil { + return *m.PropertyName + } + return "" +} + +func (m *IndexPostfix_IndexValue) GetValue() *PropertyValue { + if m != nil { + return m.Value + } + return nil +} + +type IndexPosition struct { + Key *string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + Before *bool `protobuf:"varint,2,opt,name=before,def=1" json:"before,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *IndexPosition) Reset() { *m = IndexPosition{} } +func (m *IndexPosition) String() string { return proto.CompactTextString(m) } +func (*IndexPosition) ProtoMessage() {} + +const Default_IndexPosition_Before bool = true + +func (m *IndexPosition) GetKey() string { + if m != nil && m.Key != nil { + return *m.Key + } + return "" +} + +func (m *IndexPosition) GetBefore() bool { + if m != nil && m.Before != nil { + return *m.Before + } + return Default_IndexPosition_Before +} + +type Snapshot struct { + Ts *int64 `protobuf:"varint,1,req,name=ts" json:"ts,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Snapshot) Reset() { *m = Snapshot{} } +func (m *Snapshot) String() string { return proto.CompactTextString(m) } +func (*Snapshot) ProtoMessage() {} + +func (m *Snapshot) GetTs() int64 { + if m != nil && m.Ts != nil { + return *m.Ts + } + return 0 +} + +type InternalHeader struct { + Qos *string `protobuf:"bytes,1,opt,name=qos" json:"qos,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *InternalHeader) Reset() { *m = InternalHeader{} } +func (m *InternalHeader) String() string { return proto.CompactTextString(m) } +func (*InternalHeader) ProtoMessage() {} + +func (m *InternalHeader) GetQos() string { + if m != nil && m.Qos != nil { + return *m.Qos + } + return "" +} + +type Transaction struct { + Header *InternalHeader `protobuf:"bytes,4,opt,name=header" json:"header,omitempty"` + Handle *uint64 `protobuf:"fixed64,1,req,name=handle" json:"handle,omitempty"` + App *string `protobuf:"bytes,2,req,name=app" json:"app,omitempty"` + MarkChanges *bool `protobuf:"varint,3,opt,name=mark_changes,def=0" json:"mark_changes,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Transaction) Reset() { *m = Transaction{} } +func (m *Transaction) String() string { return proto.CompactTextString(m) } +func (*Transaction) ProtoMessage() {} + +const Default_Transaction_MarkChanges bool = false + +func (m *Transaction) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *Transaction) GetHandle() uint64 { + if m != nil && m.Handle != nil { + return *m.Handle + } + return 0 +} + +func (m *Transaction) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +func (m *Transaction) GetMarkChanges() bool { + if m != nil && m.MarkChanges != nil { + return *m.MarkChanges + } + return Default_Transaction_MarkChanges +} + +type Query struct { + Header *InternalHeader `protobuf:"bytes,39,opt,name=header" json:"header,omitempty"` + App *string `protobuf:"bytes,1,req,name=app" json:"app,omitempty"` + NameSpace *string `protobuf:"bytes,29,opt,name=name_space" json:"name_space,omitempty"` + Kind *string `protobuf:"bytes,3,opt,name=kind" json:"kind,omitempty"` + Ancestor *Reference `protobuf:"bytes,17,opt,name=ancestor" json:"ancestor,omitempty"` + Filter []*Query_Filter `protobuf:"group,4,rep,name=Filter" json:"filter,omitempty"` + SearchQuery *string `protobuf:"bytes,8,opt,name=search_query" json:"search_query,omitempty"` + Order []*Query_Order `protobuf:"group,9,rep,name=Order" json:"order,omitempty"` + Hint *Query_Hint `protobuf:"varint,18,opt,name=hint,enum=appengine.Query_Hint" json:"hint,omitempty"` + Count *int32 `protobuf:"varint,23,opt,name=count" json:"count,omitempty"` + Offset *int32 `protobuf:"varint,12,opt,name=offset,def=0" json:"offset,omitempty"` + Limit *int32 `protobuf:"varint,16,opt,name=limit" json:"limit,omitempty"` + CompiledCursor *CompiledCursor `protobuf:"bytes,30,opt,name=compiled_cursor" json:"compiled_cursor,omitempty"` + EndCompiledCursor *CompiledCursor `protobuf:"bytes,31,opt,name=end_compiled_cursor" json:"end_compiled_cursor,omitempty"` + CompositeIndex []*CompositeIndex `protobuf:"bytes,19,rep,name=composite_index" json:"composite_index,omitempty"` + RequirePerfectPlan *bool `protobuf:"varint,20,opt,name=require_perfect_plan,def=0" json:"require_perfect_plan,omitempty"` + KeysOnly *bool `protobuf:"varint,21,opt,name=keys_only,def=0" json:"keys_only,omitempty"` + Transaction *Transaction `protobuf:"bytes,22,opt,name=transaction" json:"transaction,omitempty"` + Compile *bool `protobuf:"varint,25,opt,name=compile,def=0" json:"compile,omitempty"` + FailoverMs *int64 `protobuf:"varint,26,opt,name=failover_ms" json:"failover_ms,omitempty"` + Strong *bool `protobuf:"varint,32,opt,name=strong" json:"strong,omitempty"` + PropertyName []string `protobuf:"bytes,33,rep,name=property_name" json:"property_name,omitempty"` + GroupByPropertyName []string `protobuf:"bytes,34,rep,name=group_by_property_name" json:"group_by_property_name,omitempty"` + Distinct *bool `protobuf:"varint,24,opt,name=distinct" json:"distinct,omitempty"` + MinSafeTimeSeconds *int64 `protobuf:"varint,35,opt,name=min_safe_time_seconds" json:"min_safe_time_seconds,omitempty"` + SafeReplicaName []string `protobuf:"bytes,36,rep,name=safe_replica_name" json:"safe_replica_name,omitempty"` + PersistOffset *bool `protobuf:"varint,37,opt,name=persist_offset,def=0" json:"persist_offset,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Query) Reset() { *m = Query{} } +func (m *Query) String() string { return proto.CompactTextString(m) } +func (*Query) ProtoMessage() {} + +const Default_Query_Offset int32 = 0 +const Default_Query_RequirePerfectPlan bool = false +const Default_Query_KeysOnly bool = false +const Default_Query_Compile bool = false +const Default_Query_PersistOffset bool = false + +func (m *Query) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *Query) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +func (m *Query) GetNameSpace() string { + if m != nil && m.NameSpace != nil { + return *m.NameSpace + } + return "" +} + +func (m *Query) GetKind() string { + if m != nil && m.Kind != nil { + return *m.Kind + } + return "" +} + +func (m *Query) GetAncestor() *Reference { + if m != nil { + return m.Ancestor + } + return nil +} + +func (m *Query) GetFilter() []*Query_Filter { + if m != nil { + return m.Filter + } + return nil +} + +func (m *Query) GetSearchQuery() string { + if m != nil && m.SearchQuery != nil { + return *m.SearchQuery + } + return "" +} + +func (m *Query) GetOrder() []*Query_Order { + if m != nil { + return m.Order + } + return nil +} + +func (m *Query) GetHint() Query_Hint { + if m != nil && m.Hint != nil { + return *m.Hint + } + return Query_ORDER_FIRST +} + +func (m *Query) GetCount() int32 { + if m != nil && m.Count != nil { + return *m.Count + } + return 0 +} + +func (m *Query) GetOffset() int32 { + if m != nil && m.Offset != nil { + return *m.Offset + } + return Default_Query_Offset +} + +func (m *Query) GetLimit() int32 { + if m != nil && m.Limit != nil { + return *m.Limit + } + return 0 +} + +func (m *Query) GetCompiledCursor() *CompiledCursor { + if m != nil { + return m.CompiledCursor + } + return nil +} + +func (m *Query) GetEndCompiledCursor() *CompiledCursor { + if m != nil { + return m.EndCompiledCursor + } + return nil +} + +func (m *Query) GetCompositeIndex() []*CompositeIndex { + if m != nil { + return m.CompositeIndex + } + return nil +} + +func (m *Query) GetRequirePerfectPlan() bool { + if m != nil && m.RequirePerfectPlan != nil { + return *m.RequirePerfectPlan + } + return Default_Query_RequirePerfectPlan +} + +func (m *Query) GetKeysOnly() bool { + if m != nil && m.KeysOnly != nil { + return *m.KeysOnly + } + return Default_Query_KeysOnly +} + +func (m *Query) GetTransaction() *Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *Query) GetCompile() bool { + if m != nil && m.Compile != nil { + return *m.Compile + } + return Default_Query_Compile +} + +func (m *Query) GetFailoverMs() int64 { + if m != nil && m.FailoverMs != nil { + return *m.FailoverMs + } + return 0 +} + +func (m *Query) GetStrong() bool { + if m != nil && m.Strong != nil { + return *m.Strong + } + return false +} + +func (m *Query) GetPropertyName() []string { + if m != nil { + return m.PropertyName + } + return nil +} + +func (m *Query) GetGroupByPropertyName() []string { + if m != nil { + return m.GroupByPropertyName + } + return nil +} + +func (m *Query) GetDistinct() bool { + if m != nil && m.Distinct != nil { + return *m.Distinct + } + return false +} + +func (m *Query) GetMinSafeTimeSeconds() int64 { + if m != nil && m.MinSafeTimeSeconds != nil { + return *m.MinSafeTimeSeconds + } + return 0 +} + +func (m *Query) GetSafeReplicaName() []string { + if m != nil { + return m.SafeReplicaName + } + return nil +} + +func (m *Query) GetPersistOffset() bool { + if m != nil && m.PersistOffset != nil { + return *m.PersistOffset + } + return Default_Query_PersistOffset +} + +type Query_Filter struct { + Op *Query_Filter_Operator `protobuf:"varint,6,req,name=op,enum=appengine.Query_Filter_Operator" json:"op,omitempty"` + Property []*Property `protobuf:"bytes,14,rep,name=property" json:"property,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Query_Filter) Reset() { *m = Query_Filter{} } +func (m *Query_Filter) String() string { return proto.CompactTextString(m) } +func (*Query_Filter) ProtoMessage() {} + +func (m *Query_Filter) GetOp() Query_Filter_Operator { + if m != nil && m.Op != nil { + return *m.Op + } + return Query_Filter_LESS_THAN +} + +func (m *Query_Filter) GetProperty() []*Property { + if m != nil { + return m.Property + } + return nil +} + +type Query_Order struct { + Property *string `protobuf:"bytes,10,req,name=property" json:"property,omitempty"` + Direction *Query_Order_Direction `protobuf:"varint,11,opt,name=direction,enum=appengine.Query_Order_Direction,def=1" json:"direction,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Query_Order) Reset() { *m = Query_Order{} } +func (m *Query_Order) String() string { return proto.CompactTextString(m) } +func (*Query_Order) ProtoMessage() {} + +const Default_Query_Order_Direction Query_Order_Direction = Query_Order_ASCENDING + +func (m *Query_Order) GetProperty() string { + if m != nil && m.Property != nil { + return *m.Property + } + return "" +} + +func (m *Query_Order) GetDirection() Query_Order_Direction { + if m != nil && m.Direction != nil { + return *m.Direction + } + return Default_Query_Order_Direction +} + +type CompiledQuery struct { + Primaryscan *CompiledQuery_PrimaryScan `protobuf:"group,1,req,name=PrimaryScan" json:"primaryscan,omitempty"` + Mergejoinscan []*CompiledQuery_MergeJoinScan `protobuf:"group,7,rep,name=MergeJoinScan" json:"mergejoinscan,omitempty"` + IndexDef *Index `protobuf:"bytes,21,opt,name=index_def" json:"index_def,omitempty"` + Offset *int32 `protobuf:"varint,10,opt,name=offset,def=0" json:"offset,omitempty"` + Limit *int32 `protobuf:"varint,11,opt,name=limit" json:"limit,omitempty"` + KeysOnly *bool `protobuf:"varint,12,req,name=keys_only" json:"keys_only,omitempty"` + PropertyName []string `protobuf:"bytes,24,rep,name=property_name" json:"property_name,omitempty"` + DistinctInfixSize *int32 `protobuf:"varint,25,opt,name=distinct_infix_size" json:"distinct_infix_size,omitempty"` + Entityfilter *CompiledQuery_EntityFilter `protobuf:"group,13,opt,name=EntityFilter" json:"entityfilter,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledQuery) Reset() { *m = CompiledQuery{} } +func (m *CompiledQuery) String() string { return proto.CompactTextString(m) } +func (*CompiledQuery) ProtoMessage() {} + +const Default_CompiledQuery_Offset int32 = 0 + +func (m *CompiledQuery) GetPrimaryscan() *CompiledQuery_PrimaryScan { + if m != nil { + return m.Primaryscan + } + return nil +} + +func (m *CompiledQuery) GetMergejoinscan() []*CompiledQuery_MergeJoinScan { + if m != nil { + return m.Mergejoinscan + } + return nil +} + +func (m *CompiledQuery) GetIndexDef() *Index { + if m != nil { + return m.IndexDef + } + return nil +} + +func (m *CompiledQuery) GetOffset() int32 { + if m != nil && m.Offset != nil { + return *m.Offset + } + return Default_CompiledQuery_Offset +} + +func (m *CompiledQuery) GetLimit() int32 { + if m != nil && m.Limit != nil { + return *m.Limit + } + return 0 +} + +func (m *CompiledQuery) GetKeysOnly() bool { + if m != nil && m.KeysOnly != nil { + return *m.KeysOnly + } + return false +} + +func (m *CompiledQuery) GetPropertyName() []string { + if m != nil { + return m.PropertyName + } + return nil +} + +func (m *CompiledQuery) GetDistinctInfixSize() int32 { + if m != nil && m.DistinctInfixSize != nil { + return *m.DistinctInfixSize + } + return 0 +} + +func (m *CompiledQuery) GetEntityfilter() *CompiledQuery_EntityFilter { + if m != nil { + return m.Entityfilter + } + return nil +} + +type CompiledQuery_PrimaryScan struct { + IndexName *string `protobuf:"bytes,2,opt,name=index_name" json:"index_name,omitempty"` + StartKey *string `protobuf:"bytes,3,opt,name=start_key" json:"start_key,omitempty"` + StartInclusive *bool `protobuf:"varint,4,opt,name=start_inclusive" json:"start_inclusive,omitempty"` + EndKey *string `protobuf:"bytes,5,opt,name=end_key" json:"end_key,omitempty"` + EndInclusive *bool `protobuf:"varint,6,opt,name=end_inclusive" json:"end_inclusive,omitempty"` + StartPostfixValue []string `protobuf:"bytes,22,rep,name=start_postfix_value" json:"start_postfix_value,omitempty"` + EndPostfixValue []string `protobuf:"bytes,23,rep,name=end_postfix_value" json:"end_postfix_value,omitempty"` + EndUnappliedLogTimestampUs *int64 `protobuf:"varint,19,opt,name=end_unapplied_log_timestamp_us" json:"end_unapplied_log_timestamp_us,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledQuery_PrimaryScan) Reset() { *m = CompiledQuery_PrimaryScan{} } +func (m *CompiledQuery_PrimaryScan) String() string { return proto.CompactTextString(m) } +func (*CompiledQuery_PrimaryScan) ProtoMessage() {} + +func (m *CompiledQuery_PrimaryScan) GetIndexName() string { + if m != nil && m.IndexName != nil { + return *m.IndexName + } + return "" +} + +func (m *CompiledQuery_PrimaryScan) GetStartKey() string { + if m != nil && m.StartKey != nil { + return *m.StartKey + } + return "" +} + +func (m *CompiledQuery_PrimaryScan) GetStartInclusive() bool { + if m != nil && m.StartInclusive != nil { + return *m.StartInclusive + } + return false +} + +func (m *CompiledQuery_PrimaryScan) GetEndKey() string { + if m != nil && m.EndKey != nil { + return *m.EndKey + } + return "" +} + +func (m *CompiledQuery_PrimaryScan) GetEndInclusive() bool { + if m != nil && m.EndInclusive != nil { + return *m.EndInclusive + } + return false +} + +func (m *CompiledQuery_PrimaryScan) GetStartPostfixValue() []string { + if m != nil { + return m.StartPostfixValue + } + return nil +} + +func (m *CompiledQuery_PrimaryScan) GetEndPostfixValue() []string { + if m != nil { + return m.EndPostfixValue + } + return nil +} + +func (m *CompiledQuery_PrimaryScan) GetEndUnappliedLogTimestampUs() int64 { + if m != nil && m.EndUnappliedLogTimestampUs != nil { + return *m.EndUnappliedLogTimestampUs + } + return 0 +} + +type CompiledQuery_MergeJoinScan struct { + IndexName *string `protobuf:"bytes,8,req,name=index_name" json:"index_name,omitempty"` + PrefixValue []string `protobuf:"bytes,9,rep,name=prefix_value" json:"prefix_value,omitempty"` + ValuePrefix *bool `protobuf:"varint,20,opt,name=value_prefix,def=0" json:"value_prefix,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledQuery_MergeJoinScan) Reset() { *m = CompiledQuery_MergeJoinScan{} } +func (m *CompiledQuery_MergeJoinScan) String() string { return proto.CompactTextString(m) } +func (*CompiledQuery_MergeJoinScan) ProtoMessage() {} + +const Default_CompiledQuery_MergeJoinScan_ValuePrefix bool = false + +func (m *CompiledQuery_MergeJoinScan) GetIndexName() string { + if m != nil && m.IndexName != nil { + return *m.IndexName + } + return "" +} + +func (m *CompiledQuery_MergeJoinScan) GetPrefixValue() []string { + if m != nil { + return m.PrefixValue + } + return nil +} + +func (m *CompiledQuery_MergeJoinScan) GetValuePrefix() bool { + if m != nil && m.ValuePrefix != nil { + return *m.ValuePrefix + } + return Default_CompiledQuery_MergeJoinScan_ValuePrefix +} + +type CompiledQuery_EntityFilter struct { + Distinct *bool `protobuf:"varint,14,opt,name=distinct,def=0" json:"distinct,omitempty"` + Kind *string `protobuf:"bytes,17,opt,name=kind" json:"kind,omitempty"` + Ancestor *Reference `protobuf:"bytes,18,opt,name=ancestor" json:"ancestor,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledQuery_EntityFilter) Reset() { *m = CompiledQuery_EntityFilter{} } +func (m *CompiledQuery_EntityFilter) String() string { return proto.CompactTextString(m) } +func (*CompiledQuery_EntityFilter) ProtoMessage() {} + +const Default_CompiledQuery_EntityFilter_Distinct bool = false + +func (m *CompiledQuery_EntityFilter) GetDistinct() bool { + if m != nil && m.Distinct != nil { + return *m.Distinct + } + return Default_CompiledQuery_EntityFilter_Distinct +} + +func (m *CompiledQuery_EntityFilter) GetKind() string { + if m != nil && m.Kind != nil { + return *m.Kind + } + return "" +} + +func (m *CompiledQuery_EntityFilter) GetAncestor() *Reference { + if m != nil { + return m.Ancestor + } + return nil +} + +type CompiledCursor struct { + Position *CompiledCursor_Position `protobuf:"group,2,opt,name=Position" json:"position,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledCursor) Reset() { *m = CompiledCursor{} } +func (m *CompiledCursor) String() string { return proto.CompactTextString(m) } +func (*CompiledCursor) ProtoMessage() {} + +func (m *CompiledCursor) GetPosition() *CompiledCursor_Position { + if m != nil { + return m.Position + } + return nil +} + +type CompiledCursor_Position struct { + StartKey *string `protobuf:"bytes,27,opt,name=start_key" json:"start_key,omitempty"` + Indexvalue []*CompiledCursor_Position_IndexValue `protobuf:"group,29,rep,name=IndexValue" json:"indexvalue,omitempty"` + Key *Reference `protobuf:"bytes,32,opt,name=key" json:"key,omitempty"` + StartInclusive *bool `protobuf:"varint,28,opt,name=start_inclusive,def=1" json:"start_inclusive,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledCursor_Position) Reset() { *m = CompiledCursor_Position{} } +func (m *CompiledCursor_Position) String() string { return proto.CompactTextString(m) } +func (*CompiledCursor_Position) ProtoMessage() {} + +const Default_CompiledCursor_Position_StartInclusive bool = true + +func (m *CompiledCursor_Position) GetStartKey() string { + if m != nil && m.StartKey != nil { + return *m.StartKey + } + return "" +} + +func (m *CompiledCursor_Position) GetIndexvalue() []*CompiledCursor_Position_IndexValue { + if m != nil { + return m.Indexvalue + } + return nil +} + +func (m *CompiledCursor_Position) GetKey() *Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *CompiledCursor_Position) GetStartInclusive() bool { + if m != nil && m.StartInclusive != nil { + return *m.StartInclusive + } + return Default_CompiledCursor_Position_StartInclusive +} + +type CompiledCursor_Position_IndexValue struct { + Property *string `protobuf:"bytes,30,opt,name=property" json:"property,omitempty"` + Value *PropertyValue `protobuf:"bytes,31,req,name=value" json:"value,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompiledCursor_Position_IndexValue) Reset() { *m = CompiledCursor_Position_IndexValue{} } +func (m *CompiledCursor_Position_IndexValue) String() string { return proto.CompactTextString(m) } +func (*CompiledCursor_Position_IndexValue) ProtoMessage() {} + +func (m *CompiledCursor_Position_IndexValue) GetProperty() string { + if m != nil && m.Property != nil { + return *m.Property + } + return "" +} + +func (m *CompiledCursor_Position_IndexValue) GetValue() *PropertyValue { + if m != nil { + return m.Value + } + return nil +} + +type Cursor struct { + Cursor *uint64 `protobuf:"fixed64,1,req,name=cursor" json:"cursor,omitempty"` + App *string `protobuf:"bytes,2,opt,name=app" json:"app,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Cursor) Reset() { *m = Cursor{} } +func (m *Cursor) String() string { return proto.CompactTextString(m) } +func (*Cursor) ProtoMessage() {} + +func (m *Cursor) GetCursor() uint64 { + if m != nil && m.Cursor != nil { + return *m.Cursor + } + return 0 +} + +func (m *Cursor) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +type Error struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *Error) Reset() { *m = Error{} } +func (m *Error) String() string { return proto.CompactTextString(m) } +func (*Error) ProtoMessage() {} + +type Cost struct { + IndexWrites *int32 `protobuf:"varint,1,opt,name=index_writes" json:"index_writes,omitempty"` + IndexWriteBytes *int32 `protobuf:"varint,2,opt,name=index_write_bytes" json:"index_write_bytes,omitempty"` + EntityWrites *int32 `protobuf:"varint,3,opt,name=entity_writes" json:"entity_writes,omitempty"` + EntityWriteBytes *int32 `protobuf:"varint,4,opt,name=entity_write_bytes" json:"entity_write_bytes,omitempty"` + Commitcost *Cost_CommitCost `protobuf:"group,5,opt,name=CommitCost" json:"commitcost,omitempty"` + ApproximateStorageDelta *int32 `protobuf:"varint,8,opt,name=approximate_storage_delta" json:"approximate_storage_delta,omitempty"` + IdSequenceUpdates *int32 `protobuf:"varint,9,opt,name=id_sequence_updates" json:"id_sequence_updates,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Cost) Reset() { *m = Cost{} } +func (m *Cost) String() string { return proto.CompactTextString(m) } +func (*Cost) ProtoMessage() {} + +func (m *Cost) GetIndexWrites() int32 { + if m != nil && m.IndexWrites != nil { + return *m.IndexWrites + } + return 0 +} + +func (m *Cost) GetIndexWriteBytes() int32 { + if m != nil && m.IndexWriteBytes != nil { + return *m.IndexWriteBytes + } + return 0 +} + +func (m *Cost) GetEntityWrites() int32 { + if m != nil && m.EntityWrites != nil { + return *m.EntityWrites + } + return 0 +} + +func (m *Cost) GetEntityWriteBytes() int32 { + if m != nil && m.EntityWriteBytes != nil { + return *m.EntityWriteBytes + } + return 0 +} + +func (m *Cost) GetCommitcost() *Cost_CommitCost { + if m != nil { + return m.Commitcost + } + return nil +} + +func (m *Cost) GetApproximateStorageDelta() int32 { + if m != nil && m.ApproximateStorageDelta != nil { + return *m.ApproximateStorageDelta + } + return 0 +} + +func (m *Cost) GetIdSequenceUpdates() int32 { + if m != nil && m.IdSequenceUpdates != nil { + return *m.IdSequenceUpdates + } + return 0 +} + +type Cost_CommitCost struct { + RequestedEntityPuts *int32 `protobuf:"varint,6,opt,name=requested_entity_puts" json:"requested_entity_puts,omitempty"` + RequestedEntityDeletes *int32 `protobuf:"varint,7,opt,name=requested_entity_deletes" json:"requested_entity_deletes,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Cost_CommitCost) Reset() { *m = Cost_CommitCost{} } +func (m *Cost_CommitCost) String() string { return proto.CompactTextString(m) } +func (*Cost_CommitCost) ProtoMessage() {} + +func (m *Cost_CommitCost) GetRequestedEntityPuts() int32 { + if m != nil && m.RequestedEntityPuts != nil { + return *m.RequestedEntityPuts + } + return 0 +} + +func (m *Cost_CommitCost) GetRequestedEntityDeletes() int32 { + if m != nil && m.RequestedEntityDeletes != nil { + return *m.RequestedEntityDeletes + } + return 0 +} + +type GetRequest struct { + Header *InternalHeader `protobuf:"bytes,6,opt,name=header" json:"header,omitempty"` + Key []*Reference `protobuf:"bytes,1,rep,name=key" json:"key,omitempty"` + Transaction *Transaction `protobuf:"bytes,2,opt,name=transaction" json:"transaction,omitempty"` + FailoverMs *int64 `protobuf:"varint,3,opt,name=failover_ms" json:"failover_ms,omitempty"` + Strong *bool `protobuf:"varint,4,opt,name=strong" json:"strong,omitempty"` + AllowDeferred *bool `protobuf:"varint,5,opt,name=allow_deferred,def=0" json:"allow_deferred,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetRequest) Reset() { *m = GetRequest{} } +func (m *GetRequest) String() string { return proto.CompactTextString(m) } +func (*GetRequest) ProtoMessage() {} + +const Default_GetRequest_AllowDeferred bool = false + +func (m *GetRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *GetRequest) GetKey() []*Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *GetRequest) GetTransaction() *Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *GetRequest) GetFailoverMs() int64 { + if m != nil && m.FailoverMs != nil { + return *m.FailoverMs + } + return 0 +} + +func (m *GetRequest) GetStrong() bool { + if m != nil && m.Strong != nil { + return *m.Strong + } + return false +} + +func (m *GetRequest) GetAllowDeferred() bool { + if m != nil && m.AllowDeferred != nil { + return *m.AllowDeferred + } + return Default_GetRequest_AllowDeferred +} + +type GetResponse struct { + Entity []*GetResponse_Entity `protobuf:"group,1,rep,name=Entity" json:"entity,omitempty"` + Deferred []*Reference `protobuf:"bytes,5,rep,name=deferred" json:"deferred,omitempty"` + InOrder *bool `protobuf:"varint,6,opt,name=in_order,def=1" json:"in_order,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetResponse) Reset() { *m = GetResponse{} } +func (m *GetResponse) String() string { return proto.CompactTextString(m) } +func (*GetResponse) ProtoMessage() {} + +const Default_GetResponse_InOrder bool = true + +func (m *GetResponse) GetEntity() []*GetResponse_Entity { + if m != nil { + return m.Entity + } + return nil +} + +func (m *GetResponse) GetDeferred() []*Reference { + if m != nil { + return m.Deferred + } + return nil +} + +func (m *GetResponse) GetInOrder() bool { + if m != nil && m.InOrder != nil { + return *m.InOrder + } + return Default_GetResponse_InOrder +} + +type GetResponse_Entity struct { + Entity *EntityProto `protobuf:"bytes,2,opt,name=entity" json:"entity,omitempty"` + Key *Reference `protobuf:"bytes,4,opt,name=key" json:"key,omitempty"` + Version *int64 `protobuf:"varint,3,opt,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetResponse_Entity) Reset() { *m = GetResponse_Entity{} } +func (m *GetResponse_Entity) String() string { return proto.CompactTextString(m) } +func (*GetResponse_Entity) ProtoMessage() {} + +func (m *GetResponse_Entity) GetEntity() *EntityProto { + if m != nil { + return m.Entity + } + return nil +} + +func (m *GetResponse_Entity) GetKey() *Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *GetResponse_Entity) GetVersion() int64 { + if m != nil && m.Version != nil { + return *m.Version + } + return 0 +} + +type PutRequest struct { + Header *InternalHeader `protobuf:"bytes,11,opt,name=header" json:"header,omitempty"` + Entity []*EntityProto `protobuf:"bytes,1,rep,name=entity" json:"entity,omitempty"` + Transaction *Transaction `protobuf:"bytes,2,opt,name=transaction" json:"transaction,omitempty"` + CompositeIndex []*CompositeIndex `protobuf:"bytes,3,rep,name=composite_index" json:"composite_index,omitempty"` + Trusted *bool `protobuf:"varint,4,opt,name=trusted,def=0" json:"trusted,omitempty"` + Force *bool `protobuf:"varint,7,opt,name=force,def=0" json:"force,omitempty"` + MarkChanges *bool `protobuf:"varint,8,opt,name=mark_changes,def=0" json:"mark_changes,omitempty"` + Snapshot []*Snapshot `protobuf:"bytes,9,rep,name=snapshot" json:"snapshot,omitempty"` + AutoIdPolicy *PutRequest_AutoIdPolicy `protobuf:"varint,10,opt,name=auto_id_policy,enum=appengine.PutRequest_AutoIdPolicy,def=0" json:"auto_id_policy,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PutRequest) Reset() { *m = PutRequest{} } +func (m *PutRequest) String() string { return proto.CompactTextString(m) } +func (*PutRequest) ProtoMessage() {} + +const Default_PutRequest_Trusted bool = false +const Default_PutRequest_Force bool = false +const Default_PutRequest_MarkChanges bool = false +const Default_PutRequest_AutoIdPolicy PutRequest_AutoIdPolicy = PutRequest_CURRENT + +func (m *PutRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *PutRequest) GetEntity() []*EntityProto { + if m != nil { + return m.Entity + } + return nil +} + +func (m *PutRequest) GetTransaction() *Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *PutRequest) GetCompositeIndex() []*CompositeIndex { + if m != nil { + return m.CompositeIndex + } + return nil +} + +func (m *PutRequest) GetTrusted() bool { + if m != nil && m.Trusted != nil { + return *m.Trusted + } + return Default_PutRequest_Trusted +} + +func (m *PutRequest) GetForce() bool { + if m != nil && m.Force != nil { + return *m.Force + } + return Default_PutRequest_Force +} + +func (m *PutRequest) GetMarkChanges() bool { + if m != nil && m.MarkChanges != nil { + return *m.MarkChanges + } + return Default_PutRequest_MarkChanges +} + +func (m *PutRequest) GetSnapshot() []*Snapshot { + if m != nil { + return m.Snapshot + } + return nil +} + +func (m *PutRequest) GetAutoIdPolicy() PutRequest_AutoIdPolicy { + if m != nil && m.AutoIdPolicy != nil { + return *m.AutoIdPolicy + } + return Default_PutRequest_AutoIdPolicy +} + +type PutResponse struct { + Key []*Reference `protobuf:"bytes,1,rep,name=key" json:"key,omitempty"` + Cost *Cost `protobuf:"bytes,2,opt,name=cost" json:"cost,omitempty"` + Version []int64 `protobuf:"varint,3,rep,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *PutResponse) Reset() { *m = PutResponse{} } +func (m *PutResponse) String() string { return proto.CompactTextString(m) } +func (*PutResponse) ProtoMessage() {} + +func (m *PutResponse) GetKey() []*Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *PutResponse) GetCost() *Cost { + if m != nil { + return m.Cost + } + return nil +} + +func (m *PutResponse) GetVersion() []int64 { + if m != nil { + return m.Version + } + return nil +} + +type TouchRequest struct { + Header *InternalHeader `protobuf:"bytes,10,opt,name=header" json:"header,omitempty"` + Key []*Reference `protobuf:"bytes,1,rep,name=key" json:"key,omitempty"` + CompositeIndex []*CompositeIndex `protobuf:"bytes,2,rep,name=composite_index" json:"composite_index,omitempty"` + Force *bool `protobuf:"varint,3,opt,name=force,def=0" json:"force,omitempty"` + Snapshot []*Snapshot `protobuf:"bytes,9,rep,name=snapshot" json:"snapshot,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *TouchRequest) Reset() { *m = TouchRequest{} } +func (m *TouchRequest) String() string { return proto.CompactTextString(m) } +func (*TouchRequest) ProtoMessage() {} + +const Default_TouchRequest_Force bool = false + +func (m *TouchRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *TouchRequest) GetKey() []*Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *TouchRequest) GetCompositeIndex() []*CompositeIndex { + if m != nil { + return m.CompositeIndex + } + return nil +} + +func (m *TouchRequest) GetForce() bool { + if m != nil && m.Force != nil { + return *m.Force + } + return Default_TouchRequest_Force +} + +func (m *TouchRequest) GetSnapshot() []*Snapshot { + if m != nil { + return m.Snapshot + } + return nil +} + +type TouchResponse struct { + Cost *Cost `protobuf:"bytes,1,opt,name=cost" json:"cost,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *TouchResponse) Reset() { *m = TouchResponse{} } +func (m *TouchResponse) String() string { return proto.CompactTextString(m) } +func (*TouchResponse) ProtoMessage() {} + +func (m *TouchResponse) GetCost() *Cost { + if m != nil { + return m.Cost + } + return nil +} + +type DeleteRequest struct { + Header *InternalHeader `protobuf:"bytes,10,opt,name=header" json:"header,omitempty"` + Key []*Reference `protobuf:"bytes,6,rep,name=key" json:"key,omitempty"` + Transaction *Transaction `protobuf:"bytes,5,opt,name=transaction" json:"transaction,omitempty"` + Trusted *bool `protobuf:"varint,4,opt,name=trusted,def=0" json:"trusted,omitempty"` + Force *bool `protobuf:"varint,7,opt,name=force,def=0" json:"force,omitempty"` + MarkChanges *bool `protobuf:"varint,8,opt,name=mark_changes,def=0" json:"mark_changes,omitempty"` + Snapshot []*Snapshot `protobuf:"bytes,9,rep,name=snapshot" json:"snapshot,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } +func (m *DeleteRequest) String() string { return proto.CompactTextString(m) } +func (*DeleteRequest) ProtoMessage() {} + +const Default_DeleteRequest_Trusted bool = false +const Default_DeleteRequest_Force bool = false +const Default_DeleteRequest_MarkChanges bool = false + +func (m *DeleteRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *DeleteRequest) GetKey() []*Reference { + if m != nil { + return m.Key + } + return nil +} + +func (m *DeleteRequest) GetTransaction() *Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *DeleteRequest) GetTrusted() bool { + if m != nil && m.Trusted != nil { + return *m.Trusted + } + return Default_DeleteRequest_Trusted +} + +func (m *DeleteRequest) GetForce() bool { + if m != nil && m.Force != nil { + return *m.Force + } + return Default_DeleteRequest_Force +} + +func (m *DeleteRequest) GetMarkChanges() bool { + if m != nil && m.MarkChanges != nil { + return *m.MarkChanges + } + return Default_DeleteRequest_MarkChanges +} + +func (m *DeleteRequest) GetSnapshot() []*Snapshot { + if m != nil { + return m.Snapshot + } + return nil +} + +type DeleteResponse struct { + Cost *Cost `protobuf:"bytes,1,opt,name=cost" json:"cost,omitempty"` + Version []int64 `protobuf:"varint,3,rep,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *DeleteResponse) Reset() { *m = DeleteResponse{} } +func (m *DeleteResponse) String() string { return proto.CompactTextString(m) } +func (*DeleteResponse) ProtoMessage() {} + +func (m *DeleteResponse) GetCost() *Cost { + if m != nil { + return m.Cost + } + return nil +} + +func (m *DeleteResponse) GetVersion() []int64 { + if m != nil { + return m.Version + } + return nil +} + +type NextRequest struct { + Header *InternalHeader `protobuf:"bytes,5,opt,name=header" json:"header,omitempty"` + Cursor *Cursor `protobuf:"bytes,1,req,name=cursor" json:"cursor,omitempty"` + Count *int32 `protobuf:"varint,2,opt,name=count" json:"count,omitempty"` + Offset *int32 `protobuf:"varint,4,opt,name=offset,def=0" json:"offset,omitempty"` + Compile *bool `protobuf:"varint,3,opt,name=compile,def=0" json:"compile,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *NextRequest) Reset() { *m = NextRequest{} } +func (m *NextRequest) String() string { return proto.CompactTextString(m) } +func (*NextRequest) ProtoMessage() {} + +const Default_NextRequest_Offset int32 = 0 +const Default_NextRequest_Compile bool = false + +func (m *NextRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *NextRequest) GetCursor() *Cursor { + if m != nil { + return m.Cursor + } + return nil +} + +func (m *NextRequest) GetCount() int32 { + if m != nil && m.Count != nil { + return *m.Count + } + return 0 +} + +func (m *NextRequest) GetOffset() int32 { + if m != nil && m.Offset != nil { + return *m.Offset + } + return Default_NextRequest_Offset +} + +func (m *NextRequest) GetCompile() bool { + if m != nil && m.Compile != nil { + return *m.Compile + } + return Default_NextRequest_Compile +} + +type QueryResult struct { + Cursor *Cursor `protobuf:"bytes,1,opt,name=cursor" json:"cursor,omitempty"` + Result []*EntityProto `protobuf:"bytes,2,rep,name=result" json:"result,omitempty"` + SkippedResults *int32 `protobuf:"varint,7,opt,name=skipped_results" json:"skipped_results,omitempty"` + MoreResults *bool `protobuf:"varint,3,req,name=more_results" json:"more_results,omitempty"` + KeysOnly *bool `protobuf:"varint,4,opt,name=keys_only" json:"keys_only,omitempty"` + IndexOnly *bool `protobuf:"varint,9,opt,name=index_only" json:"index_only,omitempty"` + SmallOps *bool `protobuf:"varint,10,opt,name=small_ops" json:"small_ops,omitempty"` + CompiledQuery *CompiledQuery `protobuf:"bytes,5,opt,name=compiled_query" json:"compiled_query,omitempty"` + CompiledCursor *CompiledCursor `protobuf:"bytes,6,opt,name=compiled_cursor" json:"compiled_cursor,omitempty"` + Index []*CompositeIndex `protobuf:"bytes,8,rep,name=index" json:"index,omitempty"` + Version []int64 `protobuf:"varint,11,rep,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *QueryResult) Reset() { *m = QueryResult{} } +func (m *QueryResult) String() string { return proto.CompactTextString(m) } +func (*QueryResult) ProtoMessage() {} + +func (m *QueryResult) GetCursor() *Cursor { + if m != nil { + return m.Cursor + } + return nil +} + +func (m *QueryResult) GetResult() []*EntityProto { + if m != nil { + return m.Result + } + return nil +} + +func (m *QueryResult) GetSkippedResults() int32 { + if m != nil && m.SkippedResults != nil { + return *m.SkippedResults + } + return 0 +} + +func (m *QueryResult) GetMoreResults() bool { + if m != nil && m.MoreResults != nil { + return *m.MoreResults + } + return false +} + +func (m *QueryResult) GetKeysOnly() bool { + if m != nil && m.KeysOnly != nil { + return *m.KeysOnly + } + return false +} + +func (m *QueryResult) GetIndexOnly() bool { + if m != nil && m.IndexOnly != nil { + return *m.IndexOnly + } + return false +} + +func (m *QueryResult) GetSmallOps() bool { + if m != nil && m.SmallOps != nil { + return *m.SmallOps + } + return false +} + +func (m *QueryResult) GetCompiledQuery() *CompiledQuery { + if m != nil { + return m.CompiledQuery + } + return nil +} + +func (m *QueryResult) GetCompiledCursor() *CompiledCursor { + if m != nil { + return m.CompiledCursor + } + return nil +} + +func (m *QueryResult) GetIndex() []*CompositeIndex { + if m != nil { + return m.Index + } + return nil +} + +func (m *QueryResult) GetVersion() []int64 { + if m != nil { + return m.Version + } + return nil +} + +type AllocateIdsRequest struct { + Header *InternalHeader `protobuf:"bytes,4,opt,name=header" json:"header,omitempty"` + ModelKey *Reference `protobuf:"bytes,1,opt,name=model_key" json:"model_key,omitempty"` + Size *int64 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"` + Max *int64 `protobuf:"varint,3,opt,name=max" json:"max,omitempty"` + Reserve []*Reference `protobuf:"bytes,5,rep,name=reserve" json:"reserve,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AllocateIdsRequest) Reset() { *m = AllocateIdsRequest{} } +func (m *AllocateIdsRequest) String() string { return proto.CompactTextString(m) } +func (*AllocateIdsRequest) ProtoMessage() {} + +func (m *AllocateIdsRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *AllocateIdsRequest) GetModelKey() *Reference { + if m != nil { + return m.ModelKey + } + return nil +} + +func (m *AllocateIdsRequest) GetSize() int64 { + if m != nil && m.Size != nil { + return *m.Size + } + return 0 +} + +func (m *AllocateIdsRequest) GetMax() int64 { + if m != nil && m.Max != nil { + return *m.Max + } + return 0 +} + +func (m *AllocateIdsRequest) GetReserve() []*Reference { + if m != nil { + return m.Reserve + } + return nil +} + +type AllocateIdsResponse struct { + Start *int64 `protobuf:"varint,1,req,name=start" json:"start,omitempty"` + End *int64 `protobuf:"varint,2,req,name=end" json:"end,omitempty"` + Cost *Cost `protobuf:"bytes,3,opt,name=cost" json:"cost,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AllocateIdsResponse) Reset() { *m = AllocateIdsResponse{} } +func (m *AllocateIdsResponse) String() string { return proto.CompactTextString(m) } +func (*AllocateIdsResponse) ProtoMessage() {} + +func (m *AllocateIdsResponse) GetStart() int64 { + if m != nil && m.Start != nil { + return *m.Start + } + return 0 +} + +func (m *AllocateIdsResponse) GetEnd() int64 { + if m != nil && m.End != nil { + return *m.End + } + return 0 +} + +func (m *AllocateIdsResponse) GetCost() *Cost { + if m != nil { + return m.Cost + } + return nil +} + +type CompositeIndices struct { + Index []*CompositeIndex `protobuf:"bytes,1,rep,name=index" json:"index,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CompositeIndices) Reset() { *m = CompositeIndices{} } +func (m *CompositeIndices) String() string { return proto.CompactTextString(m) } +func (*CompositeIndices) ProtoMessage() {} + +func (m *CompositeIndices) GetIndex() []*CompositeIndex { + if m != nil { + return m.Index + } + return nil +} + +type AddActionsRequest struct { + Header *InternalHeader `protobuf:"bytes,3,opt,name=header" json:"header,omitempty"` + Transaction *Transaction `protobuf:"bytes,1,req,name=transaction" json:"transaction,omitempty"` + Action []*Action `protobuf:"bytes,2,rep,name=action" json:"action,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *AddActionsRequest) Reset() { *m = AddActionsRequest{} } +func (m *AddActionsRequest) String() string { return proto.CompactTextString(m) } +func (*AddActionsRequest) ProtoMessage() {} + +func (m *AddActionsRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *AddActionsRequest) GetTransaction() *Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *AddActionsRequest) GetAction() []*Action { + if m != nil { + return m.Action + } + return nil +} + +type AddActionsResponse struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *AddActionsResponse) Reset() { *m = AddActionsResponse{} } +func (m *AddActionsResponse) String() string { return proto.CompactTextString(m) } +func (*AddActionsResponse) ProtoMessage() {} + +type BeginTransactionRequest struct { + Header *InternalHeader `protobuf:"bytes,3,opt,name=header" json:"header,omitempty"` + App *string `protobuf:"bytes,1,req,name=app" json:"app,omitempty"` + AllowMultipleEg *bool `protobuf:"varint,2,opt,name=allow_multiple_eg,def=0" json:"allow_multiple_eg,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *BeginTransactionRequest) Reset() { *m = BeginTransactionRequest{} } +func (m *BeginTransactionRequest) String() string { return proto.CompactTextString(m) } +func (*BeginTransactionRequest) ProtoMessage() {} + +const Default_BeginTransactionRequest_AllowMultipleEg bool = false + +func (m *BeginTransactionRequest) GetHeader() *InternalHeader { + if m != nil { + return m.Header + } + return nil +} + +func (m *BeginTransactionRequest) GetApp() string { + if m != nil && m.App != nil { + return *m.App + } + return "" +} + +func (m *BeginTransactionRequest) GetAllowMultipleEg() bool { + if m != nil && m.AllowMultipleEg != nil { + return *m.AllowMultipleEg + } + return Default_BeginTransactionRequest_AllowMultipleEg +} + +type CommitResponse struct { + Cost *Cost `protobuf:"bytes,1,opt,name=cost" json:"cost,omitempty"` + Version []*CommitResponse_Version `protobuf:"group,3,rep,name=Version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CommitResponse) Reset() { *m = CommitResponse{} } +func (m *CommitResponse) String() string { return proto.CompactTextString(m) } +func (*CommitResponse) ProtoMessage() {} + +func (m *CommitResponse) GetCost() *Cost { + if m != nil { + return m.Cost + } + return nil +} + +func (m *CommitResponse) GetVersion() []*CommitResponse_Version { + if m != nil { + return m.Version + } + return nil +} + +type CommitResponse_Version struct { + RootEntityKey *Reference `protobuf:"bytes,4,req,name=root_entity_key" json:"root_entity_key,omitempty"` + Version *int64 `protobuf:"varint,5,req,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *CommitResponse_Version) Reset() { *m = CommitResponse_Version{} } +func (m *CommitResponse_Version) String() string { return proto.CompactTextString(m) } +func (*CommitResponse_Version) ProtoMessage() {} + +func (m *CommitResponse_Version) GetRootEntityKey() *Reference { + if m != nil { + return m.RootEntityKey + } + return nil +} + +func (m *CommitResponse_Version) GetVersion() int64 { + if m != nil && m.Version != nil { + return *m.Version + } + return 0 +} + +func init() { +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto new file mode 100755 index 000000000000..e76f126ff7c6 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/datastore/datastore_v3.proto @@ -0,0 +1,541 @@ +syntax = "proto2"; +option go_package = "datastore"; + +package appengine; + +message Action{} + +message PropertyValue { + optional int64 int64Value = 1; + optional bool booleanValue = 2; + optional string stringValue = 3; + optional double doubleValue = 4; + + optional group PointValue = 5 { + required double x = 6; + required double y = 7; + } + + optional group UserValue = 8 { + required string email = 9; + required string auth_domain = 10; + optional string nickname = 11; + optional string federated_identity = 21; + optional string federated_provider = 22; + } + + optional group ReferenceValue = 12 { + required string app = 13; + optional string name_space = 20; + repeated group PathElement = 14 { + required string type = 15; + optional int64 id = 16; + optional string name = 17; + } + } +} + +message Property { + enum Meaning { + NO_MEANING = 0; + BLOB = 14; + TEXT = 15; + BYTESTRING = 16; + + ATOM_CATEGORY = 1; + ATOM_LINK = 2; + ATOM_TITLE = 3; + ATOM_CONTENT = 4; + ATOM_SUMMARY = 5; + ATOM_AUTHOR = 6; + + GD_WHEN = 7; + GD_EMAIL = 8; + GEORSS_POINT = 9; + GD_IM = 10; + + GD_PHONENUMBER = 11; + GD_POSTALADDRESS = 12; + + GD_RATING = 13; + + BLOBKEY = 17; + ENTITY_PROTO = 19; + + INDEX_VALUE = 18; + }; + + optional Meaning meaning = 1 [default = NO_MEANING]; + optional string meaning_uri = 2; + + required string name = 3; + + required PropertyValue value = 5; + + required bool multiple = 4; + + optional bool searchable = 6 [default=false]; + + enum FtsTokenizationOption { + HTML = 1; + ATOM = 2; + } + + optional FtsTokenizationOption fts_tokenization_option = 8; + + optional string locale = 9 [default = "en"]; +} + +message Path { + repeated group Element = 1 { + required string type = 2; + optional int64 id = 3; + optional string name = 4; + } +} + +message Reference { + required string app = 13; + optional string name_space = 20; + required Path path = 14; +} + +message User { + required string email = 1; + required string auth_domain = 2; + optional string nickname = 3; + optional string federated_identity = 6; + optional string federated_provider = 7; +} + +message EntityProto { + required Reference key = 13; + required Path entity_group = 16; + optional User owner = 17; + + enum Kind { + GD_CONTACT = 1; + GD_EVENT = 2; + GD_MESSAGE = 3; + } + optional Kind kind = 4; + optional string kind_uri = 5; + + repeated Property property = 14; + repeated Property raw_property = 15; + + optional int32 rank = 18; +} + +message CompositeProperty { + required int64 index_id = 1; + repeated string value = 2; +} + +message Index { + required string entity_type = 1; + required bool ancestor = 5; + repeated group Property = 2 { + required string name = 3; + enum Direction { + ASCENDING = 1; + DESCENDING = 2; + } + optional Direction direction = 4 [default = ASCENDING]; + } +} + +message CompositeIndex { + required string app_id = 1; + required int64 id = 2; + required Index definition = 3; + + enum State { + WRITE_ONLY = 1; + READ_WRITE = 2; + DELETED = 3; + ERROR = 4; + } + required State state = 4; + + optional bool only_use_if_required = 6 [default = false]; +} + +message IndexPostfix { + message IndexValue { + required string property_name = 1; + required PropertyValue value = 2; + } + + repeated IndexValue index_value = 1; + + optional Reference key = 2; + + optional bool before = 3 [default=true]; +} + +message IndexPosition { + optional string key = 1; + + optional bool before = 2 [default=true]; +} + +message Snapshot { + enum Status { + INACTIVE = 0; + ACTIVE = 1; + } + + required int64 ts = 1; +} + +message InternalHeader { + optional string qos = 1; +} + +message Transaction { + optional InternalHeader header = 4; + required fixed64 handle = 1; + required string app = 2; + optional bool mark_changes = 3 [default = false]; +} + +message Query { + optional InternalHeader header = 39; + + required string app = 1; + optional string name_space = 29; + + optional string kind = 3; + optional Reference ancestor = 17; + + repeated group Filter = 4 { + enum Operator { + LESS_THAN = 1; + LESS_THAN_OR_EQUAL = 2; + GREATER_THAN = 3; + GREATER_THAN_OR_EQUAL = 4; + EQUAL = 5; + IN = 6; + EXISTS = 7; + } + + required Operator op = 6; + repeated Property property = 14; + } + + optional string search_query = 8; + + repeated group Order = 9 { + enum Direction { + ASCENDING = 1; + DESCENDING = 2; + } + + required string property = 10; + optional Direction direction = 11 [default = ASCENDING]; + } + + enum Hint { + ORDER_FIRST = 1; + ANCESTOR_FIRST = 2; + FILTER_FIRST = 3; + } + optional Hint hint = 18; + + optional int32 count = 23; + + optional int32 offset = 12 [default = 0]; + + optional int32 limit = 16; + + optional CompiledCursor compiled_cursor = 30; + optional CompiledCursor end_compiled_cursor = 31; + + repeated CompositeIndex composite_index = 19; + + optional bool require_perfect_plan = 20 [default = false]; + + optional bool keys_only = 21 [default = false]; + + optional Transaction transaction = 22; + + optional bool compile = 25 [default = false]; + + optional int64 failover_ms = 26; + + optional bool strong = 32; + + repeated string property_name = 33; + + repeated string group_by_property_name = 34; + + optional bool distinct = 24; + + optional int64 min_safe_time_seconds = 35; + + repeated string safe_replica_name = 36; + + optional bool persist_offset = 37 [default=false]; +} + +message CompiledQuery { + required group PrimaryScan = 1 { + optional string index_name = 2; + + optional string start_key = 3; + optional bool start_inclusive = 4; + optional string end_key = 5; + optional bool end_inclusive = 6; + + repeated string start_postfix_value = 22; + repeated string end_postfix_value = 23; + + optional int64 end_unapplied_log_timestamp_us = 19; + } + + repeated group MergeJoinScan = 7 { + required string index_name = 8; + + repeated string prefix_value = 9; + + optional bool value_prefix = 20 [default=false]; + } + + optional Index index_def = 21; + + optional int32 offset = 10 [default = 0]; + + optional int32 limit = 11; + + required bool keys_only = 12; + + repeated string property_name = 24; + + optional int32 distinct_infix_size = 25; + + optional group EntityFilter = 13 { + optional bool distinct = 14 [default=false]; + + optional string kind = 17; + optional Reference ancestor = 18; + } +} + +message CompiledCursor { + optional group Position = 2 { + optional string start_key = 27; + + repeated group IndexValue = 29 { + optional string property = 30; + required PropertyValue value = 31; + } + + optional Reference key = 32; + + optional bool start_inclusive = 28 [default=true]; + } +} + +message Cursor { + required fixed64 cursor = 1; + + optional string app = 2; +} + +message Error { + enum ErrorCode { + BAD_REQUEST = 1; + CONCURRENT_TRANSACTION = 2; + INTERNAL_ERROR = 3; + NEED_INDEX = 4; + TIMEOUT = 5; + PERMISSION_DENIED = 6; + BIGTABLE_ERROR = 7; + COMMITTED_BUT_STILL_APPLYING = 8; + CAPABILITY_DISABLED = 9; + TRY_ALTERNATE_BACKEND = 10; + SAFE_TIME_TOO_OLD = 11; + } +} + +message Cost { + optional int32 index_writes = 1; + optional int32 index_write_bytes = 2; + optional int32 entity_writes = 3; + optional int32 entity_write_bytes = 4; + optional group CommitCost = 5 { + optional int32 requested_entity_puts = 6; + optional int32 requested_entity_deletes = 7; + }; + optional int32 approximate_storage_delta = 8; + optional int32 id_sequence_updates = 9; +} + +message GetRequest { + optional InternalHeader header = 6; + + repeated Reference key = 1; + optional Transaction transaction = 2; + + optional int64 failover_ms = 3; + + optional bool strong = 4; + + optional bool allow_deferred = 5 [default=false]; +} + +message GetResponse { + repeated group Entity = 1 { + optional EntityProto entity = 2; + optional Reference key = 4; + + optional int64 version = 3; + } + + repeated Reference deferred = 5; + + optional bool in_order = 6 [default=true]; +} + +message PutRequest { + optional InternalHeader header = 11; + + repeated EntityProto entity = 1; + optional Transaction transaction = 2; + repeated CompositeIndex composite_index = 3; + + optional bool trusted = 4 [default = false]; + + optional bool force = 7 [default = false]; + + optional bool mark_changes = 8 [default = false]; + repeated Snapshot snapshot = 9; + + enum AutoIdPolicy { + CURRENT = 0; + SEQUENTIAL = 1; + } + optional AutoIdPolicy auto_id_policy = 10 [default = CURRENT]; +} + +message PutResponse { + repeated Reference key = 1; + optional Cost cost = 2; + repeated int64 version = 3; +} + +message TouchRequest { + optional InternalHeader header = 10; + + repeated Reference key = 1; + repeated CompositeIndex composite_index = 2; + optional bool force = 3 [default = false]; + repeated Snapshot snapshot = 9; +} + +message TouchResponse { + optional Cost cost = 1; +} + +message DeleteRequest { + optional InternalHeader header = 10; + + repeated Reference key = 6; + optional Transaction transaction = 5; + + optional bool trusted = 4 [default = false]; + + optional bool force = 7 [default = false]; + + optional bool mark_changes = 8 [default = false]; + repeated Snapshot snapshot = 9; +} + +message DeleteResponse { + optional Cost cost = 1; + repeated int64 version = 3; +} + +message NextRequest { + optional InternalHeader header = 5; + + required Cursor cursor = 1; + optional int32 count = 2; + + optional int32 offset = 4 [default = 0]; + + optional bool compile = 3 [default = false]; +} + +message QueryResult { + optional Cursor cursor = 1; + + repeated EntityProto result = 2; + + optional int32 skipped_results = 7; + + required bool more_results = 3; + + optional bool keys_only = 4; + + optional bool index_only = 9; + + optional bool small_ops = 10; + + optional CompiledQuery compiled_query = 5; + + optional CompiledCursor compiled_cursor = 6; + + repeated CompositeIndex index = 8; + + repeated int64 version = 11; +} + +message AllocateIdsRequest { + optional InternalHeader header = 4; + + optional Reference model_key = 1; + + optional int64 size = 2; + + optional int64 max = 3; + + repeated Reference reserve = 5; +} + +message AllocateIdsResponse { + required int64 start = 1; + required int64 end = 2; + optional Cost cost = 3; +} + +message CompositeIndices { + repeated CompositeIndex index = 1; +} + +message AddActionsRequest { + optional InternalHeader header = 3; + + required Transaction transaction = 1; + repeated Action action = 2; +} + +message AddActionsResponse { +} + +message BeginTransactionRequest { + optional InternalHeader header = 3; + + required string app = 1; + optional bool allow_multiple_eg = 2 [default = false]; +} + +message CommitResponse { + optional Cost cost = 1; + + repeated group Version = 3 { + required Reference root_entity_key = 4; + required int64 version = 5; + } +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity.go new file mode 100644 index 000000000000..d538701ab3b2 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity.go @@ -0,0 +1,14 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +import netcontext "golang.org/x/net/context" + +// These functions are implementations of the wrapper functions +// in ../appengine/identity.go. See that file for commentary. + +func AppID(c netcontext.Context) string { + return appID(FullyQualifiedAppID(c)) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity_classic.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity_classic.go new file mode 100644 index 000000000000..e6b9227c5666 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity_classic.go @@ -0,0 +1,27 @@ +// Copyright 2015 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build appengine + +package internal + +import ( + "appengine" + + netcontext "golang.org/x/net/context" +) + +func DefaultVersionHostname(ctx netcontext.Context) string { + return appengine.DefaultVersionHostname(fromContext(ctx)) +} + +func RequestID(ctx netcontext.Context) string { return appengine.RequestID(fromContext(ctx)) } +func Datacenter(_ netcontext.Context) string { return appengine.Datacenter() } +func ServerSoftware() string { return appengine.ServerSoftware() } +func ModuleName(ctx netcontext.Context) string { return appengine.ModuleName(fromContext(ctx)) } +func VersionID(ctx netcontext.Context) string { return appengine.VersionID(fromContext(ctx)) } +func InstanceID() string { return appengine.InstanceID() } +func IsDevAppServer() bool { return appengine.IsDevAppServer() } + +func fullyQualifiedAppID(ctx netcontext.Context) string { return fromContext(ctx).FullyQualifiedAppID() } diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity_vm.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity_vm.go new file mode 100644 index 000000000000..ebe68b785bb5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/identity_vm.go @@ -0,0 +1,97 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build !appengine + +package internal + +import ( + "net/http" + "os" + + netcontext "golang.org/x/net/context" +) + +// These functions are implementations of the wrapper functions +// in ../appengine/identity.go. See that file for commentary. + +const ( + hDefaultVersionHostname = "X-AppEngine-Default-Version-Hostname" + hRequestLogId = "X-AppEngine-Request-Log-Id" + hDatacenter = "X-AppEngine-Datacenter" +) + +func ctxHeaders(ctx netcontext.Context) http.Header { + return fromContext(ctx).Request().Header +} + +func DefaultVersionHostname(ctx netcontext.Context) string { + return ctxHeaders(ctx).Get(hDefaultVersionHostname) +} + +func RequestID(ctx netcontext.Context) string { + return ctxHeaders(ctx).Get(hRequestLogId) +} + +func Datacenter(ctx netcontext.Context) string { + return ctxHeaders(ctx).Get(hDatacenter) +} + +func ServerSoftware() string { + // TODO(dsymonds): Remove fallback when we've verified this. + if s := os.Getenv("SERVER_SOFTWARE"); s != "" { + return s + } + return "Google App Engine/1.x.x" +} + +// TODO(dsymonds): Remove the metadata fetches. + +func ModuleName(_ netcontext.Context) string { + if s := os.Getenv("GAE_MODULE_NAME"); s != "" { + return s + } + return string(mustGetMetadata("instance/attributes/gae_backend_name")) +} + +func VersionID(_ netcontext.Context) string { + if s1, s2 := os.Getenv("GAE_MODULE_VERSION"), os.Getenv("GAE_MINOR_VERSION"); s1 != "" && s2 != "" { + return s1 + "." + s2 + } + return string(mustGetMetadata("instance/attributes/gae_backend_version")) + "." + string(mustGetMetadata("instance/attributes/gae_backend_minor_version")) +} + +func InstanceID() string { + if s := os.Getenv("GAE_MODULE_INSTANCE"); s != "" { + return s + } + return string(mustGetMetadata("instance/attributes/gae_backend_instance")) +} + +func partitionlessAppID() string { + // gae_project has everything except the partition prefix. + appID := os.Getenv("GAE_LONG_APP_ID") + if appID == "" { + appID = string(mustGetMetadata("instance/attributes/gae_project")) + } + return appID +} + +func fullyQualifiedAppID(_ netcontext.Context) string { + appID := partitionlessAppID() + + part := os.Getenv("GAE_PARTITION") + if part == "" { + part = string(mustGetMetadata("instance/attributes/gae_partition")) + } + + if part != "" { + appID = part + "~" + appID + } + return appID +} + +func IsDevAppServer() bool { + return os.Getenv("RUN_WITH_DEVAPPSERVER") != "" +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/internal.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/internal.go new file mode 100644 index 000000000000..051ea3980abe --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/internal.go @@ -0,0 +1,110 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// Package internal provides support for package appengine. +// +// Programs should not use this package directly. Its API is not stable. +// Use packages appengine and appengine/* instead. +package internal + +import ( + "fmt" + + "github.com/golang/protobuf/proto" + + remotepb "google.golang.org/appengine/internal/remote_api" +) + +// errorCodeMaps is a map of service name to the error code map for the service. +var errorCodeMaps = make(map[string]map[int32]string) + +// RegisterErrorCodeMap is called from API implementations to register their +// error code map. This should only be called from init functions. +func RegisterErrorCodeMap(service string, m map[int32]string) { + errorCodeMaps[service] = m +} + +type timeoutCodeKey struct { + service string + code int32 +} + +// timeoutCodes is the set of service+code pairs that represent timeouts. +var timeoutCodes = make(map[timeoutCodeKey]bool) + +func RegisterTimeoutErrorCode(service string, code int32) { + timeoutCodes[timeoutCodeKey{service, code}] = true +} + +// APIError is the type returned by appengine.Context's Call method +// when an API call fails in an API-specific way. This may be, for instance, +// a taskqueue API call failing with TaskQueueServiceError::UNKNOWN_QUEUE. +type APIError struct { + Service string + Detail string + Code int32 // API-specific error code +} + +func (e *APIError) Error() string { + if e.Code == 0 { + if e.Detail == "" { + return "APIError " + } + return e.Detail + } + s := fmt.Sprintf("API error %d", e.Code) + if m, ok := errorCodeMaps[e.Service]; ok { + s += " (" + e.Service + ": " + m[e.Code] + ")" + } else { + // Shouldn't happen, but provide a bit more detail if it does. + s = e.Service + " " + s + } + if e.Detail != "" { + s += ": " + e.Detail + } + return s +} + +func (e *APIError) IsTimeout() bool { + return timeoutCodes[timeoutCodeKey{e.Service, e.Code}] +} + +// CallError is the type returned by appengine.Context's Call method when an +// API call fails in a generic way, such as RpcError::CAPABILITY_DISABLED. +type CallError struct { + Detail string + Code int32 + // TODO: Remove this if we get a distinguishable error code. + Timeout bool +} + +func (e *CallError) Error() string { + var msg string + switch remotepb.RpcError_ErrorCode(e.Code) { + case remotepb.RpcError_UNKNOWN: + return e.Detail + case remotepb.RpcError_OVER_QUOTA: + msg = "Over quota" + case remotepb.RpcError_CAPABILITY_DISABLED: + msg = "Capability disabled" + case remotepb.RpcError_CANCELLED: + msg = "Canceled" + default: + msg = fmt.Sprintf("Call error %d", e.Code) + } + s := msg + ": " + e.Detail + if e.Timeout { + s += " (timeout)" + } + return s +} + +func (e *CallError) IsTimeout() bool { + return e.Timeout +} + +// NamespaceMods is a map from API service to a function that will mutate an RPC request to attach a namespace. +// The function should be prepared to be called on the same message more than once; it should only modify the +// RPC request the first time. +var NamespaceMods = make(map[string]func(m proto.Message, namespace string)) diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/log/log_service.pb.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/log/log_service.pb.go new file mode 100644 index 000000000000..20c595be30a1 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/log/log_service.pb.go @@ -0,0 +1,899 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/log/log_service.proto +// DO NOT EDIT! + +/* +Package log is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/log/log_service.proto + +It has these top-level messages: + LogServiceError + UserAppLogLine + UserAppLogGroup + FlushRequest + SetStatusRequest + LogOffset + LogLine + RequestLog + LogModuleVersion + LogReadRequest + LogReadResponse + LogUsageRecord + LogUsageRequest + LogUsageResponse +*/ +package log + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type LogServiceError_ErrorCode int32 + +const ( + LogServiceError_OK LogServiceError_ErrorCode = 0 + LogServiceError_INVALID_REQUEST LogServiceError_ErrorCode = 1 + LogServiceError_STORAGE_ERROR LogServiceError_ErrorCode = 2 +) + +var LogServiceError_ErrorCode_name = map[int32]string{ + 0: "OK", + 1: "INVALID_REQUEST", + 2: "STORAGE_ERROR", +} +var LogServiceError_ErrorCode_value = map[string]int32{ + "OK": 0, + "INVALID_REQUEST": 1, + "STORAGE_ERROR": 2, +} + +func (x LogServiceError_ErrorCode) Enum() *LogServiceError_ErrorCode { + p := new(LogServiceError_ErrorCode) + *p = x + return p +} +func (x LogServiceError_ErrorCode) String() string { + return proto.EnumName(LogServiceError_ErrorCode_name, int32(x)) +} +func (x *LogServiceError_ErrorCode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(LogServiceError_ErrorCode_value, data, "LogServiceError_ErrorCode") + if err != nil { + return err + } + *x = LogServiceError_ErrorCode(value) + return nil +} + +type LogServiceError struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogServiceError) Reset() { *m = LogServiceError{} } +func (m *LogServiceError) String() string { return proto.CompactTextString(m) } +func (*LogServiceError) ProtoMessage() {} + +type UserAppLogLine struct { + TimestampUsec *int64 `protobuf:"varint,1,req,name=timestamp_usec" json:"timestamp_usec,omitempty"` + Level *int64 `protobuf:"varint,2,req,name=level" json:"level,omitempty"` + Message *string `protobuf:"bytes,3,req,name=message" json:"message,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *UserAppLogLine) Reset() { *m = UserAppLogLine{} } +func (m *UserAppLogLine) String() string { return proto.CompactTextString(m) } +func (*UserAppLogLine) ProtoMessage() {} + +func (m *UserAppLogLine) GetTimestampUsec() int64 { + if m != nil && m.TimestampUsec != nil { + return *m.TimestampUsec + } + return 0 +} + +func (m *UserAppLogLine) GetLevel() int64 { + if m != nil && m.Level != nil { + return *m.Level + } + return 0 +} + +func (m *UserAppLogLine) GetMessage() string { + if m != nil && m.Message != nil { + return *m.Message + } + return "" +} + +type UserAppLogGroup struct { + LogLine []*UserAppLogLine `protobuf:"bytes,2,rep,name=log_line" json:"log_line,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *UserAppLogGroup) Reset() { *m = UserAppLogGroup{} } +func (m *UserAppLogGroup) String() string { return proto.CompactTextString(m) } +func (*UserAppLogGroup) ProtoMessage() {} + +func (m *UserAppLogGroup) GetLogLine() []*UserAppLogLine { + if m != nil { + return m.LogLine + } + return nil +} + +type FlushRequest struct { + Logs []byte `protobuf:"bytes,1,opt,name=logs" json:"logs,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *FlushRequest) Reset() { *m = FlushRequest{} } +func (m *FlushRequest) String() string { return proto.CompactTextString(m) } +func (*FlushRequest) ProtoMessage() {} + +func (m *FlushRequest) GetLogs() []byte { + if m != nil { + return m.Logs + } + return nil +} + +type SetStatusRequest struct { + Status *string `protobuf:"bytes,1,req,name=status" json:"status,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SetStatusRequest) Reset() { *m = SetStatusRequest{} } +func (m *SetStatusRequest) String() string { return proto.CompactTextString(m) } +func (*SetStatusRequest) ProtoMessage() {} + +func (m *SetStatusRequest) GetStatus() string { + if m != nil && m.Status != nil { + return *m.Status + } + return "" +} + +type LogOffset struct { + RequestId []byte `protobuf:"bytes,1,opt,name=request_id" json:"request_id,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogOffset) Reset() { *m = LogOffset{} } +func (m *LogOffset) String() string { return proto.CompactTextString(m) } +func (*LogOffset) ProtoMessage() {} + +func (m *LogOffset) GetRequestId() []byte { + if m != nil { + return m.RequestId + } + return nil +} + +type LogLine struct { + Time *int64 `protobuf:"varint,1,req,name=time" json:"time,omitempty"` + Level *int32 `protobuf:"varint,2,req,name=level" json:"level,omitempty"` + LogMessage *string `protobuf:"bytes,3,req,name=log_message" json:"log_message,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogLine) Reset() { *m = LogLine{} } +func (m *LogLine) String() string { return proto.CompactTextString(m) } +func (*LogLine) ProtoMessage() {} + +func (m *LogLine) GetTime() int64 { + if m != nil && m.Time != nil { + return *m.Time + } + return 0 +} + +func (m *LogLine) GetLevel() int32 { + if m != nil && m.Level != nil { + return *m.Level + } + return 0 +} + +func (m *LogLine) GetLogMessage() string { + if m != nil && m.LogMessage != nil { + return *m.LogMessage + } + return "" +} + +type RequestLog struct { + AppId *string `protobuf:"bytes,1,req,name=app_id" json:"app_id,omitempty"` + ModuleId *string `protobuf:"bytes,37,opt,name=module_id,def=default" json:"module_id,omitempty"` + VersionId *string `protobuf:"bytes,2,req,name=version_id" json:"version_id,omitempty"` + RequestId []byte `protobuf:"bytes,3,req,name=request_id" json:"request_id,omitempty"` + Offset *LogOffset `protobuf:"bytes,35,opt,name=offset" json:"offset,omitempty"` + Ip *string `protobuf:"bytes,4,req,name=ip" json:"ip,omitempty"` + Nickname *string `protobuf:"bytes,5,opt,name=nickname" json:"nickname,omitempty"` + StartTime *int64 `protobuf:"varint,6,req,name=start_time" json:"start_time,omitempty"` + EndTime *int64 `protobuf:"varint,7,req,name=end_time" json:"end_time,omitempty"` + Latency *int64 `protobuf:"varint,8,req,name=latency" json:"latency,omitempty"` + Mcycles *int64 `protobuf:"varint,9,req,name=mcycles" json:"mcycles,omitempty"` + Method *string `protobuf:"bytes,10,req,name=method" json:"method,omitempty"` + Resource *string `protobuf:"bytes,11,req,name=resource" json:"resource,omitempty"` + HttpVersion *string `protobuf:"bytes,12,req,name=http_version" json:"http_version,omitempty"` + Status *int32 `protobuf:"varint,13,req,name=status" json:"status,omitempty"` + ResponseSize *int64 `protobuf:"varint,14,req,name=response_size" json:"response_size,omitempty"` + Referrer *string `protobuf:"bytes,15,opt,name=referrer" json:"referrer,omitempty"` + UserAgent *string `protobuf:"bytes,16,opt,name=user_agent" json:"user_agent,omitempty"` + UrlMapEntry *string `protobuf:"bytes,17,req,name=url_map_entry" json:"url_map_entry,omitempty"` + Combined *string `protobuf:"bytes,18,req,name=combined" json:"combined,omitempty"` + ApiMcycles *int64 `protobuf:"varint,19,opt,name=api_mcycles" json:"api_mcycles,omitempty"` + Host *string `protobuf:"bytes,20,opt,name=host" json:"host,omitempty"` + Cost *float64 `protobuf:"fixed64,21,opt,name=cost" json:"cost,omitempty"` + TaskQueueName *string `protobuf:"bytes,22,opt,name=task_queue_name" json:"task_queue_name,omitempty"` + TaskName *string `protobuf:"bytes,23,opt,name=task_name" json:"task_name,omitempty"` + WasLoadingRequest *bool `protobuf:"varint,24,opt,name=was_loading_request" json:"was_loading_request,omitempty"` + PendingTime *int64 `protobuf:"varint,25,opt,name=pending_time" json:"pending_time,omitempty"` + ReplicaIndex *int32 `protobuf:"varint,26,opt,name=replica_index,def=-1" json:"replica_index,omitempty"` + Finished *bool `protobuf:"varint,27,opt,name=finished,def=1" json:"finished,omitempty"` + CloneKey []byte `protobuf:"bytes,28,opt,name=clone_key" json:"clone_key,omitempty"` + Line []*LogLine `protobuf:"bytes,29,rep,name=line" json:"line,omitempty"` + LinesIncomplete *bool `protobuf:"varint,36,opt,name=lines_incomplete" json:"lines_incomplete,omitempty"` + AppEngineRelease []byte `protobuf:"bytes,38,opt,name=app_engine_release" json:"app_engine_release,omitempty"` + ExitReason *int32 `protobuf:"varint,30,opt,name=exit_reason" json:"exit_reason,omitempty"` + WasThrottledForTime *bool `protobuf:"varint,31,opt,name=was_throttled_for_time" json:"was_throttled_for_time,omitempty"` + WasThrottledForRequests *bool `protobuf:"varint,32,opt,name=was_throttled_for_requests" json:"was_throttled_for_requests,omitempty"` + ThrottledTime *int64 `protobuf:"varint,33,opt,name=throttled_time" json:"throttled_time,omitempty"` + ServerName []byte `protobuf:"bytes,34,opt,name=server_name" json:"server_name,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *RequestLog) Reset() { *m = RequestLog{} } +func (m *RequestLog) String() string { return proto.CompactTextString(m) } +func (*RequestLog) ProtoMessage() {} + +const Default_RequestLog_ModuleId string = "default" +const Default_RequestLog_ReplicaIndex int32 = -1 +const Default_RequestLog_Finished bool = true + +func (m *RequestLog) GetAppId() string { + if m != nil && m.AppId != nil { + return *m.AppId + } + return "" +} + +func (m *RequestLog) GetModuleId() string { + if m != nil && m.ModuleId != nil { + return *m.ModuleId + } + return Default_RequestLog_ModuleId +} + +func (m *RequestLog) GetVersionId() string { + if m != nil && m.VersionId != nil { + return *m.VersionId + } + return "" +} + +func (m *RequestLog) GetRequestId() []byte { + if m != nil { + return m.RequestId + } + return nil +} + +func (m *RequestLog) GetOffset() *LogOffset { + if m != nil { + return m.Offset + } + return nil +} + +func (m *RequestLog) GetIp() string { + if m != nil && m.Ip != nil { + return *m.Ip + } + return "" +} + +func (m *RequestLog) GetNickname() string { + if m != nil && m.Nickname != nil { + return *m.Nickname + } + return "" +} + +func (m *RequestLog) GetStartTime() int64 { + if m != nil && m.StartTime != nil { + return *m.StartTime + } + return 0 +} + +func (m *RequestLog) GetEndTime() int64 { + if m != nil && m.EndTime != nil { + return *m.EndTime + } + return 0 +} + +func (m *RequestLog) GetLatency() int64 { + if m != nil && m.Latency != nil { + return *m.Latency + } + return 0 +} + +func (m *RequestLog) GetMcycles() int64 { + if m != nil && m.Mcycles != nil { + return *m.Mcycles + } + return 0 +} + +func (m *RequestLog) GetMethod() string { + if m != nil && m.Method != nil { + return *m.Method + } + return "" +} + +func (m *RequestLog) GetResource() string { + if m != nil && m.Resource != nil { + return *m.Resource + } + return "" +} + +func (m *RequestLog) GetHttpVersion() string { + if m != nil && m.HttpVersion != nil { + return *m.HttpVersion + } + return "" +} + +func (m *RequestLog) GetStatus() int32 { + if m != nil && m.Status != nil { + return *m.Status + } + return 0 +} + +func (m *RequestLog) GetResponseSize() int64 { + if m != nil && m.ResponseSize != nil { + return *m.ResponseSize + } + return 0 +} + +func (m *RequestLog) GetReferrer() string { + if m != nil && m.Referrer != nil { + return *m.Referrer + } + return "" +} + +func (m *RequestLog) GetUserAgent() string { + if m != nil && m.UserAgent != nil { + return *m.UserAgent + } + return "" +} + +func (m *RequestLog) GetUrlMapEntry() string { + if m != nil && m.UrlMapEntry != nil { + return *m.UrlMapEntry + } + return "" +} + +func (m *RequestLog) GetCombined() string { + if m != nil && m.Combined != nil { + return *m.Combined + } + return "" +} + +func (m *RequestLog) GetApiMcycles() int64 { + if m != nil && m.ApiMcycles != nil { + return *m.ApiMcycles + } + return 0 +} + +func (m *RequestLog) GetHost() string { + if m != nil && m.Host != nil { + return *m.Host + } + return "" +} + +func (m *RequestLog) GetCost() float64 { + if m != nil && m.Cost != nil { + return *m.Cost + } + return 0 +} + +func (m *RequestLog) GetTaskQueueName() string { + if m != nil && m.TaskQueueName != nil { + return *m.TaskQueueName + } + return "" +} + +func (m *RequestLog) GetTaskName() string { + if m != nil && m.TaskName != nil { + return *m.TaskName + } + return "" +} + +func (m *RequestLog) GetWasLoadingRequest() bool { + if m != nil && m.WasLoadingRequest != nil { + return *m.WasLoadingRequest + } + return false +} + +func (m *RequestLog) GetPendingTime() int64 { + if m != nil && m.PendingTime != nil { + return *m.PendingTime + } + return 0 +} + +func (m *RequestLog) GetReplicaIndex() int32 { + if m != nil && m.ReplicaIndex != nil { + return *m.ReplicaIndex + } + return Default_RequestLog_ReplicaIndex +} + +func (m *RequestLog) GetFinished() bool { + if m != nil && m.Finished != nil { + return *m.Finished + } + return Default_RequestLog_Finished +} + +func (m *RequestLog) GetCloneKey() []byte { + if m != nil { + return m.CloneKey + } + return nil +} + +func (m *RequestLog) GetLine() []*LogLine { + if m != nil { + return m.Line + } + return nil +} + +func (m *RequestLog) GetLinesIncomplete() bool { + if m != nil && m.LinesIncomplete != nil { + return *m.LinesIncomplete + } + return false +} + +func (m *RequestLog) GetAppEngineRelease() []byte { + if m != nil { + return m.AppEngineRelease + } + return nil +} + +func (m *RequestLog) GetExitReason() int32 { + if m != nil && m.ExitReason != nil { + return *m.ExitReason + } + return 0 +} + +func (m *RequestLog) GetWasThrottledForTime() bool { + if m != nil && m.WasThrottledForTime != nil { + return *m.WasThrottledForTime + } + return false +} + +func (m *RequestLog) GetWasThrottledForRequests() bool { + if m != nil && m.WasThrottledForRequests != nil { + return *m.WasThrottledForRequests + } + return false +} + +func (m *RequestLog) GetThrottledTime() int64 { + if m != nil && m.ThrottledTime != nil { + return *m.ThrottledTime + } + return 0 +} + +func (m *RequestLog) GetServerName() []byte { + if m != nil { + return m.ServerName + } + return nil +} + +type LogModuleVersion struct { + ModuleId *string `protobuf:"bytes,1,opt,name=module_id,def=default" json:"module_id,omitempty"` + VersionId *string `protobuf:"bytes,2,opt,name=version_id" json:"version_id,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogModuleVersion) Reset() { *m = LogModuleVersion{} } +func (m *LogModuleVersion) String() string { return proto.CompactTextString(m) } +func (*LogModuleVersion) ProtoMessage() {} + +const Default_LogModuleVersion_ModuleId string = "default" + +func (m *LogModuleVersion) GetModuleId() string { + if m != nil && m.ModuleId != nil { + return *m.ModuleId + } + return Default_LogModuleVersion_ModuleId +} + +func (m *LogModuleVersion) GetVersionId() string { + if m != nil && m.VersionId != nil { + return *m.VersionId + } + return "" +} + +type LogReadRequest struct { + AppId *string `protobuf:"bytes,1,req,name=app_id" json:"app_id,omitempty"` + VersionId []string `protobuf:"bytes,2,rep,name=version_id" json:"version_id,omitempty"` + ModuleVersion []*LogModuleVersion `protobuf:"bytes,19,rep,name=module_version" json:"module_version,omitempty"` + StartTime *int64 `protobuf:"varint,3,opt,name=start_time" json:"start_time,omitempty"` + EndTime *int64 `protobuf:"varint,4,opt,name=end_time" json:"end_time,omitempty"` + Offset *LogOffset `protobuf:"bytes,5,opt,name=offset" json:"offset,omitempty"` + RequestId [][]byte `protobuf:"bytes,6,rep,name=request_id" json:"request_id,omitempty"` + MinimumLogLevel *int32 `protobuf:"varint,7,opt,name=minimum_log_level" json:"minimum_log_level,omitempty"` + IncludeIncomplete *bool `protobuf:"varint,8,opt,name=include_incomplete" json:"include_incomplete,omitempty"` + Count *int64 `protobuf:"varint,9,opt,name=count" json:"count,omitempty"` + CombinedLogRegex *string `protobuf:"bytes,14,opt,name=combined_log_regex" json:"combined_log_regex,omitempty"` + HostRegex *string `protobuf:"bytes,15,opt,name=host_regex" json:"host_regex,omitempty"` + ReplicaIndex *int32 `protobuf:"varint,16,opt,name=replica_index" json:"replica_index,omitempty"` + IncludeAppLogs *bool `protobuf:"varint,10,opt,name=include_app_logs" json:"include_app_logs,omitempty"` + AppLogsPerRequest *int32 `protobuf:"varint,17,opt,name=app_logs_per_request" json:"app_logs_per_request,omitempty"` + IncludeHost *bool `protobuf:"varint,11,opt,name=include_host" json:"include_host,omitempty"` + IncludeAll *bool `protobuf:"varint,12,opt,name=include_all" json:"include_all,omitempty"` + CacheIterator *bool `protobuf:"varint,13,opt,name=cache_iterator" json:"cache_iterator,omitempty"` + NumShards *int32 `protobuf:"varint,18,opt,name=num_shards" json:"num_shards,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogReadRequest) Reset() { *m = LogReadRequest{} } +func (m *LogReadRequest) String() string { return proto.CompactTextString(m) } +func (*LogReadRequest) ProtoMessage() {} + +func (m *LogReadRequest) GetAppId() string { + if m != nil && m.AppId != nil { + return *m.AppId + } + return "" +} + +func (m *LogReadRequest) GetVersionId() []string { + if m != nil { + return m.VersionId + } + return nil +} + +func (m *LogReadRequest) GetModuleVersion() []*LogModuleVersion { + if m != nil { + return m.ModuleVersion + } + return nil +} + +func (m *LogReadRequest) GetStartTime() int64 { + if m != nil && m.StartTime != nil { + return *m.StartTime + } + return 0 +} + +func (m *LogReadRequest) GetEndTime() int64 { + if m != nil && m.EndTime != nil { + return *m.EndTime + } + return 0 +} + +func (m *LogReadRequest) GetOffset() *LogOffset { + if m != nil { + return m.Offset + } + return nil +} + +func (m *LogReadRequest) GetRequestId() [][]byte { + if m != nil { + return m.RequestId + } + return nil +} + +func (m *LogReadRequest) GetMinimumLogLevel() int32 { + if m != nil && m.MinimumLogLevel != nil { + return *m.MinimumLogLevel + } + return 0 +} + +func (m *LogReadRequest) GetIncludeIncomplete() bool { + if m != nil && m.IncludeIncomplete != nil { + return *m.IncludeIncomplete + } + return false +} + +func (m *LogReadRequest) GetCount() int64 { + if m != nil && m.Count != nil { + return *m.Count + } + return 0 +} + +func (m *LogReadRequest) GetCombinedLogRegex() string { + if m != nil && m.CombinedLogRegex != nil { + return *m.CombinedLogRegex + } + return "" +} + +func (m *LogReadRequest) GetHostRegex() string { + if m != nil && m.HostRegex != nil { + return *m.HostRegex + } + return "" +} + +func (m *LogReadRequest) GetReplicaIndex() int32 { + if m != nil && m.ReplicaIndex != nil { + return *m.ReplicaIndex + } + return 0 +} + +func (m *LogReadRequest) GetIncludeAppLogs() bool { + if m != nil && m.IncludeAppLogs != nil { + return *m.IncludeAppLogs + } + return false +} + +func (m *LogReadRequest) GetAppLogsPerRequest() int32 { + if m != nil && m.AppLogsPerRequest != nil { + return *m.AppLogsPerRequest + } + return 0 +} + +func (m *LogReadRequest) GetIncludeHost() bool { + if m != nil && m.IncludeHost != nil { + return *m.IncludeHost + } + return false +} + +func (m *LogReadRequest) GetIncludeAll() bool { + if m != nil && m.IncludeAll != nil { + return *m.IncludeAll + } + return false +} + +func (m *LogReadRequest) GetCacheIterator() bool { + if m != nil && m.CacheIterator != nil { + return *m.CacheIterator + } + return false +} + +func (m *LogReadRequest) GetNumShards() int32 { + if m != nil && m.NumShards != nil { + return *m.NumShards + } + return 0 +} + +type LogReadResponse struct { + Log []*RequestLog `protobuf:"bytes,1,rep,name=log" json:"log,omitempty"` + Offset *LogOffset `protobuf:"bytes,2,opt,name=offset" json:"offset,omitempty"` + LastEndTime *int64 `protobuf:"varint,3,opt,name=last_end_time" json:"last_end_time,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogReadResponse) Reset() { *m = LogReadResponse{} } +func (m *LogReadResponse) String() string { return proto.CompactTextString(m) } +func (*LogReadResponse) ProtoMessage() {} + +func (m *LogReadResponse) GetLog() []*RequestLog { + if m != nil { + return m.Log + } + return nil +} + +func (m *LogReadResponse) GetOffset() *LogOffset { + if m != nil { + return m.Offset + } + return nil +} + +func (m *LogReadResponse) GetLastEndTime() int64 { + if m != nil && m.LastEndTime != nil { + return *m.LastEndTime + } + return 0 +} + +type LogUsageRecord struct { + VersionId *string `protobuf:"bytes,1,opt,name=version_id" json:"version_id,omitempty"` + StartTime *int32 `protobuf:"varint,2,opt,name=start_time" json:"start_time,omitempty"` + EndTime *int32 `protobuf:"varint,3,opt,name=end_time" json:"end_time,omitempty"` + Count *int64 `protobuf:"varint,4,opt,name=count" json:"count,omitempty"` + TotalSize *int64 `protobuf:"varint,5,opt,name=total_size" json:"total_size,omitempty"` + Records *int32 `protobuf:"varint,6,opt,name=records" json:"records,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogUsageRecord) Reset() { *m = LogUsageRecord{} } +func (m *LogUsageRecord) String() string { return proto.CompactTextString(m) } +func (*LogUsageRecord) ProtoMessage() {} + +func (m *LogUsageRecord) GetVersionId() string { + if m != nil && m.VersionId != nil { + return *m.VersionId + } + return "" +} + +func (m *LogUsageRecord) GetStartTime() int32 { + if m != nil && m.StartTime != nil { + return *m.StartTime + } + return 0 +} + +func (m *LogUsageRecord) GetEndTime() int32 { + if m != nil && m.EndTime != nil { + return *m.EndTime + } + return 0 +} + +func (m *LogUsageRecord) GetCount() int64 { + if m != nil && m.Count != nil { + return *m.Count + } + return 0 +} + +func (m *LogUsageRecord) GetTotalSize() int64 { + if m != nil && m.TotalSize != nil { + return *m.TotalSize + } + return 0 +} + +func (m *LogUsageRecord) GetRecords() int32 { + if m != nil && m.Records != nil { + return *m.Records + } + return 0 +} + +type LogUsageRequest struct { + AppId *string `protobuf:"bytes,1,req,name=app_id" json:"app_id,omitempty"` + VersionId []string `protobuf:"bytes,2,rep,name=version_id" json:"version_id,omitempty"` + StartTime *int32 `protobuf:"varint,3,opt,name=start_time" json:"start_time,omitempty"` + EndTime *int32 `protobuf:"varint,4,opt,name=end_time" json:"end_time,omitempty"` + ResolutionHours *uint32 `protobuf:"varint,5,opt,name=resolution_hours,def=1" json:"resolution_hours,omitempty"` + CombineVersions *bool `protobuf:"varint,6,opt,name=combine_versions" json:"combine_versions,omitempty"` + UsageVersion *int32 `protobuf:"varint,7,opt,name=usage_version" json:"usage_version,omitempty"` + VersionsOnly *bool `protobuf:"varint,8,opt,name=versions_only" json:"versions_only,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogUsageRequest) Reset() { *m = LogUsageRequest{} } +func (m *LogUsageRequest) String() string { return proto.CompactTextString(m) } +func (*LogUsageRequest) ProtoMessage() {} + +const Default_LogUsageRequest_ResolutionHours uint32 = 1 + +func (m *LogUsageRequest) GetAppId() string { + if m != nil && m.AppId != nil { + return *m.AppId + } + return "" +} + +func (m *LogUsageRequest) GetVersionId() []string { + if m != nil { + return m.VersionId + } + return nil +} + +func (m *LogUsageRequest) GetStartTime() int32 { + if m != nil && m.StartTime != nil { + return *m.StartTime + } + return 0 +} + +func (m *LogUsageRequest) GetEndTime() int32 { + if m != nil && m.EndTime != nil { + return *m.EndTime + } + return 0 +} + +func (m *LogUsageRequest) GetResolutionHours() uint32 { + if m != nil && m.ResolutionHours != nil { + return *m.ResolutionHours + } + return Default_LogUsageRequest_ResolutionHours +} + +func (m *LogUsageRequest) GetCombineVersions() bool { + if m != nil && m.CombineVersions != nil { + return *m.CombineVersions + } + return false +} + +func (m *LogUsageRequest) GetUsageVersion() int32 { + if m != nil && m.UsageVersion != nil { + return *m.UsageVersion + } + return 0 +} + +func (m *LogUsageRequest) GetVersionsOnly() bool { + if m != nil && m.VersionsOnly != nil { + return *m.VersionsOnly + } + return false +} + +type LogUsageResponse struct { + Usage []*LogUsageRecord `protobuf:"bytes,1,rep,name=usage" json:"usage,omitempty"` + Summary *LogUsageRecord `protobuf:"bytes,2,opt,name=summary" json:"summary,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *LogUsageResponse) Reset() { *m = LogUsageResponse{} } +func (m *LogUsageResponse) String() string { return proto.CompactTextString(m) } +func (*LogUsageResponse) ProtoMessage() {} + +func (m *LogUsageResponse) GetUsage() []*LogUsageRecord { + if m != nil { + return m.Usage + } + return nil +} + +func (m *LogUsageResponse) GetSummary() *LogUsageRecord { + if m != nil { + return m.Summary + } + return nil +} + +func init() { +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/log/log_service.proto b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/log/log_service.proto new file mode 100644 index 000000000000..8981dc47577c --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/log/log_service.proto @@ -0,0 +1,150 @@ +syntax = "proto2"; +option go_package = "log"; + +package appengine; + +message LogServiceError { + enum ErrorCode { + OK = 0; + INVALID_REQUEST = 1; + STORAGE_ERROR = 2; + } +} + +message UserAppLogLine { + required int64 timestamp_usec = 1; + required int64 level = 2; + required string message = 3; +} + +message UserAppLogGroup { + repeated UserAppLogLine log_line = 2; +} + +message FlushRequest { + optional bytes logs = 1; +} + +message SetStatusRequest { + required string status = 1; +} + + +message LogOffset { + optional bytes request_id = 1; +} + +message LogLine { + required int64 time = 1; + required int32 level = 2; + required string log_message = 3; +} + +message RequestLog { + required string app_id = 1; + optional string module_id = 37 [default="default"]; + required string version_id = 2; + required bytes request_id = 3; + optional LogOffset offset = 35; + required string ip = 4; + optional string nickname = 5; + required int64 start_time = 6; + required int64 end_time = 7; + required int64 latency = 8; + required int64 mcycles = 9; + required string method = 10; + required string resource = 11; + required string http_version = 12; + required int32 status = 13; + required int64 response_size = 14; + optional string referrer = 15; + optional string user_agent = 16; + required string url_map_entry = 17; + required string combined = 18; + optional int64 api_mcycles = 19; + optional string host = 20; + optional double cost = 21; + + optional string task_queue_name = 22; + optional string task_name = 23; + + optional bool was_loading_request = 24; + optional int64 pending_time = 25; + optional int32 replica_index = 26 [default = -1]; + optional bool finished = 27 [default = true]; + optional bytes clone_key = 28; + + repeated LogLine line = 29; + + optional bool lines_incomplete = 36; + optional bytes app_engine_release = 38; + + optional int32 exit_reason = 30; + optional bool was_throttled_for_time = 31; + optional bool was_throttled_for_requests = 32; + optional int64 throttled_time = 33; + + optional bytes server_name = 34; +} + +message LogModuleVersion { + optional string module_id = 1 [default="default"]; + optional string version_id = 2; +} + +message LogReadRequest { + required string app_id = 1; + repeated string version_id = 2; + repeated LogModuleVersion module_version = 19; + + optional int64 start_time = 3; + optional int64 end_time = 4; + optional LogOffset offset = 5; + repeated bytes request_id = 6; + + optional int32 minimum_log_level = 7; + optional bool include_incomplete = 8; + optional int64 count = 9; + + optional string combined_log_regex = 14; + optional string host_regex = 15; + optional int32 replica_index = 16; + + optional bool include_app_logs = 10; + optional int32 app_logs_per_request = 17; + optional bool include_host = 11; + optional bool include_all = 12; + optional bool cache_iterator = 13; + optional int32 num_shards = 18; +} + +message LogReadResponse { + repeated RequestLog log = 1; + optional LogOffset offset = 2; + optional int64 last_end_time = 3; +} + +message LogUsageRecord { + optional string version_id = 1; + optional int32 start_time = 2; + optional int32 end_time = 3; + optional int64 count = 4; + optional int64 total_size = 5; + optional int32 records = 6; +} + +message LogUsageRequest { + required string app_id = 1; + repeated string version_id = 2; + optional int32 start_time = 3; + optional int32 end_time = 4; + optional uint32 resolution_hours = 5 [default = 1]; + optional bool combine_versions = 6; + optional int32 usage_version = 7; + optional bool versions_only = 8; +} + +message LogUsageResponse { + repeated LogUsageRecord usage = 1; + optional LogUsageRecord summary = 2; +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/main.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/main.go new file mode 100644 index 000000000000..49036163c2b0 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/main.go @@ -0,0 +1,15 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build appengine + +package internal + +import ( + "appengine_internal" +) + +func Main() { + appengine_internal.Main() +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/main_vm.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/main_vm.go new file mode 100644 index 000000000000..57331ad171c4 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/main_vm.go @@ -0,0 +1,44 @@ +// Copyright 2011 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +// +build !appengine + +package internal + +import ( + "io" + "log" + "net/http" + "net/url" + "os" +) + +func Main() { + installHealthChecker(http.DefaultServeMux) + + port := "8080" + if s := os.Getenv("PORT"); s != "" { + port = s + } + + if err := http.ListenAndServe(":"+port, http.HandlerFunc(handleHTTP)); err != nil { + log.Fatalf("http.ListenAndServe: %v", err) + } +} + +func installHealthChecker(mux *http.ServeMux) { + // If no health check handler has been installed by this point, add a trivial one. + const healthPath = "/_ah/health" + hreq := &http.Request{ + Method: "GET", + URL: &url.URL{ + Path: healthPath, + }, + } + if _, pat := mux.Handler(hreq); pat != healthPath { + mux.HandleFunc(healthPath, func(w http.ResponseWriter, r *http.Request) { + io.WriteString(w, "ok") + }) + } +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/metadata.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/metadata.go new file mode 100644 index 000000000000..9cc1f71d104d --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/metadata.go @@ -0,0 +1,61 @@ +// Copyright 2014 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +// This file has code for accessing metadata. +// +// References: +// https://cloud.google.com/compute/docs/metadata + +import ( + "fmt" + "io/ioutil" + "log" + "net/http" + "net/url" +) + +const ( + metadataHost = "metadata" + metadataPath = "/computeMetadata/v1/" +) + +var ( + metadataRequestHeaders = http.Header{ + "Metadata-Flavor": []string{"Google"}, + } +) + +// TODO(dsymonds): Do we need to support default values, like Python? +func mustGetMetadata(key string) []byte { + b, err := getMetadata(key) + if err != nil { + log.Fatalf("Metadata fetch failed: %v", err) + } + return b +} + +func getMetadata(key string) ([]byte, error) { + // TODO(dsymonds): May need to use url.Parse to support keys with query args. + req := &http.Request{ + Method: "GET", + URL: &url.URL{ + Scheme: "http", + Host: metadataHost, + Path: metadataPath + key, + }, + Header: metadataRequestHeaders, + Host: metadataHost, + } + resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, err + } + defer resp.Body.Close() + if resp.StatusCode != 200 { + return nil, fmt.Errorf("metadata server returned HTTP %d", resp.StatusCode) + } + return ioutil.ReadAll(resp.Body) +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/modules/modules_service.pb.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/modules/modules_service.pb.go new file mode 100644 index 000000000000..a0145ed317c1 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/modules/modules_service.pb.go @@ -0,0 +1,375 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/modules/modules_service.proto +// DO NOT EDIT! + +/* +Package modules is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/modules/modules_service.proto + +It has these top-level messages: + ModulesServiceError + GetModulesRequest + GetModulesResponse + GetVersionsRequest + GetVersionsResponse + GetDefaultVersionRequest + GetDefaultVersionResponse + GetNumInstancesRequest + GetNumInstancesResponse + SetNumInstancesRequest + SetNumInstancesResponse + StartModuleRequest + StartModuleResponse + StopModuleRequest + StopModuleResponse + GetHostnameRequest + GetHostnameResponse +*/ +package modules + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type ModulesServiceError_ErrorCode int32 + +const ( + ModulesServiceError_OK ModulesServiceError_ErrorCode = 0 + ModulesServiceError_INVALID_MODULE ModulesServiceError_ErrorCode = 1 + ModulesServiceError_INVALID_VERSION ModulesServiceError_ErrorCode = 2 + ModulesServiceError_INVALID_INSTANCES ModulesServiceError_ErrorCode = 3 + ModulesServiceError_TRANSIENT_ERROR ModulesServiceError_ErrorCode = 4 + ModulesServiceError_UNEXPECTED_STATE ModulesServiceError_ErrorCode = 5 +) + +var ModulesServiceError_ErrorCode_name = map[int32]string{ + 0: "OK", + 1: "INVALID_MODULE", + 2: "INVALID_VERSION", + 3: "INVALID_INSTANCES", + 4: "TRANSIENT_ERROR", + 5: "UNEXPECTED_STATE", +} +var ModulesServiceError_ErrorCode_value = map[string]int32{ + "OK": 0, + "INVALID_MODULE": 1, + "INVALID_VERSION": 2, + "INVALID_INSTANCES": 3, + "TRANSIENT_ERROR": 4, + "UNEXPECTED_STATE": 5, +} + +func (x ModulesServiceError_ErrorCode) Enum() *ModulesServiceError_ErrorCode { + p := new(ModulesServiceError_ErrorCode) + *p = x + return p +} +func (x ModulesServiceError_ErrorCode) String() string { + return proto.EnumName(ModulesServiceError_ErrorCode_name, int32(x)) +} +func (x *ModulesServiceError_ErrorCode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(ModulesServiceError_ErrorCode_value, data, "ModulesServiceError_ErrorCode") + if err != nil { + return err + } + *x = ModulesServiceError_ErrorCode(value) + return nil +} + +type ModulesServiceError struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *ModulesServiceError) Reset() { *m = ModulesServiceError{} } +func (m *ModulesServiceError) String() string { return proto.CompactTextString(m) } +func (*ModulesServiceError) ProtoMessage() {} + +type GetModulesRequest struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetModulesRequest) Reset() { *m = GetModulesRequest{} } +func (m *GetModulesRequest) String() string { return proto.CompactTextString(m) } +func (*GetModulesRequest) ProtoMessage() {} + +type GetModulesResponse struct { + Module []string `protobuf:"bytes,1,rep,name=module" json:"module,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetModulesResponse) Reset() { *m = GetModulesResponse{} } +func (m *GetModulesResponse) String() string { return proto.CompactTextString(m) } +func (*GetModulesResponse) ProtoMessage() {} + +func (m *GetModulesResponse) GetModule() []string { + if m != nil { + return m.Module + } + return nil +} + +type GetVersionsRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetVersionsRequest) Reset() { *m = GetVersionsRequest{} } +func (m *GetVersionsRequest) String() string { return proto.CompactTextString(m) } +func (*GetVersionsRequest) ProtoMessage() {} + +func (m *GetVersionsRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +type GetVersionsResponse struct { + Version []string `protobuf:"bytes,1,rep,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetVersionsResponse) Reset() { *m = GetVersionsResponse{} } +func (m *GetVersionsResponse) String() string { return proto.CompactTextString(m) } +func (*GetVersionsResponse) ProtoMessage() {} + +func (m *GetVersionsResponse) GetVersion() []string { + if m != nil { + return m.Version + } + return nil +} + +type GetDefaultVersionRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetDefaultVersionRequest) Reset() { *m = GetDefaultVersionRequest{} } +func (m *GetDefaultVersionRequest) String() string { return proto.CompactTextString(m) } +func (*GetDefaultVersionRequest) ProtoMessage() {} + +func (m *GetDefaultVersionRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +type GetDefaultVersionResponse struct { + Version *string `protobuf:"bytes,1,req,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetDefaultVersionResponse) Reset() { *m = GetDefaultVersionResponse{} } +func (m *GetDefaultVersionResponse) String() string { return proto.CompactTextString(m) } +func (*GetDefaultVersionResponse) ProtoMessage() {} + +func (m *GetDefaultVersionResponse) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +type GetNumInstancesRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetNumInstancesRequest) Reset() { *m = GetNumInstancesRequest{} } +func (m *GetNumInstancesRequest) String() string { return proto.CompactTextString(m) } +func (*GetNumInstancesRequest) ProtoMessage() {} + +func (m *GetNumInstancesRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +func (m *GetNumInstancesRequest) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +type GetNumInstancesResponse struct { + Instances *int64 `protobuf:"varint,1,req,name=instances" json:"instances,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetNumInstancesResponse) Reset() { *m = GetNumInstancesResponse{} } +func (m *GetNumInstancesResponse) String() string { return proto.CompactTextString(m) } +func (*GetNumInstancesResponse) ProtoMessage() {} + +func (m *GetNumInstancesResponse) GetInstances() int64 { + if m != nil && m.Instances != nil { + return *m.Instances + } + return 0 +} + +type SetNumInstancesRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` + Instances *int64 `protobuf:"varint,3,req,name=instances" json:"instances,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SetNumInstancesRequest) Reset() { *m = SetNumInstancesRequest{} } +func (m *SetNumInstancesRequest) String() string { return proto.CompactTextString(m) } +func (*SetNumInstancesRequest) ProtoMessage() {} + +func (m *SetNumInstancesRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +func (m *SetNumInstancesRequest) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +func (m *SetNumInstancesRequest) GetInstances() int64 { + if m != nil && m.Instances != nil { + return *m.Instances + } + return 0 +} + +type SetNumInstancesResponse struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *SetNumInstancesResponse) Reset() { *m = SetNumInstancesResponse{} } +func (m *SetNumInstancesResponse) String() string { return proto.CompactTextString(m) } +func (*SetNumInstancesResponse) ProtoMessage() {} + +type StartModuleRequest struct { + Module *string `protobuf:"bytes,1,req,name=module" json:"module,omitempty"` + Version *string `protobuf:"bytes,2,req,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *StartModuleRequest) Reset() { *m = StartModuleRequest{} } +func (m *StartModuleRequest) String() string { return proto.CompactTextString(m) } +func (*StartModuleRequest) ProtoMessage() {} + +func (m *StartModuleRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +func (m *StartModuleRequest) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +type StartModuleResponse struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *StartModuleResponse) Reset() { *m = StartModuleResponse{} } +func (m *StartModuleResponse) String() string { return proto.CompactTextString(m) } +func (*StartModuleResponse) ProtoMessage() {} + +type StopModuleRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *StopModuleRequest) Reset() { *m = StopModuleRequest{} } +func (m *StopModuleRequest) String() string { return proto.CompactTextString(m) } +func (*StopModuleRequest) ProtoMessage() {} + +func (m *StopModuleRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +func (m *StopModuleRequest) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +type StopModuleResponse struct { + XXX_unrecognized []byte `json:"-"` +} + +func (m *StopModuleResponse) Reset() { *m = StopModuleResponse{} } +func (m *StopModuleResponse) String() string { return proto.CompactTextString(m) } +func (*StopModuleResponse) ProtoMessage() {} + +type GetHostnameRequest struct { + Module *string `protobuf:"bytes,1,opt,name=module" json:"module,omitempty"` + Version *string `protobuf:"bytes,2,opt,name=version" json:"version,omitempty"` + Instance *string `protobuf:"bytes,3,opt,name=instance" json:"instance,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetHostnameRequest) Reset() { *m = GetHostnameRequest{} } +func (m *GetHostnameRequest) String() string { return proto.CompactTextString(m) } +func (*GetHostnameRequest) ProtoMessage() {} + +func (m *GetHostnameRequest) GetModule() string { + if m != nil && m.Module != nil { + return *m.Module + } + return "" +} + +func (m *GetHostnameRequest) GetVersion() string { + if m != nil && m.Version != nil { + return *m.Version + } + return "" +} + +func (m *GetHostnameRequest) GetInstance() string { + if m != nil && m.Instance != nil { + return *m.Instance + } + return "" +} + +type GetHostnameResponse struct { + Hostname *string `protobuf:"bytes,1,req,name=hostname" json:"hostname,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *GetHostnameResponse) Reset() { *m = GetHostnameResponse{} } +func (m *GetHostnameResponse) String() string { return proto.CompactTextString(m) } +func (*GetHostnameResponse) ProtoMessage() {} + +func (m *GetHostnameResponse) GetHostname() string { + if m != nil && m.Hostname != nil { + return *m.Hostname + } + return "" +} + +func init() { +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/modules/modules_service.proto b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/modules/modules_service.proto new file mode 100644 index 000000000000..d29f0065a2f8 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/modules/modules_service.proto @@ -0,0 +1,80 @@ +syntax = "proto2"; +option go_package = "modules"; + +package appengine; + +message ModulesServiceError { + enum ErrorCode { + OK = 0; + INVALID_MODULE = 1; + INVALID_VERSION = 2; + INVALID_INSTANCES = 3; + TRANSIENT_ERROR = 4; + UNEXPECTED_STATE = 5; + } +} + +message GetModulesRequest { +} + +message GetModulesResponse { + repeated string module = 1; +} + +message GetVersionsRequest { + optional string module = 1; +} + +message GetVersionsResponse { + repeated string version = 1; +} + +message GetDefaultVersionRequest { + optional string module = 1; +} + +message GetDefaultVersionResponse { + required string version = 1; +} + +message GetNumInstancesRequest { + optional string module = 1; + optional string version = 2; +} + +message GetNumInstancesResponse { + required int64 instances = 1; +} + +message SetNumInstancesRequest { + optional string module = 1; + optional string version = 2; + required int64 instances = 3; +} + +message SetNumInstancesResponse {} + +message StartModuleRequest { + required string module = 1; + required string version = 2; +} + +message StartModuleResponse {} + +message StopModuleRequest { + optional string module = 1; + optional string version = 2; +} + +message StopModuleResponse {} + +message GetHostnameRequest { + optional string module = 1; + optional string version = 2; + optional string instance = 3; +} + +message GetHostnameResponse { + required string hostname = 1; +} + diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/net.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/net.go new file mode 100644 index 000000000000..3b94cf0c6a8b --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/net.go @@ -0,0 +1,56 @@ +// Copyright 2014 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +// This file implements a network dialer that limits the number of concurrent connections. +// It is only used for API calls. + +import ( + "log" + "net" + "runtime" + "sync" + "time" +) + +var limitSem = make(chan int, 100) // TODO(dsymonds): Use environment variable. + +func limitRelease() { + // non-blocking + select { + case <-limitSem: + default: + // This should not normally happen. + log.Print("appengine: unbalanced limitSem release!") + } +} + +func limitDial(network, addr string) (net.Conn, error) { + limitSem <- 1 + + // Dial with a timeout in case the API host is MIA. + // The connection should normally be very fast. + conn, err := net.DialTimeout(network, addr, 500*time.Millisecond) + if err != nil { + limitRelease() + return nil, err + } + lc := &limitConn{Conn: conn} + runtime.SetFinalizer(lc, (*limitConn).Close) // shouldn't usually be required + return lc, nil +} + +type limitConn struct { + close sync.Once + net.Conn +} + +func (lc *limitConn) Close() error { + defer lc.close.Do(func() { + limitRelease() + runtime.SetFinalizer(lc, nil) + }) + return lc.Conn.Close() +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go new file mode 100644 index 000000000000..526bd39e6d1a --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go @@ -0,0 +1,231 @@ +// Code generated by protoc-gen-go. +// source: google.golang.org/appengine/internal/remote_api/remote_api.proto +// DO NOT EDIT! + +/* +Package remote_api is a generated protocol buffer package. + +It is generated from these files: + google.golang.org/appengine/internal/remote_api/remote_api.proto + +It has these top-level messages: + Request + ApplicationError + RpcError + Response +*/ +package remote_api + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type RpcError_ErrorCode int32 + +const ( + RpcError_UNKNOWN RpcError_ErrorCode = 0 + RpcError_CALL_NOT_FOUND RpcError_ErrorCode = 1 + RpcError_PARSE_ERROR RpcError_ErrorCode = 2 + RpcError_SECURITY_VIOLATION RpcError_ErrorCode = 3 + RpcError_OVER_QUOTA RpcError_ErrorCode = 4 + RpcError_REQUEST_TOO_LARGE RpcError_ErrorCode = 5 + RpcError_CAPABILITY_DISABLED RpcError_ErrorCode = 6 + RpcError_FEATURE_DISABLED RpcError_ErrorCode = 7 + RpcError_BAD_REQUEST RpcError_ErrorCode = 8 + RpcError_RESPONSE_TOO_LARGE RpcError_ErrorCode = 9 + RpcError_CANCELLED RpcError_ErrorCode = 10 + RpcError_REPLAY_ERROR RpcError_ErrorCode = 11 + RpcError_DEADLINE_EXCEEDED RpcError_ErrorCode = 12 +) + +var RpcError_ErrorCode_name = map[int32]string{ + 0: "UNKNOWN", + 1: "CALL_NOT_FOUND", + 2: "PARSE_ERROR", + 3: "SECURITY_VIOLATION", + 4: "OVER_QUOTA", + 5: "REQUEST_TOO_LARGE", + 6: "CAPABILITY_DISABLED", + 7: "FEATURE_DISABLED", + 8: "BAD_REQUEST", + 9: "RESPONSE_TOO_LARGE", + 10: "CANCELLED", + 11: "REPLAY_ERROR", + 12: "DEADLINE_EXCEEDED", +} +var RpcError_ErrorCode_value = map[string]int32{ + "UNKNOWN": 0, + "CALL_NOT_FOUND": 1, + "PARSE_ERROR": 2, + "SECURITY_VIOLATION": 3, + "OVER_QUOTA": 4, + "REQUEST_TOO_LARGE": 5, + "CAPABILITY_DISABLED": 6, + "FEATURE_DISABLED": 7, + "BAD_REQUEST": 8, + "RESPONSE_TOO_LARGE": 9, + "CANCELLED": 10, + "REPLAY_ERROR": 11, + "DEADLINE_EXCEEDED": 12, +} + +func (x RpcError_ErrorCode) Enum() *RpcError_ErrorCode { + p := new(RpcError_ErrorCode) + *p = x + return p +} +func (x RpcError_ErrorCode) String() string { + return proto.EnumName(RpcError_ErrorCode_name, int32(x)) +} +func (x *RpcError_ErrorCode) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(RpcError_ErrorCode_value, data, "RpcError_ErrorCode") + if err != nil { + return err + } + *x = RpcError_ErrorCode(value) + return nil +} + +type Request struct { + ServiceName *string `protobuf:"bytes,2,req,name=service_name" json:"service_name,omitempty"` + Method *string `protobuf:"bytes,3,req,name=method" json:"method,omitempty"` + Request []byte `protobuf:"bytes,4,req,name=request" json:"request,omitempty"` + RequestId *string `protobuf:"bytes,5,opt,name=request_id" json:"request_id,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Request) Reset() { *m = Request{} } +func (m *Request) String() string { return proto.CompactTextString(m) } +func (*Request) ProtoMessage() {} + +func (m *Request) GetServiceName() string { + if m != nil && m.ServiceName != nil { + return *m.ServiceName + } + return "" +} + +func (m *Request) GetMethod() string { + if m != nil && m.Method != nil { + return *m.Method + } + return "" +} + +func (m *Request) GetRequest() []byte { + if m != nil { + return m.Request + } + return nil +} + +func (m *Request) GetRequestId() string { + if m != nil && m.RequestId != nil { + return *m.RequestId + } + return "" +} + +type ApplicationError struct { + Code *int32 `protobuf:"varint,1,req,name=code" json:"code,omitempty"` + Detail *string `protobuf:"bytes,2,req,name=detail" json:"detail,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ApplicationError) Reset() { *m = ApplicationError{} } +func (m *ApplicationError) String() string { return proto.CompactTextString(m) } +func (*ApplicationError) ProtoMessage() {} + +func (m *ApplicationError) GetCode() int32 { + if m != nil && m.Code != nil { + return *m.Code + } + return 0 +} + +func (m *ApplicationError) GetDetail() string { + if m != nil && m.Detail != nil { + return *m.Detail + } + return "" +} + +type RpcError struct { + Code *int32 `protobuf:"varint,1,req,name=code" json:"code,omitempty"` + Detail *string `protobuf:"bytes,2,opt,name=detail" json:"detail,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *RpcError) Reset() { *m = RpcError{} } +func (m *RpcError) String() string { return proto.CompactTextString(m) } +func (*RpcError) ProtoMessage() {} + +func (m *RpcError) GetCode() int32 { + if m != nil && m.Code != nil { + return *m.Code + } + return 0 +} + +func (m *RpcError) GetDetail() string { + if m != nil && m.Detail != nil { + return *m.Detail + } + return "" +} + +type Response struct { + Response []byte `protobuf:"bytes,1,opt,name=response" json:"response,omitempty"` + Exception []byte `protobuf:"bytes,2,opt,name=exception" json:"exception,omitempty"` + ApplicationError *ApplicationError `protobuf:"bytes,3,opt,name=application_error" json:"application_error,omitempty"` + JavaException []byte `protobuf:"bytes,4,opt,name=java_exception" json:"java_exception,omitempty"` + RpcError *RpcError `protobuf:"bytes,5,opt,name=rpc_error" json:"rpc_error,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Response) Reset() { *m = Response{} } +func (m *Response) String() string { return proto.CompactTextString(m) } +func (*Response) ProtoMessage() {} + +func (m *Response) GetResponse() []byte { + if m != nil { + return m.Response + } + return nil +} + +func (m *Response) GetException() []byte { + if m != nil { + return m.Exception + } + return nil +} + +func (m *Response) GetApplicationError() *ApplicationError { + if m != nil { + return m.ApplicationError + } + return nil +} + +func (m *Response) GetJavaException() []byte { + if m != nil { + return m.JavaException + } + return nil +} + +func (m *Response) GetRpcError() *RpcError { + if m != nil { + return m.RpcError + } + return nil +} + +func init() { +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto new file mode 100644 index 000000000000..f21763a4e239 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/remote_api/remote_api.proto @@ -0,0 +1,44 @@ +syntax = "proto2"; +option go_package = "remote_api"; + +package remote_api; + +message Request { + required string service_name = 2; + required string method = 3; + required bytes request = 4; + optional string request_id = 5; +} + +message ApplicationError { + required int32 code = 1; + required string detail = 2; +} + +message RpcError { + enum ErrorCode { + UNKNOWN = 0; + CALL_NOT_FOUND = 1; + PARSE_ERROR = 2; + SECURITY_VIOLATION = 3; + OVER_QUOTA = 4; + REQUEST_TOO_LARGE = 5; + CAPABILITY_DISABLED = 6; + FEATURE_DISABLED = 7; + BAD_REQUEST = 8; + RESPONSE_TOO_LARGE = 9; + CANCELLED = 10; + REPLAY_ERROR = 11; + DEADLINE_EXCEEDED = 12; + } + required int32 code = 1; + optional string detail = 2; +} + +message Response { + optional bytes response = 1; + optional bytes exception = 2; + optional ApplicationError application_error = 3; + optional bytes java_exception = 4; + optional RpcError rpc_error = 5; +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/transaction.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/transaction.go new file mode 100644 index 000000000000..28a6d1812061 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/internal/transaction.go @@ -0,0 +1,107 @@ +// Copyright 2014 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package internal + +// This file implements hooks for applying datastore transactions. + +import ( + "errors" + "reflect" + + "github.com/golang/protobuf/proto" + netcontext "golang.org/x/net/context" + + basepb "google.golang.org/appengine/internal/base" + pb "google.golang.org/appengine/internal/datastore" +) + +var transactionSetters = make(map[reflect.Type]reflect.Value) + +// RegisterTransactionSetter registers a function that sets transaction information +// in a protocol buffer message. f should be a function with two arguments, +// the first being a protocol buffer type, and the second being *datastore.Transaction. +func RegisterTransactionSetter(f interface{}) { + v := reflect.ValueOf(f) + transactionSetters[v.Type().In(0)] = v +} + +// applyTransaction applies the transaction t to message pb +// by using the relevant setter passed to RegisterTransactionSetter. +func applyTransaction(pb proto.Message, t *pb.Transaction) { + v := reflect.ValueOf(pb) + if f, ok := transactionSetters[v.Type()]; ok { + f.Call([]reflect.Value{v, reflect.ValueOf(t)}) + } +} + +var transactionKey = "used for *Transaction" + +func transactionFromContext(ctx netcontext.Context) *transaction { + t, _ := ctx.Value(&transactionKey).(*transaction) + return t +} + +func withTransaction(ctx netcontext.Context, t *transaction) netcontext.Context { + return netcontext.WithValue(ctx, &transactionKey, t) +} + +type transaction struct { + transaction pb.Transaction + finished bool +} + +var ErrConcurrentTransaction = errors.New("internal: concurrent transaction") + +func RunTransactionOnce(c netcontext.Context, f func(netcontext.Context) error, xg bool) error { + if transactionFromContext(c) != nil { + return errors.New("nested transactions are not supported") + } + + // Begin the transaction. + t := &transaction{} + req := &pb.BeginTransactionRequest{ + App: proto.String(FullyQualifiedAppID(c)), + } + if xg { + req.AllowMultipleEg = proto.Bool(true) + } + if err := Call(c, "datastore_v3", "BeginTransaction", req, &t.transaction); err != nil { + return err + } + + // Call f, rolling back the transaction if f returns a non-nil error, or panics. + // The panic is not recovered. + defer func() { + if t.finished { + return + } + t.finished = true + // Ignore the error return value, since we are already returning a non-nil + // error (or we're panicking). + Call(c, "datastore_v3", "Rollback", &t.transaction, &basepb.VoidProto{}) + }() + if err := f(withTransaction(c, t)); err != nil { + return err + } + t.finished = true + + // Commit the transaction. + res := &pb.CommitResponse{} + err := Call(c, "datastore_v3", "Commit", &t.transaction, res) + if ae, ok := err.(*APIError); ok { + /* TODO: restore this conditional + if appengine.IsDevAppServer() { + */ + // The Python Dev AppServer raises an ApplicationError with error code 2 (which is + // Error.CONCURRENT_TRANSACTION) and message "Concurrency exception.". + if ae.Code == int32(pb.Error_BAD_REQUEST) && ae.Detail == "ApplicationError: 2 Concurrency exception." { + return ErrConcurrentTransaction + } + if ae.Code == int32(pb.Error_CONCURRENT_TRANSACTION) { + return ErrConcurrentTransaction + } + } + return err +} diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/namespace.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/namespace.go new file mode 100644 index 000000000000..21860ca08227 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/namespace.go @@ -0,0 +1,25 @@ +// Copyright 2012 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package appengine + +import ( + "fmt" + "regexp" + + "golang.org/x/net/context" + + "google.golang.org/appengine/internal" +) + +// Namespace returns a replacement context that operates within the given namespace. +func Namespace(c context.Context, namespace string) (context.Context, error) { + if !validNamespace.MatchString(namespace) { + return nil, fmt.Errorf("appengine: namespace %q does not match /%s/", namespace, validNamespace) + } + return internal.NamespacedContext(c, namespace), nil +} + +// validNamespace matches valid namespace names. +var validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`) diff --git a/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/timeout.go b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/timeout.go new file mode 100644 index 000000000000..05642a992a39 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/_vendor/google.golang.org/appengine/timeout.go @@ -0,0 +1,20 @@ +// Copyright 2013 Google Inc. All rights reserved. +// Use of this source code is governed by the Apache 2.0 +// license that can be found in the LICENSE file. + +package appengine + +import "golang.org/x/net/context" + +// IsTimeoutError reports whether err is a timeout error. +func IsTimeoutError(err error) bool { + if err == context.DeadlineExceeded { + return true + } + if t, ok := err.(interface { + IsTimeout() bool + }); ok { + return t.IsTimeout() + } + return false +} diff --git a/staging/src/k8s.io/client-go/1.5/discovery/restmapper.go b/staging/src/k8s.io/client-go/1.5/discovery/restmapper.go index 66936d293e2e..81dc905f4cbc 100644 --- a/staging/src/k8s.io/client-go/1.5/discovery/restmapper.go +++ b/staging/src/k8s.io/client-go/1.5/discovery/restmapper.go @@ -17,6 +17,7 @@ limitations under the License. package discovery import ( + "fmt" "sync" "k8s.io/client-go/1.5/pkg/api/errors" @@ -259,5 +260,13 @@ func (d *DeferredDiscoveryRESTMapper) ResourceSingularizer(resource string) (sin return del.ResourceSingularizer(resource) } +func (d *DeferredDiscoveryRESTMapper) String() string { + del, err := d.getDelegate() + if err != nil { + return fmt.Sprintf("DeferredDiscoveryRESTMapper{%v}", err) + } + return fmt.Sprintf("DeferredDiscoveryRESTMapper{\n\t%v\n}", del) +} + // Make sure it satisfies the interface var _ meta.RESTMapper = &DeferredDiscoveryRESTMapper{} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/clientset.go b/staging/src/k8s.io/client-go/1.5/kubernetes/clientset.go index 12135a85f44e..35df6df632cf 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/clientset.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/clientset.go @@ -19,24 +19,35 @@ package kubernetes import ( "github.com/golang/glog" discovery "k8s.io/client-go/1.5/discovery" + v1alpha1apps "k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1" + v1beta1authentication "k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1" v1beta1authorization "k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1" v1autoscaling "k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1" v1batch "k8s.io/client-go/1.5/kubernetes/typed/batch/v1" + v1alpha1certificates "k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1" v1core "k8s.io/client-go/1.5/kubernetes/typed/core/v1" v1beta1extensions "k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1" v1alpha1policy "k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1" + v1alpha1rbac "k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1" + v1beta1storage "k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1" "k8s.io/client-go/1.5/pkg/util/flowcontrol" + _ "k8s.io/client-go/1.5/plugin/pkg/client/auth" rest "k8s.io/client-go/1.5/rest" ) type Interface interface { Discovery() discovery.DiscoveryInterface Core() v1core.CoreInterface + Apps() v1alpha1apps.AppsInterface + Authentication() v1beta1authentication.AuthenticationInterface Authorization() v1beta1authorization.AuthorizationInterface Autoscaling() v1autoscaling.AutoscalingInterface Batch() v1batch.BatchInterface + Certificates() v1alpha1certificates.CertificatesInterface Extensions() v1beta1extensions.ExtensionsInterface Policy() v1alpha1policy.PolicyInterface + Rbac() v1alpha1rbac.RbacInterface + Storage() v1beta1storage.StorageInterface } // Clientset contains the clients for groups. Each group has exactly one @@ -44,11 +55,16 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient *v1core.CoreClient + *v1alpha1apps.AppsClient + *v1beta1authentication.AuthenticationClient *v1beta1authorization.AuthorizationClient *v1autoscaling.AutoscalingClient *v1batch.BatchClient + *v1alpha1certificates.CertificatesClient *v1beta1extensions.ExtensionsClient *v1alpha1policy.PolicyClient + *v1alpha1rbac.RbacClient + *v1beta1storage.StorageClient } // Core retrieves the CoreClient @@ -59,6 +75,22 @@ func (c *Clientset) Core() v1core.CoreInterface { return c.CoreClient } +// Apps retrieves the AppsClient +func (c *Clientset) Apps() v1alpha1apps.AppsInterface { + if c == nil { + return nil + } + return c.AppsClient +} + +// Authentication retrieves the AuthenticationClient +func (c *Clientset) Authentication() v1beta1authentication.AuthenticationInterface { + if c == nil { + return nil + } + return c.AuthenticationClient +} + // Authorization retrieves the AuthorizationClient func (c *Clientset) Authorization() v1beta1authorization.AuthorizationInterface { if c == nil { @@ -83,6 +115,14 @@ func (c *Clientset) Batch() v1batch.BatchInterface { return c.BatchClient } +// Certificates retrieves the CertificatesClient +func (c *Clientset) Certificates() v1alpha1certificates.CertificatesInterface { + if c == nil { + return nil + } + return c.CertificatesClient +} + // Extensions retrieves the ExtensionsClient func (c *Clientset) Extensions() v1beta1extensions.ExtensionsInterface { if c == nil { @@ -99,6 +139,22 @@ func (c *Clientset) Policy() v1alpha1policy.PolicyInterface { return c.PolicyClient } +// Rbac retrieves the RbacClient +func (c *Clientset) Rbac() v1alpha1rbac.RbacInterface { + if c == nil { + return nil + } + return c.RbacClient +} + +// Storage retrieves the StorageClient +func (c *Clientset) Storage() v1beta1storage.StorageInterface { + if c == nil { + return nil + } + return c.StorageClient +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { return c.DiscoveryClient @@ -116,6 +172,14 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + clientset.AppsClient, err = v1alpha1apps.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + clientset.AuthenticationClient, err = v1beta1authentication.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } clientset.AuthorizationClient, err = v1beta1authorization.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -128,6 +192,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + clientset.CertificatesClient, err = v1alpha1certificates.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } clientset.ExtensionsClient, err = v1beta1extensions.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -136,6 +204,14 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + clientset.RbacClient, err = v1alpha1rbac.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + clientset.StorageClient, err = v1beta1storage.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } clientset.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -150,11 +226,16 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var clientset Clientset clientset.CoreClient = v1core.NewForConfigOrDie(c) + clientset.AppsClient = v1alpha1apps.NewForConfigOrDie(c) + clientset.AuthenticationClient = v1beta1authentication.NewForConfigOrDie(c) clientset.AuthorizationClient = v1beta1authorization.NewForConfigOrDie(c) clientset.AutoscalingClient = v1autoscaling.NewForConfigOrDie(c) clientset.BatchClient = v1batch.NewForConfigOrDie(c) + clientset.CertificatesClient = v1alpha1certificates.NewForConfigOrDie(c) clientset.ExtensionsClient = v1beta1extensions.NewForConfigOrDie(c) clientset.PolicyClient = v1alpha1policy.NewForConfigOrDie(c) + clientset.RbacClient = v1alpha1rbac.NewForConfigOrDie(c) + clientset.StorageClient = v1beta1storage.NewForConfigOrDie(c) clientset.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &clientset @@ -164,11 +245,16 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c *rest.RESTClient) *Clientset { var clientset Clientset clientset.CoreClient = v1core.New(c) + clientset.AppsClient = v1alpha1apps.New(c) + clientset.AuthenticationClient = v1beta1authentication.New(c) clientset.AuthorizationClient = v1beta1authorization.New(c) clientset.AutoscalingClient = v1autoscaling.New(c) clientset.BatchClient = v1batch.New(c) + clientset.CertificatesClient = v1alpha1certificates.New(c) clientset.ExtensionsClient = v1beta1extensions.New(c) clientset.PolicyClient = v1alpha1policy.New(c) + clientset.RbacClient = v1alpha1rbac.New(c) + clientset.StorageClient = v1beta1storage.New(c) clientset.DiscoveryClient = discovery.NewDiscoveryClient(c) return &clientset diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/doc.go index b945bd1175d5..bd09a3563114 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // This package has the automatically generated clientset. package kubernetes diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/fake/clientset_generated.go b/staging/src/k8s.io/client-go/1.5/kubernetes/fake/clientset_generated.go index 3ae933511337..091cf47636c1 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/fake/clientset_generated.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/fake/clientset_generated.go @@ -20,18 +20,28 @@ import ( "k8s.io/client-go/1.5/discovery" fakediscovery "k8s.io/client-go/1.5/discovery/fake" clientset "k8s.io/client-go/1.5/kubernetes" + v1alpha1apps "k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1" + fakev1alpha1apps "k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake" + v1beta1authentication "k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1" + fakev1beta1authentication "k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake" v1beta1authorization "k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1" fakev1beta1authorization "k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1/fake" v1autoscaling "k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1" fakev1autoscaling "k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1/fake" v1batch "k8s.io/client-go/1.5/kubernetes/typed/batch/v1" fakev1batch "k8s.io/client-go/1.5/kubernetes/typed/batch/v1/fake" + v1alpha1certificates "k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1" + fakev1alpha1certificates "k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake" v1core "k8s.io/client-go/1.5/kubernetes/typed/core/v1" fakev1core "k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake" v1beta1extensions "k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1" fakev1beta1extensions "k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1/fake" v1alpha1policy "k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1" fakev1alpha1policy "k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1/fake" + v1alpha1rbac "k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1" + fakev1alpha1rbac "k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake" + v1beta1storage "k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1" + fakev1beta1storage "k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake" "k8s.io/client-go/1.5/pkg/api" "k8s.io/client-go/1.5/pkg/apimachinery/registered" "k8s.io/client-go/1.5/pkg/runtime" @@ -77,6 +87,16 @@ func (c *Clientset) Core() v1core.CoreInterface { return &fakev1core.FakeCore{Fake: &c.Fake} } +// Apps retrieves the AppsClient +func (c *Clientset) Apps() v1alpha1apps.AppsInterface { + return &fakev1alpha1apps.FakeApps{Fake: &c.Fake} +} + +// Authentication retrieves the AuthenticationClient +func (c *Clientset) Authentication() v1beta1authentication.AuthenticationInterface { + return &fakev1beta1authentication.FakeAuthentication{Fake: &c.Fake} +} + // Authorization retrieves the AuthorizationClient func (c *Clientset) Authorization() v1beta1authorization.AuthorizationInterface { return &fakev1beta1authorization.FakeAuthorization{Fake: &c.Fake} @@ -92,6 +112,11 @@ func (c *Clientset) Batch() v1batch.BatchInterface { return &fakev1batch.FakeBatch{Fake: &c.Fake} } +// Certificates retrieves the CertificatesClient +func (c *Clientset) Certificates() v1alpha1certificates.CertificatesInterface { + return &fakev1alpha1certificates.FakeCertificates{Fake: &c.Fake} +} + // Extensions retrieves the ExtensionsClient func (c *Clientset) Extensions() v1beta1extensions.ExtensionsInterface { return &fakev1beta1extensions.FakeExtensions{Fake: &c.Fake} @@ -101,3 +126,13 @@ func (c *Clientset) Extensions() v1beta1extensions.ExtensionsInterface { func (c *Clientset) Policy() v1alpha1policy.PolicyInterface { return &fakev1alpha1policy.FakePolicy{Fake: &c.Fake} } + +// Rbac retrieves the RbacClient +func (c *Clientset) Rbac() v1alpha1rbac.RbacInterface { + return &fakev1alpha1rbac.FakeRbac{Fake: &c.Fake} +} + +// Storage retrieves the StorageClient +func (c *Clientset) Storage() v1beta1storage.StorageInterface { + return &fakev1beta1storage.FakeStorage{Fake: &c.Fake} +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/fake/doc.go index f68af5271934..f849c0cdaac4 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/fake/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/fake/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // This package has the automatically generated fake clientset. package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/import_known_versions.go b/staging/src/k8s.io/client-go/1.5/kubernetes/import_known_versions.go index 62b2f4e6256f..2a27c780f1bd 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/import_known_versions.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/import_known_versions.go @@ -23,11 +23,14 @@ import ( _ "k8s.io/client-go/1.5/pkg/api/install" "k8s.io/client-go/1.5/pkg/apimachinery/registered" _ "k8s.io/client-go/1.5/pkg/apis/apps/install" + _ "k8s.io/client-go/1.5/pkg/apis/authentication/install" _ "k8s.io/client-go/1.5/pkg/apis/authorization/install" _ "k8s.io/client-go/1.5/pkg/apis/autoscaling/install" _ "k8s.io/client-go/1.5/pkg/apis/batch/install" + _ "k8s.io/client-go/1.5/pkg/apis/certificates/install" _ "k8s.io/client-go/1.5/pkg/apis/extensions/install" _ "k8s.io/client-go/1.5/pkg/apis/policy/install" + _ "k8s.io/client-go/1.5/pkg/apis/rbac/install" _ "k8s.io/client-go/1.5/pkg/apis/storage/install" ) diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/apps_client.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/apps_client.go new file mode 100644 index 000000000000..6c792d936bf9 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/apps_client.go @@ -0,0 +1,96 @@ +/* +Copyright 2016 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 v1alpha1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + registered "k8s.io/client-go/1.5/pkg/apimachinery/registered" + serializer "k8s.io/client-go/1.5/pkg/runtime/serializer" + rest "k8s.io/client-go/1.5/rest" +) + +type AppsInterface interface { + GetRESTClient() *rest.RESTClient + PetSetsGetter +} + +// AppsClient is used to interact with features provided by the Apps group. +type AppsClient struct { + *rest.RESTClient +} + +func (c *AppsClient) PetSets(namespace string) PetSetInterface { + return newPetSets(c, namespace) +} + +// NewForConfig creates a new AppsClient for the given config. +func NewForConfig(c *rest.Config) (*AppsClient, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &AppsClient{client}, nil +} + +// NewForConfigOrDie creates a new AppsClient for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AppsClient { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AppsClient for the given RESTClient. +func New(c *rest.RESTClient) *AppsClient { + return &AppsClient{c} +} + +func setConfigDefaults(config *rest.Config) error { + // if apps group is not registered, return an error + g, err := registered.Group("apps") + if err != nil { + return err + } + config.APIPath = "/apis" + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + // TODO: Unconditionally set the config.Version, until we fix the config. + //if config.Version == "" { + copyGroupVersion := g.GroupVersion + config.GroupVersion = ©GroupVersion + //} + + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs} + + return nil +} + +// GetRESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AppsClient) GetRESTClient() *rest.RESTClient { + if c == nil { + return nil + } + return c.RESTClient +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/doc.go new file mode 100644 index 000000000000..0c1ca41faccf --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 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 package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/doc.go new file mode 100644 index 000000000000..6499875c0b57 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 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 package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] + +// Package fake has the automatically generated clients. +package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/fake_apps_client.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/fake_apps_client.go new file mode 100644 index 000000000000..7ac4d7d68dc5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/fake_apps_client.go @@ -0,0 +1,37 @@ +/* +Copyright 2016 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 fake + +import ( + v1alpha1 "k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1" + rest "k8s.io/client-go/1.5/rest" + testing "k8s.io/client-go/1.5/testing" +) + +type FakeApps struct { + *testing.Fake +} + +func (c *FakeApps) PetSets(namespace string) v1alpha1.PetSetInterface { + return &FakePetSets{c, namespace} +} + +// GetRESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeApps) GetRESTClient() *rest.RESTClient { + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/fake_petset.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/fake_petset.go new file mode 100644 index 000000000000..3123dd0705e8 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/fake/fake_petset.go @@ -0,0 +1,127 @@ +/* +Copyright 2016 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 fake + +import ( + api "k8s.io/client-go/1.5/pkg/api" + unversioned "k8s.io/client-go/1.5/pkg/api/unversioned" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/apps/v1alpha1" + labels "k8s.io/client-go/1.5/pkg/labels" + watch "k8s.io/client-go/1.5/pkg/watch" + testing "k8s.io/client-go/1.5/testing" +) + +// FakePetSets implements PetSetInterface +type FakePetSets struct { + Fake *FakeApps + ns string +} + +var petsetsResource = unversioned.GroupVersionResource{Group: "apps", Version: "v1alpha1", Resource: "petsets"} + +func (c *FakePetSets) Create(petSet *v1alpha1.PetSet) (result *v1alpha1.PetSet, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(petsetsResource, c.ns, petSet), &v1alpha1.PetSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PetSet), err +} + +func (c *FakePetSets) Update(petSet *v1alpha1.PetSet) (result *v1alpha1.PetSet, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(petsetsResource, c.ns, petSet), &v1alpha1.PetSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PetSet), err +} + +func (c *FakePetSets) UpdateStatus(petSet *v1alpha1.PetSet) (*v1alpha1.PetSet, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(petsetsResource, "status", c.ns, petSet), &v1alpha1.PetSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PetSet), err +} + +func (c *FakePetSets) Delete(name string, options *api.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(petsetsResource, c.ns, name), &v1alpha1.PetSet{}) + + return err +} + +func (c *FakePetSets) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + action := testing.NewDeleteCollectionAction(petsetsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.PetSetList{}) + return err +} + +func (c *FakePetSets) Get(name string) (result *v1alpha1.PetSet, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(petsetsResource, c.ns, name), &v1alpha1.PetSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PetSet), err +} + +func (c *FakePetSets) List(opts api.ListOptions) (result *v1alpha1.PetSetList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(petsetsResource, c.ns, opts), &v1alpha1.PetSetList{}) + + if obj == nil { + return nil, err + } + + label := opts.LabelSelector + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PetSetList{} + for _, item := range obj.(*v1alpha1.PetSetList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested petSets. +func (c *FakePetSets) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(petsetsResource, c.ns, opts)) + +} + +// Patch applies the patch and returns the patched petSet. +func (c *FakePetSets) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.PetSet, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(petsetsResource, c.ns, name, data, subresources...), &v1alpha1.PetSet{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PetSet), err +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/generated_expansion.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/generated_expansion.go new file mode 100644 index 000000000000..439a241b040c --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 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 v1alpha1 + +type PetSetExpansion interface{} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/petset.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/petset.go new file mode 100644 index 000000000000..611c68dc6e7c --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/apps/v1alpha1/petset.go @@ -0,0 +1,165 @@ +/* +Copyright 2016 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 v1alpha1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/apps/v1alpha1" + watch "k8s.io/client-go/1.5/pkg/watch" +) + +// PetSetsGetter has a method to return a PetSetInterface. +// A group's client should implement this interface. +type PetSetsGetter interface { + PetSets(namespace string) PetSetInterface +} + +// PetSetInterface has methods to work with PetSet resources. +type PetSetInterface interface { + Create(*v1alpha1.PetSet) (*v1alpha1.PetSet, error) + Update(*v1alpha1.PetSet) (*v1alpha1.PetSet, error) + UpdateStatus(*v1alpha1.PetSet) (*v1alpha1.PetSet, error) + Delete(name string, options *api.DeleteOptions) error + DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error + Get(name string) (*v1alpha1.PetSet, error) + List(opts api.ListOptions) (*v1alpha1.PetSetList, error) + Watch(opts api.ListOptions) (watch.Interface, error) + Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.PetSet, err error) + PetSetExpansion +} + +// petSets implements PetSetInterface +type petSets struct { + client *AppsClient + ns string +} + +// newPetSets returns a PetSets +func newPetSets(c *AppsClient, namespace string) *petSets { + return &petSets{ + client: c, + ns: namespace, + } +} + +// Create takes the representation of a petSet and creates it. Returns the server's representation of the petSet, and an error, if there is any. +func (c *petSets) Create(petSet *v1alpha1.PetSet) (result *v1alpha1.PetSet, err error) { + result = &v1alpha1.PetSet{} + err = c.client.Post(). + Namespace(c.ns). + Resource("petsets"). + Body(petSet). + Do(). + Into(result) + return +} + +// Update takes the representation of a petSet and updates it. Returns the server's representation of the petSet, and an error, if there is any. +func (c *petSets) Update(petSet *v1alpha1.PetSet) (result *v1alpha1.PetSet, err error) { + result = &v1alpha1.PetSet{} + err = c.client.Put(). + Namespace(c.ns). + Resource("petsets"). + Name(petSet.Name). + Body(petSet). + Do(). + Into(result) + return +} + +func (c *petSets) UpdateStatus(petSet *v1alpha1.PetSet) (result *v1alpha1.PetSet, err error) { + result = &v1alpha1.PetSet{} + err = c.client.Put(). + Namespace(c.ns). + Resource("petsets"). + Name(petSet.Name). + SubResource("status"). + Body(petSet). + Do(). + Into(result) + return +} + +// Delete takes name of the petSet and deletes it. Returns an error if one occurs. +func (c *petSets) Delete(name string, options *api.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("petsets"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *petSets) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("petsets"). + VersionedParams(&listOptions, api.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Get takes name of the petSet, and returns the corresponding petSet object, and an error if there is any. +func (c *petSets) Get(name string) (result *v1alpha1.PetSet, err error) { + result = &v1alpha1.PetSet{} + err = c.client.Get(). + Namespace(c.ns). + Resource("petsets"). + Name(name). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PetSets that match those selectors. +func (c *petSets) List(opts api.ListOptions) (result *v1alpha1.PetSetList, err error) { + result = &v1alpha1.PetSetList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("petsets"). + VersionedParams(&opts, api.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested petSets. +func (c *petSets) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.client.Get(). + Prefix("watch"). + Namespace(c.ns). + Resource("petsets"). + VersionedParams(&opts, api.ParameterCodec). + Watch() +} + +// Patch applies the patch and returns the patched petSet. +func (c *petSets) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.PetSet, err error) { + result = &v1alpha1.PetSet{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("petsets"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/authentication_client.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/authentication_client.go new file mode 100644 index 000000000000..878e92aa0c44 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/authentication_client.go @@ -0,0 +1,96 @@ +/* +Copyright 2016 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 v1beta1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + registered "k8s.io/client-go/1.5/pkg/apimachinery/registered" + serializer "k8s.io/client-go/1.5/pkg/runtime/serializer" + rest "k8s.io/client-go/1.5/rest" +) + +type AuthenticationInterface interface { + GetRESTClient() *rest.RESTClient + TokenReviewsGetter +} + +// AuthenticationClient is used to interact with features provided by the Authentication group. +type AuthenticationClient struct { + *rest.RESTClient +} + +func (c *AuthenticationClient) TokenReviews() TokenReviewInterface { + return newTokenReviews(c) +} + +// NewForConfig creates a new AuthenticationClient for the given config. +func NewForConfig(c *rest.Config) (*AuthenticationClient, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &AuthenticationClient{client}, nil +} + +// NewForConfigOrDie creates a new AuthenticationClient for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AuthenticationClient { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AuthenticationClient for the given RESTClient. +func New(c *rest.RESTClient) *AuthenticationClient { + return &AuthenticationClient{c} +} + +func setConfigDefaults(config *rest.Config) error { + // if authentication group is not registered, return an error + g, err := registered.Group("authentication.k8s.io") + if err != nil { + return err + } + config.APIPath = "/apis" + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + // TODO: Unconditionally set the config.Version, until we fix the config. + //if config.Version == "" { + copyGroupVersion := g.GroupVersion + config.GroupVersion = ©GroupVersion + //} + + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs} + + return nil +} + +// GetRESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AuthenticationClient) GetRESTClient() *rest.RESTClient { + if c == nil { + return nil + } + return c.RESTClient +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/doc.go new file mode 100644 index 000000000000..5616c95d3257 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 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 package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/doc.go new file mode 100644 index 000000000000..6499875c0b57 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 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 package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] + +// Package fake has the automatically generated clients. +package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/fake_authentication_client.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/fake_authentication_client.go new file mode 100644 index 000000000000..8402bfb8ba5d --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/fake_authentication_client.go @@ -0,0 +1,37 @@ +/* +Copyright 2016 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 fake + +import ( + v1beta1 "k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1" + rest "k8s.io/client-go/1.5/rest" + testing "k8s.io/client-go/1.5/testing" +) + +type FakeAuthentication struct { + *testing.Fake +} + +func (c *FakeAuthentication) TokenReviews() v1beta1.TokenReviewInterface { + return &FakeTokenReviews{c} +} + +// GetRESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAuthentication) GetRESTClient() *rest.RESTClient { + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/fake_tokenreview.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/fake_tokenreview.go new file mode 100644 index 000000000000..6508f5a94aa3 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/fake/fake_tokenreview.go @@ -0,0 +1,22 @@ +/* +Copyright 2016 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 fake + +// FakeTokenReviews implements TokenReviewInterface +type FakeTokenReviews struct { + Fake *FakeAuthentication +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/generated_expansion.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/generated_expansion.go new file mode 100644 index 000000000000..f307100297e3 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 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 v1beta1 + +type TokenReviewExpansion interface{} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/tokenreview.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/tokenreview.go new file mode 100644 index 000000000000..dc9313bae3d2 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authentication/v1beta1/tokenreview.go @@ -0,0 +1,40 @@ +/* +Copyright 2016 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 v1beta1 + +// TokenReviewsGetter has a method to return a TokenReviewInterface. +// A group's client should implement this interface. +type TokenReviewsGetter interface { + TokenReviews() TokenReviewInterface +} + +// TokenReviewInterface has methods to work with TokenReview resources. +type TokenReviewInterface interface { + TokenReviewExpansion +} + +// tokenReviews implements TokenReviewInterface +type tokenReviews struct { + client *AuthenticationClient +} + +// newTokenReviews returns a TokenReviews +func newTokenReviews(c *AuthenticationClient) *tokenReviews { + return &tokenReviews{ + client: c, + } +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1/doc.go index 831e702d9263..5616c95d3257 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // This package has the automatically generated typed clients. package v1beta1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1/fake/doc.go index 793bddf23ce2..6499875c0b57 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1/fake/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/authorization/v1beta1/fake/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // Package fake has the automatically generated clients. package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1/doc.go index 20aab35ab22c..fe27cf5c1947 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // This package has the automatically generated typed clients. package v1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1/fake/doc.go index 793bddf23ce2..6499875c0b57 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1/fake/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/autoscaling/v1/fake/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // Package fake has the automatically generated clients. package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/batch/v1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/batch/v1/doc.go index 20aab35ab22c..fe27cf5c1947 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/batch/v1/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/batch/v1/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // This package has the automatically generated typed clients. package v1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/batch/v1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/batch/v1/fake/doc.go index 793bddf23ce2..6499875c0b57 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/batch/v1/fake/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/batch/v1/fake/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // Package fake has the automatically generated clients. package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/certificates_client.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/certificates_client.go new file mode 100644 index 000000000000..56c3d4a398aa --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/certificates_client.go @@ -0,0 +1,96 @@ +/* +Copyright 2016 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 v1alpha1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + registered "k8s.io/client-go/1.5/pkg/apimachinery/registered" + serializer "k8s.io/client-go/1.5/pkg/runtime/serializer" + rest "k8s.io/client-go/1.5/rest" +) + +type CertificatesInterface interface { + GetRESTClient() *rest.RESTClient + CertificateSigningRequestsGetter +} + +// CertificatesClient is used to interact with features provided by the Certificates group. +type CertificatesClient struct { + *rest.RESTClient +} + +func (c *CertificatesClient) CertificateSigningRequests() CertificateSigningRequestInterface { + return newCertificateSigningRequests(c) +} + +// NewForConfig creates a new CertificatesClient for the given config. +func NewForConfig(c *rest.Config) (*CertificatesClient, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &CertificatesClient{client}, nil +} + +// NewForConfigOrDie creates a new CertificatesClient for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *CertificatesClient { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new CertificatesClient for the given RESTClient. +func New(c *rest.RESTClient) *CertificatesClient { + return &CertificatesClient{c} +} + +func setConfigDefaults(config *rest.Config) error { + // if certificates group is not registered, return an error + g, err := registered.Group("certificates.k8s.io") + if err != nil { + return err + } + config.APIPath = "/apis" + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + // TODO: Unconditionally set the config.Version, until we fix the config. + //if config.Version == "" { + copyGroupVersion := g.GroupVersion + config.GroupVersion = ©GroupVersion + //} + + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs} + + return nil +} + +// GetRESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *CertificatesClient) GetRESTClient() *rest.RESTClient { + if c == nil { + return nil + } + return c.RESTClient +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/certificatesigningrequest.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/certificatesigningrequest.go new file mode 100644 index 000000000000..07e6a0404113 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/certificatesigningrequest.go @@ -0,0 +1,154 @@ +/* +Copyright 2016 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 v1alpha1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/certificates/v1alpha1" + watch "k8s.io/client-go/1.5/pkg/watch" +) + +// CertificateSigningRequestsGetter has a method to return a CertificateSigningRequestInterface. +// A group's client should implement this interface. +type CertificateSigningRequestsGetter interface { + CertificateSigningRequests() CertificateSigningRequestInterface +} + +// CertificateSigningRequestInterface has methods to work with CertificateSigningRequest resources. +type CertificateSigningRequestInterface interface { + Create(*v1alpha1.CertificateSigningRequest) (*v1alpha1.CertificateSigningRequest, error) + Update(*v1alpha1.CertificateSigningRequest) (*v1alpha1.CertificateSigningRequest, error) + UpdateStatus(*v1alpha1.CertificateSigningRequest) (*v1alpha1.CertificateSigningRequest, error) + Delete(name string, options *api.DeleteOptions) error + DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error + Get(name string) (*v1alpha1.CertificateSigningRequest, error) + List(opts api.ListOptions) (*v1alpha1.CertificateSigningRequestList, error) + Watch(opts api.ListOptions) (watch.Interface, error) + Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.CertificateSigningRequest, err error) + CertificateSigningRequestExpansion +} + +// certificateSigningRequests implements CertificateSigningRequestInterface +type certificateSigningRequests struct { + client *CertificatesClient +} + +// newCertificateSigningRequests returns a CertificateSigningRequests +func newCertificateSigningRequests(c *CertificatesClient) *certificateSigningRequests { + return &certificateSigningRequests{ + client: c, + } +} + +// Create takes the representation of a certificateSigningRequest and creates it. Returns the server's representation of the certificateSigningRequest, and an error, if there is any. +func (c *certificateSigningRequests) Create(certificateSigningRequest *v1alpha1.CertificateSigningRequest) (result *v1alpha1.CertificateSigningRequest, err error) { + result = &v1alpha1.CertificateSigningRequest{} + err = c.client.Post(). + Resource("certificatesigningrequests"). + Body(certificateSigningRequest). + Do(). + Into(result) + return +} + +// Update takes the representation of a certificateSigningRequest and updates it. Returns the server's representation of the certificateSigningRequest, and an error, if there is any. +func (c *certificateSigningRequests) Update(certificateSigningRequest *v1alpha1.CertificateSigningRequest) (result *v1alpha1.CertificateSigningRequest, err error) { + result = &v1alpha1.CertificateSigningRequest{} + err = c.client.Put(). + Resource("certificatesigningrequests"). + Name(certificateSigningRequest.Name). + Body(certificateSigningRequest). + Do(). + Into(result) + return +} + +func (c *certificateSigningRequests) UpdateStatus(certificateSigningRequest *v1alpha1.CertificateSigningRequest) (result *v1alpha1.CertificateSigningRequest, err error) { + result = &v1alpha1.CertificateSigningRequest{} + err = c.client.Put(). + Resource("certificatesigningrequests"). + Name(certificateSigningRequest.Name). + SubResource("status"). + Body(certificateSigningRequest). + Do(). + Into(result) + return +} + +// Delete takes name of the certificateSigningRequest and deletes it. Returns an error if one occurs. +func (c *certificateSigningRequests) Delete(name string, options *api.DeleteOptions) error { + return c.client.Delete(). + Resource("certificatesigningrequests"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *certificateSigningRequests) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + return c.client.Delete(). + Resource("certificatesigningrequests"). + VersionedParams(&listOptions, api.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Get takes name of the certificateSigningRequest, and returns the corresponding certificateSigningRequest object, and an error if there is any. +func (c *certificateSigningRequests) Get(name string) (result *v1alpha1.CertificateSigningRequest, err error) { + result = &v1alpha1.CertificateSigningRequest{} + err = c.client.Get(). + Resource("certificatesigningrequests"). + Name(name). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of CertificateSigningRequests that match those selectors. +func (c *certificateSigningRequests) List(opts api.ListOptions) (result *v1alpha1.CertificateSigningRequestList, err error) { + result = &v1alpha1.CertificateSigningRequestList{} + err = c.client.Get(). + Resource("certificatesigningrequests"). + VersionedParams(&opts, api.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested certificateSigningRequests. +func (c *certificateSigningRequests) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.client.Get(). + Prefix("watch"). + Resource("certificatesigningrequests"). + VersionedParams(&opts, api.ParameterCodec). + Watch() +} + +// Patch applies the patch and returns the patched certificateSigningRequest. +func (c *certificateSigningRequests) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.CertificateSigningRequest, err error) { + result = &v1alpha1.CertificateSigningRequest{} + err = c.client.Patch(pt). + Resource("certificatesigningrequests"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/doc.go new file mode 100644 index 000000000000..0c1ca41faccf --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 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 package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/doc.go new file mode 100644 index 000000000000..6499875c0b57 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 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 package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] + +// Package fake has the automatically generated clients. +package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/fake_certificates_client.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/fake_certificates_client.go new file mode 100644 index 000000000000..acbc7a89a0f9 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/fake_certificates_client.go @@ -0,0 +1,37 @@ +/* +Copyright 2016 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 fake + +import ( + v1alpha1 "k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1" + rest "k8s.io/client-go/1.5/rest" + testing "k8s.io/client-go/1.5/testing" +) + +type FakeCertificates struct { + *testing.Fake +} + +func (c *FakeCertificates) CertificateSigningRequests() v1alpha1.CertificateSigningRequestInterface { + return &FakeCertificateSigningRequests{c} +} + +// GetRESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeCertificates) GetRESTClient() *rest.RESTClient { + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/fake_certificatesigningrequest.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/fake_certificatesigningrequest.go new file mode 100644 index 000000000000..38178c3644c9 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/fake/fake_certificatesigningrequest.go @@ -0,0 +1,118 @@ +/* +Copyright 2016 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 fake + +import ( + api "k8s.io/client-go/1.5/pkg/api" + unversioned "k8s.io/client-go/1.5/pkg/api/unversioned" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/certificates/v1alpha1" + labels "k8s.io/client-go/1.5/pkg/labels" + watch "k8s.io/client-go/1.5/pkg/watch" + testing "k8s.io/client-go/1.5/testing" +) + +// FakeCertificateSigningRequests implements CertificateSigningRequestInterface +type FakeCertificateSigningRequests struct { + Fake *FakeCertificates +} + +var certificatesigningrequestsResource = unversioned.GroupVersionResource{Group: "certificates.k8s.io", Version: "v1alpha1", Resource: "certificatesigningrequests"} + +func (c *FakeCertificateSigningRequests) Create(certificateSigningRequest *v1alpha1.CertificateSigningRequest) (result *v1alpha1.CertificateSigningRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(certificatesigningrequestsResource, certificateSigningRequest), &v1alpha1.CertificateSigningRequest{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CertificateSigningRequest), err +} + +func (c *FakeCertificateSigningRequests) Update(certificateSigningRequest *v1alpha1.CertificateSigningRequest) (result *v1alpha1.CertificateSigningRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(certificatesigningrequestsResource, certificateSigningRequest), &v1alpha1.CertificateSigningRequest{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CertificateSigningRequest), err +} + +func (c *FakeCertificateSigningRequests) UpdateStatus(certificateSigningRequest *v1alpha1.CertificateSigningRequest) (*v1alpha1.CertificateSigningRequest, error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateSubresourceAction(certificatesigningrequestsResource, "status", certificateSigningRequest), &v1alpha1.CertificateSigningRequest{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CertificateSigningRequest), err +} + +func (c *FakeCertificateSigningRequests) Delete(name string, options *api.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(certificatesigningrequestsResource, name), &v1alpha1.CertificateSigningRequest{}) + return err +} + +func (c *FakeCertificateSigningRequests) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(certificatesigningrequestsResource, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.CertificateSigningRequestList{}) + return err +} + +func (c *FakeCertificateSigningRequests) Get(name string) (result *v1alpha1.CertificateSigningRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(certificatesigningrequestsResource, name), &v1alpha1.CertificateSigningRequest{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CertificateSigningRequest), err +} + +func (c *FakeCertificateSigningRequests) List(opts api.ListOptions) (result *v1alpha1.CertificateSigningRequestList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(certificatesigningrequestsResource, opts), &v1alpha1.CertificateSigningRequestList{}) + if obj == nil { + return nil, err + } + + label := opts.LabelSelector + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.CertificateSigningRequestList{} + for _, item := range obj.(*v1alpha1.CertificateSigningRequestList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested certificateSigningRequests. +func (c *FakeCertificateSigningRequests) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(certificatesigningrequestsResource, opts)) +} + +// Patch applies the patch and returns the patched certificateSigningRequest. +func (c *FakeCertificateSigningRequests) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.CertificateSigningRequest, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(certificatesigningrequestsResource, name, data, subresources...), &v1alpha1.CertificateSigningRequest{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.CertificateSigningRequest), err +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/generated_expansion.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/generated_expansion.go new file mode 100644 index 000000000000..1f67dc9d8009 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/certificates/v1alpha1/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 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 v1alpha1 + +type CertificateSigningRequestExpansion interface{} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/core/v1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/core/v1/doc.go index 20aab35ab22c..fe27cf5c1947 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/core/v1/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/core/v1/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // This package has the automatically generated typed clients. package v1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/doc.go index 793bddf23ce2..6499875c0b57 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/core/v1/fake/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // Package fake has the automatically generated clients. package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1/doc.go index 831e702d9263..5616c95d3257 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // This package has the automatically generated typed clients. package v1beta1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1/fake/doc.go index 793bddf23ce2..6499875c0b57 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1/fake/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/extensions/v1beta1/fake/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // Package fake has the automatically generated clients. package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1/doc.go index 6035018e2322..0c1ca41faccf 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // This package has the automatically generated typed clients. package v1alpha1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1/fake/doc.go index 793bddf23ce2..6499875c0b57 100644 --- a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1/fake/doc.go +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/policy/v1alpha1/fake/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,authorization/v1beta1,autoscaling/v1,batch/v1,extensions/v1beta1,policy/v1alpha1] +// This package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] // Package fake has the automatically generated clients. package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/clusterrole.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/clusterrole.go new file mode 100644 index 000000000000..8e4a838d130f --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/clusterrole.go @@ -0,0 +1,141 @@ +/* +Copyright 2016 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 v1alpha1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1" + watch "k8s.io/client-go/1.5/pkg/watch" +) + +// ClusterRolesGetter has a method to return a ClusterRoleInterface. +// A group's client should implement this interface. +type ClusterRolesGetter interface { + ClusterRoles() ClusterRoleInterface +} + +// ClusterRoleInterface has methods to work with ClusterRole resources. +type ClusterRoleInterface interface { + Create(*v1alpha1.ClusterRole) (*v1alpha1.ClusterRole, error) + Update(*v1alpha1.ClusterRole) (*v1alpha1.ClusterRole, error) + Delete(name string, options *api.DeleteOptions) error + DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error + Get(name string) (*v1alpha1.ClusterRole, error) + List(opts api.ListOptions) (*v1alpha1.ClusterRoleList, error) + Watch(opts api.ListOptions) (watch.Interface, error) + Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterRole, err error) + ClusterRoleExpansion +} + +// clusterRoles implements ClusterRoleInterface +type clusterRoles struct { + client *RbacClient +} + +// newClusterRoles returns a ClusterRoles +func newClusterRoles(c *RbacClient) *clusterRoles { + return &clusterRoles{ + client: c, + } +} + +// Create takes the representation of a clusterRole and creates it. Returns the server's representation of the clusterRole, and an error, if there is any. +func (c *clusterRoles) Create(clusterRole *v1alpha1.ClusterRole) (result *v1alpha1.ClusterRole, err error) { + result = &v1alpha1.ClusterRole{} + err = c.client.Post(). + Resource("clusterroles"). + Body(clusterRole). + Do(). + Into(result) + return +} + +// Update takes the representation of a clusterRole and updates it. Returns the server's representation of the clusterRole, and an error, if there is any. +func (c *clusterRoles) Update(clusterRole *v1alpha1.ClusterRole) (result *v1alpha1.ClusterRole, err error) { + result = &v1alpha1.ClusterRole{} + err = c.client.Put(). + Resource("clusterroles"). + Name(clusterRole.Name). + Body(clusterRole). + Do(). + Into(result) + return +} + +// Delete takes name of the clusterRole and deletes it. Returns an error if one occurs. +func (c *clusterRoles) Delete(name string, options *api.DeleteOptions) error { + return c.client.Delete(). + Resource("clusterroles"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterRoles) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + return c.client.Delete(). + Resource("clusterroles"). + VersionedParams(&listOptions, api.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Get takes name of the clusterRole, and returns the corresponding clusterRole object, and an error if there is any. +func (c *clusterRoles) Get(name string) (result *v1alpha1.ClusterRole, err error) { + result = &v1alpha1.ClusterRole{} + err = c.client.Get(). + Resource("clusterroles"). + Name(name). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ClusterRoles that match those selectors. +func (c *clusterRoles) List(opts api.ListOptions) (result *v1alpha1.ClusterRoleList, err error) { + result = &v1alpha1.ClusterRoleList{} + err = c.client.Get(). + Resource("clusterroles"). + VersionedParams(&opts, api.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusterRoles. +func (c *clusterRoles) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.client.Get(). + Prefix("watch"). + Resource("clusterroles"). + VersionedParams(&opts, api.ParameterCodec). + Watch() +} + +// Patch applies the patch and returns the patched clusterRole. +func (c *clusterRoles) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterRole, err error) { + result = &v1alpha1.ClusterRole{} + err = c.client.Patch(pt). + Resource("clusterroles"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go new file mode 100644 index 000000000000..919f84074c86 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/clusterrolebinding.go @@ -0,0 +1,141 @@ +/* +Copyright 2016 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 v1alpha1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1" + watch "k8s.io/client-go/1.5/pkg/watch" +) + +// ClusterRoleBindingsGetter has a method to return a ClusterRoleBindingInterface. +// A group's client should implement this interface. +type ClusterRoleBindingsGetter interface { + ClusterRoleBindings() ClusterRoleBindingInterface +} + +// ClusterRoleBindingInterface has methods to work with ClusterRoleBinding resources. +type ClusterRoleBindingInterface interface { + Create(*v1alpha1.ClusterRoleBinding) (*v1alpha1.ClusterRoleBinding, error) + Update(*v1alpha1.ClusterRoleBinding) (*v1alpha1.ClusterRoleBinding, error) + Delete(name string, options *api.DeleteOptions) error + DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error + Get(name string) (*v1alpha1.ClusterRoleBinding, error) + List(opts api.ListOptions) (*v1alpha1.ClusterRoleBindingList, error) + Watch(opts api.ListOptions) (watch.Interface, error) + Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterRoleBinding, err error) + ClusterRoleBindingExpansion +} + +// clusterRoleBindings implements ClusterRoleBindingInterface +type clusterRoleBindings struct { + client *RbacClient +} + +// newClusterRoleBindings returns a ClusterRoleBindings +func newClusterRoleBindings(c *RbacClient) *clusterRoleBindings { + return &clusterRoleBindings{ + client: c, + } +} + +// Create takes the representation of a clusterRoleBinding and creates it. Returns the server's representation of the clusterRoleBinding, and an error, if there is any. +func (c *clusterRoleBindings) Create(clusterRoleBinding *v1alpha1.ClusterRoleBinding) (result *v1alpha1.ClusterRoleBinding, err error) { + result = &v1alpha1.ClusterRoleBinding{} + err = c.client.Post(). + Resource("clusterrolebindings"). + Body(clusterRoleBinding). + Do(). + Into(result) + return +} + +// Update takes the representation of a clusterRoleBinding and updates it. Returns the server's representation of the clusterRoleBinding, and an error, if there is any. +func (c *clusterRoleBindings) Update(clusterRoleBinding *v1alpha1.ClusterRoleBinding) (result *v1alpha1.ClusterRoleBinding, err error) { + result = &v1alpha1.ClusterRoleBinding{} + err = c.client.Put(). + Resource("clusterrolebindings"). + Name(clusterRoleBinding.Name). + Body(clusterRoleBinding). + Do(). + Into(result) + return +} + +// Delete takes name of the clusterRoleBinding and deletes it. Returns an error if one occurs. +func (c *clusterRoleBindings) Delete(name string, options *api.DeleteOptions) error { + return c.client.Delete(). + Resource("clusterrolebindings"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *clusterRoleBindings) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + return c.client.Delete(). + Resource("clusterrolebindings"). + VersionedParams(&listOptions, api.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Get takes name of the clusterRoleBinding, and returns the corresponding clusterRoleBinding object, and an error if there is any. +func (c *clusterRoleBindings) Get(name string) (result *v1alpha1.ClusterRoleBinding, err error) { + result = &v1alpha1.ClusterRoleBinding{} + err = c.client.Get(). + Resource("clusterrolebindings"). + Name(name). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ClusterRoleBindings that match those selectors. +func (c *clusterRoleBindings) List(opts api.ListOptions) (result *v1alpha1.ClusterRoleBindingList, err error) { + result = &v1alpha1.ClusterRoleBindingList{} + err = c.client.Get(). + Resource("clusterrolebindings"). + VersionedParams(&opts, api.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested clusterRoleBindings. +func (c *clusterRoleBindings) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.client.Get(). + Prefix("watch"). + Resource("clusterrolebindings"). + VersionedParams(&opts, api.ParameterCodec). + Watch() +} + +// Patch applies the patch and returns the patched clusterRoleBinding. +func (c *clusterRoleBindings) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterRoleBinding, err error) { + result = &v1alpha1.ClusterRoleBinding{} + err = c.client.Patch(pt). + Resource("clusterrolebindings"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/doc.go new file mode 100644 index 000000000000..0c1ca41faccf --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 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 package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/doc.go new file mode 100644 index 000000000000..6499875c0b57 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 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 package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] + +// Package fake has the automatically generated clients. +package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrole.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrole.go new file mode 100644 index 000000000000..ad59de50d68f --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrole.go @@ -0,0 +1,109 @@ +/* +Copyright 2016 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 fake + +import ( + api "k8s.io/client-go/1.5/pkg/api" + unversioned "k8s.io/client-go/1.5/pkg/api/unversioned" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1" + labels "k8s.io/client-go/1.5/pkg/labels" + watch "k8s.io/client-go/1.5/pkg/watch" + testing "k8s.io/client-go/1.5/testing" +) + +// FakeClusterRoles implements ClusterRoleInterface +type FakeClusterRoles struct { + Fake *FakeRbac +} + +var clusterrolesResource = unversioned.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Resource: "clusterroles"} + +func (c *FakeClusterRoles) Create(clusterRole *v1alpha1.ClusterRole) (result *v1alpha1.ClusterRole, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(clusterrolesResource, clusterRole), &v1alpha1.ClusterRole{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterRole), err +} + +func (c *FakeClusterRoles) Update(clusterRole *v1alpha1.ClusterRole) (result *v1alpha1.ClusterRole, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(clusterrolesResource, clusterRole), &v1alpha1.ClusterRole{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterRole), err +} + +func (c *FakeClusterRoles) Delete(name string, options *api.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(clusterrolesResource, name), &v1alpha1.ClusterRole{}) + return err +} + +func (c *FakeClusterRoles) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(clusterrolesResource, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ClusterRoleList{}) + return err +} + +func (c *FakeClusterRoles) Get(name string) (result *v1alpha1.ClusterRole, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(clusterrolesResource, name), &v1alpha1.ClusterRole{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterRole), err +} + +func (c *FakeClusterRoles) List(opts api.ListOptions) (result *v1alpha1.ClusterRoleList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(clusterrolesResource, opts), &v1alpha1.ClusterRoleList{}) + if obj == nil { + return nil, err + } + + label := opts.LabelSelector + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ClusterRoleList{} + for _, item := range obj.(*v1alpha1.ClusterRoleList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested clusterRoles. +func (c *FakeClusterRoles) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(clusterrolesResource, opts)) +} + +// Patch applies the patch and returns the patched clusterRole. +func (c *FakeClusterRoles) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterRole, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(clusterrolesResource, name, data, subresources...), &v1alpha1.ClusterRole{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterRole), err +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrolebinding.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrolebinding.go new file mode 100644 index 000000000000..8b94350e05a2 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_clusterrolebinding.go @@ -0,0 +1,109 @@ +/* +Copyright 2016 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 fake + +import ( + api "k8s.io/client-go/1.5/pkg/api" + unversioned "k8s.io/client-go/1.5/pkg/api/unversioned" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1" + labels "k8s.io/client-go/1.5/pkg/labels" + watch "k8s.io/client-go/1.5/pkg/watch" + testing "k8s.io/client-go/1.5/testing" +) + +// FakeClusterRoleBindings implements ClusterRoleBindingInterface +type FakeClusterRoleBindings struct { + Fake *FakeRbac +} + +var clusterrolebindingsResource = unversioned.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Resource: "clusterrolebindings"} + +func (c *FakeClusterRoleBindings) Create(clusterRoleBinding *v1alpha1.ClusterRoleBinding) (result *v1alpha1.ClusterRoleBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(clusterrolebindingsResource, clusterRoleBinding), &v1alpha1.ClusterRoleBinding{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterRoleBinding), err +} + +func (c *FakeClusterRoleBindings) Update(clusterRoleBinding *v1alpha1.ClusterRoleBinding) (result *v1alpha1.ClusterRoleBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(clusterrolebindingsResource, clusterRoleBinding), &v1alpha1.ClusterRoleBinding{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterRoleBinding), err +} + +func (c *FakeClusterRoleBindings) Delete(name string, options *api.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(clusterrolebindingsResource, name), &v1alpha1.ClusterRoleBinding{}) + return err +} + +func (c *FakeClusterRoleBindings) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(clusterrolebindingsResource, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ClusterRoleBindingList{}) + return err +} + +func (c *FakeClusterRoleBindings) Get(name string) (result *v1alpha1.ClusterRoleBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(clusterrolebindingsResource, name), &v1alpha1.ClusterRoleBinding{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterRoleBinding), err +} + +func (c *FakeClusterRoleBindings) List(opts api.ListOptions) (result *v1alpha1.ClusterRoleBindingList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(clusterrolebindingsResource, opts), &v1alpha1.ClusterRoleBindingList{}) + if obj == nil { + return nil, err + } + + label := opts.LabelSelector + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ClusterRoleBindingList{} + for _, item := range obj.(*v1alpha1.ClusterRoleBindingList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested clusterRoleBindings. +func (c *FakeClusterRoleBindings) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(clusterrolebindingsResource, opts)) +} + +// Patch applies the patch and returns the patched clusterRoleBinding. +func (c *FakeClusterRoleBindings) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.ClusterRoleBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(clusterrolebindingsResource, name, data, subresources...), &v1alpha1.ClusterRoleBinding{}) + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ClusterRoleBinding), err +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_rbac_client.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_rbac_client.go new file mode 100644 index 000000000000..282f51138c58 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_rbac_client.go @@ -0,0 +1,49 @@ +/* +Copyright 2016 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 fake + +import ( + v1alpha1 "k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1" + rest "k8s.io/client-go/1.5/rest" + testing "k8s.io/client-go/1.5/testing" +) + +type FakeRbac struct { + *testing.Fake +} + +func (c *FakeRbac) ClusterRoles() v1alpha1.ClusterRoleInterface { + return &FakeClusterRoles{c} +} + +func (c *FakeRbac) ClusterRoleBindings() v1alpha1.ClusterRoleBindingInterface { + return &FakeClusterRoleBindings{c} +} + +func (c *FakeRbac) Roles(namespace string) v1alpha1.RoleInterface { + return &FakeRoles{c, namespace} +} + +func (c *FakeRbac) RoleBindings(namespace string) v1alpha1.RoleBindingInterface { + return &FakeRoleBindings{c, namespace} +} + +// GetRESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeRbac) GetRESTClient() *rest.RESTClient { + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_role.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_role.go new file mode 100644 index 000000000000..e6ef2e7d0799 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_role.go @@ -0,0 +1,117 @@ +/* +Copyright 2016 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 fake + +import ( + api "k8s.io/client-go/1.5/pkg/api" + unversioned "k8s.io/client-go/1.5/pkg/api/unversioned" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1" + labels "k8s.io/client-go/1.5/pkg/labels" + watch "k8s.io/client-go/1.5/pkg/watch" + testing "k8s.io/client-go/1.5/testing" +) + +// FakeRoles implements RoleInterface +type FakeRoles struct { + Fake *FakeRbac + ns string +} + +var rolesResource = unversioned.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Resource: "roles"} + +func (c *FakeRoles) Create(role *v1alpha1.Role) (result *v1alpha1.Role, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(rolesResource, c.ns, role), &v1alpha1.Role{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Role), err +} + +func (c *FakeRoles) Update(role *v1alpha1.Role) (result *v1alpha1.Role, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(rolesResource, c.ns, role), &v1alpha1.Role{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Role), err +} + +func (c *FakeRoles) Delete(name string, options *api.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(rolesResource, c.ns, name), &v1alpha1.Role{}) + + return err +} + +func (c *FakeRoles) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + action := testing.NewDeleteCollectionAction(rolesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.RoleList{}) + return err +} + +func (c *FakeRoles) Get(name string) (result *v1alpha1.Role, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(rolesResource, c.ns, name), &v1alpha1.Role{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Role), err +} + +func (c *FakeRoles) List(opts api.ListOptions) (result *v1alpha1.RoleList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(rolesResource, c.ns, opts), &v1alpha1.RoleList{}) + + if obj == nil { + return nil, err + } + + label := opts.LabelSelector + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.RoleList{} + for _, item := range obj.(*v1alpha1.RoleList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested roles. +func (c *FakeRoles) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(rolesResource, c.ns, opts)) + +} + +// Patch applies the patch and returns the patched role. +func (c *FakeRoles) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.Role, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(rolesResource, c.ns, name, data, subresources...), &v1alpha1.Role{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Role), err +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_rolebinding.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_rolebinding.go new file mode 100644 index 000000000000..ba929e88063f --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/fake/fake_rolebinding.go @@ -0,0 +1,117 @@ +/* +Copyright 2016 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 fake + +import ( + api "k8s.io/client-go/1.5/pkg/api" + unversioned "k8s.io/client-go/1.5/pkg/api/unversioned" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1" + labels "k8s.io/client-go/1.5/pkg/labels" + watch "k8s.io/client-go/1.5/pkg/watch" + testing "k8s.io/client-go/1.5/testing" +) + +// FakeRoleBindings implements RoleBindingInterface +type FakeRoleBindings struct { + Fake *FakeRbac + ns string +} + +var rolebindingsResource = unversioned.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1alpha1", Resource: "rolebindings"} + +func (c *FakeRoleBindings) Create(roleBinding *v1alpha1.RoleBinding) (result *v1alpha1.RoleBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(rolebindingsResource, c.ns, roleBinding), &v1alpha1.RoleBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.RoleBinding), err +} + +func (c *FakeRoleBindings) Update(roleBinding *v1alpha1.RoleBinding) (result *v1alpha1.RoleBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(rolebindingsResource, c.ns, roleBinding), &v1alpha1.RoleBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.RoleBinding), err +} + +func (c *FakeRoleBindings) Delete(name string, options *api.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(rolebindingsResource, c.ns, name), &v1alpha1.RoleBinding{}) + + return err +} + +func (c *FakeRoleBindings) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + action := testing.NewDeleteCollectionAction(rolebindingsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.RoleBindingList{}) + return err +} + +func (c *FakeRoleBindings) Get(name string) (result *v1alpha1.RoleBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(rolebindingsResource, c.ns, name), &v1alpha1.RoleBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.RoleBinding), err +} + +func (c *FakeRoleBindings) List(opts api.ListOptions) (result *v1alpha1.RoleBindingList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(rolebindingsResource, c.ns, opts), &v1alpha1.RoleBindingList{}) + + if obj == nil { + return nil, err + } + + label := opts.LabelSelector + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.RoleBindingList{} + for _, item := range obj.(*v1alpha1.RoleBindingList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested roleBindings. +func (c *FakeRoleBindings) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(rolebindingsResource, c.ns, opts)) + +} + +// Patch applies the patch and returns the patched roleBinding. +func (c *FakeRoleBindings) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.RoleBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(rolebindingsResource, c.ns, name, data, subresources...), &v1alpha1.RoleBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.RoleBinding), err +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/generated_expansion.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/generated_expansion.go new file mode 100644 index 000000000000..86def26631fd --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/generated_expansion.go @@ -0,0 +1,25 @@ +/* +Copyright 2016 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 v1alpha1 + +type ClusterRoleExpansion interface{} + +type ClusterRoleBindingExpansion interface{} + +type RoleExpansion interface{} + +type RoleBindingExpansion interface{} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/rbac_client.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/rbac_client.go new file mode 100644 index 000000000000..fde5a6036107 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/rbac_client.go @@ -0,0 +1,111 @@ +/* +Copyright 2016 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 v1alpha1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + registered "k8s.io/client-go/1.5/pkg/apimachinery/registered" + serializer "k8s.io/client-go/1.5/pkg/runtime/serializer" + rest "k8s.io/client-go/1.5/rest" +) + +type RbacInterface interface { + GetRESTClient() *rest.RESTClient + ClusterRolesGetter + ClusterRoleBindingsGetter + RolesGetter + RoleBindingsGetter +} + +// RbacClient is used to interact with features provided by the Rbac group. +type RbacClient struct { + *rest.RESTClient +} + +func (c *RbacClient) ClusterRoles() ClusterRoleInterface { + return newClusterRoles(c) +} + +func (c *RbacClient) ClusterRoleBindings() ClusterRoleBindingInterface { + return newClusterRoleBindings(c) +} + +func (c *RbacClient) Roles(namespace string) RoleInterface { + return newRoles(c, namespace) +} + +func (c *RbacClient) RoleBindings(namespace string) RoleBindingInterface { + return newRoleBindings(c, namespace) +} + +// NewForConfig creates a new RbacClient for the given config. +func NewForConfig(c *rest.Config) (*RbacClient, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &RbacClient{client}, nil +} + +// NewForConfigOrDie creates a new RbacClient for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *RbacClient { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new RbacClient for the given RESTClient. +func New(c *rest.RESTClient) *RbacClient { + return &RbacClient{c} +} + +func setConfigDefaults(config *rest.Config) error { + // if rbac group is not registered, return an error + g, err := registered.Group("rbac.authorization.k8s.io") + if err != nil { + return err + } + config.APIPath = "/apis" + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + // TODO: Unconditionally set the config.Version, until we fix the config. + //if config.Version == "" { + copyGroupVersion := g.GroupVersion + config.GroupVersion = ©GroupVersion + //} + + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs} + + return nil +} + +// GetRESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *RbacClient) GetRESTClient() *rest.RESTClient { + if c == nil { + return nil + } + return c.RESTClient +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/role.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/role.go new file mode 100644 index 000000000000..72de75c65f06 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/role.go @@ -0,0 +1,151 @@ +/* +Copyright 2016 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 v1alpha1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1" + watch "k8s.io/client-go/1.5/pkg/watch" +) + +// RolesGetter has a method to return a RoleInterface. +// A group's client should implement this interface. +type RolesGetter interface { + Roles(namespace string) RoleInterface +} + +// RoleInterface has methods to work with Role resources. +type RoleInterface interface { + Create(*v1alpha1.Role) (*v1alpha1.Role, error) + Update(*v1alpha1.Role) (*v1alpha1.Role, error) + Delete(name string, options *api.DeleteOptions) error + DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error + Get(name string) (*v1alpha1.Role, error) + List(opts api.ListOptions) (*v1alpha1.RoleList, error) + Watch(opts api.ListOptions) (watch.Interface, error) + Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.Role, err error) + RoleExpansion +} + +// roles implements RoleInterface +type roles struct { + client *RbacClient + ns string +} + +// newRoles returns a Roles +func newRoles(c *RbacClient, namespace string) *roles { + return &roles{ + client: c, + ns: namespace, + } +} + +// Create takes the representation of a role and creates it. Returns the server's representation of the role, and an error, if there is any. +func (c *roles) Create(role *v1alpha1.Role) (result *v1alpha1.Role, err error) { + result = &v1alpha1.Role{} + err = c.client.Post(). + Namespace(c.ns). + Resource("roles"). + Body(role). + Do(). + Into(result) + return +} + +// Update takes the representation of a role and updates it. Returns the server's representation of the role, and an error, if there is any. +func (c *roles) Update(role *v1alpha1.Role) (result *v1alpha1.Role, err error) { + result = &v1alpha1.Role{} + err = c.client.Put(). + Namespace(c.ns). + Resource("roles"). + Name(role.Name). + Body(role). + Do(). + Into(result) + return +} + +// Delete takes name of the role and deletes it. Returns an error if one occurs. +func (c *roles) Delete(name string, options *api.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("roles"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *roles) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("roles"). + VersionedParams(&listOptions, api.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Get takes name of the role, and returns the corresponding role object, and an error if there is any. +func (c *roles) Get(name string) (result *v1alpha1.Role, err error) { + result = &v1alpha1.Role{} + err = c.client.Get(). + Namespace(c.ns). + Resource("roles"). + Name(name). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Roles that match those selectors. +func (c *roles) List(opts api.ListOptions) (result *v1alpha1.RoleList, err error) { + result = &v1alpha1.RoleList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("roles"). + VersionedParams(&opts, api.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested roles. +func (c *roles) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.client.Get(). + Prefix("watch"). + Namespace(c.ns). + Resource("roles"). + VersionedParams(&opts, api.ParameterCodec). + Watch() +} + +// Patch applies the patch and returns the patched role. +func (c *roles) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.Role, err error) { + result = &v1alpha1.Role{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("roles"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/rolebinding.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/rolebinding.go new file mode 100644 index 000000000000..649a9dd3014d --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/rbac/v1alpha1/rolebinding.go @@ -0,0 +1,151 @@ +/* +Copyright 2016 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 v1alpha1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + v1alpha1 "k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1" + watch "k8s.io/client-go/1.5/pkg/watch" +) + +// RoleBindingsGetter has a method to return a RoleBindingInterface. +// A group's client should implement this interface. +type RoleBindingsGetter interface { + RoleBindings(namespace string) RoleBindingInterface +} + +// RoleBindingInterface has methods to work with RoleBinding resources. +type RoleBindingInterface interface { + Create(*v1alpha1.RoleBinding) (*v1alpha1.RoleBinding, error) + Update(*v1alpha1.RoleBinding) (*v1alpha1.RoleBinding, error) + Delete(name string, options *api.DeleteOptions) error + DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error + Get(name string) (*v1alpha1.RoleBinding, error) + List(opts api.ListOptions) (*v1alpha1.RoleBindingList, error) + Watch(opts api.ListOptions) (watch.Interface, error) + Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.RoleBinding, err error) + RoleBindingExpansion +} + +// roleBindings implements RoleBindingInterface +type roleBindings struct { + client *RbacClient + ns string +} + +// newRoleBindings returns a RoleBindings +func newRoleBindings(c *RbacClient, namespace string) *roleBindings { + return &roleBindings{ + client: c, + ns: namespace, + } +} + +// Create takes the representation of a roleBinding and creates it. Returns the server's representation of the roleBinding, and an error, if there is any. +func (c *roleBindings) Create(roleBinding *v1alpha1.RoleBinding) (result *v1alpha1.RoleBinding, err error) { + result = &v1alpha1.RoleBinding{} + err = c.client.Post(). + Namespace(c.ns). + Resource("rolebindings"). + Body(roleBinding). + Do(). + Into(result) + return +} + +// Update takes the representation of a roleBinding and updates it. Returns the server's representation of the roleBinding, and an error, if there is any. +func (c *roleBindings) Update(roleBinding *v1alpha1.RoleBinding) (result *v1alpha1.RoleBinding, err error) { + result = &v1alpha1.RoleBinding{} + err = c.client.Put(). + Namespace(c.ns). + Resource("rolebindings"). + Name(roleBinding.Name). + Body(roleBinding). + Do(). + Into(result) + return +} + +// Delete takes name of the roleBinding and deletes it. Returns an error if one occurs. +func (c *roleBindings) Delete(name string, options *api.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("rolebindings"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *roleBindings) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("rolebindings"). + VersionedParams(&listOptions, api.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Get takes name of the roleBinding, and returns the corresponding roleBinding object, and an error if there is any. +func (c *roleBindings) Get(name string) (result *v1alpha1.RoleBinding, err error) { + result = &v1alpha1.RoleBinding{} + err = c.client.Get(). + Namespace(c.ns). + Resource("rolebindings"). + Name(name). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of RoleBindings that match those selectors. +func (c *roleBindings) List(opts api.ListOptions) (result *v1alpha1.RoleBindingList, err error) { + result = &v1alpha1.RoleBindingList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("rolebindings"). + VersionedParams(&opts, api.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested roleBindings. +func (c *roleBindings) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.client.Get(). + Prefix("watch"). + Namespace(c.ns). + Resource("rolebindings"). + VersionedParams(&opts, api.ParameterCodec). + Watch() +} + +// Patch applies the patch and returns the patched roleBinding. +func (c *roleBindings) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1alpha1.RoleBinding, err error) { + result = &v1alpha1.RoleBinding{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("rolebindings"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/doc.go new file mode 100644 index 000000000000..5616c95d3257 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 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 package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/doc.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/doc.go new file mode 100644 index 000000000000..6499875c0b57 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2016 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 package is generated by client-gen with arguments: --clientset-name=release_1_5 --input=[api/v1,apps/v1alpha1,authentication/v1beta1,authorization/v1beta1,autoscaling/v1,batch/v1,certificates/v1alpha1,extensions/v1beta1,policy/v1alpha1,rbac/v1alpha1,storage/v1beta1] + +// Package fake has the automatically generated clients. +package fake diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/fake_storage_client.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/fake_storage_client.go new file mode 100644 index 000000000000..43c2fecac3bf --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/fake_storage_client.go @@ -0,0 +1,37 @@ +/* +Copyright 2016 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 fake + +import ( + v1beta1 "k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1" + rest "k8s.io/client-go/1.5/rest" + testing "k8s.io/client-go/1.5/testing" +) + +type FakeStorage struct { + *testing.Fake +} + +func (c *FakeStorage) StorageClasses() v1beta1.StorageClassInterface { + return &FakeStorageClasses{c} +} + +// GetRESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeStorage) GetRESTClient() *rest.RESTClient { + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/fake_storageclass.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/fake_storageclass.go new file mode 100644 index 000000000000..acc82518a30f --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/fake/fake_storageclass.go @@ -0,0 +1,109 @@ +/* +Copyright 2016 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 fake + +import ( + api "k8s.io/client-go/1.5/pkg/api" + unversioned "k8s.io/client-go/1.5/pkg/api/unversioned" + v1beta1 "k8s.io/client-go/1.5/pkg/apis/storage/v1beta1" + labels "k8s.io/client-go/1.5/pkg/labels" + watch "k8s.io/client-go/1.5/pkg/watch" + testing "k8s.io/client-go/1.5/testing" +) + +// FakeStorageClasses implements StorageClassInterface +type FakeStorageClasses struct { + Fake *FakeStorage +} + +var storageclassesResource = unversioned.GroupVersionResource{Group: "storage.k8s.io", Version: "v1beta1", Resource: "storageclasses"} + +func (c *FakeStorageClasses) Create(storageClass *v1beta1.StorageClass) (result *v1beta1.StorageClass, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootCreateAction(storageclassesResource, storageClass), &v1beta1.StorageClass{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.StorageClass), err +} + +func (c *FakeStorageClasses) Update(storageClass *v1beta1.StorageClass) (result *v1beta1.StorageClass, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootUpdateAction(storageclassesResource, storageClass), &v1beta1.StorageClass{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.StorageClass), err +} + +func (c *FakeStorageClasses) Delete(name string, options *api.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewRootDeleteAction(storageclassesResource, name), &v1beta1.StorageClass{}) + return err +} + +func (c *FakeStorageClasses) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + action := testing.NewRootDeleteCollectionAction(storageclassesResource, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.StorageClassList{}) + return err +} + +func (c *FakeStorageClasses) Get(name string) (result *v1beta1.StorageClass, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootGetAction(storageclassesResource, name), &v1beta1.StorageClass{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.StorageClass), err +} + +func (c *FakeStorageClasses) List(opts api.ListOptions) (result *v1beta1.StorageClassList, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootListAction(storageclassesResource, opts), &v1beta1.StorageClassList{}) + if obj == nil { + return nil, err + } + + label := opts.LabelSelector + if label == nil { + label = labels.Everything() + } + list := &v1beta1.StorageClassList{} + for _, item := range obj.(*v1beta1.StorageClassList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested storageClasses. +func (c *FakeStorageClasses) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewRootWatchAction(storageclassesResource, opts)) +} + +// Patch applies the patch and returns the patched storageClass. +func (c *FakeStorageClasses) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.StorageClass, err error) { + obj, err := c.Fake. + Invokes(testing.NewRootPatchSubresourceAction(storageclassesResource, name, data, subresources...), &v1beta1.StorageClass{}) + if obj == nil { + return nil, err + } + return obj.(*v1beta1.StorageClass), err +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/generated_expansion.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/generated_expansion.go new file mode 100644 index 000000000000..b18dda009f26 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/generated_expansion.go @@ -0,0 +1,19 @@ +/* +Copyright 2016 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 v1beta1 + +type StorageClassExpansion interface{} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/storage_client.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/storage_client.go new file mode 100644 index 000000000000..813cdbf053d6 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/storage_client.go @@ -0,0 +1,96 @@ +/* +Copyright 2016 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 v1beta1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + registered "k8s.io/client-go/1.5/pkg/apimachinery/registered" + serializer "k8s.io/client-go/1.5/pkg/runtime/serializer" + rest "k8s.io/client-go/1.5/rest" +) + +type StorageInterface interface { + GetRESTClient() *rest.RESTClient + StorageClassesGetter +} + +// StorageClient is used to interact with features provided by the Storage group. +type StorageClient struct { + *rest.RESTClient +} + +func (c *StorageClient) StorageClasses() StorageClassInterface { + return newStorageClasses(c) +} + +// NewForConfig creates a new StorageClient for the given config. +func NewForConfig(c *rest.Config) (*StorageClient, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &StorageClient{client}, nil +} + +// NewForConfigOrDie creates a new StorageClient for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *StorageClient { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new StorageClient for the given RESTClient. +func New(c *rest.RESTClient) *StorageClient { + return &StorageClient{c} +} + +func setConfigDefaults(config *rest.Config) error { + // if storage group is not registered, return an error + g, err := registered.Group("storage.k8s.io") + if err != nil { + return err + } + config.APIPath = "/apis" + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + // TODO: Unconditionally set the config.Version, until we fix the config. + //if config.Version == "" { + copyGroupVersion := g.GroupVersion + config.GroupVersion = ©GroupVersion + //} + + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: api.Codecs} + + return nil +} + +// GetRESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *StorageClient) GetRESTClient() *rest.RESTClient { + if c == nil { + return nil + } + return c.RESTClient +} diff --git a/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/storageclass.go b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/storageclass.go new file mode 100644 index 000000000000..c1453cd43b69 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/kubernetes/typed/storage/v1beta1/storageclass.go @@ -0,0 +1,141 @@ +/* +Copyright 2016 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 v1beta1 + +import ( + api "k8s.io/client-go/1.5/pkg/api" + v1beta1 "k8s.io/client-go/1.5/pkg/apis/storage/v1beta1" + watch "k8s.io/client-go/1.5/pkg/watch" +) + +// StorageClassesGetter has a method to return a StorageClassInterface. +// A group's client should implement this interface. +type StorageClassesGetter interface { + StorageClasses() StorageClassInterface +} + +// StorageClassInterface has methods to work with StorageClass resources. +type StorageClassInterface interface { + Create(*v1beta1.StorageClass) (*v1beta1.StorageClass, error) + Update(*v1beta1.StorageClass) (*v1beta1.StorageClass, error) + Delete(name string, options *api.DeleteOptions) error + DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error + Get(name string) (*v1beta1.StorageClass, error) + List(opts api.ListOptions) (*v1beta1.StorageClassList, error) + Watch(opts api.ListOptions) (watch.Interface, error) + Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.StorageClass, err error) + StorageClassExpansion +} + +// storageClasses implements StorageClassInterface +type storageClasses struct { + client *StorageClient +} + +// newStorageClasses returns a StorageClasses +func newStorageClasses(c *StorageClient) *storageClasses { + return &storageClasses{ + client: c, + } +} + +// Create takes the representation of a storageClass and creates it. Returns the server's representation of the storageClass, and an error, if there is any. +func (c *storageClasses) Create(storageClass *v1beta1.StorageClass) (result *v1beta1.StorageClass, err error) { + result = &v1beta1.StorageClass{} + err = c.client.Post(). + Resource("storageclasses"). + Body(storageClass). + Do(). + Into(result) + return +} + +// Update takes the representation of a storageClass and updates it. Returns the server's representation of the storageClass, and an error, if there is any. +func (c *storageClasses) Update(storageClass *v1beta1.StorageClass) (result *v1beta1.StorageClass, err error) { + result = &v1beta1.StorageClass{} + err = c.client.Put(). + Resource("storageclasses"). + Name(storageClass.Name). + Body(storageClass). + Do(). + Into(result) + return +} + +// Delete takes name of the storageClass and deletes it. Returns an error if one occurs. +func (c *storageClasses) Delete(name string, options *api.DeleteOptions) error { + return c.client.Delete(). + Resource("storageclasses"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *storageClasses) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { + return c.client.Delete(). + Resource("storageclasses"). + VersionedParams(&listOptions, api.ParameterCodec). + Body(options). + Do(). + Error() +} + +// Get takes name of the storageClass, and returns the corresponding storageClass object, and an error if there is any. +func (c *storageClasses) Get(name string) (result *v1beta1.StorageClass, err error) { + result = &v1beta1.StorageClass{} + err = c.client.Get(). + Resource("storageclasses"). + Name(name). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of StorageClasses that match those selectors. +func (c *storageClasses) List(opts api.ListOptions) (result *v1beta1.StorageClassList, err error) { + result = &v1beta1.StorageClassList{} + err = c.client.Get(). + Resource("storageclasses"). + VersionedParams(&opts, api.ParameterCodec). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested storageClasses. +func (c *storageClasses) Watch(opts api.ListOptions) (watch.Interface, error) { + return c.client.Get(). + Prefix("watch"). + Resource("storageclasses"). + VersionedParams(&opts, api.ParameterCodec). + Watch() +} + +// Patch applies the patch and returns the patched storageClass. +func (c *storageClasses) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1beta1.StorageClass, err error) { + result = &v1beta1.StorageClass{} + err = c.client.Patch(pt). + Resource("storageclasses"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/context.go b/staging/src/k8s.io/client-go/1.5/pkg/api/context.go index f72159689ea3..fba7b73380c0 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/context.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/context.go @@ -59,6 +59,9 @@ const ( // uidKey is the context key for the uid to assign to an object on create. uidKey + + // userAgentKey is the context key for the request user agent. + userAgentKey ) // NewContext instantiates a base context object for request flows. @@ -136,3 +139,14 @@ func UIDFrom(ctx Context) (types.UID, bool) { uid, ok := ctx.Value(uidKey).(types.UID) return uid, ok } + +// WithUserAgent returns a copy of parent in which the user value is set +func WithUserAgent(parent Context, userAgent string) Context { + return WithValue(parent, userAgentKey, userAgent) +} + +// UserAgentFrom returns the value of the userAgent key on the ctx +func UserAgentFrom(ctx Context) (string, bool) { + userAgent, ok := ctx.Value(userAgentKey).(string) + return userAgent, ok +} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/api/install/install.go index b963282fb112..a4518bc0a473 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/install/install.go @@ -82,13 +82,9 @@ func enableVersions(externalVersions []unversioned.GroupVersion) error { if err := registered.RegisterGroup(groupMeta); err != nil { return err } - api.RegisterRESTMapper(groupMeta.RESTMapper) return nil } -// userResources is a group of resources mostly used by a kubectl user -var userResources = []string{"rc", "svc", "pods", "pvc"} - func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { // the list of kinds that are scoped at the root of the api hierarchy // if a kind is not enumerated here, it is assumed to have a namespace scope @@ -115,8 +111,6 @@ func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper "ThirdPartyResourceList") mapper := api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) - // setup aliases for groups of resources - mapper.AddResourceAlias("all", userResources...) return mapper } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/mapper.go b/staging/src/k8s.io/client-go/1.5/pkg/api/mapper.go index b4237483b926..17e624f93036 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/mapper.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/mapper.go @@ -25,16 +25,6 @@ import ( "k8s.io/client-go/1.5/pkg/util/sets" ) -var RESTMapper meta.RESTMapper - -func init() { - RESTMapper = meta.MultiRESTMapper{} -} - -func RegisterRESTMapper(m meta.RESTMapper) { - RESTMapper = append(RESTMapper.(meta.MultiRESTMapper), m) -} - // Instantiates a DefaultRESTMapper based on types registered in api.Scheme func NewDefaultRESTMapper(defaultGroupVersions []unversioned.GroupVersion, interfacesFunc meta.VersionInterfacesFunc, importPathPrefix string, ignoredKinds, rootScoped sets.String) *meta.DefaultRESTMapper { diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/meta/firsthit_restmapper.go b/staging/src/k8s.io/client-go/1.5/pkg/api/meta/firsthit_restmapper.go new file mode 100644 index 000000000000..224e7153058a --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/meta/firsthit_restmapper.go @@ -0,0 +1,97 @@ +/* +Copyright 2014 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 meta + +import ( + "fmt" + + "k8s.io/client-go/1.5/pkg/api/unversioned" + utilerrors "k8s.io/client-go/1.5/pkg/util/errors" +) + +// FirstHitRESTMapper is a wrapper for multiple RESTMappers which returns the +// first successful result for the singular requests +type FirstHitRESTMapper struct { + MultiRESTMapper +} + +func (m FirstHitRESTMapper) String() string { + return fmt.Sprintf("FirstHitRESTMapper{\n\t%v\n}", m.MultiRESTMapper) +} + +func (m FirstHitRESTMapper) ResourceFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionResource, error) { + errors := []error{} + for _, t := range m.MultiRESTMapper { + ret, err := t.ResourceFor(resource) + if err == nil { + return ret, nil + } + errors = append(errors, err) + } + + return unversioned.GroupVersionResource{}, collapseAggregateErrors(errors) +} + +func (m FirstHitRESTMapper) KindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error) { + errors := []error{} + for _, t := range m.MultiRESTMapper { + ret, err := t.KindFor(resource) + if err == nil { + return ret, nil + } + errors = append(errors, err) + } + + return unversioned.GroupVersionKind{}, collapseAggregateErrors(errors) +} + +// RESTMapping provides the REST mapping for the resource based on the +// kind and version. This implementation supports multiple REST schemas and +// return the first match. +func (m FirstHitRESTMapper) RESTMapping(gk unversioned.GroupKind, versions ...string) (*RESTMapping, error) { + errors := []error{} + for _, t := range m.MultiRESTMapper { + ret, err := t.RESTMapping(gk, versions...) + if err == nil { + return ret, nil + } + errors = append(errors, err) + } + + return nil, collapseAggregateErrors(errors) +} + +// collapseAggregateErrors returns the minimal errors. it handles empty as nil, handles one item in a list +// by returning the item, and collapses all NoMatchErrors to a single one (since they should all be the same) +func collapseAggregateErrors(errors []error) error { + if len(errors) == 0 { + return nil + } + if len(errors) == 1 { + return errors[0] + } + + allNoMatchErrors := true + for _, err := range errors { + allNoMatchErrors = allNoMatchErrors && IsNoMatchError(err) + } + if allNoMatchErrors { + return errors[0] + } + + return utilerrors.NewAggregate(errors) +} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/meta/restmapper.go b/staging/src/k8s.io/client-go/1.5/pkg/api/meta/restmapper.go index be0f358db5c3..063f48e4b08d 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/meta/restmapper.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/meta/restmapper.go @@ -526,7 +526,7 @@ func (m *DefaultRESTMapper) RESTMapping(gk unversioned.GroupKind, versions ...st interfaces, err := m.interfacesFunc(gvk.GroupVersion()) if err != nil { - return nil, fmt.Errorf("the provided version %q has no relevant versions", gvk.GroupVersion().String()) + return nil, fmt.Errorf("the provided version %q has no relevant versions: %v", gvk.GroupVersion().String(), err) } retVal := &RESTMapping{ @@ -565,7 +565,7 @@ func (m *DefaultRESTMapper) RESTMappings(gk unversioned.GroupKind) ([]*RESTMappi interfaces, err := m.interfacesFunc(gvk.GroupVersion()) if err != nil { - return nil, fmt.Errorf("the provided version %q has no relevant versions", gvk.GroupVersion().String()) + return nil, fmt.Errorf("the provided version %q has no relevant versions: %v", gvk.GroupVersion().String(), err) } mappings = append(mappings, &RESTMapping{ diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/requestcontext.go b/staging/src/k8s.io/client-go/1.5/pkg/api/requestcontext.go index 14983b2d41fe..724fea811daa 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/requestcontext.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/requestcontext.go @@ -20,6 +20,8 @@ import ( "errors" "net/http" "sync" + + "github.com/golang/glog" ) // RequestContextMapper keeps track of the context associated with a particular request @@ -89,21 +91,21 @@ func (c *requestContextMap) remove(req *http.Request) { delete(c.contexts, req) } -// NewRequestContextFilter ensures there is a Context object associated with the request before calling the passed handler. +// WithRequestContext ensures there is a Context object associated with the request before calling the passed handler. // After the passed handler runs, the context is cleaned up. -func NewRequestContextFilter(mapper RequestContextMapper, handler http.Handler) (http.Handler, error) { - if mapper, ok := mapper.(*requestContextMap); ok { - return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - if mapper.init(req, NewContext()) { - // If we were the ones to successfully initialize, pair with a remove - defer mapper.remove(req) - } - handler.ServeHTTP(w, req) - }), nil - } else { - return handler, errors.New("Unknown RequestContextMapper implementation.") +func WithRequestContext(handler http.Handler, mapper RequestContextMapper) http.Handler { + rcMap, ok := mapper.(*requestContextMap) + if !ok { + glog.Fatal("Unknown RequestContextMapper implementation.") } + return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + if rcMap.init(req, NewContext()) { + // If we were the ones to successfully initialize, pair with a remove + defer rcMap.remove(req) + } + handler.ServeHTTP(w, req) + }) } // IsEmpty returns true if there are no contexts registered, or an error if it could not be determined. Intended for use by tests. diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/resource/quantity.go b/staging/src/k8s.io/client-go/1.5/pkg/api/resource/quantity.go index 15527276b2db..df8bcd51017b 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/resource/quantity.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/resource/quantity.go @@ -29,7 +29,7 @@ import ( "github.com/go-openapi/spec" inf "gopkg.in/inf.v0" - "k8s.io/client-go/1.5/cmd/libs/go2idl/openapi-gen/generators/common" + "k8s.io/client-go/1.5/pkg/genericapiserver/openapi/common" ) // Quantity is a fixed-point representation of a number. diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/testapi/testapi.go b/staging/src/k8s.io/client-go/1.5/pkg/api/testapi/testapi.go index a2266f9dfa26..7ef6b01f13ad 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/testapi/testapi.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/testapi/testapi.go @@ -15,6 +15,12 @@ limitations under the License. */ // Package testapi provides a helper for retrieving the KUBE_TEST_API environment variable. +// +// TODO(lavalamp): this package is a huge disaster at the moment. I intend to +// refactor. All code currently using this package should change: +// 1. Declare your own registered.APIGroupRegistrationManager in your own test code. +// 2. Import the relevant install packages. +// 3. Register the types you need, from the announced.APIGroupAnnouncementManager. package testapi import ( @@ -109,8 +115,10 @@ func init() { kubeTestAPI := os.Getenv("KUBE_TEST_API") if len(kubeTestAPI) != 0 { + // priority is "first in list preferred", so this has to run in reverse order testGroupVersions := strings.Split(kubeTestAPI, ",") - for _, gvString := range testGroupVersions { + for i := len(testGroupVersions) - 1; i >= 0; i-- { + gvString := testGroupVersions[i] groupVersion, err := unversioned.ParseGroupVersion(gvString) if err != nil { panic(fmt.Sprintf("Error parsing groupversion %v: %v", gvString, err)) diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/types.go b/staging/src/k8s.io/client-go/1.5/pkg/api/types.go index f3340c34dc1c..078779d3b615 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/types.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/types.go @@ -2086,9 +2086,13 @@ type NodeDaemonEndpoints struct { // NodeSystemInfo is a set of ids/uuids to uniquely identify the node. type NodeSystemInfo struct { - // Machine ID reported by the node. + // MachineID reported by the node. For unique machine identification + // in the cluster this field is prefered. Learn more from man(5) + // machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html MachineID string `json:"machineID"` - // System UUID reported by the node. + // SystemUUID reported by the node. For unique machine identification + // MachineID is prefered. This field is specific to Red Hat hosts + // https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html/RHSM/getting-system-uuid.html SystemUUID string `json:"systemUUID"` // Boot ID reported by the node. BootID string `json:"bootID"` diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/unversioned/time.go b/staging/src/k8s.io/client-go/1.5/pkg/api/unversioned/time.go index 0a84e66db42e..aedc119d2748 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/unversioned/time.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/unversioned/time.go @@ -20,7 +20,7 @@ import ( "encoding/json" "time" - "k8s.io/client-go/1.5/cmd/libs/go2idl/openapi-gen/generators/common" + "k8s.io/client-go/1.5/pkg/genericapiserver/openapi/common" "github.com/go-openapi/spec" "github.com/google/gofuzz" diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/v1/conversion.go b/staging/src/k8s.io/client-go/1.5/pkg/api/v1/conversion.go index d72248a42283..2ba5c32b23c9 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/v1/conversion.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/v1/conversion.go @@ -414,14 +414,22 @@ func Convert_api_PodStatusResult_To_v1_PodStatusResult(in *api.PodStatusResult, return err } out.Annotations[PodInitContainerStatusesAnnotationKey] = string(value) + out.Annotations[PodInitContainerStatusesBetaAnnotationKey] = string(value) } else { delete(out.Annotations, PodInitContainerStatusesAnnotationKey) + delete(out.Annotations, PodInitContainerStatusesBetaAnnotationKey) } return nil } func Convert_v1_PodStatusResult_To_api_PodStatusResult(in *PodStatusResult, out *api.PodStatusResult, s conversion.Scope) error { // TODO: sometime after we move init container to stable, remove these conversions + // If there is a beta annotation, copy to alpha key. + // See commit log for PR #31026 for why we do this. + if valueBeta, okBeta := in.Annotations[PodInitContainerStatusesBetaAnnotationKey]; okBeta { + in.Annotations[PodInitContainerStatusesAnnotationKey] = valueBeta + } + // Move the annotation to the internal repr. field if value, ok := in.Annotations[PodInitContainerStatusesAnnotationKey]; ok { var values []ContainerStatus if err := json.Unmarshal([]byte(value), &values); err != nil { @@ -446,6 +454,7 @@ func Convert_v1_PodStatusResult_To_api_PodStatusResult(in *PodStatusResult, out out.Annotations[k] = v } delete(out.Annotations, PodInitContainerStatusesAnnotationKey) + delete(out.Annotations, PodInitContainerStatusesBetaAnnotationKey) } return nil } @@ -575,6 +584,7 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error delete(out.Annotations, PodInitContainersAnnotationKey) delete(out.Annotations, PodInitContainersBetaAnnotationKey) delete(out.Annotations, PodInitContainerStatusesAnnotationKey) + delete(out.Annotations, PodInitContainerStatusesBetaAnnotationKey) } if len(out.Spec.InitContainers) > 0 { value, err := json.Marshal(out.Spec.InitContainers) @@ -590,6 +600,7 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error return err } out.Annotations[PodInitContainerStatusesAnnotationKey] = string(value) + out.Annotations[PodInitContainerStatusesBetaAnnotationKey] = string(value) } // We need to reset certain fields for mirror pods from pre-v1.1 kubelet @@ -627,6 +638,11 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error // back to the caller. in.Spec.InitContainers = values } + // If there is a beta annotation, copy to alpha key. + // See commit log for PR #31026 for why we do this. + if valueBeta, okBeta := in.Annotations[PodInitContainerStatusesBetaAnnotationKey]; okBeta { + in.Annotations[PodInitContainerStatusesAnnotationKey] = valueBeta + } if value, ok := in.Annotations[PodInitContainerStatusesAnnotationKey]; ok { var values []ContainerStatus if err := json.Unmarshal([]byte(value), &values); err != nil { @@ -653,6 +669,7 @@ func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error delete(out.Annotations, PodInitContainersAnnotationKey) delete(out.Annotations, PodInitContainersBetaAnnotationKey) delete(out.Annotations, PodInitContainerStatusesAnnotationKey) + delete(out.Annotations, PodInitContainerStatusesBetaAnnotationKey) } return nil } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/v1/generated.proto b/staging/src/k8s.io/client-go/1.5/pkg/api/v1/generated.proto index 9552a5d558db..94ce93a8d6e8 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/v1/generated.proto +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/v1/generated.proto @@ -1383,10 +1383,14 @@ message NodeStatus { // NodeSystemInfo is a set of ids/uuids to uniquely identify the node. message NodeSystemInfo { - // Machine ID reported by the node. + // MachineID reported by the node. For unique machine identification + // in the cluster this field is prefered. Learn more from man(5) + // machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html optional string machineID = 1; - // System UUID reported by the node. + // SystemUUID reported by the node. For unique machine identification + // MachineID is prefered. This field is specific to Red Hat hosts + // https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html/RHSM/getting-system-uuid.html optional string systemUUID = 2; // Boot ID reported by the node. diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/v1/types.go b/staging/src/k8s.io/client-go/1.5/pkg/api/v1/types.go index 3344b938ff73..6ef628af16ab 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/v1/types.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/v1/types.go @@ -1749,8 +1749,13 @@ const ( PodInitContainersAnnotationKey = "pod.alpha.kubernetes.io/init-containers" // This annotation key will be used to contain an array of v1 JSON encoded // ContainerStatuses for init containers. The annotation will be placed into the internal - // type and cleared. - PodInitContainerStatusesAnnotationKey = "pod.beta.kubernetes.io/init-container-statuses" + // type and cleared. This key is only recognized by version >= 1.4. + PodInitContainerStatusesBetaAnnotationKey = "pod.beta.kubernetes.io/init-container-statuses" + // This annotation key will be used to contain an array of v1 JSON encoded + // ContainerStatuses for init containers. The annotation will be placed into the internal + // type and cleared. This key is recognized by version >= 1.3. For version 1.4 code, + // this key will have its value copied to the beta key. + PodInitContainerStatusesAnnotationKey = "pod.alpha.kubernetes.io/init-container-statuses" ) // PodSpec is a description of a pod. @@ -2465,9 +2470,13 @@ type NodeDaemonEndpoints struct { // NodeSystemInfo is a set of ids/uuids to uniquely identify the node. type NodeSystemInfo struct { - // Machine ID reported by the node. + // MachineID reported by the node. For unique machine identification + // in the cluster this field is prefered. Learn more from man(5) + // machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html MachineID string `json:"machineID" protobuf:"bytes,1,opt,name=machineID"` - // System UUID reported by the node. + // SystemUUID reported by the node. For unique machine identification + // MachineID is prefered. This field is specific to Red Hat hosts + // https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html/RHSM/getting-system-uuid.html SystemUUID string `json:"systemUUID" protobuf:"bytes,2,opt,name=systemUUID"` // Boot ID reported by the node. BootID string `json:"bootID" protobuf:"bytes,3,opt,name=bootID"` diff --git a/staging/src/k8s.io/client-go/1.5/pkg/api/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/client-go/1.5/pkg/api/v1/types_swagger_doc_generated.go index a2552bdf3f52..3f0ac8f0238e 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/api/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/api/v1/types_swagger_doc_generated.go @@ -927,8 +927,8 @@ func (NodeStatus) SwaggerDoc() map[string]string { var map_NodeSystemInfo = map[string]string{ "": "NodeSystemInfo is a set of ids/uuids to uniquely identify the node.", - "machineID": "Machine ID reported by the node.", - "systemUUID": "System UUID reported by the node.", + "machineID": "MachineID reported by the node. For unique machine identification in the cluster this field is prefered. Learn more from man(5) machine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html", + "systemUUID": "SystemUUID reported by the node. For unique machine identification MachineID is prefered. This field is specific to Red Hat hosts https://access.redhat.com/documentation/en-US/Red_Hat_Subscription_Management/1/html/RHSM/getting-system-uuid.html", "bootID": "Boot ID reported by the node.", "kernelVersion": "Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).", "osImage": "OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).", diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/announced/announced.go b/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/announced/announced.go new file mode 100644 index 000000000000..18195480b189 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/announced/announced.go @@ -0,0 +1,107 @@ +/* +Copyright 2016 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 announced contains tools for announcing API group factories. This is +// distinct from registration (in the 'registered' package) in that it's safe +// to announce every possible group linked in, but only groups requested at +// runtime should be registered. This package contains both a registry, and +// factory code (which was formerly copy-pasta in every install package). +package announced + +import ( + "fmt" + + "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/runtime" +) + +var ( + DefaultGroupFactoryRegistry = make(APIGroupFactoryRegistry) + + // These functions will announce your group or version. + AnnounceGroupVersion = DefaultGroupFactoryRegistry.AnnounceGroupVersion + AnnounceGroup = DefaultGroupFactoryRegistry.AnnounceGroup +) + +// APIGroupFactoryRegistry allows for groups and versions to announce themselves, +// which simply makes them available and doesn't take other actions. Later, +// users of the registry can select which groups and versions they'd actually +// like to register with an APIRegistrationManager. +// +// (Right now APIRegistrationManager has separate 'registration' and 'enabled' +// concepts-- APIGroupFactory is going to take over the former function; +// they will overlap untill the refactoring is finished.) +// +// The key is the group name. After initialization, this should be treated as +// read-only. It is implemented as a map from group name to group factory, and +// it is safe to use this knowledge to manually pick out groups to register +// (e.g., for testing). +type APIGroupFactoryRegistry map[string]*GroupMetaFactory + +func (gar APIGroupFactoryRegistry) group(groupName string) *GroupMetaFactory { + gmf, ok := gar[groupName] + if !ok { + gmf = &GroupMetaFactory{VersionArgs: map[string]*GroupVersionFactoryArgs{}} + gar[groupName] = gmf + } + return gmf +} + +// AnnounceGroupVersion adds the particular arguments for this group version to the group factory. +func (gar APIGroupFactoryRegistry) AnnounceGroupVersion(gvf *GroupVersionFactoryArgs) error { + gmf := gar.group(gvf.GroupName) + if _, ok := gmf.VersionArgs[gvf.VersionName]; ok { + return fmt.Errorf("version %q in group %q has already been announced", gvf.VersionName, gvf.GroupName) + } + gmf.VersionArgs[gvf.VersionName] = gvf + return nil +} + +// AnnounceGroup adds the group-wide arguments to the group factory. +func (gar APIGroupFactoryRegistry) AnnounceGroup(args *GroupMetaFactoryArgs) error { + gmf := gar.group(args.GroupName) + if gmf.GroupArgs != nil { + return fmt.Errorf("group %q has already been announced", args.GroupName) + } + gmf.GroupArgs = args + return nil +} + +// RegisterAndEnableAll throws every factory at the specified API registration +// manager, and lets it decide which to register. (If you want to do this a la +// cart, you may look through gar itself-- it's just a map.) +func (gar APIGroupFactoryRegistry) RegisterAndEnableAll(m *registered.APIRegistrationManager, scheme *runtime.Scheme) error { + for groupName, gmf := range gar { + if err := gmf.Register(m); err != nil { + return fmt.Errorf("error registering %v: %v", groupName, err) + } + if err := gmf.Enable(m, scheme); err != nil { + return fmt.Errorf("error enabling %v: %v", groupName, err) + } + } + return nil +} + +// AnnouncePreconstructedFactory announces a factory which you've manually assembled. +// You may call this instead of calling AnnounceGroup and AnnounceGroupVersion. +func (gar APIGroupFactoryRegistry) AnnouncePreconstructedFactory(gmf *GroupMetaFactory) error { + name := gmf.GroupArgs.GroupName + if _, exists := gar[name]; exists { + return fmt.Errorf("the group %q has already been announced.", name) + } + gar[name] = gmf + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/announced/group_factory.go b/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/announced/group_factory.go new file mode 100644 index 000000000000..2895b15c2a7b --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/announced/group_factory.go @@ -0,0 +1,247 @@ +/* +Copyright 2016 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 announced + +import ( + "fmt" + + "github.com/golang/glog" + + "k8s.io/client-go/1.5/pkg/api" + "k8s.io/client-go/1.5/pkg/api/meta" + "k8s.io/client-go/1.5/pkg/api/unversioned" + "k8s.io/client-go/1.5/pkg/apimachinery" + "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/runtime" + "k8s.io/client-go/1.5/pkg/util/sets" +) + +type SchemeFunc func(*runtime.Scheme) error +type VersionToSchemeFunc map[string]SchemeFunc + +// GroupVersionFactoryArgs contains all the per-version parts of a GroupMetaFactory. +type GroupVersionFactoryArgs struct { + GroupName string + VersionName string + + AddToScheme SchemeFunc +} + +// GroupMetaFactoryArgs contains the group-level args of a GroupMetaFactory. +type GroupMetaFactoryArgs struct { + GroupName string + VersionPreferenceOrder []string + ImportPrefix string + + RootScopedKinds sets.String // nil is allowed + IgnoredKinds sets.String // nil is allowed + + // May be nil if there are no internal objects. + AddInternalObjectsToScheme SchemeFunc +} + +// NewGroupMetaFactory builds the args for you. This is for if you're +// constructing a factory all at once and not using the registry. +func NewGroupMetaFactory(groupArgs *GroupMetaFactoryArgs, versions VersionToSchemeFunc) *GroupMetaFactory { + gmf := &GroupMetaFactory{ + GroupArgs: groupArgs, + VersionArgs: map[string]*GroupVersionFactoryArgs{}, + } + for v, f := range versions { + gmf.VersionArgs[v] = &GroupVersionFactoryArgs{ + GroupName: groupArgs.GroupName, + VersionName: v, + AddToScheme: f, + } + } + return gmf +} + +// Announce adds this Group factory to the global factory registry. It should +// only be called if you constructed the GroupMetaFactory yourself via +// NewGroupMetadFactory. +// Note that this will panic on an error, since it's expected that you'll be +// calling this at initialization time and any error is a result of a +// programmer importing the wrong set of packages. If this assumption doesn't +// work for you, just call DefaultGroupFactoryRegistry.AnnouncePreconstructedFactory +// yourself. +func (gmf *GroupMetaFactory) Announce() *GroupMetaFactory { + if err := DefaultGroupFactoryRegistry.AnnouncePreconstructedFactory(gmf); err != nil { + panic(err) + } + return gmf +} + +// GroupMetaFactory has the logic for actually assembling and registering a group. +// +// There are two ways of obtaining one of these. +// 1. You can announce your group and versions separately, and then let the +// GroupFactoryRegistry assemble this object for you. (This allows group and +// versions to be imported separately, without referencing each other, to +// keep import trees small.) +// 2. You can call NewGroupMetaFactory(), which is mostly a drop-in replacement +// for the old, bad way of doing things. You can then call .Announce() to +// announce your constructed factory to any code that would like to do +// things the new, better way. +// +// Note that GroupMetaFactory actually does construct GroupMeta objects, but +// currently it does so in a way that's very entangled with an +// APIRegistrationManager. It's a TODO item to cleanly separate that interface. +type GroupMetaFactory struct { + GroupArgs *GroupMetaFactoryArgs + // map of version name to version factory + VersionArgs map[string]*GroupVersionFactoryArgs + + // assembled by Register() + prioritizedVersionList []unversioned.GroupVersion +} + +// Register constructs the finalized prioritized version list and sanity checks +// the announced group & versions. Then it calls register. +func (gmf *GroupMetaFactory) Register(m *registered.APIRegistrationManager) error { + if gmf.GroupArgs == nil { + return fmt.Errorf("partially announced groups are not allowed, only got versions: %#v", gmf.VersionArgs) + } + if len(gmf.VersionArgs) == 0 { + return fmt.Errorf("group %v announced but no versions announced", gmf.GroupArgs.GroupName) + } + + pvSet := sets.NewString(gmf.GroupArgs.VersionPreferenceOrder...) + if pvSet.Len() != len(gmf.GroupArgs.VersionPreferenceOrder) { + return fmt.Errorf("preference order for group %v has duplicates: %v", gmf.GroupArgs.GroupName, gmf.GroupArgs.VersionPreferenceOrder) + } + prioritizedVersions := []unversioned.GroupVersion{} + for _, v := range gmf.GroupArgs.VersionPreferenceOrder { + prioritizedVersions = append( + prioritizedVersions, + unversioned.GroupVersion{ + Group: gmf.GroupArgs.GroupName, + Version: v, + }, + ) + } + + // Go through versions that weren't explicitly prioritized. + unprioritizedVersions := []unversioned.GroupVersion{} + for _, v := range gmf.VersionArgs { + if v.GroupName != gmf.GroupArgs.GroupName { + return fmt.Errorf("found %v/%v in group %v?", v.GroupName, v.VersionName, gmf.GroupArgs.GroupName) + } + if pvSet.Has(v.VersionName) { + pvSet.Delete(v.VersionName) + continue + } + unprioritizedVersions = append(unprioritizedVersions, unversioned.GroupVersion{Group: v.GroupName, Version: v.VersionName}) + } + if len(unprioritizedVersions) > 1 { + glog.Warningf("group %v has multiple unprioritized versions: %#v. They will have an arbitrary preference order!", gmf.GroupArgs.GroupName, unprioritizedVersions) + } + if pvSet.Len() != 0 { + return fmt.Errorf("group %v has versions in the priority list that were never announced: %s", gmf.GroupArgs.GroupName, pvSet) + } + prioritizedVersions = append(prioritizedVersions, unprioritizedVersions...) + m.RegisterVersions(prioritizedVersions) + gmf.prioritizedVersionList = prioritizedVersions + return nil +} + +func (gmf *GroupMetaFactory) newRESTMapper(scheme *runtime.Scheme, externalVersions []unversioned.GroupVersion, groupMeta *apimachinery.GroupMeta) meta.RESTMapper { + // the list of kinds that are scoped at the root of the api hierarchy + // if a kind is not enumerated here, it is assumed to have a namespace scope + rootScoped := sets.NewString() + if gmf.GroupArgs.RootScopedKinds != nil { + rootScoped = gmf.GroupArgs.RootScopedKinds + } + ignoredKinds := sets.NewString() + if gmf.GroupArgs.IgnoredKinds != nil { + ignoredKinds = gmf.GroupArgs.IgnoredKinds + } + + return api.NewDefaultRESTMapperFromScheme( + externalVersions, + groupMeta.InterfacesFor, + gmf.GroupArgs.ImportPrefix, + ignoredKinds, + rootScoped, + scheme, + ) +} + +// Enable enables group versions that are allowed, adds methods to the scheme, etc. +func (gmf *GroupMetaFactory) Enable(m *registered.APIRegistrationManager, scheme *runtime.Scheme) error { + externalVersions := []unversioned.GroupVersion{} + for _, v := range gmf.prioritizedVersionList { + if !m.IsAllowedVersion(v) { + continue + } + externalVersions = append(externalVersions, v) + if err := m.EnableVersions(v); err != nil { + return err + } + gmf.VersionArgs[v.Version].AddToScheme(scheme) + } + if len(externalVersions) == 0 { + glog.V(4).Infof("No version is registered for group %v", gmf.GroupArgs.GroupName) + return nil + } + + if gmf.GroupArgs.AddInternalObjectsToScheme != nil { + gmf.GroupArgs.AddInternalObjectsToScheme(scheme) + } + + preferredExternalVersion := externalVersions[0] + accessor := meta.NewAccessor() + + groupMeta := &apimachinery.GroupMeta{ + GroupVersion: preferredExternalVersion, + GroupVersions: externalVersions, + SelfLinker: runtime.SelfLinker(accessor), + } + for _, v := range externalVersions { + gvf := gmf.VersionArgs[v.Version] + if err := groupMeta.AddVersionInterfaces( + unversioned.GroupVersion{Group: gvf.GroupName, Version: gvf.VersionName}, + &meta.VersionInterfaces{ + ObjectConvertor: scheme, + MetadataAccessor: accessor, + }, + ); err != nil { + return err + } + } + groupMeta.InterfacesFor = groupMeta.DefaultInterfacesFor + groupMeta.RESTMapper = gmf.newRESTMapper(scheme, externalVersions, groupMeta) + + if err := m.RegisterGroup(*groupMeta); err != nil { + return err + } + return nil +} + +// RegisterAndEnable is provided only to allow this code to get added in multiple steps. +// It's really bad that this is called in init() methods, but supporting this +// temporarily lets us do the change incrementally. +func (gmf *GroupMetaFactory) RegisterAndEnable() error { + if err := gmf.Register(registered.DefaultAPIRegistrationManager); err != nil { + return err + } + if err := gmf.Enable(registered.DefaultAPIRegistrationManager, api.Scheme); err != nil { + return err + } + + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/registered/registered.go b/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/registered/registered.go index 974b5da174ad..5ca48f5149de 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/registered/registered.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/registered/registered.go @@ -35,7 +35,14 @@ var ( DefaultAPIRegistrationManager = NewOrDie(os.Getenv("KUBE_API_VERSIONS")) ) -// APIRegistrationManager +// APIRegistrationManager provides the concept of what API groups are enabled. +// +// TODO: currently, it also provides a "registered" concept. But it's wrong to +// have both concepts in the same object. Therefore the "announced" package is +// going to take over the registered concept. After all the install packages +// are switched to using the announce package instead of this package, then we +// can combine the registered/enabled concepts in this object. Simplifying this +// isn't easy right now because there are so many callers of this package. type APIRegistrationManager struct { // registeredGroupVersions stores all API group versions for which RegisterGroup is called. registeredVersions map[unversioned.GroupVersion]struct{} @@ -111,6 +118,7 @@ var ( EnableVersions = DefaultAPIRegistrationManager.EnableVersions RegisterGroup = DefaultAPIRegistrationManager.RegisterGroup RegisterVersions = DefaultAPIRegistrationManager.RegisterVersions + InterfacesFor = DefaultAPIRegistrationManager.InterfacesFor ) // RegisterVersions adds the given group versions to the list of registered group versions. @@ -265,6 +273,15 @@ func (m *APIRegistrationManager) AddThirdPartyAPIGroupVersions(gvs ...unversione return skippedGVs } +// InterfacesFor is a union meta.VersionInterfacesFunc func for all registered types +func (m *APIRegistrationManager) InterfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { + groupMeta, err := m.Group(version.Group) + if err != nil { + return nil, err + } + return groupMeta.InterfacesFor(version) +} + // TODO: This is an expedient function, because we don't check if a Group is // supported throughout the code base. We will abandon this function and // checking the error returned by the Group() function. diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/types.go b/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/types.go index 8dd9a51230c7..b3fc7b83405a 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/types.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apimachinery/types.go @@ -17,6 +17,8 @@ limitations under the License. package apimachinery import ( + "fmt" + "k8s.io/client-go/1.5/pkg/api/meta" "k8s.io/client-go/1.5/pkg/api/unversioned" "k8s.io/client-go/1.5/pkg/runtime" @@ -47,6 +49,45 @@ type GroupMeta struct { RESTMapper meta.RESTMapper // InterfacesFor returns the default Codec and ResourceVersioner for a given version - // or an error if the version is not known. + // string, or an error if the version is not known. + // TODO: make this stop being a func pointer and always use the default + // function provided below once every place that populates this field has been changed. InterfacesFor func(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) + + // InterfacesByVersion stores the per-version interfaces. + InterfacesByVersion map[unversioned.GroupVersion]*meta.VersionInterfaces +} + +// DefaultInterfacesFor returns the default Codec and ResourceVersioner for a given version +// string, or an error if the version is not known. +// TODO: Remove the "Default" prefix. +func (gm *GroupMeta) DefaultInterfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { + if v, ok := gm.InterfacesByVersion[version]; ok { + return v, nil + } + return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, gm.GroupVersions) +} + +// AddVersionInterfaces adds the given version to the group. Only call during +// init, after that GroupMeta objects should be immutable. Not thread safe. +// (If you use this, be sure to set .InterfacesFor = .DefaultInterfacesFor) +// TODO: remove the "Interfaces" suffix and make this also maintain the +// .GroupVersions member. +func (gm *GroupMeta) AddVersionInterfaces(version unversioned.GroupVersion, interfaces *meta.VersionInterfaces) error { + if e, a := gm.GroupVersion.Group, version.Group; a != e { + return fmt.Errorf("got a version in group %v, but am in group %v", a, e) + } + if gm.InterfacesByVersion == nil { + gm.InterfacesByVersion = make(map[unversioned.GroupVersion]*meta.VersionInterfaces) + } + gm.InterfacesByVersion[version] = interfaces + + // TODO: refactor to make the below error not possible, this function + // should *set* GroupVersions rather than depend on it. + for _, v := range gm.GroupVersions { + if v == version { + return nil + } + } + return fmt.Errorf("added a version interface without the corresponding version %v being in the list %#v", version, gm.GroupVersions) } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/apps/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/apps/install/install.go index da5709bdfca9..ef8f7e7ad722 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/apps/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/apps/install/install.go @@ -19,113 +19,23 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/apps" "k8s.io/client-go/1.5/pkg/apis/apps/v1alpha1" - "k8s.io/client-go/1.5/pkg/runtime" - "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/apps" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1alpha1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", apps.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - // the list of kinds that are scoped at the root of the api hierarchy - // if a kind is not enumerated here, it is assumed to have a namespace scope - rootScoped := sets.NewString() - - ignoredKinds := sets.NewString() - - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -// interfacesFor returns the default Codec and ResourceVersioner for a given version -// string, or an error if the version is not known. -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1alpha1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(apps.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := apps.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: apps.GroupName, + VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/apps", + AddInternalObjectsToScheme: apps.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1alpha1.SchemeGroupVersion: - if err := v1alpha1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/apps/v1alpha1/types.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/apps/v1alpha1/types.go index 27c5fc2e398c..7502cc1929e5 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/apps/v1alpha1/types.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/apps/v1alpha1/types.go @@ -21,6 +21,8 @@ import ( "k8s.io/client-go/1.5/pkg/api/v1" ) +// +genclient=true + // PetSet represents a set of pods with consistent identities. // Identities are defined as: // - Network: A single stable DNS and hostname. diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/authentication/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/authentication/install/install.go index 91b0db19e7e7..e4caa753d1e8 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/authentication/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/authentication/install/install.go @@ -19,111 +19,25 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/authentication" "k8s.io/client-go/1.5/pkg/apis/authentication/v1beta1" - "k8s.io/client-go/1.5/pkg/runtime" "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/authentication" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1beta1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", authentication.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions there. -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := authentication.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: authentication.GroupName, + VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/authentication", + RootScopedKinds: sets.NewString("TokenReview"), + AddInternalObjectsToScheme: authentication.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1beta1.SchemeGroupVersion: - if err := v1beta1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - rootScoped := sets.NewString("TokenReview") - ignoredKinds := sets.NewString() - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1beta1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(authentication.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/authorization/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/authorization/install/install.go index 4d8a208ac259..49667c72fa22 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/authorization/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/authorization/install/install.go @@ -19,116 +19,25 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/authorization" "k8s.io/client-go/1.5/pkg/apis/authorization/v1beta1" - "k8s.io/client-go/1.5/pkg/runtime" "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/authorization" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1beta1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", authorization.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions there. -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := authorization.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: authorization.GroupName, + VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/authorization", + RootScopedKinds: sets.NewString("SubjectAccessReview", "SelfSubjectAccessReview"), + AddInternalObjectsToScheme: authorization.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1beta1.SchemeGroupVersion: - if err := v1beta1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - worstToBestGroupVersions := []unversioned.GroupVersion{} - for i := len(externalVersions) - 1; i >= 0; i-- { - worstToBestGroupVersions = append(worstToBestGroupVersions, externalVersions[i]) - } - - rootScoped := sets.NewString("SubjectAccessReview", "SelfSubjectAccessReview") - ignoredKinds := sets.NewString() - return api.NewDefaultRESTMapper(worstToBestGroupVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1beta1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(authorization.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/autoscaling/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/autoscaling/install/install.go index 30fcd7c4417a..bf0f08f41366 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/autoscaling/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/autoscaling/install/install.go @@ -19,117 +19,23 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/autoscaling" "k8s.io/client-go/1.5/pkg/apis/autoscaling/v1" - "k8s.io/client-go/1.5/pkg/runtime" - "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/autoscaling" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", autoscaling.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions there. -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - // the list of kinds that are scoped at the root of the api hierarchy - // if a kind is not enumerated here, it is assumed to have a namespace scope - rootScoped := sets.NewString() - - ignoredKinds := sets.NewString() - - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -// interfacesFor returns the default Codec and ResourceVersioner for a given version -// string, or an error if the version is not known. -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(autoscaling.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := autoscaling.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: autoscaling.GroupName, + VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/autoscaling", + AddInternalObjectsToScheme: autoscaling.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1.SchemeGroupVersion.Version: v1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1.SchemeGroupVersion: - if err := v1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/batch/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/batch/install/install.go index 0ea372a88133..9e511cea831a 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/batch/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/batch/install/install.go @@ -19,128 +19,25 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/batch" "k8s.io/client-go/1.5/pkg/apis/batch/v1" "k8s.io/client-go/1.5/pkg/apis/batch/v2alpha1" - "k8s.io/client-go/1.5/pkg/runtime" - "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/batch" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1.SchemeGroupVersion, v2alpha1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", batch.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions there. -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - // the list of kinds that are scoped at the root of the api hierarchy - // if a kind is not enumerated here, it is assumed to have a namespace scope - rootScoped := sets.NewString() - - ignoredKinds := sets.NewString() - - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -// interfacesFor returns the default Codec and ResourceVersioner for a given version -// string, or an error if the version is not known. -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - case v2alpha1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(batch.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := batch.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: batch.GroupName, + VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v2alpha1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/batch", + AddInternalObjectsToScheme: batch.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1.SchemeGroupVersion.Version: v1.AddToScheme, + v2alpha1.SchemeGroupVersion.Version: v2alpha1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1.SchemeGroupVersion: - if err := v1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - case v2alpha1.SchemeGroupVersion: - if err := v2alpha1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/certificates/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/certificates/install/install.go index e2d9341c9ef9..6ae04015729e 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/certificates/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/certificates/install/install.go @@ -19,119 +19,25 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/certificates" "k8s.io/client-go/1.5/pkg/apis/certificates/v1alpha1" - "k8s.io/client-go/1.5/pkg/runtime" "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/certificates" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1alpha1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", certificates.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions therecertificates -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - // the list of kinds that are scoped at the root of the api hierarchy - // if a kind is not enumerated here, it is assumed to have a namespace scope - rootScoped := sets.NewString( - "CertificateSigningRequest", - ) - - ignoredKinds := sets.NewString() - - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -// interfacesFor returns the default Codec and ResourceVersioner for a given version -// string, or an error if the version is not known. -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1alpha1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(certificates.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := certificates.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: certificates.GroupName, + VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/certificates", + RootScopedKinds: sets.NewString("CertificateSigningRequest"), + AddInternalObjectsToScheme: certificates.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1alpha1.SchemeGroupVersion: - if err := v1alpha1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/certificates/v1alpha1/doc.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/certificates/v1alpha1/doc.go index 82f36bd6013a..08eb645976f2 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/certificates/v1alpha1/doc.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/certificates/v1alpha1/doc.go @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -// +groupName=certificates.k8s.io // +k8s:deepcopy-gen=package,register // +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/certificates // +k8s:openapi-gen=true +// +groupName=certificates.k8s.io package v1alpha1 diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/install/install.go index cb0f12c91637..891ee47a5fc0 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/install/install.go @@ -19,117 +19,23 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/componentconfig" "k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1" - "k8s.io/client-go/1.5/pkg/runtime" - "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/componentconfig" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1alpha1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", componentconfig.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions there. -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - // the list of kinds that are scoped at the root of the api hierarchy - // if a kind is not enumerated here, it is assumed to have a namespace scope - rootScoped := sets.NewString() - - ignoredKinds := sets.NewString() - - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -// interfacesFor returns the default Codec and ResourceVersioner for a given version -// string, or an error if the version is not known. -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1alpha1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(componentconfig.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := componentconfig.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: componentconfig.GroupName, + VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/componentconfig", + AddInternalObjectsToScheme: componentconfig.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1alpha1.SchemeGroupVersion: - if err := v1alpha1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.generated.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.generated.go index 841f42fee02b..c963b7aca902 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.generated.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.generated.go @@ -1218,7 +1218,7 @@ func (x *KubeletConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep130 := !z.EncBinary() yy2arr130 := z.EncBasicHandle().StructToArray - var yyq130 [107]bool + var yyq130 [108]bool _, _, _ = yysep130, yyq130, yy2arr130 const yyr130 bool = false yyq130[0] = x.Kind != "" @@ -1243,9 +1243,10 @@ func (x *KubeletConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { yyq130[96] = x.EvictionMaxPodGracePeriod != 0 yyq130[97] = x.EvictionMinimumReclaim != "" yyq130[106] = len(x.AllowedUnsafeSysctls) != 0 + yyq130[107] = x.ExperimentalRuntimeIntegrationType != "" var yynn130 int if yyr130 || yy2arr130 { - r.EncodeArrayStart(107) + r.EncodeArrayStart(108) } else { yynn130 = 85 for _, b := range yyq130 { @@ -3569,6 +3570,31 @@ func (x *KubeletConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { } } } + if yyr130 || yy2arr130 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + if yyq130[107] { + yym475 := z.EncBinary() + _ = yym475 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.ExperimentalRuntimeIntegrationType)) + } + } else { + r.EncodeString(codecSelferC_UTF81234, "") + } + } else { + if yyq130[107] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("experimentalRuntimeIntegrationType")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yym476 := z.EncBinary() + _ = yym476 + if false { + } else { + r.EncodeString(codecSelferC_UTF81234, string(x.ExperimentalRuntimeIntegrationType)) + } + } + } if yyr130 || yy2arr130 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) } else { @@ -3582,25 +3608,25 @@ func (x *KubeletConfiguration) CodecDecodeSelf(d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - yym474 := z.DecBinary() - _ = yym474 + yym477 := z.DecBinary() + _ = yym477 if false { } else if z.HasExtensions() && z.DecExt(x) { } else { - yyct475 := r.ContainerType() - if yyct475 == codecSelferValueTypeMap1234 { - yyl475 := r.ReadMapStart() - if yyl475 == 0 { + yyct478 := r.ContainerType() + if yyct478 == codecSelferValueTypeMap1234 { + yyl478 := r.ReadMapStart() + if yyl478 == 0 { z.DecSendContainerState(codecSelfer_containerMapEnd1234) } else { - x.codecDecodeSelfFromMap(yyl475, d) + x.codecDecodeSelfFromMap(yyl478, d) } - } else if yyct475 == codecSelferValueTypeArray1234 { - yyl475 := r.ReadArrayStart() - if yyl475 == 0 { + } else if yyct478 == codecSelferValueTypeArray1234 { + yyl478 := r.ReadArrayStart() + if yyl478 == 0 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } else { - x.codecDecodeSelfFromArray(yyl475, d) + x.codecDecodeSelfFromArray(yyl478, d) } } else { panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) @@ -3612,12 +3638,12 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yys476Slc = z.DecScratchBuffer() // default slice to decode into - _ = yys476Slc - var yyhl476 bool = l >= 0 - for yyj476 := 0; ; yyj476++ { - if yyhl476 { - if yyj476 >= l { + var yys479Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys479Slc + var yyhl479 bool = l >= 0 + for yyj479 := 0; ; yyj479++ { + if yyhl479 { + if yyj479 >= l { break } } else { @@ -3626,10 +3652,10 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode } } z.DecSendContainerState(codecSelfer_containerMapKey1234) - yys476Slc = r.DecodeBytes(yys476Slc, true, true) - yys476 := string(yys476Slc) + yys479Slc = r.DecodeBytes(yys479Slc, true, true) + yys479 := string(yys479Slc) z.DecSendContainerState(codecSelfer_containerMapValue1234) - switch yys476 { + switch yys479 { case "kind": if r.TryDecodeAsNil() { x.Kind = "" @@ -3652,45 +3678,45 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.SyncFrequency = pkg1_unversioned.Duration{} } else { - yyv480 := &x.SyncFrequency - yym481 := z.DecBinary() - _ = yym481 + yyv483 := &x.SyncFrequency + yym484 := z.DecBinary() + _ = yym484 if false { - } else if z.HasExtensions() && z.DecExt(yyv480) { - } else if !yym481 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv480) + } else if z.HasExtensions() && z.DecExt(yyv483) { + } else if !yym484 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv483) } else { - z.DecFallback(yyv480, false) + z.DecFallback(yyv483, false) } } case "fileCheckFrequency": if r.TryDecodeAsNil() { x.FileCheckFrequency = pkg1_unversioned.Duration{} } else { - yyv482 := &x.FileCheckFrequency - yym483 := z.DecBinary() - _ = yym483 + yyv485 := &x.FileCheckFrequency + yym486 := z.DecBinary() + _ = yym486 if false { - } else if z.HasExtensions() && z.DecExt(yyv482) { - } else if !yym483 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv482) + } else if z.HasExtensions() && z.DecExt(yyv485) { + } else if !yym486 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv485) } else { - z.DecFallback(yyv482, false) + z.DecFallback(yyv485, false) } } case "httpCheckFrequency": if r.TryDecodeAsNil() { x.HTTPCheckFrequency = pkg1_unversioned.Duration{} } else { - yyv484 := &x.HTTPCheckFrequency - yym485 := z.DecBinary() - _ = yym485 + yyv487 := &x.HTTPCheckFrequency + yym488 := z.DecBinary() + _ = yym488 if false { - } else if z.HasExtensions() && z.DecExt(yyv484) { - } else if !yym485 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv484) + } else if z.HasExtensions() && z.DecExt(yyv487) { + } else if !yym488 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv487) } else { - z.DecFallback(yyv484, false) + z.DecFallback(yyv487, false) } } case "manifestURL": @@ -3787,36 +3813,36 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.HostNetworkSources = nil } else { - yyv501 := &x.HostNetworkSources - yym502 := z.DecBinary() - _ = yym502 + yyv504 := &x.HostNetworkSources + yym505 := z.DecBinary() + _ = yym505 if false { } else { - z.F.DecSliceStringX(yyv501, false, d) + z.F.DecSliceStringX(yyv504, false, d) } } case "hostPIDSources": if r.TryDecodeAsNil() { x.HostPIDSources = nil } else { - yyv503 := &x.HostPIDSources - yym504 := z.DecBinary() - _ = yym504 + yyv506 := &x.HostPIDSources + yym507 := z.DecBinary() + _ = yym507 if false { } else { - z.F.DecSliceStringX(yyv503, false, d) + z.F.DecSliceStringX(yyv506, false, d) } } case "hostIPCSources": if r.TryDecodeAsNil() { x.HostIPCSources = nil } else { - yyv505 := &x.HostIPCSources - yym506 := z.DecBinary() - _ = yym506 + yyv508 := &x.HostIPCSources + yym509 := z.DecBinary() + _ = yym509 if false { } else { - z.F.DecSliceStringX(yyv505, false, d) + z.F.DecSliceStringX(yyv508, false, d) } } case "registryPullQPS": @@ -3853,15 +3879,15 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.MinimumGCAge = pkg1_unversioned.Duration{} } else { - yyv512 := &x.MinimumGCAge - yym513 := z.DecBinary() - _ = yym513 + yyv515 := &x.MinimumGCAge + yym516 := z.DecBinary() + _ = yym516 if false { - } else if z.HasExtensions() && z.DecExt(yyv512) { - } else if !yym513 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv512) + } else if z.HasExtensions() && z.DecExt(yyv515) { + } else if !yym516 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv515) } else { - z.DecFallback(yyv512, false) + z.DecFallback(yyv515, false) } } case "maxPerPodContainerCount": @@ -3928,45 +3954,45 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.StreamingConnectionIdleTimeout = pkg1_unversioned.Duration{} } else { - yyv524 := &x.StreamingConnectionIdleTimeout - yym525 := z.DecBinary() - _ = yym525 + yyv527 := &x.StreamingConnectionIdleTimeout + yym528 := z.DecBinary() + _ = yym528 if false { - } else if z.HasExtensions() && z.DecExt(yyv524) { - } else if !yym525 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv524) + } else if z.HasExtensions() && z.DecExt(yyv527) { + } else if !yym528 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv527) } else { - z.DecFallback(yyv524, false) + z.DecFallback(yyv527, false) } } case "nodeStatusUpdateFrequency": if r.TryDecodeAsNil() { x.NodeStatusUpdateFrequency = pkg1_unversioned.Duration{} } else { - yyv526 := &x.NodeStatusUpdateFrequency - yym527 := z.DecBinary() - _ = yym527 + yyv529 := &x.NodeStatusUpdateFrequency + yym530 := z.DecBinary() + _ = yym530 if false { - } else if z.HasExtensions() && z.DecExt(yyv526) { - } else if !yym527 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv526) + } else if z.HasExtensions() && z.DecExt(yyv529) { + } else if !yym530 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv529) } else { - z.DecFallback(yyv526, false) + z.DecFallback(yyv529, false) } } case "imageMinimumGCAge": if r.TryDecodeAsNil() { x.ImageMinimumGCAge = pkg1_unversioned.Duration{} } else { - yyv528 := &x.ImageMinimumGCAge - yym529 := z.DecBinary() - _ = yym529 + yyv531 := &x.ImageMinimumGCAge + yym532 := z.DecBinary() + _ = yym532 if false { - } else if z.HasExtensions() && z.DecExt(yyv528) { - } else if !yym529 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv528) + } else if z.HasExtensions() && z.DecExt(yyv531) { + } else if !yym532 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv531) } else { - z.DecFallback(yyv528, false) + z.DecFallback(yyv531, false) } } case "imageGCHighThresholdPercent": @@ -3991,15 +4017,15 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.VolumeStatsAggPeriod = pkg1_unversioned.Duration{} } else { - yyv533 := &x.VolumeStatsAggPeriod - yym534 := z.DecBinary() - _ = yym534 + yyv536 := &x.VolumeStatsAggPeriod + yym537 := z.DecBinary() + _ = yym537 if false { - } else if z.HasExtensions() && z.DecExt(yyv533) { - } else if !yym534 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv533) + } else if z.HasExtensions() && z.DecExt(yyv536) { + } else if !yym537 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv536) } else { - z.DecFallback(yyv533, false) + z.DecFallback(yyv536, false) } } case "networkPluginName": @@ -4102,15 +4128,15 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.RuntimeRequestTimeout = pkg1_unversioned.Duration{} } else { - yyv551 := &x.RuntimeRequestTimeout - yym552 := z.DecBinary() - _ = yym552 + yyv554 := &x.RuntimeRequestTimeout + yym555 := z.DecBinary() + _ = yym555 if false { - } else if z.HasExtensions() && z.DecExt(yyv551) { - } else if !yym552 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv551) + } else if z.HasExtensions() && z.DecExt(yyv554) { + } else if !yym555 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv554) } else { - z.DecFallback(yyv551, false) + z.DecFallback(yyv554, false) } } case "rktPath": @@ -4255,15 +4281,15 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.OutOfDiskTransitionFrequency = pkg1_unversioned.Duration{} } else { - yyv576 := &x.OutOfDiskTransitionFrequency - yym577 := z.DecBinary() - _ = yym577 + yyv579 := &x.OutOfDiskTransitionFrequency + yym580 := z.DecBinary() + _ = yym580 if false { - } else if z.HasExtensions() && z.DecExt(yyv576) { - } else if !yym577 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv576) + } else if z.HasExtensions() && z.DecExt(yyv579) { + } else if !yym580 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv579) } else { - z.DecFallback(yyv576, false) + z.DecFallback(yyv579, false) } } case "nodeIP": @@ -4276,12 +4302,12 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.NodeLabels = nil } else { - yyv579 := &x.NodeLabels - yym580 := z.DecBinary() - _ = yym580 + yyv582 := &x.NodeLabels + yym583 := z.DecBinary() + _ = yym583 if false { } else { - z.F.DecMapStringStringX(yyv579, false, d) + z.F.DecMapStringStringX(yyv582, false, d) } } case "nonMasqueradeCIDR": @@ -4318,15 +4344,15 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.EvictionPressureTransitionPeriod = pkg1_unversioned.Duration{} } else { - yyv586 := &x.EvictionPressureTransitionPeriod - yym587 := z.DecBinary() - _ = yym587 + yyv589 := &x.EvictionPressureTransitionPeriod + yym590 := z.DecBinary() + _ = yym590 if false { - } else if z.HasExtensions() && z.DecExt(yyv586) { - } else if !yym587 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv586) + } else if z.HasExtensions() && z.DecExt(yyv589) { + } else if !yym590 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv589) } else { - z.DecFallback(yyv586, false) + z.DecFallback(yyv589, false) } } case "evictionMaxPodGracePeriod": @@ -4357,26 +4383,26 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.SystemReserved = nil } else { - yyv592 := &x.SystemReserved - yym593 := z.DecBinary() - _ = yym593 + yyv595 := &x.SystemReserved + yym596 := z.DecBinary() + _ = yym596 if false { - } else if z.HasExtensions() && z.DecExt(yyv592) { + } else if z.HasExtensions() && z.DecExt(yyv595) { } else { - h.decconfig_ConfigurationMap((*pkg2_config.ConfigurationMap)(yyv592), d) + h.decconfig_ConfigurationMap((*pkg2_config.ConfigurationMap)(yyv595), d) } } case "kubeReserved": if r.TryDecodeAsNil() { x.KubeReserved = nil } else { - yyv594 := &x.KubeReserved - yym595 := z.DecBinary() - _ = yym595 + yyv597 := &x.KubeReserved + yym598 := z.DecBinary() + _ = yym598 if false { - } else if z.HasExtensions() && z.DecExt(yyv594) { + } else if z.HasExtensions() && z.DecExt(yyv597) { } else { - h.decconfig_ConfigurationMap((*pkg2_config.ConfigurationMap)(yyv594), d) + h.decconfig_ConfigurationMap((*pkg2_config.ConfigurationMap)(yyv597), d) } } case "protectKernelDefaults": @@ -4407,18 +4433,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode if r.TryDecodeAsNil() { x.AllowedUnsafeSysctls = nil } else { - yyv600 := &x.AllowedUnsafeSysctls - yym601 := z.DecBinary() - _ = yym601 + yyv603 := &x.AllowedUnsafeSysctls + yym604 := z.DecBinary() + _ = yym604 if false { } else { - z.F.DecSliceStringX(yyv600, false, d) + z.F.DecSliceStringX(yyv603, false, d) } } + case "experimentalRuntimeIntegrationType": + if r.TryDecodeAsNil() { + x.ExperimentalRuntimeIntegrationType = "" + } else { + x.ExperimentalRuntimeIntegrationType = string(r.DecodeString()) + } default: - z.DecStructFieldNotFound(-1, yys476) - } // end switch yys476 - } // end for yyj476 + z.DecStructFieldNotFound(-1, yys479) + } // end switch yys479 + } // end for yyj479 z.DecSendContainerState(codecSelfer_containerMapEnd1234) } @@ -4426,16 +4458,16 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj602 int - var yyb602 bool - var yyhl602 bool = l >= 0 - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + var yyj606 int + var yyb606 bool + var yyhl606 bool = l >= 0 + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4445,13 +4477,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.Kind = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4461,13 +4493,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.APIVersion = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4477,13 +4509,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.PodManifestPath = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4491,24 +4523,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.SyncFrequency = pkg1_unversioned.Duration{} } else { - yyv606 := &x.SyncFrequency - yym607 := z.DecBinary() - _ = yym607 + yyv610 := &x.SyncFrequency + yym611 := z.DecBinary() + _ = yym611 if false { - } else if z.HasExtensions() && z.DecExt(yyv606) { - } else if !yym607 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv606) + } else if z.HasExtensions() && z.DecExt(yyv610) { + } else if !yym611 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv610) } else { - z.DecFallback(yyv606, false) + z.DecFallback(yyv610, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4516,24 +4548,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.FileCheckFrequency = pkg1_unversioned.Duration{} } else { - yyv608 := &x.FileCheckFrequency - yym609 := z.DecBinary() - _ = yym609 + yyv612 := &x.FileCheckFrequency + yym613 := z.DecBinary() + _ = yym613 if false { - } else if z.HasExtensions() && z.DecExt(yyv608) { - } else if !yym609 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv608) + } else if z.HasExtensions() && z.DecExt(yyv612) { + } else if !yym613 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv612) } else { - z.DecFallback(yyv608, false) + z.DecFallback(yyv612, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4541,24 +4573,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.HTTPCheckFrequency = pkg1_unversioned.Duration{} } else { - yyv610 := &x.HTTPCheckFrequency - yym611 := z.DecBinary() - _ = yym611 + yyv614 := &x.HTTPCheckFrequency + yym615 := z.DecBinary() + _ = yym615 if false { - } else if z.HasExtensions() && z.DecExt(yyv610) { - } else if !yym611 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv610) + } else if z.HasExtensions() && z.DecExt(yyv614) { + } else if !yym615 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv614) } else { - z.DecFallback(yyv610, false) + z.DecFallback(yyv614, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4568,13 +4600,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ManifestURL = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4584,13 +4616,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ManifestURLHeader = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4600,13 +4632,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EnableServer = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4616,13 +4648,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.Address = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4632,13 +4664,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.Port = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4648,13 +4680,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ReadOnlyPort = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4664,13 +4696,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.TLSCertFile = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4680,13 +4712,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.TLSPrivateKeyFile = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4696,13 +4728,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.CertDirectory = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4712,13 +4744,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.HostnameOverride = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4728,13 +4760,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.PodInfraContainerImage = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4744,13 +4776,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.DockerEndpoint = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4760,13 +4792,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RootDirectory = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4776,13 +4808,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.SeccompProfileRoot = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4792,13 +4824,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.AllowPrivileged = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4806,21 +4838,21 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.HostNetworkSources = nil } else { - yyv627 := &x.HostNetworkSources - yym628 := z.DecBinary() - _ = yym628 + yyv631 := &x.HostNetworkSources + yym632 := z.DecBinary() + _ = yym632 if false { } else { - z.F.DecSliceStringX(yyv627, false, d) + z.F.DecSliceStringX(yyv631, false, d) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4828,21 +4860,21 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.HostPIDSources = nil } else { - yyv629 := &x.HostPIDSources - yym630 := z.DecBinary() - _ = yym630 + yyv633 := &x.HostPIDSources + yym634 := z.DecBinary() + _ = yym634 if false { } else { - z.F.DecSliceStringX(yyv629, false, d) + z.F.DecSliceStringX(yyv633, false, d) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4850,21 +4882,21 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.HostIPCSources = nil } else { - yyv631 := &x.HostIPCSources - yym632 := z.DecBinary() - _ = yym632 + yyv635 := &x.HostIPCSources + yym636 := z.DecBinary() + _ = yym636 if false { } else { - z.F.DecSliceStringX(yyv631, false, d) + z.F.DecSliceStringX(yyv635, false, d) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4874,13 +4906,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RegistryPullQPS = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4890,13 +4922,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RegistryBurst = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4906,13 +4938,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EventRecordQPS = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4922,13 +4954,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EventBurst = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4938,13 +4970,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EnableDebuggingHandlers = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4952,24 +4984,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.MinimumGCAge = pkg1_unversioned.Duration{} } else { - yyv638 := &x.MinimumGCAge - yym639 := z.DecBinary() - _ = yym639 + yyv642 := &x.MinimumGCAge + yym643 := z.DecBinary() + _ = yym643 if false { - } else if z.HasExtensions() && z.DecExt(yyv638) { - } else if !yym639 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv638) + } else if z.HasExtensions() && z.DecExt(yyv642) { + } else if !yym643 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv642) } else { - z.DecFallback(yyv638, false) + z.DecFallback(yyv642, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4979,13 +5011,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.MaxPerPodContainerCount = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -4995,13 +5027,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.MaxContainerCount = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5011,13 +5043,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.CAdvisorPort = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5027,13 +5059,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.HealthzPort = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5043,13 +5075,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.HealthzBindAddress = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5059,13 +5091,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.OOMScoreAdj = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5075,13 +5107,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RegisterNode = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5091,13 +5123,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ClusterDomain = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5107,13 +5139,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.MasterServiceNamespace = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5123,13 +5155,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ClusterDNS = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5137,24 +5169,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.StreamingConnectionIdleTimeout = pkg1_unversioned.Duration{} } else { - yyv650 := &x.StreamingConnectionIdleTimeout - yym651 := z.DecBinary() - _ = yym651 + yyv654 := &x.StreamingConnectionIdleTimeout + yym655 := z.DecBinary() + _ = yym655 if false { - } else if z.HasExtensions() && z.DecExt(yyv650) { - } else if !yym651 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv650) + } else if z.HasExtensions() && z.DecExt(yyv654) { + } else if !yym655 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv654) } else { - z.DecFallback(yyv650, false) + z.DecFallback(yyv654, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5162,24 +5194,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.NodeStatusUpdateFrequency = pkg1_unversioned.Duration{} } else { - yyv652 := &x.NodeStatusUpdateFrequency - yym653 := z.DecBinary() - _ = yym653 + yyv656 := &x.NodeStatusUpdateFrequency + yym657 := z.DecBinary() + _ = yym657 if false { - } else if z.HasExtensions() && z.DecExt(yyv652) { - } else if !yym653 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv652) + } else if z.HasExtensions() && z.DecExt(yyv656) { + } else if !yym657 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv656) } else { - z.DecFallback(yyv652, false) + z.DecFallback(yyv656, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5187,24 +5219,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.ImageMinimumGCAge = pkg1_unversioned.Duration{} } else { - yyv654 := &x.ImageMinimumGCAge - yym655 := z.DecBinary() - _ = yym655 + yyv658 := &x.ImageMinimumGCAge + yym659 := z.DecBinary() + _ = yym659 if false { - } else if z.HasExtensions() && z.DecExt(yyv654) { - } else if !yym655 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv654) + } else if z.HasExtensions() && z.DecExt(yyv658) { + } else if !yym659 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv658) } else { - z.DecFallback(yyv654, false) + z.DecFallback(yyv658, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5214,13 +5246,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ImageGCHighThresholdPercent = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5230,13 +5262,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ImageGCLowThresholdPercent = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5246,13 +5278,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.LowDiskSpaceThresholdMB = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5260,24 +5292,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.VolumeStatsAggPeriod = pkg1_unversioned.Duration{} } else { - yyv659 := &x.VolumeStatsAggPeriod - yym660 := z.DecBinary() - _ = yym660 + yyv663 := &x.VolumeStatsAggPeriod + yym664 := z.DecBinary() + _ = yym664 if false { - } else if z.HasExtensions() && z.DecExt(yyv659) { - } else if !yym660 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv659) + } else if z.HasExtensions() && z.DecExt(yyv663) { + } else if !yym664 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv663) } else { - z.DecFallback(yyv659, false) + z.DecFallback(yyv663, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5287,13 +5319,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.NetworkPluginName = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5303,13 +5335,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.NetworkPluginMTU = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5319,13 +5351,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.NetworkPluginDir = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5335,13 +5367,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.CNIConfDir = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5351,13 +5383,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.CNIBinDir = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5367,13 +5399,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.VolumePluginDir = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5383,13 +5415,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.CloudProvider = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5399,13 +5431,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.CloudConfigFile = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5415,13 +5447,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.KubeletCgroups = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5431,13 +5463,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.CgroupsPerQOS = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5447,13 +5479,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RuntimeCgroups = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5463,13 +5495,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.SystemCgroups = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5479,13 +5511,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.CgroupRoot = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5495,13 +5527,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ContainerRuntime = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5511,13 +5543,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RemoteRuntimeEndpoint = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5527,13 +5559,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RemoteImageEndpoint = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5541,24 +5573,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.RuntimeRequestTimeout = pkg1_unversioned.Duration{} } else { - yyv677 := &x.RuntimeRequestTimeout - yym678 := z.DecBinary() - _ = yym678 + yyv681 := &x.RuntimeRequestTimeout + yym682 := z.DecBinary() + _ = yym682 if false { - } else if z.HasExtensions() && z.DecExt(yyv677) { - } else if !yym678 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv677) + } else if z.HasExtensions() && z.DecExt(yyv681) { + } else if !yym682 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv681) } else { - z.DecFallback(yyv677, false) + z.DecFallback(yyv681, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5568,13 +5600,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RktPath = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5584,13 +5616,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RktAPIEndpoint = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5600,13 +5632,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RktStage1Image = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5616,13 +5648,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.LockFilePath = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5632,13 +5664,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ExitOnLockContention = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5648,13 +5680,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ConfigureCBR0 = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5664,13 +5696,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.HairpinMode = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5680,13 +5712,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.BabysitDaemons = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5696,13 +5728,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.MaxPods = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5712,13 +5744,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.NvidiaGPUs = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5728,13 +5760,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.DockerExecHandlerName = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5744,13 +5776,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.PodCIDR = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5760,13 +5792,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ResolverConfig = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5776,13 +5808,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.CPUCFSQuota = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5792,13 +5824,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.Containerized = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5808,13 +5840,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.MaxOpenFiles = int64(r.DecodeInt(64)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5824,13 +5856,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ReconcileCIDR = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5840,13 +5872,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.RegisterSchedulable = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5856,13 +5888,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ContentType = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5872,13 +5904,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.KubeAPIQPS = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5888,13 +5920,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.KubeAPIBurst = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5904,13 +5936,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.SerializeImagePulls = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5920,13 +5952,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ExperimentalFlannelOverlay = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5934,24 +5966,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.OutOfDiskTransitionFrequency = pkg1_unversioned.Duration{} } else { - yyv702 := &x.OutOfDiskTransitionFrequency - yym703 := z.DecBinary() - _ = yym703 + yyv706 := &x.OutOfDiskTransitionFrequency + yym707 := z.DecBinary() + _ = yym707 if false { - } else if z.HasExtensions() && z.DecExt(yyv702) { - } else if !yym703 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv702) + } else if z.HasExtensions() && z.DecExt(yyv706) { + } else if !yym707 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv706) } else { - z.DecFallback(yyv702, false) + z.DecFallback(yyv706, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5961,13 +5993,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.NodeIP = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5975,21 +6007,21 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.NodeLabels = nil } else { - yyv705 := &x.NodeLabels - yym706 := z.DecBinary() - _ = yym706 + yyv709 := &x.NodeLabels + yym710 := z.DecBinary() + _ = yym710 if false { } else { - z.F.DecMapStringStringX(yyv705, false, d) + z.F.DecMapStringStringX(yyv709, false, d) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -5999,13 +6031,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.NonMasqueradeCIDR = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6015,13 +6047,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EnableCustomMetrics = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6031,13 +6063,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EvictionHard = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6047,13 +6079,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EvictionSoft = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6063,13 +6095,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EvictionSoftGracePeriod = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6077,24 +6109,24 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.EvictionPressureTransitionPeriod = pkg1_unversioned.Duration{} } else { - yyv712 := &x.EvictionPressureTransitionPeriod - yym713 := z.DecBinary() - _ = yym713 + yyv716 := &x.EvictionPressureTransitionPeriod + yym717 := z.DecBinary() + _ = yym717 if false { - } else if z.HasExtensions() && z.DecExt(yyv712) { - } else if !yym713 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv712) + } else if z.HasExtensions() && z.DecExt(yyv716) { + } else if !yym717 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv716) } else { - z.DecFallback(yyv712, false) + z.DecFallback(yyv716, false) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6104,13 +6136,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EvictionMaxPodGracePeriod = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6120,13 +6152,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EvictionMinimumReclaim = string(r.DecodeString()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6136,13 +6168,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.PodsPerCore = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6152,13 +6184,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.EnableControllerAttachDetach = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6166,22 +6198,22 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.SystemReserved = nil } else { - yyv718 := &x.SystemReserved - yym719 := z.DecBinary() - _ = yym719 + yyv722 := &x.SystemReserved + yym723 := z.DecBinary() + _ = yym723 if false { - } else if z.HasExtensions() && z.DecExt(yyv718) { + } else if z.HasExtensions() && z.DecExt(yyv722) { } else { - h.decconfig_ConfigurationMap((*pkg2_config.ConfigurationMap)(yyv718), d) + h.decconfig_ConfigurationMap((*pkg2_config.ConfigurationMap)(yyv722), d) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6189,22 +6221,22 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.KubeReserved = nil } else { - yyv720 := &x.KubeReserved - yym721 := z.DecBinary() - _ = yym721 + yyv724 := &x.KubeReserved + yym725 := z.DecBinary() + _ = yym725 if false { - } else if z.HasExtensions() && z.DecExt(yyv720) { + } else if z.HasExtensions() && z.DecExt(yyv724) { } else { - h.decconfig_ConfigurationMap((*pkg2_config.ConfigurationMap)(yyv720), d) + h.decconfig_ConfigurationMap((*pkg2_config.ConfigurationMap)(yyv724), d) } } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6214,13 +6246,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.ProtectKernelDefaults = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6230,13 +6262,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.MakeIPTablesUtilChains = bool(r.DecodeBool()) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6246,13 +6278,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.IPTablesMasqueradeBit = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6262,13 +6294,13 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco } else { x.IPTablesDropBit = int32(r.DecodeInt(32)) } - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6276,26 +6308,42 @@ func (x *KubeletConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Deco if r.TryDecodeAsNil() { x.AllowedUnsafeSysctls = nil } else { - yyv726 := &x.AllowedUnsafeSysctls - yym727 := z.DecBinary() - _ = yym727 + yyv730 := &x.AllowedUnsafeSysctls + yym731 := z.DecBinary() + _ = yym731 if false { } else { - z.F.DecSliceStringX(yyv726, false, d) + z.F.DecSliceStringX(yyv730, false, d) } } + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l + } else { + yyb606 = r.CheckBreak() + } + if yyb606 { + z.DecSendContainerState(codecSelfer_containerArrayEnd1234) + return + } + z.DecSendContainerState(codecSelfer_containerArrayElem1234) + if r.TryDecodeAsNil() { + x.ExperimentalRuntimeIntegrationType = "" + } else { + x.ExperimentalRuntimeIntegrationType = string(r.DecodeString()) + } for { - yyj602++ - if yyhl602 { - yyb602 = yyj602 > l + yyj606++ + if yyhl606 { + yyb606 = yyj606 > l } else { - yyb602 = r.CheckBreak() + yyb606 = r.CheckBreak() } - if yyb602 { + if yyb606 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj602-1, "") + z.DecStructFieldNotFound(yyj606-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -6307,36 +6355,36 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { if x == nil { r.EncodeNil() } else { - yym728 := z.EncBinary() - _ = yym728 + yym733 := z.EncBinary() + _ = yym733 if false { } else if z.HasExtensions() && z.EncExt(x) { } else { - yysep729 := !z.EncBinary() - yy2arr729 := z.EncBasicHandle().StructToArray - var yyq729 [14]bool - _, _, _ = yysep729, yyq729, yy2arr729 - const yyr729 bool = false - yyq729[0] = x.Kind != "" - yyq729[1] = x.APIVersion != "" - var yynn729 int - if yyr729 || yy2arr729 { + yysep734 := !z.EncBinary() + yy2arr734 := z.EncBasicHandle().StructToArray + var yyq734 [14]bool + _, _, _ = yysep734, yyq734, yy2arr734 + const yyr734 bool = false + yyq734[0] = x.Kind != "" + yyq734[1] = x.APIVersion != "" + var yynn734 int + if yyr734 || yy2arr734 { r.EncodeArrayStart(14) } else { - yynn729 = 12 - for _, b := range yyq729 { + yynn734 = 12 + for _, b := range yyq734 { if b { - yynn729++ + yynn734++ } } - r.EncodeMapStart(yynn729) - yynn729 = 0 + r.EncodeMapStart(yynn734) + yynn734 = 0 } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if yyq729[0] { - yym731 := z.EncBinary() - _ = yym731 + if yyq734[0] { + yym736 := z.EncBinary() + _ = yym736 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) @@ -6345,23 +6393,23 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeString(codecSelferC_UTF81234, "") } } else { - if yyq729[0] { + if yyq734[0] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("kind")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym732 := z.EncBinary() - _ = yym732 + yym737 := z.EncBinary() + _ = yym737 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) } } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if yyq729[1] { - yym734 := z.EncBinary() - _ = yym734 + if yyq734[1] { + yym739 := z.EncBinary() + _ = yym739 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) @@ -6370,22 +6418,22 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeString(codecSelferC_UTF81234, "") } } else { - if yyq729[1] { + if yyq734[1] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("apiVersion")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym735 := z.EncBinary() - _ = yym735 + yym740 := z.EncBinary() + _ = yym740 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) } } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym737 := z.EncBinary() - _ = yym737 + yym742 := z.EncBinary() + _ = yym742 if false { } else { r.EncodeInt(int64(x.Port)) @@ -6394,17 +6442,17 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("port")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym738 := z.EncBinary() - _ = yym738 + yym743 := z.EncBinary() + _ = yym743 if false { } else { r.EncodeInt(int64(x.Port)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym740 := z.EncBinary() - _ = yym740 + yym745 := z.EncBinary() + _ = yym745 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.Address)) @@ -6413,17 +6461,17 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("address")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym741 := z.EncBinary() - _ = yym741 + yym746 := z.EncBinary() + _ = yym746 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.Address)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym743 := z.EncBinary() - _ = yym743 + yym748 := z.EncBinary() + _ = yym748 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.AlgorithmProvider)) @@ -6432,17 +6480,17 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("algorithmProvider")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym744 := z.EncBinary() - _ = yym744 + yym749 := z.EncBinary() + _ = yym749 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.AlgorithmProvider)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym746 := z.EncBinary() - _ = yym746 + yym751 := z.EncBinary() + _ = yym751 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.PolicyConfigFile)) @@ -6451,17 +6499,17 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("policyConfigFile")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym747 := z.EncBinary() - _ = yym747 + yym752 := z.EncBinary() + _ = yym752 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.PolicyConfigFile)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym749 := z.EncBinary() - _ = yym749 + yym754 := z.EncBinary() + _ = yym754 if false { } else { r.EncodeBool(bool(x.EnableProfiling)) @@ -6470,17 +6518,17 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("enableProfiling")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym750 := z.EncBinary() - _ = yym750 + yym755 := z.EncBinary() + _ = yym755 if false { } else { r.EncodeBool(bool(x.EnableProfiling)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym752 := z.EncBinary() - _ = yym752 + yym757 := z.EncBinary() + _ = yym757 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ContentType)) @@ -6489,17 +6537,17 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("contentType")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym753 := z.EncBinary() - _ = yym753 + yym758 := z.EncBinary() + _ = yym758 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ContentType)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym755 := z.EncBinary() - _ = yym755 + yym760 := z.EncBinary() + _ = yym760 if false { } else { r.EncodeFloat32(float32(x.KubeAPIQPS)) @@ -6508,17 +6556,17 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("kubeAPIQPS")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym756 := z.EncBinary() - _ = yym756 + yym761 := z.EncBinary() + _ = yym761 if false { } else { r.EncodeFloat32(float32(x.KubeAPIQPS)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym758 := z.EncBinary() - _ = yym758 + yym763 := z.EncBinary() + _ = yym763 if false { } else { r.EncodeInt(int64(x.KubeAPIBurst)) @@ -6527,17 +6575,17 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("kubeAPIBurst")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym759 := z.EncBinary() - _ = yym759 + yym764 := z.EncBinary() + _ = yym764 if false { } else { r.EncodeInt(int64(x.KubeAPIBurst)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym761 := z.EncBinary() - _ = yym761 + yym766 := z.EncBinary() + _ = yym766 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.SchedulerName)) @@ -6546,17 +6594,17 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("schedulerName")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym762 := z.EncBinary() - _ = yym762 + yym767 := z.EncBinary() + _ = yym767 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.SchedulerName)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym764 := z.EncBinary() - _ = yym764 + yym769 := z.EncBinary() + _ = yym769 if false { } else { r.EncodeInt(int64(x.HardPodAffinitySymmetricWeight)) @@ -6565,17 +6613,17 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("hardPodAffinitySymmetricWeight")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym765 := z.EncBinary() - _ = yym765 + yym770 := z.EncBinary() + _ = yym770 if false { } else { r.EncodeInt(int64(x.HardPodAffinitySymmetricWeight)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym767 := z.EncBinary() - _ = yym767 + yym772 := z.EncBinary() + _ = yym772 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.FailureDomains)) @@ -6584,25 +6632,25 @@ func (x *KubeSchedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("failureDomains")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym768 := z.EncBinary() - _ = yym768 + yym773 := z.EncBinary() + _ = yym773 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.FailureDomains)) } } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy770 := &x.LeaderElection - yy770.CodecEncodeSelf(e) + yy775 := &x.LeaderElection + yy775.CodecEncodeSelf(e) } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("leaderElection")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy771 := &x.LeaderElection - yy771.CodecEncodeSelf(e) + yy776 := &x.LeaderElection + yy776.CodecEncodeSelf(e) } - if yyr729 || yy2arr729 { + if yyr734 || yy2arr734 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) } else { z.EncSendContainerState(codecSelfer_containerMapEnd1234) @@ -6615,25 +6663,25 @@ func (x *KubeSchedulerConfiguration) CodecDecodeSelf(d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - yym772 := z.DecBinary() - _ = yym772 + yym777 := z.DecBinary() + _ = yym777 if false { } else if z.HasExtensions() && z.DecExt(x) { } else { - yyct773 := r.ContainerType() - if yyct773 == codecSelferValueTypeMap1234 { - yyl773 := r.ReadMapStart() - if yyl773 == 0 { + yyct778 := r.ContainerType() + if yyct778 == codecSelferValueTypeMap1234 { + yyl778 := r.ReadMapStart() + if yyl778 == 0 { z.DecSendContainerState(codecSelfer_containerMapEnd1234) } else { - x.codecDecodeSelfFromMap(yyl773, d) + x.codecDecodeSelfFromMap(yyl778, d) } - } else if yyct773 == codecSelferValueTypeArray1234 { - yyl773 := r.ReadArrayStart() - if yyl773 == 0 { + } else if yyct778 == codecSelferValueTypeArray1234 { + yyl778 := r.ReadArrayStart() + if yyl778 == 0 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } else { - x.codecDecodeSelfFromArray(yyl773, d) + x.codecDecodeSelfFromArray(yyl778, d) } } else { panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) @@ -6645,12 +6693,12 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromMap(l int, d *codec1978. var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yys774Slc = z.DecScratchBuffer() // default slice to decode into - _ = yys774Slc - var yyhl774 bool = l >= 0 - for yyj774 := 0; ; yyj774++ { - if yyhl774 { - if yyj774 >= l { + var yys779Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys779Slc + var yyhl779 bool = l >= 0 + for yyj779 := 0; ; yyj779++ { + if yyhl779 { + if yyj779 >= l { break } } else { @@ -6659,10 +6707,10 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromMap(l int, d *codec1978. } } z.DecSendContainerState(codecSelfer_containerMapKey1234) - yys774Slc = r.DecodeBytes(yys774Slc, true, true) - yys774 := string(yys774Slc) + yys779Slc = r.DecodeBytes(yys779Slc, true, true) + yys779 := string(yys779Slc) z.DecSendContainerState(codecSelfer_containerMapValue1234) - switch yys774 { + switch yys779 { case "kind": if r.TryDecodeAsNil() { x.Kind = "" @@ -6745,13 +6793,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromMap(l int, d *codec1978. if r.TryDecodeAsNil() { x.LeaderElection = LeaderElectionConfiguration{} } else { - yyv788 := &x.LeaderElection - yyv788.CodecDecodeSelf(d) + yyv793 := &x.LeaderElection + yyv793.CodecDecodeSelf(d) } default: - z.DecStructFieldNotFound(-1, yys774) - } // end switch yys774 - } // end for yyj774 + z.DecStructFieldNotFound(-1, yys779) + } // end switch yys779 + } // end for yyj779 z.DecSendContainerState(codecSelfer_containerMapEnd1234) } @@ -6759,16 +6807,16 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj789 int - var yyb789 bool - var yyhl789 bool = l >= 0 - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + var yyj794 int + var yyb794 bool + var yyhl794 bool = l >= 0 + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6778,13 +6826,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.Kind = string(r.DecodeString()) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6794,13 +6842,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.APIVersion = string(r.DecodeString()) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6810,13 +6858,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.Port = int32(r.DecodeInt(32)) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6826,13 +6874,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.Address = string(r.DecodeString()) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6842,13 +6890,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.AlgorithmProvider = string(r.DecodeString()) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6858,13 +6906,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.PolicyConfigFile = string(r.DecodeString()) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6874,13 +6922,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.EnableProfiling = bool(r.DecodeBool()) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6890,13 +6938,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.ContentType = string(r.DecodeString()) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6906,13 +6954,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.KubeAPIQPS = float32(r.DecodeFloat(true)) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6922,13 +6970,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.KubeAPIBurst = int32(r.DecodeInt(32)) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6938,13 +6986,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.SchedulerName = string(r.DecodeString()) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6954,13 +7002,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.HardPodAffinitySymmetricWeight = int(r.DecodeInt(codecSelferBitsize1234)) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6970,13 +7018,13 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 } else { x.FailureDomains = string(r.DecodeString()) } - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -6984,21 +7032,21 @@ func (x *KubeSchedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec197 if r.TryDecodeAsNil() { x.LeaderElection = LeaderElectionConfiguration{} } else { - yyv803 := &x.LeaderElection - yyv803.CodecDecodeSelf(d) + yyv808 := &x.LeaderElection + yyv808.CodecDecodeSelf(d) } for { - yyj789++ - if yyhl789 { - yyb789 = yyj789 > l + yyj794++ + if yyhl794 { + yyb794 = yyj794 > l } else { - yyb789 = r.CheckBreak() + yyb794 = r.CheckBreak() } - if yyb789 { + if yyb794 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj789-1, "") + z.DecStructFieldNotFound(yyj794-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -7010,33 +7058,33 @@ func (x *LeaderElectionConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { if x == nil { r.EncodeNil() } else { - yym804 := z.EncBinary() - _ = yym804 + yym809 := z.EncBinary() + _ = yym809 if false { } else if z.HasExtensions() && z.EncExt(x) { } else { - yysep805 := !z.EncBinary() - yy2arr805 := z.EncBasicHandle().StructToArray - var yyq805 [4]bool - _, _, _ = yysep805, yyq805, yy2arr805 - const yyr805 bool = false - var yynn805 int - if yyr805 || yy2arr805 { + yysep810 := !z.EncBinary() + yy2arr810 := z.EncBasicHandle().StructToArray + var yyq810 [4]bool + _, _, _ = yysep810, yyq810, yy2arr810 + const yyr810 bool = false + var yynn810 int + if yyr810 || yy2arr810 { r.EncodeArrayStart(4) } else { - yynn805 = 4 - for _, b := range yyq805 { + yynn810 = 4 + for _, b := range yyq810 { if b { - yynn805++ + yynn810++ } } - r.EncodeMapStart(yynn805) - yynn805 = 0 + r.EncodeMapStart(yynn810) + yynn810 = 0 } - if yyr805 || yy2arr805 { + if yyr810 || yy2arr810 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym807 := z.EncBinary() - _ = yym807 + yym812 := z.EncBinary() + _ = yym812 if false { } else { r.EncodeBool(bool(x.LeaderElect)) @@ -7045,43 +7093,16 @@ func (x *LeaderElectionConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("leaderElect")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym808 := z.EncBinary() - _ = yym808 - if false { - } else { - r.EncodeBool(bool(x.LeaderElect)) - } - } - if yyr805 || yy2arr805 { - z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy810 := &x.LeaseDuration - yym811 := z.EncBinary() - _ = yym811 - if false { - } else if z.HasExtensions() && z.EncExt(yy810) { - } else if !yym811 && z.IsJSONHandle() { - z.EncJSONMarshal(yy810) - } else { - z.EncFallback(yy810) - } - } else { - z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("leaseDuration")) - z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy812 := &x.LeaseDuration yym813 := z.EncBinary() _ = yym813 if false { - } else if z.HasExtensions() && z.EncExt(yy812) { - } else if !yym813 && z.IsJSONHandle() { - z.EncJSONMarshal(yy812) } else { - z.EncFallback(yy812) + r.EncodeBool(bool(x.LeaderElect)) } } - if yyr805 || yy2arr805 { + if yyr810 || yy2arr810 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy815 := &x.RenewDeadline + yy815 := &x.LeaseDuration yym816 := z.EncBinary() _ = yym816 if false { @@ -7093,9 +7114,9 @@ func (x *LeaderElectionConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("renewDeadline")) + r.EncodeString(codecSelferC_UTF81234, string("leaseDuration")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy817 := &x.RenewDeadline + yy817 := &x.LeaseDuration yym818 := z.EncBinary() _ = yym818 if false { @@ -7106,9 +7127,9 @@ func (x *LeaderElectionConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncFallback(yy817) } } - if yyr805 || yy2arr805 { + if yyr810 || yy2arr810 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy820 := &x.RetryPeriod + yy820 := &x.RenewDeadline yym821 := z.EncBinary() _ = yym821 if false { @@ -7120,9 +7141,9 @@ func (x *LeaderElectionConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("retryPeriod")) + r.EncodeString(codecSelferC_UTF81234, string("renewDeadline")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy822 := &x.RetryPeriod + yy822 := &x.RenewDeadline yym823 := z.EncBinary() _ = yym823 if false { @@ -7133,7 +7154,34 @@ func (x *LeaderElectionConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncFallback(yy822) } } - if yyr805 || yy2arr805 { + if yyr810 || yy2arr810 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yy825 := &x.RetryPeriod + yym826 := z.EncBinary() + _ = yym826 + if false { + } else if z.HasExtensions() && z.EncExt(yy825) { + } else if !yym826 && z.IsJSONHandle() { + z.EncJSONMarshal(yy825) + } else { + z.EncFallback(yy825) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("retryPeriod")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy827 := &x.RetryPeriod + yym828 := z.EncBinary() + _ = yym828 + if false { + } else if z.HasExtensions() && z.EncExt(yy827) { + } else if !yym828 && z.IsJSONHandle() { + z.EncJSONMarshal(yy827) + } else { + z.EncFallback(yy827) + } + } + if yyr810 || yy2arr810 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) } else { z.EncSendContainerState(codecSelfer_containerMapEnd1234) @@ -7146,25 +7194,25 @@ func (x *LeaderElectionConfiguration) CodecDecodeSelf(d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - yym824 := z.DecBinary() - _ = yym824 + yym829 := z.DecBinary() + _ = yym829 if false { } else if z.HasExtensions() && z.DecExt(x) { } else { - yyct825 := r.ContainerType() - if yyct825 == codecSelferValueTypeMap1234 { - yyl825 := r.ReadMapStart() - if yyl825 == 0 { + yyct830 := r.ContainerType() + if yyct830 == codecSelferValueTypeMap1234 { + yyl830 := r.ReadMapStart() + if yyl830 == 0 { z.DecSendContainerState(codecSelfer_containerMapEnd1234) } else { - x.codecDecodeSelfFromMap(yyl825, d) + x.codecDecodeSelfFromMap(yyl830, d) } - } else if yyct825 == codecSelferValueTypeArray1234 { - yyl825 := r.ReadArrayStart() - if yyl825 == 0 { + } else if yyct830 == codecSelferValueTypeArray1234 { + yyl830 := r.ReadArrayStart() + if yyl830 == 0 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } else { - x.codecDecodeSelfFromArray(yyl825, d) + x.codecDecodeSelfFromArray(yyl830, d) } } else { panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) @@ -7176,12 +7224,12 @@ func (x *LeaderElectionConfiguration) codecDecodeSelfFromMap(l int, d *codec1978 var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yys826Slc = z.DecScratchBuffer() // default slice to decode into - _ = yys826Slc - var yyhl826 bool = l >= 0 - for yyj826 := 0; ; yyj826++ { - if yyhl826 { - if yyj826 >= l { + var yys831Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys831Slc + var yyhl831 bool = l >= 0 + for yyj831 := 0; ; yyj831++ { + if yyhl831 { + if yyj831 >= l { break } } else { @@ -7190,10 +7238,10 @@ func (x *LeaderElectionConfiguration) codecDecodeSelfFromMap(l int, d *codec1978 } } z.DecSendContainerState(codecSelfer_containerMapKey1234) - yys826Slc = r.DecodeBytes(yys826Slc, true, true) - yys826 := string(yys826Slc) + yys831Slc = r.DecodeBytes(yys831Slc, true, true) + yys831 := string(yys831Slc) z.DecSendContainerState(codecSelfer_containerMapValue1234) - switch yys826 { + switch yys831 { case "leaderElect": if r.TryDecodeAsNil() { x.LeaderElect = false @@ -7204,51 +7252,51 @@ func (x *LeaderElectionConfiguration) codecDecodeSelfFromMap(l int, d *codec1978 if r.TryDecodeAsNil() { x.LeaseDuration = pkg1_unversioned.Duration{} } else { - yyv828 := &x.LeaseDuration - yym829 := z.DecBinary() - _ = yym829 + yyv833 := &x.LeaseDuration + yym834 := z.DecBinary() + _ = yym834 if false { - } else if z.HasExtensions() && z.DecExt(yyv828) { - } else if !yym829 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv828) + } else if z.HasExtensions() && z.DecExt(yyv833) { + } else if !yym834 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv833) } else { - z.DecFallback(yyv828, false) + z.DecFallback(yyv833, false) } } case "renewDeadline": if r.TryDecodeAsNil() { x.RenewDeadline = pkg1_unversioned.Duration{} } else { - yyv830 := &x.RenewDeadline - yym831 := z.DecBinary() - _ = yym831 + yyv835 := &x.RenewDeadline + yym836 := z.DecBinary() + _ = yym836 if false { - } else if z.HasExtensions() && z.DecExt(yyv830) { - } else if !yym831 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv830) + } else if z.HasExtensions() && z.DecExt(yyv835) { + } else if !yym836 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv835) } else { - z.DecFallback(yyv830, false) + z.DecFallback(yyv835, false) } } case "retryPeriod": if r.TryDecodeAsNil() { x.RetryPeriod = pkg1_unversioned.Duration{} } else { - yyv832 := &x.RetryPeriod - yym833 := z.DecBinary() - _ = yym833 + yyv837 := &x.RetryPeriod + yym838 := z.DecBinary() + _ = yym838 if false { - } else if z.HasExtensions() && z.DecExt(yyv832) { - } else if !yym833 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv832) + } else if z.HasExtensions() && z.DecExt(yyv837) { + } else if !yym838 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv837) } else { - z.DecFallback(yyv832, false) + z.DecFallback(yyv837, false) } } default: - z.DecStructFieldNotFound(-1, yys826) - } // end switch yys826 - } // end for yyj826 + z.DecStructFieldNotFound(-1, yys831) + } // end switch yys831 + } // end for yyj831 z.DecSendContainerState(codecSelfer_containerMapEnd1234) } @@ -7256,16 +7304,16 @@ func (x *LeaderElectionConfiguration) codecDecodeSelfFromArray(l int, d *codec19 var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj834 int - var yyb834 bool - var yyhl834 bool = l >= 0 - yyj834++ - if yyhl834 { - yyb834 = yyj834 > l + var yyj839 int + var yyb839 bool + var yyhl839 bool = l >= 0 + yyj839++ + if yyhl839 { + yyb839 = yyj839 > l } else { - yyb834 = r.CheckBreak() + yyb839 = r.CheckBreak() } - if yyb834 { + if yyb839 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -7275,13 +7323,13 @@ func (x *LeaderElectionConfiguration) codecDecodeSelfFromArray(l int, d *codec19 } else { x.LeaderElect = bool(r.DecodeBool()) } - yyj834++ - if yyhl834 { - yyb834 = yyj834 > l + yyj839++ + if yyhl839 { + yyb839 = yyj839 > l } else { - yyb834 = r.CheckBreak() + yyb839 = r.CheckBreak() } - if yyb834 { + if yyb839 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -7289,24 +7337,24 @@ func (x *LeaderElectionConfiguration) codecDecodeSelfFromArray(l int, d *codec19 if r.TryDecodeAsNil() { x.LeaseDuration = pkg1_unversioned.Duration{} } else { - yyv836 := &x.LeaseDuration - yym837 := z.DecBinary() - _ = yym837 + yyv841 := &x.LeaseDuration + yym842 := z.DecBinary() + _ = yym842 if false { - } else if z.HasExtensions() && z.DecExt(yyv836) { - } else if !yym837 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv836) + } else if z.HasExtensions() && z.DecExt(yyv841) { + } else if !yym842 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv841) } else { - z.DecFallback(yyv836, false) + z.DecFallback(yyv841, false) } } - yyj834++ - if yyhl834 { - yyb834 = yyj834 > l + yyj839++ + if yyhl839 { + yyb839 = yyj839 > l } else { - yyb834 = r.CheckBreak() + yyb839 = r.CheckBreak() } - if yyb834 { + if yyb839 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -7314,24 +7362,24 @@ func (x *LeaderElectionConfiguration) codecDecodeSelfFromArray(l int, d *codec19 if r.TryDecodeAsNil() { x.RenewDeadline = pkg1_unversioned.Duration{} } else { - yyv838 := &x.RenewDeadline - yym839 := z.DecBinary() - _ = yym839 + yyv843 := &x.RenewDeadline + yym844 := z.DecBinary() + _ = yym844 if false { - } else if z.HasExtensions() && z.DecExt(yyv838) { - } else if !yym839 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv838) + } else if z.HasExtensions() && z.DecExt(yyv843) { + } else if !yym844 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv843) } else { - z.DecFallback(yyv838, false) + z.DecFallback(yyv843, false) } } - yyj834++ - if yyhl834 { - yyb834 = yyj834 > l + yyj839++ + if yyhl839 { + yyb839 = yyj839 > l } else { - yyb834 = r.CheckBreak() + yyb839 = r.CheckBreak() } - if yyb834 { + if yyb839 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -7339,29 +7387,29 @@ func (x *LeaderElectionConfiguration) codecDecodeSelfFromArray(l int, d *codec19 if r.TryDecodeAsNil() { x.RetryPeriod = pkg1_unversioned.Duration{} } else { - yyv840 := &x.RetryPeriod - yym841 := z.DecBinary() - _ = yym841 + yyv845 := &x.RetryPeriod + yym846 := z.DecBinary() + _ = yym846 if false { - } else if z.HasExtensions() && z.DecExt(yyv840) { - } else if !yym841 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv840) + } else if z.HasExtensions() && z.DecExt(yyv845) { + } else if !yym846 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv845) } else { - z.DecFallback(yyv840, false) + z.DecFallback(yyv845, false) } } for { - yyj834++ - if yyhl834 { - yyb834 = yyj834 > l + yyj839++ + if yyhl839 { + yyb839 = yyj839 > l } else { - yyb834 = r.CheckBreak() + yyb839 = r.CheckBreak() } - if yyb834 { + if yyb839 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj834-1, "") + z.DecStructFieldNotFound(yyj839-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -7373,36 +7421,36 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode if x == nil { r.EncodeNil() } else { - yym842 := z.EncBinary() - _ = yym842 + yym847 := z.EncBinary() + _ = yym847 if false { } else if z.HasExtensions() && z.EncExt(x) { } else { - yysep843 := !z.EncBinary() - yy2arr843 := z.EncBasicHandle().StructToArray - var yyq843 [60]bool - _, _, _ = yysep843, yyq843, yy2arr843 - const yyr843 bool = false - yyq843[0] = x.Kind != "" - yyq843[1] = x.APIVersion != "" - var yynn843 int - if yyr843 || yy2arr843 { + yysep848 := !z.EncBinary() + yy2arr848 := z.EncBasicHandle().StructToArray + var yyq848 [60]bool + _, _, _ = yysep848, yyq848, yy2arr848 + const yyr848 bool = false + yyq848[0] = x.Kind != "" + yyq848[1] = x.APIVersion != "" + var yynn848 int + if yyr848 || yy2arr848 { r.EncodeArrayStart(60) } else { - yynn843 = 58 - for _, b := range yyq843 { + yynn848 = 58 + for _, b := range yyq848 { if b { - yynn843++ + yynn848++ } } - r.EncodeMapStart(yynn843) - yynn843 = 0 + r.EncodeMapStart(yynn848) + yynn848 = 0 } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if yyq843[0] { - yym845 := z.EncBinary() - _ = yym845 + if yyq848[0] { + yym850 := z.EncBinary() + _ = yym850 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) @@ -7411,23 +7459,23 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode r.EncodeString(codecSelferC_UTF81234, "") } } else { - if yyq843[0] { + if yyq848[0] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("kind")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym846 := z.EncBinary() - _ = yym846 + yym851 := z.EncBinary() + _ = yym851 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) } } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if yyq843[1] { - yym848 := z.EncBinary() - _ = yym848 + if yyq848[1] { + yym853 := z.EncBinary() + _ = yym853 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) @@ -7436,22 +7484,22 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode r.EncodeString(codecSelferC_UTF81234, "") } } else { - if yyq843[1] { + if yyq848[1] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("apiVersion")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym849 := z.EncBinary() - _ = yym849 + yym854 := z.EncBinary() + _ = yym854 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) } } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym851 := z.EncBinary() - _ = yym851 + yym856 := z.EncBinary() + _ = yym856 if false { } else { r.EncodeInt(int64(x.Port)) @@ -7460,17 +7508,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("port")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym852 := z.EncBinary() - _ = yym852 + yym857 := z.EncBinary() + _ = yym857 if false { } else { r.EncodeInt(int64(x.Port)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym854 := z.EncBinary() - _ = yym854 + yym859 := z.EncBinary() + _ = yym859 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.Address)) @@ -7479,17 +7527,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("address")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym855 := z.EncBinary() - _ = yym855 + yym860 := z.EncBinary() + _ = yym860 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.Address)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym857 := z.EncBinary() - _ = yym857 + yym862 := z.EncBinary() + _ = yym862 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.CloudProvider)) @@ -7498,17 +7546,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("cloudProvider")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym858 := z.EncBinary() - _ = yym858 + yym863 := z.EncBinary() + _ = yym863 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.CloudProvider)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym860 := z.EncBinary() - _ = yym860 + yym865 := z.EncBinary() + _ = yym865 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.CloudConfigFile)) @@ -7517,17 +7565,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("cloudConfigFile")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym861 := z.EncBinary() - _ = yym861 + yym866 := z.EncBinary() + _ = yym866 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.CloudConfigFile)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym863 := z.EncBinary() - _ = yym863 + yym868 := z.EncBinary() + _ = yym868 if false { } else { r.EncodeInt(int64(x.ConcurrentEndpointSyncs)) @@ -7536,17 +7584,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentEndpointSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym864 := z.EncBinary() - _ = yym864 + yym869 := z.EncBinary() + _ = yym869 if false { } else { r.EncodeInt(int64(x.ConcurrentEndpointSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym866 := z.EncBinary() - _ = yym866 + yym871 := z.EncBinary() + _ = yym871 if false { } else { r.EncodeInt(int64(x.ConcurrentRSSyncs)) @@ -7555,17 +7603,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentRSSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym867 := z.EncBinary() - _ = yym867 + yym872 := z.EncBinary() + _ = yym872 if false { } else { r.EncodeInt(int64(x.ConcurrentRSSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym869 := z.EncBinary() - _ = yym869 + yym874 := z.EncBinary() + _ = yym874 if false { } else { r.EncodeInt(int64(x.ConcurrentRCSyncs)) @@ -7574,17 +7622,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentRCSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym870 := z.EncBinary() - _ = yym870 + yym875 := z.EncBinary() + _ = yym875 if false { } else { r.EncodeInt(int64(x.ConcurrentRCSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym872 := z.EncBinary() - _ = yym872 + yym877 := z.EncBinary() + _ = yym877 if false { } else { r.EncodeInt(int64(x.ConcurrentServiceSyncs)) @@ -7593,17 +7641,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentServiceSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym873 := z.EncBinary() - _ = yym873 + yym878 := z.EncBinary() + _ = yym878 if false { } else { r.EncodeInt(int64(x.ConcurrentServiceSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym875 := z.EncBinary() - _ = yym875 + yym880 := z.EncBinary() + _ = yym880 if false { } else { r.EncodeInt(int64(x.ConcurrentResourceQuotaSyncs)) @@ -7612,17 +7660,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentResourceQuotaSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym876 := z.EncBinary() - _ = yym876 + yym881 := z.EncBinary() + _ = yym881 if false { } else { r.EncodeInt(int64(x.ConcurrentResourceQuotaSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym878 := z.EncBinary() - _ = yym878 + yym883 := z.EncBinary() + _ = yym883 if false { } else { r.EncodeInt(int64(x.ConcurrentDeploymentSyncs)) @@ -7631,17 +7679,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentDeploymentSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym879 := z.EncBinary() - _ = yym879 + yym884 := z.EncBinary() + _ = yym884 if false { } else { r.EncodeInt(int64(x.ConcurrentDeploymentSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym881 := z.EncBinary() - _ = yym881 + yym886 := z.EncBinary() + _ = yym886 if false { } else { r.EncodeInt(int64(x.ConcurrentDaemonSetSyncs)) @@ -7650,17 +7698,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentDaemonSetSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym882 := z.EncBinary() - _ = yym882 + yym887 := z.EncBinary() + _ = yym887 if false { } else { r.EncodeInt(int64(x.ConcurrentDaemonSetSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym884 := z.EncBinary() - _ = yym884 + yym889 := z.EncBinary() + _ = yym889 if false { } else { r.EncodeInt(int64(x.ConcurrentJobSyncs)) @@ -7669,17 +7717,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentJobSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym885 := z.EncBinary() - _ = yym885 + yym890 := z.EncBinary() + _ = yym890 if false { } else { r.EncodeInt(int64(x.ConcurrentJobSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym887 := z.EncBinary() - _ = yym887 + yym892 := z.EncBinary() + _ = yym892 if false { } else { r.EncodeInt(int64(x.ConcurrentNamespaceSyncs)) @@ -7688,17 +7736,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentNamespaceSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym888 := z.EncBinary() - _ = yym888 + yym893 := z.EncBinary() + _ = yym893 if false { } else { r.EncodeInt(int64(x.ConcurrentNamespaceSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym890 := z.EncBinary() - _ = yym890 + yym895 := z.EncBinary() + _ = yym895 if false { } else { r.EncodeInt(int64(x.ConcurrentSATokenSyncs)) @@ -7707,17 +7755,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentSATokenSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym891 := z.EncBinary() - _ = yym891 + yym896 := z.EncBinary() + _ = yym896 if false { } else { r.EncodeInt(int64(x.ConcurrentSATokenSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym893 := z.EncBinary() - _ = yym893 + yym898 := z.EncBinary() + _ = yym898 if false { } else { r.EncodeInt(int64(x.LookupCacheSizeForRC)) @@ -7726,17 +7774,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("lookupCacheSizeForRC")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym894 := z.EncBinary() - _ = yym894 + yym899 := z.EncBinary() + _ = yym899 if false { } else { r.EncodeInt(int64(x.LookupCacheSizeForRC)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym896 := z.EncBinary() - _ = yym896 + yym901 := z.EncBinary() + _ = yym901 if false { } else { r.EncodeInt(int64(x.LookupCacheSizeForRS)) @@ -7745,17 +7793,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("lookupCacheSizeForRS")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym897 := z.EncBinary() - _ = yym897 + yym902 := z.EncBinary() + _ = yym902 if false { } else { r.EncodeInt(int64(x.LookupCacheSizeForRS)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym899 := z.EncBinary() - _ = yym899 + yym904 := z.EncBinary() + _ = yym904 if false { } else { r.EncodeInt(int64(x.LookupCacheSizeForDaemonSet)) @@ -7764,43 +7812,16 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("lookupCacheSizeForDaemonSet")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym900 := z.EncBinary() - _ = yym900 - if false { - } else { - r.EncodeInt(int64(x.LookupCacheSizeForDaemonSet)) - } - } - if yyr843 || yy2arr843 { - z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy902 := &x.ServiceSyncPeriod - yym903 := z.EncBinary() - _ = yym903 - if false { - } else if z.HasExtensions() && z.EncExt(yy902) { - } else if !yym903 && z.IsJSONHandle() { - z.EncJSONMarshal(yy902) - } else { - z.EncFallback(yy902) - } - } else { - z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("serviceSyncPeriod")) - z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy904 := &x.ServiceSyncPeriod yym905 := z.EncBinary() _ = yym905 if false { - } else if z.HasExtensions() && z.EncExt(yy904) { - } else if !yym905 && z.IsJSONHandle() { - z.EncJSONMarshal(yy904) } else { - z.EncFallback(yy904) + r.EncodeInt(int64(x.LookupCacheSizeForDaemonSet)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy907 := &x.NodeSyncPeriod + yy907 := &x.ServiceSyncPeriod yym908 := z.EncBinary() _ = yym908 if false { @@ -7812,9 +7833,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("nodeSyncPeriod")) + r.EncodeString(codecSelferC_UTF81234, string("serviceSyncPeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy909 := &x.NodeSyncPeriod + yy909 := &x.ServiceSyncPeriod yym910 := z.EncBinary() _ = yym910 if false { @@ -7825,9 +7846,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncFallback(yy909) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy912 := &x.RouteReconciliationPeriod + yy912 := &x.NodeSyncPeriod yym913 := z.EncBinary() _ = yym913 if false { @@ -7839,9 +7860,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("routeReconciliationPeriod")) + r.EncodeString(codecSelferC_UTF81234, string("nodeSyncPeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy914 := &x.RouteReconciliationPeriod + yy914 := &x.NodeSyncPeriod yym915 := z.EncBinary() _ = yym915 if false { @@ -7852,9 +7873,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncFallback(yy914) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy917 := &x.ResourceQuotaSyncPeriod + yy917 := &x.RouteReconciliationPeriod yym918 := z.EncBinary() _ = yym918 if false { @@ -7866,9 +7887,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("resourceQuotaSyncPeriod")) + r.EncodeString(codecSelferC_UTF81234, string("routeReconciliationPeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy919 := &x.ResourceQuotaSyncPeriod + yy919 := &x.RouteReconciliationPeriod yym920 := z.EncBinary() _ = yym920 if false { @@ -7879,9 +7900,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncFallback(yy919) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy922 := &x.NamespaceSyncPeriod + yy922 := &x.ResourceQuotaSyncPeriod yym923 := z.EncBinary() _ = yym923 if false { @@ -7893,9 +7914,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("namespaceSyncPeriod")) + r.EncodeString(codecSelferC_UTF81234, string("resourceQuotaSyncPeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy924 := &x.NamespaceSyncPeriod + yy924 := &x.ResourceQuotaSyncPeriod yym925 := z.EncBinary() _ = yym925 if false { @@ -7906,9 +7927,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncFallback(yy924) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy927 := &x.PVClaimBinderSyncPeriod + yy927 := &x.NamespaceSyncPeriod yym928 := z.EncBinary() _ = yym928 if false { @@ -7920,9 +7941,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("pvClaimBinderSyncPeriod")) + r.EncodeString(codecSelferC_UTF81234, string("namespaceSyncPeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy929 := &x.PVClaimBinderSyncPeriod + yy929 := &x.NamespaceSyncPeriod yym930 := z.EncBinary() _ = yym930 if false { @@ -7933,9 +7954,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncFallback(yy929) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy932 := &x.MinResyncPeriod + yy932 := &x.PVClaimBinderSyncPeriod yym933 := z.EncBinary() _ = yym933 if false { @@ -7947,9 +7968,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("minResyncPeriod")) + r.EncodeString(codecSelferC_UTF81234, string("pvClaimBinderSyncPeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy934 := &x.MinResyncPeriod + yy934 := &x.PVClaimBinderSyncPeriod yym935 := z.EncBinary() _ = yym935 if false { @@ -7960,55 +7981,55 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncFallback(yy934) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym937 := z.EncBinary() - _ = yym937 + yy937 := &x.MinResyncPeriod + yym938 := z.EncBinary() + _ = yym938 if false { + } else if z.HasExtensions() && z.EncExt(yy937) { + } else if !yym938 && z.IsJSONHandle() { + z.EncJSONMarshal(yy937) } else { - r.EncodeInt(int64(x.TerminatedPodGCThreshold)) + z.EncFallback(yy937) } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("terminatedPodGCThreshold")) + r.EncodeString(codecSelferC_UTF81234, string("minResyncPeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym938 := z.EncBinary() - _ = yym938 + yy939 := &x.MinResyncPeriod + yym940 := z.EncBinary() + _ = yym940 if false { + } else if z.HasExtensions() && z.EncExt(yy939) { + } else if !yym940 && z.IsJSONHandle() { + z.EncJSONMarshal(yy939) } else { - r.EncodeInt(int64(x.TerminatedPodGCThreshold)) + z.EncFallback(yy939) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy940 := &x.HorizontalPodAutoscalerSyncPeriod - yym941 := z.EncBinary() - _ = yym941 + yym942 := z.EncBinary() + _ = yym942 if false { - } else if z.HasExtensions() && z.EncExt(yy940) { - } else if !yym941 && z.IsJSONHandle() { - z.EncJSONMarshal(yy940) } else { - z.EncFallback(yy940) + r.EncodeInt(int64(x.TerminatedPodGCThreshold)) } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("horizontalPodAutoscalerSyncPeriod")) + r.EncodeString(codecSelferC_UTF81234, string("terminatedPodGCThreshold")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy942 := &x.HorizontalPodAutoscalerSyncPeriod yym943 := z.EncBinary() _ = yym943 if false { - } else if z.HasExtensions() && z.EncExt(yy942) { - } else if !yym943 && z.IsJSONHandle() { - z.EncJSONMarshal(yy942) } else { - z.EncFallback(yy942) + r.EncodeInt(int64(x.TerminatedPodGCThreshold)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy945 := &x.DeploymentControllerSyncPeriod + yy945 := &x.HorizontalPodAutoscalerSyncPeriod yym946 := z.EncBinary() _ = yym946 if false { @@ -8020,9 +8041,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("deploymentControllerSyncPeriod")) + r.EncodeString(codecSelferC_UTF81234, string("horizontalPodAutoscalerSyncPeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy947 := &x.DeploymentControllerSyncPeriod + yy947 := &x.HorizontalPodAutoscalerSyncPeriod yym948 := z.EncBinary() _ = yym948 if false { @@ -8033,9 +8054,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncFallback(yy947) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy950 := &x.PodEvictionTimeout + yy950 := &x.DeploymentControllerSyncPeriod yym951 := z.EncBinary() _ = yym951 if false { @@ -8047,9 +8068,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("podEvictionTimeout")) + r.EncodeString(codecSelferC_UTF81234, string("deploymentControllerSyncPeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy952 := &x.PodEvictionTimeout + yy952 := &x.DeploymentControllerSyncPeriod yym953 := z.EncBinary() _ = yym953 if false { @@ -8060,120 +8081,120 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncFallback(yy952) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym955 := z.EncBinary() - _ = yym955 + yy955 := &x.PodEvictionTimeout + yym956 := z.EncBinary() + _ = yym956 if false { + } else if z.HasExtensions() && z.EncExt(yy955) { + } else if !yym956 && z.IsJSONHandle() { + z.EncJSONMarshal(yy955) } else { - r.EncodeFloat32(float32(x.DeletingPodsQps)) + z.EncFallback(yy955) } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("deletingPodsQps")) + r.EncodeString(codecSelferC_UTF81234, string("podEvictionTimeout")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym956 := z.EncBinary() - _ = yym956 + yy957 := &x.PodEvictionTimeout + yym958 := z.EncBinary() + _ = yym958 if false { + } else if z.HasExtensions() && z.EncExt(yy957) { + } else if !yym958 && z.IsJSONHandle() { + z.EncJSONMarshal(yy957) } else { - r.EncodeFloat32(float32(x.DeletingPodsQps)) + z.EncFallback(yy957) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym958 := z.EncBinary() - _ = yym958 + yym960 := z.EncBinary() + _ = yym960 if false { } else { - r.EncodeInt(int64(x.DeletingPodsBurst)) + r.EncodeFloat32(float32(x.DeletingPodsQps)) } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("deletingPodsBurst")) + r.EncodeString(codecSelferC_UTF81234, string("deletingPodsQps")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym959 := z.EncBinary() - _ = yym959 + yym961 := z.EncBinary() + _ = yym961 if false { } else { - r.EncodeInt(int64(x.DeletingPodsBurst)) + r.EncodeFloat32(float32(x.DeletingPodsQps)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy961 := &x.NodeMonitorGracePeriod - yym962 := z.EncBinary() - _ = yym962 + yym963 := z.EncBinary() + _ = yym963 if false { - } else if z.HasExtensions() && z.EncExt(yy961) { - } else if !yym962 && z.IsJSONHandle() { - z.EncJSONMarshal(yy961) } else { - z.EncFallback(yy961) + r.EncodeInt(int64(x.DeletingPodsBurst)) } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("nodeMonitorGracePeriod")) + r.EncodeString(codecSelferC_UTF81234, string("deletingPodsBurst")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy963 := &x.NodeMonitorGracePeriod yym964 := z.EncBinary() _ = yym964 if false { - } else if z.HasExtensions() && z.EncExt(yy963) { - } else if !yym964 && z.IsJSONHandle() { - z.EncJSONMarshal(yy963) } else { - z.EncFallback(yy963) + r.EncodeInt(int64(x.DeletingPodsBurst)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym966 := z.EncBinary() - _ = yym966 + yy966 := &x.NodeMonitorGracePeriod + yym967 := z.EncBinary() + _ = yym967 if false { + } else if z.HasExtensions() && z.EncExt(yy966) { + } else if !yym967 && z.IsJSONHandle() { + z.EncJSONMarshal(yy966) } else { - r.EncodeInt(int64(x.RegisterRetryCount)) + z.EncFallback(yy966) } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("registerRetryCount")) + r.EncodeString(codecSelferC_UTF81234, string("nodeMonitorGracePeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym967 := z.EncBinary() - _ = yym967 + yy968 := &x.NodeMonitorGracePeriod + yym969 := z.EncBinary() + _ = yym969 if false { + } else if z.HasExtensions() && z.EncExt(yy968) { + } else if !yym969 && z.IsJSONHandle() { + z.EncJSONMarshal(yy968) } else { - r.EncodeInt(int64(x.RegisterRetryCount)) + z.EncFallback(yy968) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy969 := &x.NodeStartupGracePeriod - yym970 := z.EncBinary() - _ = yym970 + yym971 := z.EncBinary() + _ = yym971 if false { - } else if z.HasExtensions() && z.EncExt(yy969) { - } else if !yym970 && z.IsJSONHandle() { - z.EncJSONMarshal(yy969) } else { - z.EncFallback(yy969) + r.EncodeInt(int64(x.RegisterRetryCount)) } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("nodeStartupGracePeriod")) + r.EncodeString(codecSelferC_UTF81234, string("registerRetryCount")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy971 := &x.NodeStartupGracePeriod yym972 := z.EncBinary() _ = yym972 if false { - } else if z.HasExtensions() && z.EncExt(yy971) { - } else if !yym972 && z.IsJSONHandle() { - z.EncJSONMarshal(yy971) } else { - z.EncFallback(yy971) + r.EncodeInt(int64(x.RegisterRetryCount)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy974 := &x.NodeMonitorPeriod + yy974 := &x.NodeStartupGracePeriod yym975 := z.EncBinary() _ = yym975 if false { @@ -8185,9 +8206,9 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("nodeMonitorPeriod")) + r.EncodeString(codecSelferC_UTF81234, string("nodeStartupGracePeriod")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy976 := &x.NodeMonitorPeriod + yy976 := &x.NodeStartupGracePeriod yym977 := z.EncBinary() _ = yym977 if false { @@ -8198,10 +8219,37 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncFallback(yy976) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym979 := z.EncBinary() - _ = yym979 + yy979 := &x.NodeMonitorPeriod + yym980 := z.EncBinary() + _ = yym980 + if false { + } else if z.HasExtensions() && z.EncExt(yy979) { + } else if !yym980 && z.IsJSONHandle() { + z.EncJSONMarshal(yy979) + } else { + z.EncFallback(yy979) + } + } else { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("nodeMonitorPeriod")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + yy981 := &x.NodeMonitorPeriod + yym982 := z.EncBinary() + _ = yym982 + if false { + } else if z.HasExtensions() && z.EncExt(yy981) { + } else if !yym982 && z.IsJSONHandle() { + z.EncJSONMarshal(yy981) + } else { + z.EncFallback(yy981) + } + } + if yyr848 || yy2arr848 { + z.EncSendContainerState(codecSelfer_containerArrayElem1234) + yym984 := z.EncBinary() + _ = yym984 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ServiceAccountKeyFile)) @@ -8210,17 +8258,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("serviceAccountKeyFile")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym980 := z.EncBinary() - _ = yym980 + yym985 := z.EncBinary() + _ = yym985 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ServiceAccountKeyFile)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym982 := z.EncBinary() - _ = yym982 + yym987 := z.EncBinary() + _ = yym987 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ClusterSigningCertFile)) @@ -8229,17 +8277,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("clusterSigningCertFile")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym983 := z.EncBinary() - _ = yym983 + yym988 := z.EncBinary() + _ = yym988 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ClusterSigningCertFile)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym985 := z.EncBinary() - _ = yym985 + yym990 := z.EncBinary() + _ = yym990 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ClusterSigningKeyFile)) @@ -8248,17 +8296,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("clusterSigningKeyFile")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym986 := z.EncBinary() - _ = yym986 + yym991 := z.EncBinary() + _ = yym991 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ClusterSigningKeyFile)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym988 := z.EncBinary() - _ = yym988 + yym993 := z.EncBinary() + _ = yym993 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ApproveAllKubeletCSRsForGroup)) @@ -8267,17 +8315,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("approveAllKubeletCSRsForGroup")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym989 := z.EncBinary() - _ = yym989 + yym994 := z.EncBinary() + _ = yym994 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ApproveAllKubeletCSRsForGroup)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym991 := z.EncBinary() - _ = yym991 + yym996 := z.EncBinary() + _ = yym996 if false { } else { r.EncodeBool(bool(x.EnableProfiling)) @@ -8286,17 +8334,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("enableProfiling")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym992 := z.EncBinary() - _ = yym992 + yym997 := z.EncBinary() + _ = yym997 if false { } else { r.EncodeBool(bool(x.EnableProfiling)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym994 := z.EncBinary() - _ = yym994 + yym999 := z.EncBinary() + _ = yym999 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ClusterName)) @@ -8305,17 +8353,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("clusterName")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym995 := z.EncBinary() - _ = yym995 + yym1000 := z.EncBinary() + _ = yym1000 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ClusterName)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym997 := z.EncBinary() - _ = yym997 + yym1002 := z.EncBinary() + _ = yym1002 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ClusterCIDR)) @@ -8324,17 +8372,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("clusterCIDR")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym998 := z.EncBinary() - _ = yym998 + yym1003 := z.EncBinary() + _ = yym1003 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ClusterCIDR)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1000 := z.EncBinary() - _ = yym1000 + yym1005 := z.EncBinary() + _ = yym1005 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ServiceCIDR)) @@ -8343,17 +8391,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("serviceCIDR")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1001 := z.EncBinary() - _ = yym1001 + yym1006 := z.EncBinary() + _ = yym1006 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ServiceCIDR)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1003 := z.EncBinary() - _ = yym1003 + yym1008 := z.EncBinary() + _ = yym1008 if false { } else { r.EncodeInt(int64(x.NodeCIDRMaskSize)) @@ -8362,17 +8410,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("nodeCIDRMaskSize")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1004 := z.EncBinary() - _ = yym1004 + yym1009 := z.EncBinary() + _ = yym1009 if false { } else { r.EncodeInt(int64(x.NodeCIDRMaskSize)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1006 := z.EncBinary() - _ = yym1006 + yym1011 := z.EncBinary() + _ = yym1011 if false { } else { r.EncodeBool(bool(x.AllocateNodeCIDRs)) @@ -8381,17 +8429,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("allocateNodeCIDRs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1007 := z.EncBinary() - _ = yym1007 + yym1012 := z.EncBinary() + _ = yym1012 if false { } else { r.EncodeBool(bool(x.AllocateNodeCIDRs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1009 := z.EncBinary() - _ = yym1009 + yym1014 := z.EncBinary() + _ = yym1014 if false { } else { r.EncodeBool(bool(x.ConfigureCloudRoutes)) @@ -8400,17 +8448,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("configureCloudRoutes")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1010 := z.EncBinary() - _ = yym1010 + yym1015 := z.EncBinary() + _ = yym1015 if false { } else { r.EncodeBool(bool(x.ConfigureCloudRoutes)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1012 := z.EncBinary() - _ = yym1012 + yym1017 := z.EncBinary() + _ = yym1017 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.RootCAFile)) @@ -8419,17 +8467,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("rootCAFile")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1013 := z.EncBinary() - _ = yym1013 + yym1018 := z.EncBinary() + _ = yym1018 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.RootCAFile)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1015 := z.EncBinary() - _ = yym1015 + yym1020 := z.EncBinary() + _ = yym1020 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ContentType)) @@ -8438,17 +8486,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("contentType")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1016 := z.EncBinary() - _ = yym1016 + yym1021 := z.EncBinary() + _ = yym1021 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.ContentType)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1018 := z.EncBinary() - _ = yym1018 + yym1023 := z.EncBinary() + _ = yym1023 if false { } else { r.EncodeFloat32(float32(x.KubeAPIQPS)) @@ -8457,17 +8505,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("kubeAPIQPS")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1019 := z.EncBinary() - _ = yym1019 + yym1024 := z.EncBinary() + _ = yym1024 if false { } else { r.EncodeFloat32(float32(x.KubeAPIQPS)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1021 := z.EncBinary() - _ = yym1021 + yym1026 := z.EncBinary() + _ = yym1026 if false { } else { r.EncodeInt(int64(x.KubeAPIBurst)) @@ -8476,66 +8524,66 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("kubeAPIBurst")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1022 := z.EncBinary() - _ = yym1022 + yym1027 := z.EncBinary() + _ = yym1027 if false { } else { r.EncodeInt(int64(x.KubeAPIBurst)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy1024 := &x.LeaderElection - yy1024.CodecEncodeSelf(e) + yy1029 := &x.LeaderElection + yy1029.CodecEncodeSelf(e) } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("leaderElection")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy1025 := &x.LeaderElection - yy1025.CodecEncodeSelf(e) + yy1030 := &x.LeaderElection + yy1030.CodecEncodeSelf(e) } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy1027 := &x.VolumeConfiguration - yy1027.CodecEncodeSelf(e) + yy1032 := &x.VolumeConfiguration + yy1032.CodecEncodeSelf(e) } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("volumeConfiguration")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy1028 := &x.VolumeConfiguration - yy1028.CodecEncodeSelf(e) + yy1033 := &x.VolumeConfiguration + yy1033.CodecEncodeSelf(e) } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy1030 := &x.ControllerStartInterval - yym1031 := z.EncBinary() - _ = yym1031 + yy1035 := &x.ControllerStartInterval + yym1036 := z.EncBinary() + _ = yym1036 if false { - } else if z.HasExtensions() && z.EncExt(yy1030) { - } else if !yym1031 && z.IsJSONHandle() { - z.EncJSONMarshal(yy1030) + } else if z.HasExtensions() && z.EncExt(yy1035) { + } else if !yym1036 && z.IsJSONHandle() { + z.EncJSONMarshal(yy1035) } else { - z.EncFallback(yy1030) + z.EncFallback(yy1035) } } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("controllerStartInterval")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy1032 := &x.ControllerStartInterval - yym1033 := z.EncBinary() - _ = yym1033 + yy1037 := &x.ControllerStartInterval + yym1038 := z.EncBinary() + _ = yym1038 if false { - } else if z.HasExtensions() && z.EncExt(yy1032) { - } else if !yym1033 && z.IsJSONHandle() { - z.EncJSONMarshal(yy1032) + } else if z.HasExtensions() && z.EncExt(yy1037) { + } else if !yym1038 && z.IsJSONHandle() { + z.EncJSONMarshal(yy1037) } else { - z.EncFallback(yy1032) + z.EncFallback(yy1037) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1035 := z.EncBinary() - _ = yym1035 + yym1040 := z.EncBinary() + _ = yym1040 if false { } else { r.EncodeBool(bool(x.EnableGarbageCollector)) @@ -8544,17 +8592,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("enableGarbageCollector")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1036 := z.EncBinary() - _ = yym1036 + yym1041 := z.EncBinary() + _ = yym1041 if false { } else { r.EncodeBool(bool(x.EnableGarbageCollector)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1038 := z.EncBinary() - _ = yym1038 + yym1043 := z.EncBinary() + _ = yym1043 if false { } else { r.EncodeInt(int64(x.ConcurrentGCSyncs)) @@ -8563,17 +8611,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("concurrentGCSyncs")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1039 := z.EncBinary() - _ = yym1039 + yym1044 := z.EncBinary() + _ = yym1044 if false { } else { r.EncodeInt(int64(x.ConcurrentGCSyncs)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1041 := z.EncBinary() - _ = yym1041 + yym1046 := z.EncBinary() + _ = yym1046 if false { } else { r.EncodeFloat32(float32(x.NodeEvictionRate)) @@ -8582,17 +8630,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("nodeEvictionRate")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1042 := z.EncBinary() - _ = yym1042 + yym1047 := z.EncBinary() + _ = yym1047 if false { } else { r.EncodeFloat32(float32(x.NodeEvictionRate)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1044 := z.EncBinary() - _ = yym1044 + yym1049 := z.EncBinary() + _ = yym1049 if false { } else { r.EncodeFloat32(float32(x.SecondaryNodeEvictionRate)) @@ -8601,17 +8649,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("secondaryNodeEvictionRate")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1045 := z.EncBinary() - _ = yym1045 + yym1050 := z.EncBinary() + _ = yym1050 if false { } else { r.EncodeFloat32(float32(x.SecondaryNodeEvictionRate)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1047 := z.EncBinary() - _ = yym1047 + yym1052 := z.EncBinary() + _ = yym1052 if false { } else { r.EncodeInt(int64(x.LargeClusterSizeThreshold)) @@ -8620,17 +8668,17 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("largeClusterSizeThreshold")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1048 := z.EncBinary() - _ = yym1048 + yym1053 := z.EncBinary() + _ = yym1053 if false { } else { r.EncodeInt(int64(x.LargeClusterSizeThreshold)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1050 := z.EncBinary() - _ = yym1050 + yym1055 := z.EncBinary() + _ = yym1055 if false { } else { r.EncodeFloat32(float32(x.UnhealthyZoneThreshold)) @@ -8639,14 +8687,14 @@ func (x *KubeControllerManagerConfiguration) CodecEncodeSelf(e *codec1978.Encode z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("unhealthyZoneThreshold")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1051 := z.EncBinary() - _ = yym1051 + yym1056 := z.EncBinary() + _ = yym1056 if false { } else { r.EncodeFloat32(float32(x.UnhealthyZoneThreshold)) } } - if yyr843 || yy2arr843 { + if yyr848 || yy2arr848 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) } else { z.EncSendContainerState(codecSelfer_containerMapEnd1234) @@ -8659,25 +8707,25 @@ func (x *KubeControllerManagerConfiguration) CodecDecodeSelf(d *codec1978.Decode var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - yym1052 := z.DecBinary() - _ = yym1052 + yym1057 := z.DecBinary() + _ = yym1057 if false { } else if z.HasExtensions() && z.DecExt(x) { } else { - yyct1053 := r.ContainerType() - if yyct1053 == codecSelferValueTypeMap1234 { - yyl1053 := r.ReadMapStart() - if yyl1053 == 0 { + yyct1058 := r.ContainerType() + if yyct1058 == codecSelferValueTypeMap1234 { + yyl1058 := r.ReadMapStart() + if yyl1058 == 0 { z.DecSendContainerState(codecSelfer_containerMapEnd1234) } else { - x.codecDecodeSelfFromMap(yyl1053, d) + x.codecDecodeSelfFromMap(yyl1058, d) } - } else if yyct1053 == codecSelferValueTypeArray1234 { - yyl1053 := r.ReadArrayStart() - if yyl1053 == 0 { + } else if yyct1058 == codecSelferValueTypeArray1234 { + yyl1058 := r.ReadArrayStart() + if yyl1058 == 0 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } else { - x.codecDecodeSelfFromArray(yyl1053, d) + x.codecDecodeSelfFromArray(yyl1058, d) } } else { panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) @@ -8689,12 +8737,12 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromMap(l int, d *co var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yys1054Slc = z.DecScratchBuffer() // default slice to decode into - _ = yys1054Slc - var yyhl1054 bool = l >= 0 - for yyj1054 := 0; ; yyj1054++ { - if yyhl1054 { - if yyj1054 >= l { + var yys1059Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys1059Slc + var yyhl1059 bool = l >= 0 + for yyj1059 := 0; ; yyj1059++ { + if yyhl1059 { + if yyj1059 >= l { break } } else { @@ -8703,10 +8751,10 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromMap(l int, d *co } } z.DecSendContainerState(codecSelfer_containerMapKey1234) - yys1054Slc = r.DecodeBytes(yys1054Slc, true, true) - yys1054 := string(yys1054Slc) + yys1059Slc = r.DecodeBytes(yys1059Slc, true, true) + yys1059 := string(yys1059Slc) z.DecSendContainerState(codecSelfer_containerMapValue1234) - switch yys1054 { + switch yys1059 { case "kind": if r.TryDecodeAsNil() { x.Kind = "" @@ -8825,105 +8873,105 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromMap(l int, d *co if r.TryDecodeAsNil() { x.ServiceSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1074 := &x.ServiceSyncPeriod - yym1075 := z.DecBinary() - _ = yym1075 + yyv1079 := &x.ServiceSyncPeriod + yym1080 := z.DecBinary() + _ = yym1080 if false { - } else if z.HasExtensions() && z.DecExt(yyv1074) { - } else if !yym1075 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1074) + } else if z.HasExtensions() && z.DecExt(yyv1079) { + } else if !yym1080 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1079) } else { - z.DecFallback(yyv1074, false) + z.DecFallback(yyv1079, false) } } case "nodeSyncPeriod": if r.TryDecodeAsNil() { x.NodeSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1076 := &x.NodeSyncPeriod - yym1077 := z.DecBinary() - _ = yym1077 + yyv1081 := &x.NodeSyncPeriod + yym1082 := z.DecBinary() + _ = yym1082 if false { - } else if z.HasExtensions() && z.DecExt(yyv1076) { - } else if !yym1077 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1076) + } else if z.HasExtensions() && z.DecExt(yyv1081) { + } else if !yym1082 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1081) } else { - z.DecFallback(yyv1076, false) + z.DecFallback(yyv1081, false) } } case "routeReconciliationPeriod": if r.TryDecodeAsNil() { x.RouteReconciliationPeriod = pkg1_unversioned.Duration{} } else { - yyv1078 := &x.RouteReconciliationPeriod - yym1079 := z.DecBinary() - _ = yym1079 + yyv1083 := &x.RouteReconciliationPeriod + yym1084 := z.DecBinary() + _ = yym1084 if false { - } else if z.HasExtensions() && z.DecExt(yyv1078) { - } else if !yym1079 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1078) + } else if z.HasExtensions() && z.DecExt(yyv1083) { + } else if !yym1084 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1083) } else { - z.DecFallback(yyv1078, false) + z.DecFallback(yyv1083, false) } } case "resourceQuotaSyncPeriod": if r.TryDecodeAsNil() { x.ResourceQuotaSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1080 := &x.ResourceQuotaSyncPeriod - yym1081 := z.DecBinary() - _ = yym1081 + yyv1085 := &x.ResourceQuotaSyncPeriod + yym1086 := z.DecBinary() + _ = yym1086 if false { - } else if z.HasExtensions() && z.DecExt(yyv1080) { - } else if !yym1081 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1080) + } else if z.HasExtensions() && z.DecExt(yyv1085) { + } else if !yym1086 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1085) } else { - z.DecFallback(yyv1080, false) + z.DecFallback(yyv1085, false) } } case "namespaceSyncPeriod": if r.TryDecodeAsNil() { x.NamespaceSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1082 := &x.NamespaceSyncPeriod - yym1083 := z.DecBinary() - _ = yym1083 + yyv1087 := &x.NamespaceSyncPeriod + yym1088 := z.DecBinary() + _ = yym1088 if false { - } else if z.HasExtensions() && z.DecExt(yyv1082) { - } else if !yym1083 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1082) + } else if z.HasExtensions() && z.DecExt(yyv1087) { + } else if !yym1088 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1087) } else { - z.DecFallback(yyv1082, false) + z.DecFallback(yyv1087, false) } } case "pvClaimBinderSyncPeriod": if r.TryDecodeAsNil() { x.PVClaimBinderSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1084 := &x.PVClaimBinderSyncPeriod - yym1085 := z.DecBinary() - _ = yym1085 + yyv1089 := &x.PVClaimBinderSyncPeriod + yym1090 := z.DecBinary() + _ = yym1090 if false { - } else if z.HasExtensions() && z.DecExt(yyv1084) { - } else if !yym1085 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1084) + } else if z.HasExtensions() && z.DecExt(yyv1089) { + } else if !yym1090 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1089) } else { - z.DecFallback(yyv1084, false) + z.DecFallback(yyv1089, false) } } case "minResyncPeriod": if r.TryDecodeAsNil() { x.MinResyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1086 := &x.MinResyncPeriod - yym1087 := z.DecBinary() - _ = yym1087 + yyv1091 := &x.MinResyncPeriod + yym1092 := z.DecBinary() + _ = yym1092 if false { - } else if z.HasExtensions() && z.DecExt(yyv1086) { - } else if !yym1087 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1086) + } else if z.HasExtensions() && z.DecExt(yyv1091) { + } else if !yym1092 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1091) } else { - z.DecFallback(yyv1086, false) + z.DecFallback(yyv1091, false) } } case "terminatedPodGCThreshold": @@ -8936,45 +8984,45 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromMap(l int, d *co if r.TryDecodeAsNil() { x.HorizontalPodAutoscalerSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1089 := &x.HorizontalPodAutoscalerSyncPeriod - yym1090 := z.DecBinary() - _ = yym1090 + yyv1094 := &x.HorizontalPodAutoscalerSyncPeriod + yym1095 := z.DecBinary() + _ = yym1095 if false { - } else if z.HasExtensions() && z.DecExt(yyv1089) { - } else if !yym1090 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1089) + } else if z.HasExtensions() && z.DecExt(yyv1094) { + } else if !yym1095 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1094) } else { - z.DecFallback(yyv1089, false) + z.DecFallback(yyv1094, false) } } case "deploymentControllerSyncPeriod": if r.TryDecodeAsNil() { x.DeploymentControllerSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1091 := &x.DeploymentControllerSyncPeriod - yym1092 := z.DecBinary() - _ = yym1092 + yyv1096 := &x.DeploymentControllerSyncPeriod + yym1097 := z.DecBinary() + _ = yym1097 if false { - } else if z.HasExtensions() && z.DecExt(yyv1091) { - } else if !yym1092 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1091) + } else if z.HasExtensions() && z.DecExt(yyv1096) { + } else if !yym1097 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1096) } else { - z.DecFallback(yyv1091, false) + z.DecFallback(yyv1096, false) } } case "podEvictionTimeout": if r.TryDecodeAsNil() { x.PodEvictionTimeout = pkg1_unversioned.Duration{} } else { - yyv1093 := &x.PodEvictionTimeout - yym1094 := z.DecBinary() - _ = yym1094 + yyv1098 := &x.PodEvictionTimeout + yym1099 := z.DecBinary() + _ = yym1099 if false { - } else if z.HasExtensions() && z.DecExt(yyv1093) { - } else if !yym1094 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1093) + } else if z.HasExtensions() && z.DecExt(yyv1098) { + } else if !yym1099 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1098) } else { - z.DecFallback(yyv1093, false) + z.DecFallback(yyv1098, false) } } case "deletingPodsQps": @@ -8993,15 +9041,15 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromMap(l int, d *co if r.TryDecodeAsNil() { x.NodeMonitorGracePeriod = pkg1_unversioned.Duration{} } else { - yyv1097 := &x.NodeMonitorGracePeriod - yym1098 := z.DecBinary() - _ = yym1098 + yyv1102 := &x.NodeMonitorGracePeriod + yym1103 := z.DecBinary() + _ = yym1103 if false { - } else if z.HasExtensions() && z.DecExt(yyv1097) { - } else if !yym1098 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1097) + } else if z.HasExtensions() && z.DecExt(yyv1102) { + } else if !yym1103 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1102) } else { - z.DecFallback(yyv1097, false) + z.DecFallback(yyv1102, false) } } case "registerRetryCount": @@ -9014,30 +9062,30 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromMap(l int, d *co if r.TryDecodeAsNil() { x.NodeStartupGracePeriod = pkg1_unversioned.Duration{} } else { - yyv1100 := &x.NodeStartupGracePeriod - yym1101 := z.DecBinary() - _ = yym1101 + yyv1105 := &x.NodeStartupGracePeriod + yym1106 := z.DecBinary() + _ = yym1106 if false { - } else if z.HasExtensions() && z.DecExt(yyv1100) { - } else if !yym1101 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1100) + } else if z.HasExtensions() && z.DecExt(yyv1105) { + } else if !yym1106 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1105) } else { - z.DecFallback(yyv1100, false) + z.DecFallback(yyv1105, false) } } case "nodeMonitorPeriod": if r.TryDecodeAsNil() { x.NodeMonitorPeriod = pkg1_unversioned.Duration{} } else { - yyv1102 := &x.NodeMonitorPeriod - yym1103 := z.DecBinary() - _ = yym1103 + yyv1107 := &x.NodeMonitorPeriod + yym1108 := z.DecBinary() + _ = yym1108 if false { - } else if z.HasExtensions() && z.DecExt(yyv1102) { - } else if !yym1103 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1102) + } else if z.HasExtensions() && z.DecExt(yyv1107) { + } else if !yym1108 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1107) } else { - z.DecFallback(yyv1102, false) + z.DecFallback(yyv1107, false) } } case "serviceAccountKeyFile": @@ -9134,29 +9182,29 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromMap(l int, d *co if r.TryDecodeAsNil() { x.LeaderElection = LeaderElectionConfiguration{} } else { - yyv1119 := &x.LeaderElection - yyv1119.CodecDecodeSelf(d) + yyv1124 := &x.LeaderElection + yyv1124.CodecDecodeSelf(d) } case "volumeConfiguration": if r.TryDecodeAsNil() { x.VolumeConfiguration = VolumeConfiguration{} } else { - yyv1120 := &x.VolumeConfiguration - yyv1120.CodecDecodeSelf(d) + yyv1125 := &x.VolumeConfiguration + yyv1125.CodecDecodeSelf(d) } case "controllerStartInterval": if r.TryDecodeAsNil() { x.ControllerStartInterval = pkg1_unversioned.Duration{} } else { - yyv1121 := &x.ControllerStartInterval - yym1122 := z.DecBinary() - _ = yym1122 + yyv1126 := &x.ControllerStartInterval + yym1127 := z.DecBinary() + _ = yym1127 if false { - } else if z.HasExtensions() && z.DecExt(yyv1121) { - } else if !yym1122 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1121) + } else if z.HasExtensions() && z.DecExt(yyv1126) { + } else if !yym1127 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1126) } else { - z.DecFallback(yyv1121, false) + z.DecFallback(yyv1126, false) } } case "enableGarbageCollector": @@ -9196,9 +9244,9 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromMap(l int, d *co x.UnhealthyZoneThreshold = float32(r.DecodeFloat(true)) } default: - z.DecStructFieldNotFound(-1, yys1054) - } // end switch yys1054 - } // end for yyj1054 + z.DecStructFieldNotFound(-1, yys1059) + } // end switch yys1059 + } // end for yyj1059 z.DecSendContainerState(codecSelfer_containerMapEnd1234) } @@ -9206,16 +9254,16 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj1129 int - var yyb1129 bool - var yyhl1129 bool = l >= 0 - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + var yyj1134 int + var yyb1134 bool + var yyhl1134 bool = l >= 0 + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9225,13 +9273,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.Kind = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9241,13 +9289,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.APIVersion = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9257,13 +9305,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.Port = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9273,13 +9321,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.Address = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9289,13 +9337,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.CloudProvider = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9305,13 +9353,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.CloudConfigFile = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9321,13 +9369,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentEndpointSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9337,13 +9385,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentRSSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9353,13 +9401,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentRCSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9369,13 +9417,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentServiceSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9385,13 +9433,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentResourceQuotaSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9401,13 +9449,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentDeploymentSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9417,13 +9465,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentDaemonSetSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9433,13 +9481,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentJobSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9449,13 +9497,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentNamespaceSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9465,13 +9513,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentSATokenSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9481,13 +9529,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.LookupCacheSizeForRC = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9497,13 +9545,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.LookupCacheSizeForRS = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9513,13 +9561,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.LookupCacheSizeForDaemonSet = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9527,24 +9575,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.ServiceSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1149 := &x.ServiceSyncPeriod - yym1150 := z.DecBinary() - _ = yym1150 + yyv1154 := &x.ServiceSyncPeriod + yym1155 := z.DecBinary() + _ = yym1155 if false { - } else if z.HasExtensions() && z.DecExt(yyv1149) { - } else if !yym1150 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1149) + } else if z.HasExtensions() && z.DecExt(yyv1154) { + } else if !yym1155 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1154) } else { - z.DecFallback(yyv1149, false) + z.DecFallback(yyv1154, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9552,24 +9600,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.NodeSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1151 := &x.NodeSyncPeriod - yym1152 := z.DecBinary() - _ = yym1152 + yyv1156 := &x.NodeSyncPeriod + yym1157 := z.DecBinary() + _ = yym1157 if false { - } else if z.HasExtensions() && z.DecExt(yyv1151) { - } else if !yym1152 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1151) + } else if z.HasExtensions() && z.DecExt(yyv1156) { + } else if !yym1157 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1156) } else { - z.DecFallback(yyv1151, false) + z.DecFallback(yyv1156, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9577,24 +9625,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.RouteReconciliationPeriod = pkg1_unversioned.Duration{} } else { - yyv1153 := &x.RouteReconciliationPeriod - yym1154 := z.DecBinary() - _ = yym1154 + yyv1158 := &x.RouteReconciliationPeriod + yym1159 := z.DecBinary() + _ = yym1159 if false { - } else if z.HasExtensions() && z.DecExt(yyv1153) { - } else if !yym1154 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1153) + } else if z.HasExtensions() && z.DecExt(yyv1158) { + } else if !yym1159 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1158) } else { - z.DecFallback(yyv1153, false) + z.DecFallback(yyv1158, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9602,24 +9650,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.ResourceQuotaSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1155 := &x.ResourceQuotaSyncPeriod - yym1156 := z.DecBinary() - _ = yym1156 + yyv1160 := &x.ResourceQuotaSyncPeriod + yym1161 := z.DecBinary() + _ = yym1161 if false { - } else if z.HasExtensions() && z.DecExt(yyv1155) { - } else if !yym1156 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1155) + } else if z.HasExtensions() && z.DecExt(yyv1160) { + } else if !yym1161 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1160) } else { - z.DecFallback(yyv1155, false) + z.DecFallback(yyv1160, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9627,24 +9675,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.NamespaceSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1157 := &x.NamespaceSyncPeriod - yym1158 := z.DecBinary() - _ = yym1158 + yyv1162 := &x.NamespaceSyncPeriod + yym1163 := z.DecBinary() + _ = yym1163 if false { - } else if z.HasExtensions() && z.DecExt(yyv1157) { - } else if !yym1158 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1157) + } else if z.HasExtensions() && z.DecExt(yyv1162) { + } else if !yym1163 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1162) } else { - z.DecFallback(yyv1157, false) + z.DecFallback(yyv1162, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9652,24 +9700,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.PVClaimBinderSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1159 := &x.PVClaimBinderSyncPeriod - yym1160 := z.DecBinary() - _ = yym1160 + yyv1164 := &x.PVClaimBinderSyncPeriod + yym1165 := z.DecBinary() + _ = yym1165 if false { - } else if z.HasExtensions() && z.DecExt(yyv1159) { - } else if !yym1160 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1159) + } else if z.HasExtensions() && z.DecExt(yyv1164) { + } else if !yym1165 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1164) } else { - z.DecFallback(yyv1159, false) + z.DecFallback(yyv1164, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9677,24 +9725,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.MinResyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1161 := &x.MinResyncPeriod - yym1162 := z.DecBinary() - _ = yym1162 + yyv1166 := &x.MinResyncPeriod + yym1167 := z.DecBinary() + _ = yym1167 if false { - } else if z.HasExtensions() && z.DecExt(yyv1161) { - } else if !yym1162 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1161) + } else if z.HasExtensions() && z.DecExt(yyv1166) { + } else if !yym1167 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1166) } else { - z.DecFallback(yyv1161, false) + z.DecFallback(yyv1166, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9704,13 +9752,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.TerminatedPodGCThreshold = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9718,24 +9766,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.HorizontalPodAutoscalerSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1164 := &x.HorizontalPodAutoscalerSyncPeriod - yym1165 := z.DecBinary() - _ = yym1165 + yyv1169 := &x.HorizontalPodAutoscalerSyncPeriod + yym1170 := z.DecBinary() + _ = yym1170 if false { - } else if z.HasExtensions() && z.DecExt(yyv1164) { - } else if !yym1165 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1164) + } else if z.HasExtensions() && z.DecExt(yyv1169) { + } else if !yym1170 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1169) } else { - z.DecFallback(yyv1164, false) + z.DecFallback(yyv1169, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9743,24 +9791,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.DeploymentControllerSyncPeriod = pkg1_unversioned.Duration{} } else { - yyv1166 := &x.DeploymentControllerSyncPeriod - yym1167 := z.DecBinary() - _ = yym1167 + yyv1171 := &x.DeploymentControllerSyncPeriod + yym1172 := z.DecBinary() + _ = yym1172 if false { - } else if z.HasExtensions() && z.DecExt(yyv1166) { - } else if !yym1167 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1166) + } else if z.HasExtensions() && z.DecExt(yyv1171) { + } else if !yym1172 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1171) } else { - z.DecFallback(yyv1166, false) + z.DecFallback(yyv1171, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9768,24 +9816,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.PodEvictionTimeout = pkg1_unversioned.Duration{} } else { - yyv1168 := &x.PodEvictionTimeout - yym1169 := z.DecBinary() - _ = yym1169 + yyv1173 := &x.PodEvictionTimeout + yym1174 := z.DecBinary() + _ = yym1174 if false { - } else if z.HasExtensions() && z.DecExt(yyv1168) { - } else if !yym1169 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1168) + } else if z.HasExtensions() && z.DecExt(yyv1173) { + } else if !yym1174 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1173) } else { - z.DecFallback(yyv1168, false) + z.DecFallback(yyv1173, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9795,13 +9843,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.DeletingPodsQps = float32(r.DecodeFloat(true)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9811,13 +9859,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.DeletingPodsBurst = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9825,24 +9873,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.NodeMonitorGracePeriod = pkg1_unversioned.Duration{} } else { - yyv1172 := &x.NodeMonitorGracePeriod - yym1173 := z.DecBinary() - _ = yym1173 + yyv1177 := &x.NodeMonitorGracePeriod + yym1178 := z.DecBinary() + _ = yym1178 if false { - } else if z.HasExtensions() && z.DecExt(yyv1172) { - } else if !yym1173 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1172) + } else if z.HasExtensions() && z.DecExt(yyv1177) { + } else if !yym1178 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1177) } else { - z.DecFallback(yyv1172, false) + z.DecFallback(yyv1177, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9852,13 +9900,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.RegisterRetryCount = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9866,24 +9914,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.NodeStartupGracePeriod = pkg1_unversioned.Duration{} } else { - yyv1175 := &x.NodeStartupGracePeriod - yym1176 := z.DecBinary() - _ = yym1176 + yyv1180 := &x.NodeStartupGracePeriod + yym1181 := z.DecBinary() + _ = yym1181 if false { - } else if z.HasExtensions() && z.DecExt(yyv1175) { - } else if !yym1176 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1175) + } else if z.HasExtensions() && z.DecExt(yyv1180) { + } else if !yym1181 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1180) } else { - z.DecFallback(yyv1175, false) + z.DecFallback(yyv1180, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9891,24 +9939,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.NodeMonitorPeriod = pkg1_unversioned.Duration{} } else { - yyv1177 := &x.NodeMonitorPeriod - yym1178 := z.DecBinary() - _ = yym1178 + yyv1182 := &x.NodeMonitorPeriod + yym1183 := z.DecBinary() + _ = yym1183 if false { - } else if z.HasExtensions() && z.DecExt(yyv1177) { - } else if !yym1178 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1177) + } else if z.HasExtensions() && z.DecExt(yyv1182) { + } else if !yym1183 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1182) } else { - z.DecFallback(yyv1177, false) + z.DecFallback(yyv1182, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9918,13 +9966,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ServiceAccountKeyFile = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9934,13 +9982,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ClusterSigningCertFile = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9950,13 +9998,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ClusterSigningKeyFile = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9966,13 +10014,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ApproveAllKubeletCSRsForGroup = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9982,13 +10030,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.EnableProfiling = bool(r.DecodeBool()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -9998,13 +10046,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ClusterName = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10014,13 +10062,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ClusterCIDR = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10030,13 +10078,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ServiceCIDR = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10046,13 +10094,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.NodeCIDRMaskSize = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10062,13 +10110,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.AllocateNodeCIDRs = bool(r.DecodeBool()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10078,13 +10126,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConfigureCloudRoutes = bool(r.DecodeBool()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10094,13 +10142,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.RootCAFile = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10110,13 +10158,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ContentType = string(r.DecodeString()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10126,13 +10174,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.KubeAPIQPS = float32(r.DecodeFloat(true)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10142,13 +10190,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.KubeAPIBurst = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10156,16 +10204,16 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.LeaderElection = LeaderElectionConfiguration{} } else { - yyv1194 := &x.LeaderElection - yyv1194.CodecDecodeSelf(d) + yyv1199 := &x.LeaderElection + yyv1199.CodecDecodeSelf(d) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10173,16 +10221,16 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.VolumeConfiguration = VolumeConfiguration{} } else { - yyv1195 := &x.VolumeConfiguration - yyv1195.CodecDecodeSelf(d) + yyv1200 := &x.VolumeConfiguration + yyv1200.CodecDecodeSelf(d) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10190,24 +10238,24 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * if r.TryDecodeAsNil() { x.ControllerStartInterval = pkg1_unversioned.Duration{} } else { - yyv1196 := &x.ControllerStartInterval - yym1197 := z.DecBinary() - _ = yym1197 + yyv1201 := &x.ControllerStartInterval + yym1202 := z.DecBinary() + _ = yym1202 if false { - } else if z.HasExtensions() && z.DecExt(yyv1196) { - } else if !yym1197 && z.IsJSONHandle() { - z.DecJSONUnmarshal(yyv1196) + } else if z.HasExtensions() && z.DecExt(yyv1201) { + } else if !yym1202 && z.IsJSONHandle() { + z.DecJSONUnmarshal(yyv1201) } else { - z.DecFallback(yyv1196, false) + z.DecFallback(yyv1201, false) } } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10217,13 +10265,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.EnableGarbageCollector = bool(r.DecodeBool()) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10233,13 +10281,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.ConcurrentGCSyncs = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10249,13 +10297,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.NodeEvictionRate = float32(r.DecodeFloat(true)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10265,13 +10313,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.SecondaryNodeEvictionRate = float32(r.DecodeFloat(true)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10281,13 +10329,13 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * } else { x.LargeClusterSizeThreshold = int32(r.DecodeInt(32)) } - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10298,17 +10346,17 @@ func (x *KubeControllerManagerConfiguration) codecDecodeSelfFromArray(l int, d * x.UnhealthyZoneThreshold = float32(r.DecodeFloat(true)) } for { - yyj1129++ - if yyhl1129 { - yyb1129 = yyj1129 > l + yyj1134++ + if yyhl1134 { + yyb1134 = yyj1134 > l } else { - yyb1129 = r.CheckBreak() + yyb1134 = r.CheckBreak() } - if yyb1129 { + if yyb1134 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj1129-1, "") + z.DecStructFieldNotFound(yyj1134-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -10320,33 +10368,33 @@ func (x *VolumeConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { if x == nil { r.EncodeNil() } else { - yym1204 := z.EncBinary() - _ = yym1204 + yym1209 := z.EncBinary() + _ = yym1209 if false { } else if z.HasExtensions() && z.EncExt(x) { } else { - yysep1205 := !z.EncBinary() - yy2arr1205 := z.EncBasicHandle().StructToArray - var yyq1205 [4]bool - _, _, _ = yysep1205, yyq1205, yy2arr1205 - const yyr1205 bool = false - var yynn1205 int - if yyr1205 || yy2arr1205 { + yysep1210 := !z.EncBinary() + yy2arr1210 := z.EncBasicHandle().StructToArray + var yyq1210 [4]bool + _, _, _ = yysep1210, yyq1210, yy2arr1210 + const yyr1210 bool = false + var yynn1210 int + if yyr1210 || yy2arr1210 { r.EncodeArrayStart(4) } else { - yynn1205 = 4 - for _, b := range yyq1205 { + yynn1210 = 4 + for _, b := range yyq1210 { if b { - yynn1205++ + yynn1210++ } } - r.EncodeMapStart(yynn1205) - yynn1205 = 0 + r.EncodeMapStart(yynn1210) + yynn1210 = 0 } - if yyr1205 || yy2arr1205 { + if yyr1210 || yy2arr1210 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1207 := z.EncBinary() - _ = yym1207 + yym1212 := z.EncBinary() + _ = yym1212 if false { } else { r.EncodeBool(bool(x.EnableHostPathProvisioning)) @@ -10355,17 +10403,17 @@ func (x *VolumeConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("enableHostPathProvisioning")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1208 := z.EncBinary() - _ = yym1208 + yym1213 := z.EncBinary() + _ = yym1213 if false { } else { r.EncodeBool(bool(x.EnableHostPathProvisioning)) } } - if yyr1205 || yy2arr1205 { + if yyr1210 || yy2arr1210 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1210 := z.EncBinary() - _ = yym1210 + yym1215 := z.EncBinary() + _ = yym1215 if false { } else { r.EncodeBool(bool(x.EnableDynamicProvisioning)) @@ -10374,28 +10422,28 @@ func (x *VolumeConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("enableDynamicProvisioning")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1211 := z.EncBinary() - _ = yym1211 + yym1216 := z.EncBinary() + _ = yym1216 if false { } else { r.EncodeBool(bool(x.EnableDynamicProvisioning)) } } - if yyr1205 || yy2arr1205 { + if yyr1210 || yy2arr1210 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yy1213 := &x.PersistentVolumeRecyclerConfiguration - yy1213.CodecEncodeSelf(e) + yy1218 := &x.PersistentVolumeRecyclerConfiguration + yy1218.CodecEncodeSelf(e) } else { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("persitentVolumeRecyclerConfiguration")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yy1214 := &x.PersistentVolumeRecyclerConfiguration - yy1214.CodecEncodeSelf(e) + yy1219 := &x.PersistentVolumeRecyclerConfiguration + yy1219.CodecEncodeSelf(e) } - if yyr1205 || yy2arr1205 { + if yyr1210 || yy2arr1210 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1216 := z.EncBinary() - _ = yym1216 + yym1221 := z.EncBinary() + _ = yym1221 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.FlexVolumePluginDir)) @@ -10404,14 +10452,14 @@ func (x *VolumeConfiguration) CodecEncodeSelf(e *codec1978.Encoder) { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("flexVolumePluginDir")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1217 := z.EncBinary() - _ = yym1217 + yym1222 := z.EncBinary() + _ = yym1222 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.FlexVolumePluginDir)) } } - if yyr1205 || yy2arr1205 { + if yyr1210 || yy2arr1210 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) } else { z.EncSendContainerState(codecSelfer_containerMapEnd1234) @@ -10424,25 +10472,25 @@ func (x *VolumeConfiguration) CodecDecodeSelf(d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - yym1218 := z.DecBinary() - _ = yym1218 + yym1223 := z.DecBinary() + _ = yym1223 if false { } else if z.HasExtensions() && z.DecExt(x) { } else { - yyct1219 := r.ContainerType() - if yyct1219 == codecSelferValueTypeMap1234 { - yyl1219 := r.ReadMapStart() - if yyl1219 == 0 { + yyct1224 := r.ContainerType() + if yyct1224 == codecSelferValueTypeMap1234 { + yyl1224 := r.ReadMapStart() + if yyl1224 == 0 { z.DecSendContainerState(codecSelfer_containerMapEnd1234) } else { - x.codecDecodeSelfFromMap(yyl1219, d) + x.codecDecodeSelfFromMap(yyl1224, d) } - } else if yyct1219 == codecSelferValueTypeArray1234 { - yyl1219 := r.ReadArrayStart() - if yyl1219 == 0 { + } else if yyct1224 == codecSelferValueTypeArray1234 { + yyl1224 := r.ReadArrayStart() + if yyl1224 == 0 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } else { - x.codecDecodeSelfFromArray(yyl1219, d) + x.codecDecodeSelfFromArray(yyl1224, d) } } else { panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) @@ -10454,12 +10502,12 @@ func (x *VolumeConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decoder var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yys1220Slc = z.DecScratchBuffer() // default slice to decode into - _ = yys1220Slc - var yyhl1220 bool = l >= 0 - for yyj1220 := 0; ; yyj1220++ { - if yyhl1220 { - if yyj1220 >= l { + var yys1225Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys1225Slc + var yyhl1225 bool = l >= 0 + for yyj1225 := 0; ; yyj1225++ { + if yyhl1225 { + if yyj1225 >= l { break } } else { @@ -10468,10 +10516,10 @@ func (x *VolumeConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decoder } } z.DecSendContainerState(codecSelfer_containerMapKey1234) - yys1220Slc = r.DecodeBytes(yys1220Slc, true, true) - yys1220 := string(yys1220Slc) + yys1225Slc = r.DecodeBytes(yys1225Slc, true, true) + yys1225 := string(yys1225Slc) z.DecSendContainerState(codecSelfer_containerMapValue1234) - switch yys1220 { + switch yys1225 { case "enableHostPathProvisioning": if r.TryDecodeAsNil() { x.EnableHostPathProvisioning = false @@ -10488,8 +10536,8 @@ func (x *VolumeConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decoder if r.TryDecodeAsNil() { x.PersistentVolumeRecyclerConfiguration = PersistentVolumeRecyclerConfiguration{} } else { - yyv1223 := &x.PersistentVolumeRecyclerConfiguration - yyv1223.CodecDecodeSelf(d) + yyv1228 := &x.PersistentVolumeRecyclerConfiguration + yyv1228.CodecDecodeSelf(d) } case "flexVolumePluginDir": if r.TryDecodeAsNil() { @@ -10498,9 +10546,9 @@ func (x *VolumeConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decoder x.FlexVolumePluginDir = string(r.DecodeString()) } default: - z.DecStructFieldNotFound(-1, yys1220) - } // end switch yys1220 - } // end for yyj1220 + z.DecStructFieldNotFound(-1, yys1225) + } // end switch yys1225 + } // end for yyj1225 z.DecSendContainerState(codecSelfer_containerMapEnd1234) } @@ -10508,16 +10556,16 @@ func (x *VolumeConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Decod var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj1225 int - var yyb1225 bool - var yyhl1225 bool = l >= 0 - yyj1225++ - if yyhl1225 { - yyb1225 = yyj1225 > l + var yyj1230 int + var yyb1230 bool + var yyhl1230 bool = l >= 0 + yyj1230++ + if yyhl1230 { + yyb1230 = yyj1230 > l } else { - yyb1225 = r.CheckBreak() + yyb1230 = r.CheckBreak() } - if yyb1225 { + if yyb1230 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10527,13 +10575,13 @@ func (x *VolumeConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Decod } else { x.EnableHostPathProvisioning = bool(r.DecodeBool()) } - yyj1225++ - if yyhl1225 { - yyb1225 = yyj1225 > l + yyj1230++ + if yyhl1230 { + yyb1230 = yyj1230 > l } else { - yyb1225 = r.CheckBreak() + yyb1230 = r.CheckBreak() } - if yyb1225 { + if yyb1230 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10543,13 +10591,13 @@ func (x *VolumeConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Decod } else { x.EnableDynamicProvisioning = bool(r.DecodeBool()) } - yyj1225++ - if yyhl1225 { - yyb1225 = yyj1225 > l + yyj1230++ + if yyhl1230 { + yyb1230 = yyj1230 > l } else { - yyb1225 = r.CheckBreak() + yyb1230 = r.CheckBreak() } - if yyb1225 { + if yyb1230 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10557,16 +10605,16 @@ func (x *VolumeConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Decod if r.TryDecodeAsNil() { x.PersistentVolumeRecyclerConfiguration = PersistentVolumeRecyclerConfiguration{} } else { - yyv1228 := &x.PersistentVolumeRecyclerConfiguration - yyv1228.CodecDecodeSelf(d) + yyv1233 := &x.PersistentVolumeRecyclerConfiguration + yyv1233.CodecDecodeSelf(d) } - yyj1225++ - if yyhl1225 { - yyb1225 = yyj1225 > l + yyj1230++ + if yyhl1230 { + yyb1230 = yyj1230 > l } else { - yyb1225 = r.CheckBreak() + yyb1230 = r.CheckBreak() } - if yyb1225 { + if yyb1230 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10577,17 +10625,17 @@ func (x *VolumeConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.Decod x.FlexVolumePluginDir = string(r.DecodeString()) } for { - yyj1225++ - if yyhl1225 { - yyb1225 = yyj1225 > l + yyj1230++ + if yyhl1230 { + yyb1230 = yyj1230 > l } else { - yyb1225 = r.CheckBreak() + yyb1230 = r.CheckBreak() } - if yyb1225 { + if yyb1230 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj1225-1, "") + z.DecStructFieldNotFound(yyj1230-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -10599,33 +10647,33 @@ func (x *PersistentVolumeRecyclerConfiguration) CodecEncodeSelf(e *codec1978.Enc if x == nil { r.EncodeNil() } else { - yym1230 := z.EncBinary() - _ = yym1230 + yym1235 := z.EncBinary() + _ = yym1235 if false { } else if z.HasExtensions() && z.EncExt(x) { } else { - yysep1231 := !z.EncBinary() - yy2arr1231 := z.EncBasicHandle().StructToArray - var yyq1231 [7]bool - _, _, _ = yysep1231, yyq1231, yy2arr1231 - const yyr1231 bool = false - var yynn1231 int - if yyr1231 || yy2arr1231 { + yysep1236 := !z.EncBinary() + yy2arr1236 := z.EncBasicHandle().StructToArray + var yyq1236 [7]bool + _, _, _ = yysep1236, yyq1236, yy2arr1236 + const yyr1236 bool = false + var yynn1236 int + if yyr1236 || yy2arr1236 { r.EncodeArrayStart(7) } else { - yynn1231 = 7 - for _, b := range yyq1231 { + yynn1236 = 7 + for _, b := range yyq1236 { if b { - yynn1231++ + yynn1236++ } } - r.EncodeMapStart(yynn1231) - yynn1231 = 0 + r.EncodeMapStart(yynn1236) + yynn1236 = 0 } - if yyr1231 || yy2arr1231 { + if yyr1236 || yy2arr1236 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1233 := z.EncBinary() - _ = yym1233 + yym1238 := z.EncBinary() + _ = yym1238 if false { } else { r.EncodeInt(int64(x.MaximumRetry)) @@ -10634,17 +10682,17 @@ func (x *PersistentVolumeRecyclerConfiguration) CodecEncodeSelf(e *codec1978.Enc z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("maximumRetry")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1234 := z.EncBinary() - _ = yym1234 + yym1239 := z.EncBinary() + _ = yym1239 if false { } else { r.EncodeInt(int64(x.MaximumRetry)) } } - if yyr1231 || yy2arr1231 { + if yyr1236 || yy2arr1236 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1236 := z.EncBinary() - _ = yym1236 + yym1241 := z.EncBinary() + _ = yym1241 if false { } else { r.EncodeInt(int64(x.MinimumTimeoutNFS)) @@ -10653,17 +10701,17 @@ func (x *PersistentVolumeRecyclerConfiguration) CodecEncodeSelf(e *codec1978.Enc z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("minimumTimeoutNFS")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1237 := z.EncBinary() - _ = yym1237 + yym1242 := z.EncBinary() + _ = yym1242 if false { } else { r.EncodeInt(int64(x.MinimumTimeoutNFS)) } } - if yyr1231 || yy2arr1231 { + if yyr1236 || yy2arr1236 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1239 := z.EncBinary() - _ = yym1239 + yym1244 := z.EncBinary() + _ = yym1244 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.PodTemplateFilePathNFS)) @@ -10672,17 +10720,17 @@ func (x *PersistentVolumeRecyclerConfiguration) CodecEncodeSelf(e *codec1978.Enc z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("podTemplateFilePathNFS")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1240 := z.EncBinary() - _ = yym1240 + yym1245 := z.EncBinary() + _ = yym1245 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.PodTemplateFilePathNFS)) } } - if yyr1231 || yy2arr1231 { + if yyr1236 || yy2arr1236 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1242 := z.EncBinary() - _ = yym1242 + yym1247 := z.EncBinary() + _ = yym1247 if false { } else { r.EncodeInt(int64(x.IncrementTimeoutNFS)) @@ -10691,17 +10739,17 @@ func (x *PersistentVolumeRecyclerConfiguration) CodecEncodeSelf(e *codec1978.Enc z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("incrementTimeoutNFS")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1243 := z.EncBinary() - _ = yym1243 + yym1248 := z.EncBinary() + _ = yym1248 if false { } else { r.EncodeInt(int64(x.IncrementTimeoutNFS)) } } - if yyr1231 || yy2arr1231 { + if yyr1236 || yy2arr1236 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1245 := z.EncBinary() - _ = yym1245 + yym1250 := z.EncBinary() + _ = yym1250 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.PodTemplateFilePathHostPath)) @@ -10710,17 +10758,17 @@ func (x *PersistentVolumeRecyclerConfiguration) CodecEncodeSelf(e *codec1978.Enc z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("podTemplateFilePathHostPath")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1246 := z.EncBinary() - _ = yym1246 + yym1251 := z.EncBinary() + _ = yym1251 if false { } else { r.EncodeString(codecSelferC_UTF81234, string(x.PodTemplateFilePathHostPath)) } } - if yyr1231 || yy2arr1231 { + if yyr1236 || yy2arr1236 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1248 := z.EncBinary() - _ = yym1248 + yym1253 := z.EncBinary() + _ = yym1253 if false { } else { r.EncodeInt(int64(x.MinimumTimeoutHostPath)) @@ -10729,17 +10777,17 @@ func (x *PersistentVolumeRecyclerConfiguration) CodecEncodeSelf(e *codec1978.Enc z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("minimumTimeoutHostPath")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1249 := z.EncBinary() - _ = yym1249 + yym1254 := z.EncBinary() + _ = yym1254 if false { } else { r.EncodeInt(int64(x.MinimumTimeoutHostPath)) } } - if yyr1231 || yy2arr1231 { + if yyr1236 || yy2arr1236 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - yym1251 := z.EncBinary() - _ = yym1251 + yym1256 := z.EncBinary() + _ = yym1256 if false { } else { r.EncodeInt(int64(x.IncrementTimeoutHostPath)) @@ -10748,14 +10796,14 @@ func (x *PersistentVolumeRecyclerConfiguration) CodecEncodeSelf(e *codec1978.Enc z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("incrementTimeoutHostPath")) z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1252 := z.EncBinary() - _ = yym1252 + yym1257 := z.EncBinary() + _ = yym1257 if false { } else { r.EncodeInt(int64(x.IncrementTimeoutHostPath)) } } - if yyr1231 || yy2arr1231 { + if yyr1236 || yy2arr1236 { z.EncSendContainerState(codecSelfer_containerArrayEnd1234) } else { z.EncSendContainerState(codecSelfer_containerMapEnd1234) @@ -10768,25 +10816,25 @@ func (x *PersistentVolumeRecyclerConfiguration) CodecDecodeSelf(d *codec1978.Dec var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - yym1253 := z.DecBinary() - _ = yym1253 + yym1258 := z.DecBinary() + _ = yym1258 if false { } else if z.HasExtensions() && z.DecExt(x) { } else { - yyct1254 := r.ContainerType() - if yyct1254 == codecSelferValueTypeMap1234 { - yyl1254 := r.ReadMapStart() - if yyl1254 == 0 { + yyct1259 := r.ContainerType() + if yyct1259 == codecSelferValueTypeMap1234 { + yyl1259 := r.ReadMapStart() + if yyl1259 == 0 { z.DecSendContainerState(codecSelfer_containerMapEnd1234) } else { - x.codecDecodeSelfFromMap(yyl1254, d) + x.codecDecodeSelfFromMap(yyl1259, d) } - } else if yyct1254 == codecSelferValueTypeArray1234 { - yyl1254 := r.ReadArrayStart() - if yyl1254 == 0 { + } else if yyct1259 == codecSelferValueTypeArray1234 { + yyl1259 := r.ReadArrayStart() + if yyl1259 == 0 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } else { - x.codecDecodeSelfFromArray(yyl1254, d) + x.codecDecodeSelfFromArray(yyl1259, d) } } else { panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) @@ -10798,12 +10846,12 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromMap(l int, d var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yys1255Slc = z.DecScratchBuffer() // default slice to decode into - _ = yys1255Slc - var yyhl1255 bool = l >= 0 - for yyj1255 := 0; ; yyj1255++ { - if yyhl1255 { - if yyj1255 >= l { + var yys1260Slc = z.DecScratchBuffer() // default slice to decode into + _ = yys1260Slc + var yyhl1260 bool = l >= 0 + for yyj1260 := 0; ; yyj1260++ { + if yyhl1260 { + if yyj1260 >= l { break } } else { @@ -10812,10 +10860,10 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromMap(l int, d } } z.DecSendContainerState(codecSelfer_containerMapKey1234) - yys1255Slc = r.DecodeBytes(yys1255Slc, true, true) - yys1255 := string(yys1255Slc) + yys1260Slc = r.DecodeBytes(yys1260Slc, true, true) + yys1260 := string(yys1260Slc) z.DecSendContainerState(codecSelfer_containerMapValue1234) - switch yys1255 { + switch yys1260 { case "maximumRetry": if r.TryDecodeAsNil() { x.MaximumRetry = 0 @@ -10859,9 +10907,9 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromMap(l int, d x.IncrementTimeoutHostPath = int32(r.DecodeInt(32)) } default: - z.DecStructFieldNotFound(-1, yys1255) - } // end switch yys1255 - } // end for yyj1255 + z.DecStructFieldNotFound(-1, yys1260) + } // end switch yys1260 + } // end for yyj1260 z.DecSendContainerState(codecSelfer_containerMapEnd1234) } @@ -10869,16 +10917,16 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromArray(l int, var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj1263 int - var yyb1263 bool - var yyhl1263 bool = l >= 0 - yyj1263++ - if yyhl1263 { - yyb1263 = yyj1263 > l + var yyj1268 int + var yyb1268 bool + var yyhl1268 bool = l >= 0 + yyj1268++ + if yyhl1268 { + yyb1268 = yyj1268 > l } else { - yyb1263 = r.CheckBreak() + yyb1268 = r.CheckBreak() } - if yyb1263 { + if yyb1268 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10888,13 +10936,13 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromArray(l int, } else { x.MaximumRetry = int32(r.DecodeInt(32)) } - yyj1263++ - if yyhl1263 { - yyb1263 = yyj1263 > l + yyj1268++ + if yyhl1268 { + yyb1268 = yyj1268 > l } else { - yyb1263 = r.CheckBreak() + yyb1268 = r.CheckBreak() } - if yyb1263 { + if yyb1268 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10904,13 +10952,13 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromArray(l int, } else { x.MinimumTimeoutNFS = int32(r.DecodeInt(32)) } - yyj1263++ - if yyhl1263 { - yyb1263 = yyj1263 > l + yyj1268++ + if yyhl1268 { + yyb1268 = yyj1268 > l } else { - yyb1263 = r.CheckBreak() + yyb1268 = r.CheckBreak() } - if yyb1263 { + if yyb1268 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10920,13 +10968,13 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromArray(l int, } else { x.PodTemplateFilePathNFS = string(r.DecodeString()) } - yyj1263++ - if yyhl1263 { - yyb1263 = yyj1263 > l + yyj1268++ + if yyhl1268 { + yyb1268 = yyj1268 > l } else { - yyb1263 = r.CheckBreak() + yyb1268 = r.CheckBreak() } - if yyb1263 { + if yyb1268 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10936,13 +10984,13 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromArray(l int, } else { x.IncrementTimeoutNFS = int32(r.DecodeInt(32)) } - yyj1263++ - if yyhl1263 { - yyb1263 = yyj1263 > l + yyj1268++ + if yyhl1268 { + yyb1268 = yyj1268 > l } else { - yyb1263 = r.CheckBreak() + yyb1268 = r.CheckBreak() } - if yyb1263 { + if yyb1268 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10952,13 +11000,13 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromArray(l int, } else { x.PodTemplateFilePathHostPath = string(r.DecodeString()) } - yyj1263++ - if yyhl1263 { - yyb1263 = yyj1263 > l + yyj1268++ + if yyhl1268 { + yyb1268 = yyj1268 > l } else { - yyb1263 = r.CheckBreak() + yyb1268 = r.CheckBreak() } - if yyb1263 { + if yyb1268 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10968,13 +11016,13 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromArray(l int, } else { x.MinimumTimeoutHostPath = int32(r.DecodeInt(32)) } - yyj1263++ - if yyhl1263 { - yyb1263 = yyj1263 > l + yyj1268++ + if yyhl1268 { + yyb1268 = yyj1268 > l } else { - yyb1263 = r.CheckBreak() + yyb1268 = r.CheckBreak() } - if yyb1263 { + if yyb1268 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -10985,17 +11033,17 @@ func (x *PersistentVolumeRecyclerConfiguration) codecDecodeSelfFromArray(l int, x.IncrementTimeoutHostPath = int32(r.DecodeInt(32)) } for { - yyj1263++ - if yyhl1263 { - yyb1263 = yyj1263 > l + yyj1268++ + if yyhl1268 { + yyb1268 = yyj1268 > l } else { - yyb1263 = r.CheckBreak() + yyb1268 = r.CheckBreak() } - if yyb1263 { + if yyb1268 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj1263-1, "") + z.DecStructFieldNotFound(yyj1268-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } @@ -11005,20 +11053,20 @@ func (x codecSelfer1234) encconfig_ConfigurationMap(v pkg2_config.ConfigurationM z, r := codec1978.GenHelperEncoder(e) _, _, _ = h, z, r r.EncodeMapStart(len(v)) - for yyk1271, yyv1271 := range v { + for yyk1276, yyv1276 := range v { z.EncSendContainerState(codecSelfer_containerMapKey1234) - yym1272 := z.EncBinary() - _ = yym1272 + yym1277 := z.EncBinary() + _ = yym1277 if false { } else { - r.EncodeString(codecSelferC_UTF81234, string(yyk1271)) + r.EncodeString(codecSelferC_UTF81234, string(yyk1276)) } z.EncSendContainerState(codecSelfer_containerMapValue1234) - yym1273 := z.EncBinary() - _ = yym1273 + yym1278 := z.EncBinary() + _ = yym1278 if false { } else { - r.EncodeString(codecSelferC_UTF81234, string(yyv1271)) + r.EncodeString(codecSelferC_UTF81234, string(yyv1276)) } } z.EncSendContainerState(codecSelfer_containerMapEnd1234) @@ -11029,63 +11077,63 @@ func (x codecSelfer1234) decconfig_ConfigurationMap(v *pkg2_config.Configuration z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - yyv1274 := *v - yyl1274 := r.ReadMapStart() - yybh1274 := z.DecBasicHandle() - if yyv1274 == nil { - yyrl1274, _ := z.DecInferLen(yyl1274, yybh1274.MaxInitLen, 32) - yyv1274 = make(map[string]string, yyrl1274) - *v = yyv1274 - } - var yymk1274 string - var yymv1274 string - var yymg1274 bool - if yybh1274.MapValueReset { - } - if yyl1274 > 0 { - for yyj1274 := 0; yyj1274 < yyl1274; yyj1274++ { + yyv1279 := *v + yyl1279 := r.ReadMapStart() + yybh1279 := z.DecBasicHandle() + if yyv1279 == nil { + yyrl1279, _ := z.DecInferLen(yyl1279, yybh1279.MaxInitLen, 32) + yyv1279 = make(map[string]string, yyrl1279) + *v = yyv1279 + } + var yymk1279 string + var yymv1279 string + var yymg1279 bool + if yybh1279.MapValueReset { + } + if yyl1279 > 0 { + for yyj1279 := 0; yyj1279 < yyl1279; yyj1279++ { z.DecSendContainerState(codecSelfer_containerMapKey1234) if r.TryDecodeAsNil() { - yymk1274 = "" + yymk1279 = "" } else { - yymk1274 = string(r.DecodeString()) + yymk1279 = string(r.DecodeString()) } - if yymg1274 { - yymv1274 = yyv1274[yymk1274] + if yymg1279 { + yymv1279 = yyv1279[yymk1279] } z.DecSendContainerState(codecSelfer_containerMapValue1234) if r.TryDecodeAsNil() { - yymv1274 = "" + yymv1279 = "" } else { - yymv1274 = string(r.DecodeString()) + yymv1279 = string(r.DecodeString()) } - if yyv1274 != nil { - yyv1274[yymk1274] = yymv1274 + if yyv1279 != nil { + yyv1279[yymk1279] = yymv1279 } } - } else if yyl1274 < 0 { - for yyj1274 := 0; !r.CheckBreak(); yyj1274++ { + } else if yyl1279 < 0 { + for yyj1279 := 0; !r.CheckBreak(); yyj1279++ { z.DecSendContainerState(codecSelfer_containerMapKey1234) if r.TryDecodeAsNil() { - yymk1274 = "" + yymk1279 = "" } else { - yymk1274 = string(r.DecodeString()) + yymk1279 = string(r.DecodeString()) } - if yymg1274 { - yymv1274 = yyv1274[yymk1274] + if yymg1279 { + yymv1279 = yyv1279[yymk1279] } z.DecSendContainerState(codecSelfer_containerMapValue1234) if r.TryDecodeAsNil() { - yymv1274 = "" + yymv1279 = "" } else { - yymv1274 = string(r.DecodeString()) + yymv1279 = string(r.DecodeString()) } - if yyv1274 != nil { - yyv1274[yymk1274] = yymv1274 + if yyv1279 != nil { + yyv1279[yymk1279] = yymv1279 } } } // else len==0: TODO: Should we clear map entries? diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.go index abbb385e7faf..bc6ba76755c1 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/types.go @@ -427,6 +427,9 @@ type KubeletConfiguration struct { IPTablesDropBit int32 `json:"iptablesDropBit"` // Whitelist of unsafe sysctls or sysctl patterns (ending in *). AllowedUnsafeSysctls []string `json:"experimentalAllowedUnsafeSysctls,omitempty"` + // How to integrate with runtime. If set to cri, kubelet will switch to + // using the new Container Runtine Interface. + ExperimentalRuntimeIntegrationType string `json:"experimentalRuntimeIntegrationType,omitempty"` } type KubeSchedulerConfiguration struct { diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/types.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/types.go index febd2851e962..b38d6598324a 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/types.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/types.go @@ -483,4 +483,7 @@ type KubeletConfiguration struct { // Whitelist of unsafe sysctls or sysctl patterns (ending in *). Use these at your own risk. // Resource isolation might be lacking and pod might influence each other on the same node. AllowedUnsafeSysctls []string `json:"allowedUnsafeSysctls,omitempty"` + // How to integrate with runtime. If set to CRI, kubelet will switch to + // using the new Container Runtine Interface. + ExperimentalRuntimeIntegrationType string `json:"experimentalRuntimeIntegrationType,omitempty"` } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go index 64ee6bee8e1b..b360c92a1cc2 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/zz_generated.conversion.go @@ -335,6 +335,7 @@ func autoConvert_v1alpha1_KubeletConfiguration_To_componentconfig_KubeletConfigu return err } out.AllowedUnsafeSysctls = in.AllowedUnsafeSysctls + out.ExperimentalRuntimeIntegrationType = in.ExperimentalRuntimeIntegrationType return nil } @@ -515,6 +516,7 @@ func autoConvert_componentconfig_KubeletConfiguration_To_v1alpha1_KubeletConfigu return err } out.AllowedUnsafeSysctls = in.AllowedUnsafeSysctls + out.ExperimentalRuntimeIntegrationType = in.ExperimentalRuntimeIntegrationType return nil } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go index 5464a1b7d06e..60382152c2a4 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/v1alpha1/zz_generated.deepcopy.go @@ -411,6 +411,7 @@ func DeepCopy_v1alpha1_KubeletConfiguration(in interface{}, out interface{}, c * } else { out.AllowedUnsafeSysctls = nil } + out.ExperimentalRuntimeIntegrationType = in.ExperimentalRuntimeIntegrationType return nil } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/zz_generated.deepcopy.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/zz_generated.deepcopy.go index 627808e9a75f..28424cb78a6c 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/zz_generated.deepcopy.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/componentconfig/zz_generated.deepcopy.go @@ -347,6 +347,7 @@ func DeepCopy_componentconfig_KubeletConfiguration(in interface{}, out interface } else { out.AllowedUnsafeSysctls = nil } + out.ExperimentalRuntimeIntegrationType = in.ExperimentalRuntimeIntegrationType return nil } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/extensions/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/extensions/install/install.go index b7c95daeea84..4d1d1cdc942a 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/extensions/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/extensions/install/install.go @@ -19,121 +19,25 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/extensions" "k8s.io/client-go/1.5/pkg/apis/extensions/v1beta1" - "k8s.io/client-go/1.5/pkg/runtime" "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/extensions" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1beta1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", extensions.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions there. -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - // the list of kinds that are scoped at the root of the api hierarchy - // if a kind is not enumerated here, it is assumed to have a namespace scope - rootScoped := sets.NewString( - "PodSecurityPolicy", - "ThirdPartyResource", - "StorageClass", - ) - - ignoredKinds := sets.NewString() - - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -// interfacesFor returns the default Codec and ResourceVersioner for a given version -// string, or an error if the version is not known. -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1beta1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(extensions.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := extensions.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: extensions.GroupName, + VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/extensions", + RootScopedKinds: sets.NewString("PodSecurityPolicy", "ThirdPartyResource"), + AddInternalObjectsToScheme: extensions.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1beta1.SchemeGroupVersion: - if err := v1beta1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/install/install.go index 8101aafc17db..87fd9974b591 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/install/install.go @@ -19,105 +19,25 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/imagepolicy" "k8s.io/client-go/1.5/pkg/apis/imagepolicy/v1alpha1" - "k8s.io/client-go/1.5/pkg/runtime" "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/imagepolicy" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1alpha1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", imagepolicy.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions there. -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - imagepolicy.AddToScheme(api.Scheme) - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1alpha1.SchemeGroupVersion: - v1alpha1.AddToScheme(api.Scheme) - } - } -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - rootScoped := sets.NewString("ImageReview") - ignoredKinds := sets.NewString() - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1alpha1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(imagepolicy.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: imagepolicy.GroupName, + VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/imagepolicy", + RootScopedKinds: sets.NewString("ImageReview"), + AddInternalObjectsToScheme: imagepolicy.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { + panic(err) } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/v1alpha1/doc.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/v1alpha1/doc.go index a5897446fb7c..6892fbef2be9 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/v1alpha1/doc.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/v1alpha1/doc.go @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -// +groupName=imagepolicy.k8s.io // +k8s:deepcopy-gen=package,register // +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/imagepolicy // +k8s:openapi-gen=true +// +groupName=imagepolicy.k8s.io package v1alpha1 diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/v1alpha1/types_swagger_doc_generated.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/v1alpha1/types_swagger_doc_generated.go new file mode 100644 index 000000000000..f4b26f5e8f8d --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/imagepolicy/v1alpha1/types_swagger_doc_generated.go @@ -0,0 +1,70 @@ +/* +Copyright 2016 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 v1alpha1 + +// This file contains a collection of methods that can be used from go-restful to +// generate Swagger API documentation for its models. Please read this PR for more +// information on the implementation: https://github.com/emicklei/go-restful/pull/215 +// +// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if +// they are on one line! For multiple line or blocks that you want to ignore use ---. +// Any context after a --- is ignored. +// +// Those methods can be generated by using hack/update-generated-swagger-docs.sh + +// AUTO-GENERATED FUNCTIONS START HERE +var map_ImageReview = map[string]string{ + "": "ImageReview checks if the set of images in a pod are allowed.", + "spec": "Spec holds information about the pod being evaluated", + "status": "Status is filled in by the backend and indicates whether the pod should be allowed.", +} + +func (ImageReview) SwaggerDoc() map[string]string { + return map_ImageReview +} + +var map_ImageReviewContainerSpec = map[string]string{ + "": "ImageReviewContainerSpec is a description of a container within the pod creation request.", + "image": "This can be in the form image:tag or image@SHA:012345679abcdef.", +} + +func (ImageReviewContainerSpec) SwaggerDoc() map[string]string { + return map_ImageReviewContainerSpec +} + +var map_ImageReviewSpec = map[string]string{ + "": "ImageReviewSpec is a description of the pod creation request.", + "containers": "Containers is a list of a subset of the information in each container of the Pod being created.", + "annotations": "Annotations is a list of key-value pairs extracted from the Pod's annotations. It only includes keys which match the pattern `*.image-policy.k8s.io/*`. It is up to each webhook backend to determine how to interpret these annotations, if at all.", + "namespace": "Namespace is the namespace the pod is being created in.", +} + +func (ImageReviewSpec) SwaggerDoc() map[string]string { + return map_ImageReviewSpec +} + +var map_ImageReviewStatus = map[string]string{ + "": "ImageReviewStatus is the result of the token authentication request.", + "allowed": "Allowed indicates that all images were allowed to be run.", + "reason": "Reason should be empty unless Allowed is false in which case it may contain a short description of what is wrong. Kubernetes may truncate excessively long errors when displaying to the user.", +} + +func (ImageReviewStatus) SwaggerDoc() map[string]string { + return map_ImageReviewStatus +} + +// AUTO-GENERATED FUNCTIONS END HERE diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/policy/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/policy/install/install.go index 0304fd0a351b..26d374d46259 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/policy/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/policy/install/install.go @@ -19,117 +19,23 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/policy" "k8s.io/client-go/1.5/pkg/apis/policy/v1alpha1" - "k8s.io/client-go/1.5/pkg/runtime" - "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/policy" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1alpha1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", policy.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions there. -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - // the list of kinds that are scoped at the root of the api hierarchy - // if a kind is not enumerated here, it is assumed to have a namespace scope - rootScoped := sets.NewString() - - ignoredKinds := sets.NewString() - - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -// interfacesFor returns the default Codec and ResourceVersioner for a given version -// string, or an error if the version is not known. -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1alpha1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(policy.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := policy.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: policy.GroupName, + VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/policy", + AddInternalObjectsToScheme: policy.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1alpha1.SchemeGroupVersion: - if err := v1alpha1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/policy/types.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/policy/types.go index 5c6dc8754892..c2d272437191 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/policy/types.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/policy/types.go @@ -50,7 +50,6 @@ type PodDisruptionBudgetStatus struct { } // +genclient=true -// +noMethods=true // PodDisruptionBudget is an object to define the max disruption that can be caused to a collection of pods type PodDisruptionBudget struct { diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/helpers.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/helpers.go index 4693c3d5999f..0bfefb1b5cb8 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/helpers.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/helpers.go @@ -17,9 +17,80 @@ limitations under the License. package rbac import ( + "strings" + "k8s.io/client-go/1.5/pkg/api/unversioned" ) func RoleRefGroupKind(roleRef RoleRef) unversioned.GroupKind { return unversioned.GroupKind{Group: roleRef.APIGroup, Kind: roleRef.Kind} } + +func VerbMatches(rule PolicyRule, requestedVerb string) bool { + for _, ruleVerb := range rule.Verbs { + if ruleVerb == VerbAll { + return true + } + if ruleVerb == requestedVerb { + return true + } + } + + return false +} + +func APIGroupMatches(rule PolicyRule, requestedGroup string) bool { + for _, ruleGroup := range rule.APIGroups { + if ruleGroup == APIGroupAll { + return true + } + if ruleGroup == requestedGroup { + return true + } + } + + return false +} + +func ResourceMatches(rule PolicyRule, requestedResource string) bool { + for _, ruleResource := range rule.Resources { + if ruleResource == ResourceAll { + return true + } + if ruleResource == requestedResource { + return true + } + } + + return false +} + +func ResourceNameMatches(rule PolicyRule, requestedName string) bool { + if len(rule.ResourceNames) == 0 { + return true + } + + for _, ruleName := range rule.ResourceNames { + if ruleName == requestedName { + return true + } + } + + return false +} + +func NonResourceURLMatches(rule PolicyRule, requestedURL string) bool { + for _, ruleURL := range rule.NonResourceURLs { + if ruleURL == NonResourceAll { + return true + } + if ruleURL == requestedURL { + return true + } + if strings.HasSuffix(ruleURL, "*") && strings.HasPrefix(requestedURL, strings.TrimRight(ruleURL, "*")) { + return true + } + } + + return false +} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/install/install.go index a7afd9fb5561..d02f33943d60 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/install/install.go @@ -19,118 +19,25 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/rbac" "k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1" - "k8s.io/client-go/1.5/pkg/runtime" "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/rbac" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1alpha1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", rbac.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions there. -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - rootScoped := sets.NewString( - "ClusterRole", - "ClusterRoleBinding", - ) - - ignoredKinds := sets.NewString() - - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -// interfacesFor returns the default Codec and ResourceVersioner for a given version -// string, or an error if the version is not known. -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1alpha1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(rbac.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := rbac.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: rbac.GroupName, + VersionPreferenceOrder: []string{v1alpha1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/rbac", + RootScopedKinds: sets.NewString("ClusterRole", "ClusterRoleBinding"), + AddInternalObjectsToScheme: rbac.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1alpha1.SchemeGroupVersion.Version: v1alpha1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1alpha1.SchemeGroupVersion: - if err := v1alpha1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1/doc.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1/doc.go index c3f50e2e7fa4..ab6aa6aba4d7 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1/doc.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/rbac/v1alpha1/doc.go @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -// +groupName=rbac.authorization.k8s.io // +k8s:deepcopy-gen=package,register // +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/rbac // +k8s:openapi-gen=true +// +groupName=rbac.authorization.k8s.io package v1alpha1 diff --git a/staging/src/k8s.io/client-go/1.5/pkg/apis/storage/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/apis/storage/install/install.go index ba5b75bd165d..175ee2c7192d 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/apis/storage/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/apis/storage/install/install.go @@ -19,119 +19,25 @@ limitations under the License. package install import ( - "fmt" - - "github.com/golang/glog" - - "k8s.io/client-go/1.5/pkg/api" - "k8s.io/client-go/1.5/pkg/api/meta" - "k8s.io/client-go/1.5/pkg/api/unversioned" - "k8s.io/client-go/1.5/pkg/apimachinery" - "k8s.io/client-go/1.5/pkg/apimachinery/registered" + "k8s.io/client-go/1.5/pkg/apimachinery/announced" "k8s.io/client-go/1.5/pkg/apis/storage" "k8s.io/client-go/1.5/pkg/apis/storage/v1beta1" - "k8s.io/client-go/1.5/pkg/runtime" "k8s.io/client-go/1.5/pkg/util/sets" ) -const importPrefix = "k8s.io/client-go/1.5/pkg/apis/storage" - -var accessor = meta.NewAccessor() - -// availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []unversioned.GroupVersion{v1beta1.SchemeGroupVersion} - func init() { - registered.RegisterVersions(availableVersions) - externalVersions := []unversioned.GroupVersion{} - for _, v := range availableVersions { - if registered.IsAllowedVersion(v) { - externalVersions = append(externalVersions, v) - } - } - if len(externalVersions) == 0 { - glog.V(4).Infof("No version is registered for group %v", storage.GroupName) - return - } - - if err := registered.EnableVersions(externalVersions...); err != nil { - glog.V(4).Infof("%v", err) - return - } - if err := enableVersions(externalVersions); err != nil { - glog.V(4).Infof("%v", err) - return - } -} - -// TODO: enableVersions should be centralized rather than spread in each API -// group. -// We can combine registered.RegisterVersions, registered.EnableVersions and -// registered.RegisterGroup once we have moved enableVersions there. -func enableVersions(externalVersions []unversioned.GroupVersion) error { - addVersionsToScheme(externalVersions...) - preferredExternalVersion := externalVersions[0] - - groupMeta := apimachinery.GroupMeta{ - GroupVersion: preferredExternalVersion, - GroupVersions: externalVersions, - RESTMapper: newRESTMapper(externalVersions), - SelfLinker: runtime.SelfLinker(accessor), - InterfacesFor: interfacesFor, - } - - if err := registered.RegisterGroup(groupMeta); err != nil { - return err - } - api.RegisterRESTMapper(groupMeta.RESTMapper) - return nil -} - -func newRESTMapper(externalVersions []unversioned.GroupVersion) meta.RESTMapper { - // the list of kinds that are scoped at the root of the api hierarchy - // if a kind is not enumerated here, it is assumed to have a namespace scope - rootScoped := sets.NewString( - "StorageClass", - ) - - ignoredKinds := sets.NewString() - - return api.NewDefaultRESTMapper(externalVersions, interfacesFor, importPrefix, ignoredKinds, rootScoped) -} - -// interfacesFor returns the default Codec and ResourceVersioner for a given version -// string, or an error if the version is not known. -func interfacesFor(version unversioned.GroupVersion) (*meta.VersionInterfaces, error) { - switch version { - case v1beta1.SchemeGroupVersion: - return &meta.VersionInterfaces{ - ObjectConvertor: api.Scheme, - MetadataAccessor: accessor, - }, nil - default: - g, _ := registered.Group(storage.GroupName) - return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) - } -} - -func addVersionsToScheme(externalVersions ...unversioned.GroupVersion) { - // add the internal version to Scheme - if err := storage.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately + if err := announced.NewGroupMetaFactory( + &announced.GroupMetaFactoryArgs{ + GroupName: storage.GroupName, + VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version}, + ImportPrefix: "k8s.io/client-go/1.5/pkg/apis/storage", + RootScopedKinds: sets.NewString("StorageClass"), + AddInternalObjectsToScheme: storage.AddToScheme, + }, + announced.VersionToSchemeFunc{ + v1beta1.SchemeGroupVersion.Version: v1beta1.AddToScheme, + }, + ).Announce().RegisterAndEnable(); err != nil { panic(err) } - // add the enabled external versions to Scheme - for _, v := range externalVersions { - if !registered.IsEnabledVersion(v) { - glog.Errorf("Version %s is not enabled, so it will not be added to the Scheme.", v) - continue - } - switch v { - case v1beta1.SchemeGroupVersion: - if err := v1beta1.AddToScheme(api.Scheme); err != nil { - // Programmer error, detect immediately - panic(err) - } - } - } } diff --git a/staging/src/k8s.io/client-go/1.5/pkg/federation/apis/federation/install/install.go b/staging/src/k8s.io/client-go/1.5/pkg/federation/apis/federation/install/install.go index b68ec0863077..afc2c021fe53 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/federation/apis/federation/install/install.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/federation/apis/federation/install/install.go @@ -81,7 +81,6 @@ func enableVersions(externalVersions []unversioned.GroupVersion) error { if err := registered.RegisterGroup(groupMeta); err != nil { return err } - api.RegisterRESTMapper(groupMeta.RESTMapper) return nil } diff --git a/staging/src/k8s.io/client-go/1.5/cmd/libs/go2idl/openapi-gen/generators/common/common.go b/staging/src/k8s.io/client-go/1.5/pkg/genericapiserver/openapi/common/common.go similarity index 100% rename from staging/src/k8s.io/client-go/1.5/cmd/libs/go2idl/openapi-gen/generators/common/common.go rename to staging/src/k8s.io/client-go/1.5/pkg/genericapiserver/openapi/common/common.go diff --git a/staging/src/k8s.io/client-go/1.5/cmd/libs/go2idl/openapi-gen/generators/common/doc.go b/staging/src/k8s.io/client-go/1.5/pkg/genericapiserver/openapi/common/doc.go similarity index 100% rename from staging/src/k8s.io/client-go/1.5/cmd/libs/go2idl/openapi-gen/generators/common/doc.go rename to staging/src/k8s.io/client-go/1.5/pkg/genericapiserver/openapi/common/doc.go diff --git a/staging/src/k8s.io/client-go/1.5/pkg/kubelet/qos/policy.go b/staging/src/k8s.io/client-go/1.5/pkg/kubelet/qos/policy.go index e900e0d8ae06..657709a323ba 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/kubelet/qos/policy.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/kubelet/qos/policy.go @@ -21,8 +21,9 @@ import ( ) const ( - PodInfraOOMAdj int = -999 + PodInfraOOMAdj int = -998 KubeletOOMScoreAdj int = -999 + DockerOOMScoreAdj int = -999 KubeProxyOOMScoreAdj int = -999 guaranteedOOMScoreAdj int = -998 besteffortOOMScoreAdj int = 1000 @@ -53,10 +54,10 @@ func GetContainerOOMScoreAdjust(pod *api.Pod, container *api.Container, memoryCa // Note that this is a heuristic, it won't work if a container has many small processes. memoryRequest := container.Resources.Requests.Memory().Value() oomScoreAdjust := 1000 - (1000*memoryRequest)/memoryCapacity - // A guaranteed pod using 100% of memory can have an OOM score of 1. Ensure + // A guaranteed pod using 100% of memory can have an OOM score of 10. Ensure // that burstable pods have a higher OOM score adjustment. - if oomScoreAdjust < 2 { - return 2 + if int(oomScoreAdjust) < (1000 + guaranteedOOMScoreAdj) { + return (1000 + guaranteedOOMScoreAdj) } // Give burstable pods a higher chance of survival over besteffort pods. if int(oomScoreAdjust) == besteffortOOMScoreAdj { diff --git a/staging/src/k8s.io/client-go/1.5/pkg/kubelet/qos/qos.go b/staging/src/k8s.io/client-go/1.5/pkg/kubelet/qos/qos.go index b2c2510886fb..52cfadfc1cca 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/kubelet/qos/qos.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/kubelet/qos/qos.go @@ -19,6 +19,7 @@ package qos import ( "k8s.io/client-go/1.5/pkg/api" "k8s.io/client-go/1.5/pkg/api/resource" + "k8s.io/client-go/1.5/pkg/util/sets" ) // isResourceGuaranteed returns true if the container's resource requirements are Guaranteed. @@ -53,6 +54,9 @@ func GetPodQOS(pod *api.Pod) QOSClass { for _, container := range pod.Spec.Containers { // process requests for name, quantity := range container.Resources.Requests { + if !supportedQoSComputeResources.Has(string(name)) { + continue + } if quantity.Cmp(zeroQuantity) == 1 { delta := quantity.Copy() if _, exists := requests[name]; !exists { @@ -65,6 +69,9 @@ func GetPodQOS(pod *api.Pod) QOSClass { } // process limits for name, quantity := range container.Resources.Limits { + if !supportedQoSComputeResources.Has(string(name)) { + continue + } if quantity.Cmp(zeroQuantity) == 1 { delta := quantity.Copy() if _, exists := limits[name]; !exists { @@ -75,7 +82,7 @@ func GetPodQOS(pod *api.Pod) QOSClass { } } } - if len(container.Resources.Limits) != len(supportedComputeResources) { + if len(limits) != len(supportedQoSComputeResources) { isGuaranteed = false } } @@ -92,8 +99,7 @@ func GetPodQOS(pod *api.Pod) QOSClass { } } if isGuaranteed && - len(requests) == len(limits) && - len(limits) == len(supportedComputeResources) { + len(requests) == len(limits) { return Guaranteed } return Burstable @@ -118,17 +124,14 @@ func GetQOS(container *api.Container) QOSList { return resourceToQOS } -// supportedComputeResources is the list of supported compute resources -var supportedComputeResources = []api.ResourceName{ - api.ResourceCPU, - api.ResourceMemory, -} +// supportedComputeResources is the list of compute resources for with QoS is supported. +var supportedQoSComputeResources = sets.NewString(string(api.ResourceCPU), string(api.ResourceMemory)) // allResources returns a set of all possible resources whose mapped key value is true if present on the container func allResources(container *api.Container) map[api.ResourceName]bool { resources := map[api.ResourceName]bool{} - for _, resource := range supportedComputeResources { - resources[resource] = false + for _, resource := range supportedQoSComputeResources.List() { + resources[api.ResourceName(resource)] = false } for resource := range container.Resources.Requests { resources[resource] = true diff --git a/staging/src/k8s.io/client-go/1.5/pkg/util/cert/cert.go b/staging/src/k8s.io/client-go/1.5/pkg/util/cert/cert.go new file mode 100644 index 000000000000..8617744a7321 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/pkg/util/cert/cert.go @@ -0,0 +1,190 @@ +/* +Copyright 2014 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 cert + +import ( + "bytes" + "crypto/ecdsa" + "crypto/elliptic" + cryptorand "crypto/rand" + "crypto/rsa" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "fmt" + "math" + "math/big" + "net" + "time" +) + +const ( + rsaKeySize = 2048 + duration365d = time.Hour * 24 * 365 +) + +// Config containes the basic fields required for creating a certificate +type Config struct { + CommonName string + Organization []string + AltNames AltNames +} + +// AltNames contains the domain names and IP addresses that will be added +// to the API Server's x509 certificate SubAltNames field. The values will +// be passed directly to the x509.Certificate object. +type AltNames struct { + DNSNames []string + IPs []net.IP +} + +// NewPrivateKey creates an RSA private key +func NewPrivateKey() (*rsa.PrivateKey, error) { + return rsa.GenerateKey(cryptorand.Reader, rsaKeySize) +} + +// NewSelfSignedCACert creates a CA certificate +func NewSelfSignedCACert(cfg Config, key *rsa.PrivateKey) (*x509.Certificate, error) { + now := time.Now() + tmpl := x509.Certificate{ + SerialNumber: new(big.Int).SetInt64(0), + Subject: pkix.Name{ + CommonName: cfg.CommonName, + Organization: cfg.Organization, + }, + NotBefore: now.UTC(), + NotAfter: now.Add(duration365d * 10).UTC(), + KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, + BasicConstraintsValid: true, + IsCA: true, + } + + certDERBytes, err := x509.CreateCertificate(cryptorand.Reader, &tmpl, &tmpl, key.Public(), key) + if err != nil { + return nil, err + } + return x509.ParseCertificate(certDERBytes) +} + +// NewSignedCert creates a signed certificate using the given CA certificate and key +func NewSignedCert(cfg Config, key *rsa.PrivateKey, caCert *x509.Certificate, caKey *rsa.PrivateKey) (*x509.Certificate, error) { + serial, err := cryptorand.Int(cryptorand.Reader, new(big.Int).SetInt64(math.MaxInt64)) + if err != nil { + return nil, err + } + + certTmpl := x509.Certificate{ + Subject: pkix.Name{ + CommonName: cfg.CommonName, + Organization: caCert.Subject.Organization, + }, + DNSNames: cfg.AltNames.DNSNames, + IPAddresses: cfg.AltNames.IPs, + SerialNumber: serial, + NotBefore: caCert.NotBefore, + NotAfter: time.Now().Add(duration365d).UTC(), + KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth}, + } + certDERBytes, err := x509.CreateCertificate(cryptorand.Reader, &certTmpl, caCert, key.Public(), caKey) + if err != nil { + return nil, err + } + return x509.ParseCertificate(certDERBytes) +} + +// MakeEllipticPrivateKeyPEM creates an ECDSA private key +func MakeEllipticPrivateKeyPEM() ([]byte, error) { + privateKey, err := ecdsa.GenerateKey(elliptic.P256(), cryptorand.Reader) + if err != nil { + return nil, err + } + + derBytes, err := x509.MarshalECPrivateKey(privateKey) + if err != nil { + return nil, err + } + + privateKeyPemBlock := &pem.Block{ + Type: "EC PRIVATE KEY", + Bytes: derBytes, + } + return pem.EncodeToMemory(privateKeyPemBlock), nil +} + +// GenerateSelfSignedCert creates a self-signed certificate and key for the given host. +// Host may be an IP or a DNS name +// You may also specify additional subject alt names (either ip or dns names) for the certificate +// The certificate will be created with file mode 0644. The key will be created with file mode 0600. +// If the certificate or key files already exist, they will be overwritten. +// Any parent directories of the certPath or keyPath will be created as needed with file mode 0755. +func GenerateSelfSignedCert(host, certPath, keyPath string, alternateIPs []net.IP, alternateDNS []string) error { + priv, err := rsa.GenerateKey(cryptorand.Reader, 2048) + if err != nil { + return err + } + + template := x509.Certificate{ + SerialNumber: big.NewInt(1), + Subject: pkix.Name{ + CommonName: fmt.Sprintf("%s@%d", host, time.Now().Unix()), + }, + NotBefore: time.Now(), + NotAfter: time.Now().Add(time.Hour * 24 * 365), + + KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, + BasicConstraintsValid: true, + IsCA: true, + } + + if ip := net.ParseIP(host); ip != nil { + template.IPAddresses = append(template.IPAddresses, ip) + } else { + template.DNSNames = append(template.DNSNames, host) + } + + template.IPAddresses = append(template.IPAddresses, alternateIPs...) + template.DNSNames = append(template.DNSNames, alternateDNS...) + + derBytes, err := x509.CreateCertificate(cryptorand.Reader, &template, &template, &priv.PublicKey, priv) + if err != nil { + return err + } + + // Generate cert + certBuffer := bytes.Buffer{} + if err := pem.Encode(&certBuffer, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}); err != nil { + return err + } + + // Generate key + keyBuffer := bytes.Buffer{} + if err := pem.Encode(&keyBuffer, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)}); err != nil { + return err + } + + if err := WriteCert(certPath, certBuffer.Bytes()); err != nil { + return err + } + + if err := WriteKey(keyPath, keyBuffer.Bytes()); err != nil { + return err + } + + return nil +} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/util/cert/csr.go b/staging/src/k8s.io/client-go/1.5/pkg/util/cert/csr.go new file mode 100644 index 000000000000..f03e8d82620e --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/pkg/util/cert/csr.go @@ -0,0 +1,81 @@ +/* +Copyright 2016 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 cert + +import ( + cryptorand "crypto/rand" + "crypto/rsa" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "errors" + "net" + + "k8s.io/client-go/1.5/pkg/apis/certificates" +) + +// ParseCSR extracts the CSR from the API object and decodes it. +func ParseCSR(obj *certificates.CertificateSigningRequest) (*x509.CertificateRequest, error) { + // extract PEM from request object + pemBytes := obj.Spec.Request + block, _ := pem.Decode(pemBytes) + if block == nil || block.Type != "CERTIFICATE REQUEST" { + return nil, errors.New("PEM block type must be CERTIFICATE REQUEST") + } + csr, err := x509.ParseCertificateRequest(block.Bytes) + if err != nil { + return nil, err + } + return csr, nil +} + +// MakeCSR generates a PEM-encoded CSR using the supplied private key, subject, and SANs. +// All key types that are implemented via crypto.Signer are supported (This includes *rsa.PrivateKey and *ecdsa.PrivateKey.) +func MakeCSR(privateKey interface{}, subject *pkix.Name, dnsSANs []string, ipSANs []net.IP) (csr []byte, err error) { + // Customize the signature for RSA keys, depending on the key size + var sigType x509.SignatureAlgorithm + if privateKey, ok := privateKey.(*rsa.PrivateKey); ok { + keySize := privateKey.N.BitLen() + switch { + case keySize >= 4096: + sigType = x509.SHA512WithRSA + case keySize >= 3072: + sigType = x509.SHA384WithRSA + default: + sigType = x509.SHA256WithRSA + } + } + + template := &x509.CertificateRequest{ + Subject: *subject, + SignatureAlgorithm: sigType, + DNSNames: dnsSANs, + IPAddresses: ipSANs, + } + + csr, err = x509.CreateCertificateRequest(cryptorand.Reader, template, privateKey) + if err != nil { + return nil, err + } + + csrPemBlock := &pem.Block{ + Type: "CERTIFICATE REQUEST", + Bytes: csr, + } + + return pem.EncodeToMemory(csrPemBlock), nil +} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/util/cert/io.go b/staging/src/k8s.io/client-go/1.5/pkg/util/cert/io.go new file mode 100644 index 000000000000..9a3e1622f37a --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/pkg/util/cert/io.go @@ -0,0 +1,108 @@ +/* +Copyright 2014 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 cert + +import ( + "crypto/x509" + "errors" + "fmt" + "io/ioutil" + "os" + "path/filepath" +) + +// CanReadCertOrKey returns true if the certificate or key files already exists, +// otherwise returns false. +func CanReadCertOrKey(certPath, keyPath string) bool { + if canReadFile(certPath) || canReadFile(keyPath) { + return true + } + + return false +} + +// If the file represented by path exists and +// readable, returns true otherwise returns false. +func canReadFile(path string) bool { + f, err := os.Open(path) + if err != nil { + return false + } + + defer f.Close() + + return true +} + +// WriteCert writes the pem-encoded certificate data to certPath. +// The certificate file will be created with file mode 0644. +// If the certificate file already exists, it will be overwritten. +// The parent directory of the certPath will be created as needed with file mode 0755. +func WriteCert(certPath string, data []byte) error { + if err := os.MkdirAll(filepath.Dir(certPath), os.FileMode(0755)); err != nil { + return err + } + if err := ioutil.WriteFile(certPath, data, os.FileMode(0644)); err != nil { + return err + } + return nil +} + +// WriteKey writes the pem-encoded key data to keyPath. +// The key file will be created with file mode 0600. +// If the key file already exists, it will be overwritten. +// The parent directory of the keyPath will be created as needed with file mode 0755. +func WriteKey(keyPath string, data []byte) error { + if err := os.MkdirAll(filepath.Dir(keyPath), os.FileMode(0755)); err != nil { + return err + } + if err := ioutil.WriteFile(keyPath, data, os.FileMode(0600)); err != nil { + return err + } + return nil +} + +// NewPool returns an x509.CertPool containing the certificates in the given PEM-encoded file. +// Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates +func NewPool(filename string) (*x509.CertPool, error) { + certs, err := certsFromFile(filename) + if err != nil { + return nil, err + } + pool := x509.NewCertPool() + for _, cert := range certs { + pool.AddCert(cert) + } + return pool, nil +} + +// certsFromFile returns the x509.Certificates contained in the given PEM-encoded file. +// Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates +func certsFromFile(file string) ([]*x509.Certificate, error) { + if len(file) == 0 { + return nil, errors.New("error reading certificates from an empty filename") + } + pemBlock, err := ioutil.ReadFile(file) + if err != nil { + return nil, err + } + certs, err := ParseCertsPEM(pemBlock) + if err != nil { + return nil, fmt.Errorf("error reading %s: %s", file, err) + } + return certs, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/util/cert/pem.go b/staging/src/k8s.io/client-go/1.5/pkg/util/cert/pem.go new file mode 100644 index 000000000000..59e602d2f1c5 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/pkg/util/cert/pem.go @@ -0,0 +1,107 @@ +/* +Copyright 2014 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 cert + +import ( + "crypto/rsa" + "crypto/x509" + "encoding/pem" + "errors" + "fmt" +) + +// EncodePublicKeyPEM returns PEM-endcode public data +func EncodePublicKeyPEM(key *rsa.PublicKey) ([]byte, error) { + der, err := x509.MarshalPKIXPublicKey(key) + if err != nil { + return []byte{}, err + } + block := pem.Block{ + Type: "PUBLIC KEY", + Bytes: der, + } + return pem.EncodeToMemory(&block), nil +} + +// EncodePrivateKeyPEM returns PEM-encoded private key data +func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte { + block := pem.Block{ + Type: "RSA PRIVATE KEY", + Bytes: x509.MarshalPKCS1PrivateKey(key), + } + return pem.EncodeToMemory(&block) +} + +// EncodeCertPEM returns PEM-endcoded certificate data +func EncodeCertPEM(cert *x509.Certificate) []byte { + block := pem.Block{ + Type: "CERTIFICATE", + Bytes: cert.Raw, + } + return pem.EncodeToMemory(&block) +} + +// ParsePrivateKeyPEM returns a private key parsed from a PEM block in the supplied data. +// Recognizes PEM blocks for "EC PRIVATE KEY" and "RSA PRIVATE KEY" +func ParsePrivateKeyPEM(keyData []byte) (interface{}, error) { + for { + var privateKeyPemBlock *pem.Block + privateKeyPemBlock, keyData = pem.Decode(keyData) + if privateKeyPemBlock == nil { + // we read all the PEM blocks and didn't recognize one + return nil, fmt.Errorf("no private key PEM block found") + } + + switch privateKeyPemBlock.Type { + case "EC PRIVATE KEY": + return x509.ParseECPrivateKey(privateKeyPemBlock.Bytes) + case "RSA PRIVATE KEY": + return x509.ParsePKCS1PrivateKey(privateKeyPemBlock.Bytes) + } + } +} + +// ParseCertsPEM returns the x509.Certificates contained in the given PEM-encoded byte array +// Returns an error if a certificate could not be parsed, or if the data does not contain any certificates +func ParseCertsPEM(pemCerts []byte) ([]*x509.Certificate, error) { + ok := false + certs := []*x509.Certificate{} + for len(pemCerts) > 0 { + var block *pem.Block + block, pemCerts = pem.Decode(pemCerts) + if block == nil { + break + } + // Only use PEM "CERTIFICATE" blocks without extra headers + if block.Type != "CERTIFICATE" || len(block.Headers) != 0 { + continue + } + + cert, err := x509.ParseCertificate(block.Bytes) + if err != nil { + return certs, err + } + + certs = append(certs, cert) + ok = true + } + + if !ok { + return certs, errors.New("could not read any certificates") + } + return certs, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/util/crypto/crypto.go b/staging/src/k8s.io/client-go/1.5/pkg/util/crypto/crypto.go deleted file mode 100644 index 7e926450844b..000000000000 --- a/staging/src/k8s.io/client-go/1.5/pkg/util/crypto/crypto.go +++ /dev/null @@ -1,212 +0,0 @@ -/* -Copyright 2014 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 crypto - -import ( - "bytes" - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "crypto/x509/pkix" - "encoding/pem" - "errors" - "fmt" - "io/ioutil" - "math/big" - "net" - "os" - "path/filepath" - "time" -) - -// FoundCertOrKey returns true if the certificate or key files already exists, -// otherwise returns false. -func FoundCertOrKey(certPath, keyPath string) bool { - if canReadFile(certPath) || canReadFile(keyPath) { - return true - } - - return false -} - -// If the file represented by path exists and -// readable, returns true otherwise returns false. -func canReadFile(path string) bool { - f, err := os.Open(path) - if err != nil { - return false - } - - defer f.Close() - - return true -} - -// GenerateSelfSignedCert creates a self-signed certificate and key for the given host. -// Host may be an IP or a DNS name -// You may also specify additional subject alt names (either ip or dns names) for the certificate -// The certificate will be created with file mode 0644. The key will be created with file mode 0600. -// If the certificate or key files already exist, they will be overwritten. -// Any parent directories of the certPath or keyPath will be created as needed with file mode 0755. -func GenerateSelfSignedCert(host, certPath, keyPath string, alternateIPs []net.IP, alternateDNS []string) error { - priv, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - return err - } - - template := x509.Certificate{ - SerialNumber: big.NewInt(1), - Subject: pkix.Name{ - CommonName: fmt.Sprintf("%s@%d", host, time.Now().Unix()), - }, - NotBefore: time.Now(), - NotAfter: time.Now().Add(time.Hour * 24 * 365), - - KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, - ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, - BasicConstraintsValid: true, - IsCA: true, - } - - if ip := net.ParseIP(host); ip != nil { - template.IPAddresses = append(template.IPAddresses, ip) - } else { - template.DNSNames = append(template.DNSNames, host) - } - - template.IPAddresses = append(template.IPAddresses, alternateIPs...) - template.DNSNames = append(template.DNSNames, alternateDNS...) - - derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) - if err != nil { - return err - } - - // Generate cert - certBuffer := bytes.Buffer{} - if err := pem.Encode(&certBuffer, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}); err != nil { - return err - } - - // Generate key - keyBuffer := bytes.Buffer{} - if err := pem.Encode(&keyBuffer, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)}); err != nil { - return err - } - - // Write cert - if err := WriteCertToPath(certPath, certBuffer.Bytes()); err != nil { - return err - } - - // Write key - if err := WriteKeyToPath(keyPath, keyBuffer.Bytes()); err != nil { - return err - } - - return nil -} - -// WriteCertToPath writes the pem-encoded certificate data to certPath. -// The certificate file will be created with file mode 0644. -// If the certificate file already exists, it will be overwritten. -// The parent directory of the certPath will be created as needed with file mode 0755. -func WriteCertToPath(certPath string, data []byte) error { - if err := os.MkdirAll(filepath.Dir(certPath), os.FileMode(0755)); err != nil { - return err - } - if err := ioutil.WriteFile(certPath, data, os.FileMode(0644)); err != nil { - return err - } - return nil -} - -// WriteKeyToPath writes the pem-encoded key data to keyPath. -// The key file will be created with file mode 0600. -// If the key file already exists, it will be overwritten. -// The parent directory of the keyPath will be created as needed with file mode 0755. -func WriteKeyToPath(keyPath string, data []byte) error { - if err := os.MkdirAll(filepath.Dir(keyPath), os.FileMode(0755)); err != nil { - return err - } - if err := ioutil.WriteFile(keyPath, data, os.FileMode(0600)); err != nil { - return err - } - return nil -} - -// CertPoolFromFile returns an x509.CertPool containing the certificates in the given PEM-encoded file. -// Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates -func CertPoolFromFile(filename string) (*x509.CertPool, error) { - certs, err := certificatesFromFile(filename) - if err != nil { - return nil, err - } - pool := x509.NewCertPool() - for _, cert := range certs { - pool.AddCert(cert) - } - return pool, nil -} - -// certificatesFromFile returns the x509.Certificates contained in the given PEM-encoded file. -// Returns an error if the file could not be read, a certificate could not be parsed, or if the file does not contain any certificates -func certificatesFromFile(file string) ([]*x509.Certificate, error) { - if len(file) == 0 { - return nil, errors.New("error reading certificates from an empty filename") - } - pemBlock, err := ioutil.ReadFile(file) - if err != nil { - return nil, err - } - certs, err := CertsFromPEM(pemBlock) - if err != nil { - return nil, fmt.Errorf("error reading %s: %s", file, err) - } - return certs, nil -} - -// CertsFromPEM returns the x509.Certificates contained in the given PEM-encoded byte array -// Returns an error if a certificate could not be parsed, or if the data does not contain any certificates -func CertsFromPEM(pemCerts []byte) ([]*x509.Certificate, error) { - ok := false - certs := []*x509.Certificate{} - for len(pemCerts) > 0 { - var block *pem.Block - block, pemCerts = pem.Decode(pemCerts) - if block == nil { - break - } - // Only use PEM "CERTIFICATE" blocks without extra headers - if block.Type != "CERTIFICATE" || len(block.Headers) != 0 { - continue - } - - cert, err := x509.ParseCertificate(block.Bytes) - if err != nil { - return certs, err - } - - certs = append(certs, cert) - ok = true - } - - if !ok { - return certs, errors.New("could not read any certificates") - } - return certs, nil -} diff --git a/staging/src/k8s.io/client-go/1.5/pkg/util/intstr/intstr.go b/staging/src/k8s.io/client-go/1.5/pkg/util/intstr/intstr.go index 4c21ba5b9be3..28c0c0ed4353 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/util/intstr/intstr.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/util/intstr/intstr.go @@ -23,7 +23,7 @@ import ( "strconv" "strings" - "k8s.io/client-go/1.5/cmd/libs/go2idl/openapi-gen/generators/common" + "k8s.io/client-go/1.5/pkg/genericapiserver/openapi/common" "github.com/go-openapi/spec" "github.com/google/gofuzz" diff --git a/staging/src/k8s.io/client-go/1.5/pkg/util/net/http.go b/staging/src/k8s.io/client-go/1.5/pkg/util/net/http.go index 53f28dfca253..15df077412eb 100644 --- a/staging/src/k8s.io/client-go/1.5/pkg/util/net/http.go +++ b/staging/src/k8s.io/client-go/1.5/pkg/util/net/http.go @@ -108,6 +108,34 @@ func Dialer(transport http.RoundTripper) (DialFunc, error) { } } +// CloneTLSConfig returns a tls.Config with all exported fields except SessionTicketsDisabled and SessionTicketKey copied. +// This makes it safe to call CloneTLSConfig on a config in active use by a server. +// TODO: replace with tls.Config#Clone when we move to go1.8 +func CloneTLSConfig(cfg *tls.Config) *tls.Config { + if cfg == nil { + return &tls.Config{} + } + return &tls.Config{ + Rand: cfg.Rand, + Time: cfg.Time, + Certificates: cfg.Certificates, + NameToCertificate: cfg.NameToCertificate, + GetCertificate: cfg.GetCertificate, + RootCAs: cfg.RootCAs, + NextProtos: cfg.NextProtos, + ServerName: cfg.ServerName, + ClientAuth: cfg.ClientAuth, + ClientCAs: cfg.ClientCAs, + InsecureSkipVerify: cfg.InsecureSkipVerify, + CipherSuites: cfg.CipherSuites, + PreferServerCipherSuites: cfg.PreferServerCipherSuites, + ClientSessionCache: cfg.ClientSessionCache, + MinVersion: cfg.MinVersion, + MaxVersion: cfg.MaxVersion, + CurvePreferences: cfg.CurvePreferences, + } +} + func TLSClientConfig(transport http.RoundTripper) (*tls.Config, error) { if transport == nil { return nil, nil diff --git a/staging/src/k8s.io/client-go/1.5/plugin/pkg/auth/authenticator/token/oidc/testing/provider.go b/staging/src/k8s.io/client-go/1.5/plugin/pkg/auth/authenticator/token/oidc/testing/provider.go new file mode 100644 index 000000000000..ae7353ff276e --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/plugin/pkg/auth/authenticator/token/oidc/testing/provider.go @@ -0,0 +1,200 @@ +/* +Copyright 2016 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 testing + +import ( + "bytes" + "crypto/rand" + "crypto/rsa" + "crypto/tls" + "crypto/x509" + "crypto/x509/pkix" + "encoding/json" + "encoding/pem" + "fmt" + "io/ioutil" + "math/big" + "net" + "net/http" + "net/http/httptest" + "net/url" + "os" + "path" + "path/filepath" + "testing" + "time" + + "github.com/coreos/go-oidc/jose" + "github.com/coreos/go-oidc/key" + "github.com/coreos/go-oidc/oidc" +) + +// NewOIDCProvider provides a bare minimum OIDC IdP Server useful for testing. +func NewOIDCProvider(t *testing.T, issuerPath string) *OIDCProvider { + privKey, err := key.GeneratePrivateKey() + if err != nil { + t.Fatalf("Cannot create OIDC Provider: %v", err) + return nil + } + + op := &OIDCProvider{ + Mux: http.NewServeMux(), + PrivKey: privKey, + issuerPath: issuerPath, + } + + op.Mux.HandleFunc(path.Join(issuerPath, "/.well-known/openid-configuration"), op.handleConfig) + op.Mux.HandleFunc(path.Join(issuerPath, "/keys"), op.handleKeys) + + return op +} + +type OIDCProvider struct { + Mux *http.ServeMux + PCFG oidc.ProviderConfig + PrivKey *key.PrivateKey + issuerPath string +} + +func (op *OIDCProvider) ServeTLSWithKeyPair(cert, key string) (*httptest.Server, error) { + srv := httptest.NewUnstartedServer(op.Mux) + + srv.TLS = &tls.Config{Certificates: make([]tls.Certificate, 1)} + var err error + srv.TLS.Certificates[0], err = tls.LoadX509KeyPair(cert, key) + if err != nil { + return nil, fmt.Errorf("Cannot load cert/key pair: %v", err) + } + srv.StartTLS() + + // The issuer's URL is extended by an optional path. This ensures that the plugin can + // handle issuers that use a non-root path for discovery (see kubernetes/kubernetes#29749). + srv.URL = srv.URL + op.issuerPath + + u, err := url.Parse(srv.URL) + if err != nil { + return nil, err + } + pathFor := func(p string) *url.URL { + u2 := *u // Shallow copy. + u2.Path = path.Join(u2.Path, p) + return &u2 + } + + op.PCFG = oidc.ProviderConfig{ + Issuer: u, + AuthEndpoint: pathFor("/auth"), + TokenEndpoint: pathFor("/token"), + KeysEndpoint: pathFor("/keys"), + ResponseTypesSupported: []string{"code"}, + SubjectTypesSupported: []string{"public"}, + IDTokenSigningAlgValues: []string{"RS256"}, + } + return srv, nil +} + +func (op *OIDCProvider) handleConfig(w http.ResponseWriter, req *http.Request) { + b, err := json.Marshal(&op.PCFG) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + w.Header().Set("Content-Type", "application/json") + w.Write(b) +} + +func (op *OIDCProvider) handleKeys(w http.ResponseWriter, req *http.Request) { + keys := struct { + Keys []jose.JWK `json:"keys"` + }{ + Keys: []jose.JWK{op.PrivKey.JWK()}, + } + + b, err := json.Marshal(keys) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", int(time.Hour.Seconds()))) + w.Header().Set("Expires", time.Now().Add(time.Hour).Format(time.RFC1123)) + w.Header().Set("Content-Type", "application/json") + w.Write(b) +} + +// generateSelfSignedCert generates a self-signed cert/key pairs and writes to the certPath/keyPath. +// This method is mostly identical to crypto.GenerateSelfSignedCert except for the 'IsCA' and 'KeyUsage' +// in the certificate template. (Maybe we can merge these two methods). +func GenerateSelfSignedCert(t *testing.T, host, certPath, keyPath string) { + priv, err := rsa.GenerateKey(rand.Reader, 2048) + if err != nil { + t.Fatal(err) + } + + template := x509.Certificate{ + SerialNumber: big.NewInt(1), + Subject: pkix.Name{ + CommonName: fmt.Sprintf("%s@%d", host, time.Now().Unix()), + }, + NotBefore: time.Now(), + NotAfter: time.Now().Add(time.Hour * 24 * 365), + + KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, + BasicConstraintsValid: true, + IsCA: true, + } + + if ip := net.ParseIP(host); ip != nil { + template.IPAddresses = append(template.IPAddresses, ip) + } else { + template.DNSNames = append(template.DNSNames, host) + } + + derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) + if err != nil { + t.Fatal(err) + } + + // Generate cert + certBuffer := bytes.Buffer{} + if err := pem.Encode(&certBuffer, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}); err != nil { + t.Fatal(err) + } + + // Generate key + keyBuffer := bytes.Buffer{} + if err := pem.Encode(&keyBuffer, &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)}); err != nil { + t.Fatal(err) + } + + // Write cert + if err := os.MkdirAll(filepath.Dir(certPath), os.FileMode(0755)); err != nil { + t.Fatal(err) + } + if err := ioutil.WriteFile(certPath, certBuffer.Bytes(), os.FileMode(0644)); err != nil { + t.Fatal(err) + } + + // Write key + if err := os.MkdirAll(filepath.Dir(keyPath), os.FileMode(0755)); err != nil { + t.Fatal(err) + } + if err := ioutil.WriteFile(keyPath, keyBuffer.Bytes(), os.FileMode(0600)); err != nil { + t.Fatal(err) + } +} diff --git a/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/gcp/gcp.go b/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/gcp/gcp.go new file mode 100644 index 000000000000..bbc0f0b8b061 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/gcp/gcp.go @@ -0,0 +1,105 @@ +/* +Copyright 2016 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 gcp + +import ( + "net/http" + "time" + + "github.com/golang/glog" + "golang.org/x/net/context" + "golang.org/x/oauth2" + "golang.org/x/oauth2/google" + "k8s.io/client-go/1.5/rest" +) + +func init() { + if err := rest.RegisterAuthProviderPlugin("gcp", newGCPAuthProvider); err != nil { + glog.Fatalf("Failed to register gcp auth plugin: %v", err) + } +} + +type gcpAuthProvider struct { + tokenSource oauth2.TokenSource + persister rest.AuthProviderConfigPersister +} + +func newGCPAuthProvider(_ string, gcpConfig map[string]string, persister rest.AuthProviderConfigPersister) (rest.AuthProvider, error) { + ts, err := newCachedTokenSource(gcpConfig["access-token"], gcpConfig["expiry"], persister) + if err != nil { + return nil, err + } + return &gcpAuthProvider{ts, persister}, nil +} + +func (g *gcpAuthProvider) WrapTransport(rt http.RoundTripper) http.RoundTripper { + return &oauth2.Transport{ + Source: g.tokenSource, + Base: rt, + } +} + +func (g *gcpAuthProvider) Login() error { return nil } + +type cachedTokenSource struct { + source oauth2.TokenSource + accessToken string + expiry time.Time + persister rest.AuthProviderConfigPersister +} + +func newCachedTokenSource(accessToken, expiry string, persister rest.AuthProviderConfigPersister) (*cachedTokenSource, error) { + var expiryTime time.Time + if parsedTime, err := time.Parse(time.RFC3339Nano, expiry); err == nil { + expiryTime = parsedTime + } + ts, err := google.DefaultTokenSource(context.Background(), "https://www.googleapis.com/auth/cloud-platform") + if err != nil { + return nil, err + } + return &cachedTokenSource{ + source: ts, + accessToken: accessToken, + expiry: expiryTime, + persister: persister, + }, nil +} + +func (t *cachedTokenSource) Token() (*oauth2.Token, error) { + tok := &oauth2.Token{ + AccessToken: t.accessToken, + TokenType: "Bearer", + Expiry: t.expiry, + } + if tok.Valid() && !tok.Expiry.IsZero() { + return tok, nil + } + tok, err := t.source.Token() + if err != nil { + return nil, err + } + if t.persister != nil { + cached := map[string]string{ + "access-token": tok.AccessToken, + "expiry": tok.Expiry.Format(time.RFC3339Nano), + } + if err := t.persister.Persist(cached); err != nil { + glog.V(4).Infof("Failed to persist token: %v", err) + } + } + return tok, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/OWNERS b/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/OWNERS new file mode 100644 index 000000000000..2f80bc7e10f3 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/OWNERS @@ -0,0 +1,2 @@ +assignees: + - ericchiang diff --git a/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/oidc.go b/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/oidc.go new file mode 100644 index 000000000000..b397fa162609 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/oidc.go @@ -0,0 +1,270 @@ +/* +Copyright 2016 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 oidc + +import ( + "encoding/base64" + "errors" + "fmt" + "net/http" + "strings" + "time" + + "github.com/coreos/go-oidc/jose" + "github.com/coreos/go-oidc/oauth2" + "github.com/coreos/go-oidc/oidc" + "github.com/golang/glog" + + "k8s.io/client-go/1.5/pkg/util/wait" + "k8s.io/client-go/1.5/rest" +) + +const ( + cfgIssuerUrl = "idp-issuer-url" + cfgClientID = "client-id" + cfgClientSecret = "client-secret" + cfgCertificateAuthority = "idp-certificate-authority" + cfgCertificateAuthorityData = "idp-certificate-authority-data" + cfgExtraScopes = "extra-scopes" + cfgIDToken = "id-token" + cfgRefreshToken = "refresh-token" +) + +var ( + backoff = wait.Backoff{ + Duration: 1 * time.Second, + Factor: 2, + Jitter: .1, + Steps: 5, + } +) + +func init() { + if err := rest.RegisterAuthProviderPlugin("oidc", newOIDCAuthProvider); err != nil { + glog.Fatalf("Failed to register oidc auth plugin: %v", err) + } +} + +func newOIDCAuthProvider(_ string, cfg map[string]string, persister rest.AuthProviderConfigPersister) (rest.AuthProvider, error) { + issuer := cfg[cfgIssuerUrl] + if issuer == "" { + return nil, fmt.Errorf("Must provide %s", cfgIssuerUrl) + } + + clientID := cfg[cfgClientID] + if clientID == "" { + return nil, fmt.Errorf("Must provide %s", cfgClientID) + } + + clientSecret := cfg[cfgClientSecret] + if clientSecret == "" { + return nil, fmt.Errorf("Must provide %s", cfgClientSecret) + } + + var certAuthData []byte + var err error + if cfg[cfgCertificateAuthorityData] != "" { + certAuthData, err = base64.StdEncoding.DecodeString(cfg[cfgCertificateAuthorityData]) + if err != nil { + return nil, err + } + } + + clientConfig := rest.Config{ + TLSClientConfig: rest.TLSClientConfig{ + CAFile: cfg[cfgCertificateAuthority], + CAData: certAuthData, + }, + } + + trans, err := rest.TransportFor(&clientConfig) + if err != nil { + return nil, err + } + hc := &http.Client{Transport: trans} + + providerCfg, err := oidc.FetchProviderConfig(hc, issuer) + if err != nil { + return nil, fmt.Errorf("error fetching provider config: %v", err) + } + + scopes := strings.Split(cfg[cfgExtraScopes], ",") + oidcCfg := oidc.ClientConfig{ + HTTPClient: hc, + Credentials: oidc.ClientCredentials{ + ID: clientID, + Secret: clientSecret, + }, + ProviderConfig: providerCfg, + Scope: append(scopes, oidc.DefaultScope...), + } + + client, err := oidc.NewClient(oidcCfg) + if err != nil { + return nil, fmt.Errorf("error creating OIDC Client: %v", err) + } + + oClient := &oidcClient{client} + + var initialIDToken jose.JWT + if cfg[cfgIDToken] != "" { + initialIDToken, err = jose.ParseJWT(cfg[cfgIDToken]) + if err != nil { + return nil, err + } + } + + return &oidcAuthProvider{ + initialIDToken: initialIDToken, + refresher: &idTokenRefresher{ + client: oClient, + cfg: cfg, + persister: persister, + }, + }, nil +} + +type oidcAuthProvider struct { + refresher *idTokenRefresher + initialIDToken jose.JWT +} + +func (g *oidcAuthProvider) WrapTransport(rt http.RoundTripper) http.RoundTripper { + at := &oidc.AuthenticatedTransport{ + TokenRefresher: g.refresher, + RoundTripper: rt, + } + at.SetJWT(g.initialIDToken) + return &roundTripper{ + wrapped: at, + refresher: g.refresher, + } +} + +func (g *oidcAuthProvider) Login() error { + return errors.New("not yet implemented") +} + +type OIDCClient interface { + refreshToken(rt string) (oauth2.TokenResponse, error) + verifyJWT(jwt jose.JWT) error +} + +type roundTripper struct { + refresher *idTokenRefresher + wrapped *oidc.AuthenticatedTransport +} + +func (r *roundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + var res *http.Response + var err error + firstTime := true + wait.ExponentialBackoff(backoff, func() (bool, error) { + if !firstTime { + var jwt jose.JWT + jwt, err = r.refresher.Refresh() + if err != nil { + return true, nil + } + r.wrapped.SetJWT(jwt) + } else { + firstTime = false + } + + res, err = r.wrapped.RoundTrip(req) + if err != nil { + return true, nil + } + if res.StatusCode == http.StatusUnauthorized { + return false, nil + } + return true, nil + }) + return res, err +} + +type idTokenRefresher struct { + cfg map[string]string + client OIDCClient + persister rest.AuthProviderConfigPersister + intialIDToken jose.JWT +} + +func (r *idTokenRefresher) Verify(jwt jose.JWT) error { + claims, err := jwt.Claims() + if err != nil { + return err + } + + now := time.Now() + exp, ok, err := claims.TimeClaim("exp") + switch { + case err != nil: + return fmt.Errorf("failed to parse 'exp' claim: %v", err) + case !ok: + return errors.New("missing required 'exp' claim") + case exp.Before(now): + return fmt.Errorf("token already expired at: %v", exp) + } + + return nil +} + +func (r *idTokenRefresher) Refresh() (jose.JWT, error) { + rt, ok := r.cfg[cfgRefreshToken] + if !ok { + return jose.JWT{}, errors.New("No valid id-token, and cannot refresh without refresh-token") + } + + tokens, err := r.client.refreshToken(rt) + if err != nil { + return jose.JWT{}, fmt.Errorf("could not refresh token: %v", err) + } + jwt, err := jose.ParseJWT(tokens.IDToken) + if err != nil { + return jose.JWT{}, err + } + + if tokens.RefreshToken != "" && tokens.RefreshToken != rt { + r.cfg[cfgRefreshToken] = tokens.RefreshToken + } + r.cfg[cfgIDToken] = jwt.Encode() + + err = r.persister.Persist(r.cfg) + if err != nil { + return jose.JWT{}, fmt.Errorf("could not perist new tokens: %v", err) + } + + return jwt, r.client.verifyJWT(jwt) +} + +type oidcClient struct { + client *oidc.Client +} + +func (o *oidcClient) refreshToken(rt string) (oauth2.TokenResponse, error) { + oac, err := o.client.OAuthClient() + if err != nil { + return oauth2.TokenResponse{}, err + } + + return oac.RequestToken(oauth2.GrantTypeRefreshToken, rt) +} + +func (o *oidcClient) verifyJWT(jwt jose.JWT) error { + return o.client.VerifyJWT(jwt) +} diff --git a/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/oidc_test.go b/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/oidc_test.go new file mode 100644 index 000000000000..395bfc58eb1b --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc/oidc_test.go @@ -0,0 +1,646 @@ +/* +Copyright 2016 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 oidc + +import ( + "encoding/base64" + "errors" + "fmt" + "io/ioutil" + "net/http" + "os" + "path" + "reflect" + "strings" + "testing" + "time" + + "github.com/coreos/go-oidc/jose" + "github.com/coreos/go-oidc/key" + "github.com/coreos/go-oidc/oauth2" + + "k8s.io/client-go/1.5/pkg/util/diff" + "k8s.io/client-go/1.5/pkg/util/wait" + oidctesting "k8s.io/client-go/1.5/plugin/pkg/auth/authenticator/token/oidc/testing" +) + +func TestNewOIDCAuthProvider(t *testing.T) { + tempDir, err := ioutil.TempDir(os.TempDir(), "oidc_test") + if err != nil { + t.Fatalf("Cannot make temp dir %v", err) + } + cert := path.Join(tempDir, "oidc-cert") + key := path.Join(tempDir, "oidc-key") + + defer os.Remove(cert) + defer os.Remove(key) + defer os.Remove(tempDir) + + oidctesting.GenerateSelfSignedCert(t, "127.0.0.1", cert, key) + op := oidctesting.NewOIDCProvider(t, "") + srv, err := op.ServeTLSWithKeyPair(cert, key) + if err != nil { + t.Fatalf("Cannot start server %v", err) + } + defer srv.Close() + + certData, err := ioutil.ReadFile(cert) + if err != nil { + t.Fatalf("Could not read cert bytes %v", err) + } + + jwt, err := jose.NewSignedJWT(jose.Claims(map[string]interface{}{ + "test": "jwt", + }), op.PrivKey.Signer()) + if err != nil { + t.Fatalf("Could not create signed JWT %v", err) + } + + tests := []struct { + cfg map[string]string + + wantErr bool + wantInitialIDToken jose.JWT + }{ + { + // A Valid configuration + cfg: map[string]string{ + cfgIssuerUrl: srv.URL, + cfgCertificateAuthority: cert, + cfgClientID: "client-id", + cfgClientSecret: "client-secret", + }, + }, + { + // A Valid configuration with an Initial JWT + cfg: map[string]string{ + cfgIssuerUrl: srv.URL, + cfgCertificateAuthority: cert, + cfgClientID: "client-id", + cfgClientSecret: "client-secret", + cfgIDToken: jwt.Encode(), + }, + wantInitialIDToken: *jwt, + }, + { + // Valid config, but using cfgCertificateAuthorityData + cfg: map[string]string{ + cfgIssuerUrl: srv.URL, + cfgCertificateAuthorityData: base64.StdEncoding.EncodeToString(certData), + cfgClientID: "client-id", + cfgClientSecret: "client-secret", + }, + }, + { + // Missing client id + cfg: map[string]string{ + cfgIssuerUrl: srv.URL, + cfgCertificateAuthority: cert, + cfgClientSecret: "client-secret", + }, + wantErr: true, + }, + { + // Missing client secret + cfg: map[string]string{ + cfgIssuerUrl: srv.URL, + cfgCertificateAuthority: cert, + cfgClientID: "client-id", + }, + wantErr: true, + }, + { + // Missing issuer url. + cfg: map[string]string{ + cfgCertificateAuthority: cert, + cfgClientID: "client-id", + cfgClientSecret: "secret", + }, + wantErr: true, + }, + { + // No TLS config + cfg: map[string]string{ + cfgIssuerUrl: srv.URL, + cfgClientID: "client-id", + cfgClientSecret: "secret", + }, + wantErr: true, + }, + } + + for i, tt := range tests { + ap, err := newOIDCAuthProvider("cluster.example.com", tt.cfg, nil) + if tt.wantErr { + if err == nil { + t.Errorf("case %d: want non-nil err", i) + } + continue + } + + if err != nil { + t.Errorf("case %d: unexpected error on newOIDCAuthProvider: %v", i, err) + continue + } + + oidcAP, ok := ap.(*oidcAuthProvider) + if !ok { + t.Errorf("case %d: expected ap to be an oidcAuthProvider", i) + continue + } + + if diff := compareJWTs(tt.wantInitialIDToken, oidcAP.initialIDToken); diff != "" { + t.Errorf("case %d: compareJWTs(tt.wantInitialIDToken, oidcAP.initialIDToken)=%v", i, diff) + } + } +} + +func TestWrapTranport(t *testing.T) { + oldBackoff := backoff + defer func() { + backoff = oldBackoff + }() + backoff = wait.Backoff{ + Duration: 1 * time.Nanosecond, + Steps: 3, + } + + privKey, err := key.GeneratePrivateKey() + if err != nil { + t.Fatalf("can't generate private key: %v", err) + } + + makeToken := func(s string, exp time.Time, count int) *jose.JWT { + jwt, err := jose.NewSignedJWT(jose.Claims(map[string]interface{}{ + "test": s, + "exp": exp.UTC().Unix(), + "count": count, + }), privKey.Signer()) + if err != nil { + t.Fatalf("Could not create signed JWT %v", err) + } + return jwt + } + + goodToken := makeToken("good", time.Now().Add(time.Hour), 0) + goodToken2 := makeToken("good", time.Now().Add(time.Hour), 1) + expiredToken := makeToken("good", time.Now().Add(-time.Hour), 0) + + str := func(s string) *string { + return &s + } + tests := []struct { + cfgIDToken *jose.JWT + cfgRefreshToken *string + + expectRequests []testRoundTrip + + expectRefreshes []testRefresh + + expectPersists []testPersist + + wantStatus int + wantErr bool + }{ + { + // Initial JWT is set, it is good, it is set as bearer. + cfgIDToken: goodToken, + + expectRequests: []testRoundTrip{ + { + expectBearerToken: goodToken.Encode(), + returnHTTPStatus: 200, + }, + }, + + wantStatus: 200, + }, + { + // Initial JWT is set, but it's expired, so it gets refreshed. + cfgIDToken: expiredToken, + cfgRefreshToken: str("rt1"), + + expectRefreshes: []testRefresh{ + { + expectRefreshToken: "rt1", + returnTokens: oauth2.TokenResponse{ + IDToken: goodToken.Encode(), + }, + }, + }, + + expectRequests: []testRoundTrip{ + { + expectBearerToken: goodToken.Encode(), + returnHTTPStatus: 200, + }, + }, + + expectPersists: []testPersist{ + { + cfg: map[string]string{ + cfgIDToken: goodToken.Encode(), + cfgRefreshToken: "rt1", + }, + }, + }, + + wantStatus: 200, + }, + { + // Initial JWT is set, but it's expired, so it gets refreshed - this + // time the refresh token itself is also refreshed + cfgIDToken: expiredToken, + cfgRefreshToken: str("rt1"), + + expectRefreshes: []testRefresh{ + { + expectRefreshToken: "rt1", + returnTokens: oauth2.TokenResponse{ + IDToken: goodToken.Encode(), + RefreshToken: "rt2", + }, + }, + }, + + expectRequests: []testRoundTrip{ + { + expectBearerToken: goodToken.Encode(), + returnHTTPStatus: 200, + }, + }, + + expectPersists: []testPersist{ + { + cfg: map[string]string{ + cfgIDToken: goodToken.Encode(), + cfgRefreshToken: "rt2", + }, + }, + }, + + wantStatus: 200, + }, + { + // Initial JWT is not set, so it gets refreshed. + cfgRefreshToken: str("rt1"), + + expectRefreshes: []testRefresh{ + { + expectRefreshToken: "rt1", + returnTokens: oauth2.TokenResponse{ + IDToken: goodToken.Encode(), + }, + }, + }, + + expectRequests: []testRoundTrip{ + { + expectBearerToken: goodToken.Encode(), + returnHTTPStatus: 200, + }, + }, + + expectPersists: []testPersist{ + { + cfg: map[string]string{ + cfgIDToken: goodToken.Encode(), + cfgRefreshToken: "rt1", + }, + }, + }, + + wantStatus: 200, + }, + { + // Expired token, but no refresh token. + cfgIDToken: expiredToken, + + wantErr: true, + }, + { + // Initial JWT is not set, so it gets refreshed, but the server + // rejects it when it is used, so it refreshes again, which + // succeeds. + cfgRefreshToken: str("rt1"), + + expectRefreshes: []testRefresh{ + { + expectRefreshToken: "rt1", + returnTokens: oauth2.TokenResponse{ + IDToken: goodToken.Encode(), + }, + }, + { + expectRefreshToken: "rt1", + returnTokens: oauth2.TokenResponse{ + IDToken: goodToken2.Encode(), + }, + }, + }, + + expectRequests: []testRoundTrip{ + { + expectBearerToken: goodToken.Encode(), + returnHTTPStatus: http.StatusUnauthorized, + }, + { + expectBearerToken: goodToken2.Encode(), + returnHTTPStatus: http.StatusOK, + }, + }, + + expectPersists: []testPersist{ + { + cfg: map[string]string{ + cfgIDToken: goodToken.Encode(), + cfgRefreshToken: "rt1", + }, + }, + { + cfg: map[string]string{ + cfgIDToken: goodToken2.Encode(), + cfgRefreshToken: "rt1", + }, + }, + }, + + wantStatus: 200, + }, + { + // Initial JWT is but the server rejects it when it is used, so it + // refreshes again, which succeeds. + cfgRefreshToken: str("rt1"), + cfgIDToken: goodToken, + + expectRefreshes: []testRefresh{ + { + expectRefreshToken: "rt1", + returnTokens: oauth2.TokenResponse{ + IDToken: goodToken2.Encode(), + }, + }, + }, + + expectRequests: []testRoundTrip{ + { + expectBearerToken: goodToken.Encode(), + returnHTTPStatus: http.StatusUnauthorized, + }, + { + expectBearerToken: goodToken2.Encode(), + returnHTTPStatus: http.StatusOK, + }, + }, + + expectPersists: []testPersist{ + { + cfg: map[string]string{ + cfgIDToken: goodToken2.Encode(), + cfgRefreshToken: "rt1", + }, + }, + }, + wantStatus: 200, + }, + } + + for i, tt := range tests { + client := &testOIDCClient{ + refreshes: tt.expectRefreshes, + } + + persister := &testPersister{ + tt.expectPersists, + } + + cfg := map[string]string{} + if tt.cfgIDToken != nil { + cfg[cfgIDToken] = tt.cfgIDToken.Encode() + } + + if tt.cfgRefreshToken != nil { + cfg[cfgRefreshToken] = *tt.cfgRefreshToken + } + + ap := &oidcAuthProvider{ + refresher: &idTokenRefresher{ + client: client, + cfg: cfg, + persister: persister, + }, + } + + if tt.cfgIDToken != nil { + ap.initialIDToken = *tt.cfgIDToken + } + + tstRT := &testRoundTripper{ + tt.expectRequests, + } + + rt := ap.WrapTransport(tstRT) + + req, err := http.NewRequest("GET", "http://cluster.example.com", nil) + if err != nil { + t.Errorf("case %d: unexpected error making request: %v", i, err) + } + + res, err := rt.RoundTrip(req) + if tt.wantErr { + if err == nil { + t.Errorf("case %d: Expected non-nil error", i) + } + } else if err != nil { + t.Errorf("case %d: unexpected error making round trip: %v", i, err) + + } else { + if res.StatusCode != tt.wantStatus { + t.Errorf("case %d: want=%d, got=%d", i, tt.wantStatus, res.StatusCode) + } + } + + if err = client.verify(); err != nil { + t.Errorf("case %d: %v", i, err) + } + + if err = persister.verify(); err != nil { + t.Errorf("case %d: %v", i, err) + } + + if err = tstRT.verify(); err != nil { + t.Errorf("case %d: %v", i, err) + continue + } + + } +} + +type testRoundTrip struct { + expectBearerToken string + returnHTTPStatus int +} + +type testRoundTripper struct { + trips []testRoundTrip +} + +func (t *testRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + if len(t.trips) == 0 { + return nil, errors.New("unexpected RoundTrip call") + } + + var trip testRoundTrip + trip, t.trips = t.trips[0], t.trips[1:] + + var bt string + var parts []string + auth := strings.TrimSpace(req.Header.Get("Authorization")) + if auth == "" { + goto Compare + } + + parts = strings.Split(auth, " ") + if len(parts) < 2 || strings.ToLower(parts[0]) != "bearer" { + goto Compare + } + + bt = parts[1] + +Compare: + if trip.expectBearerToken != bt { + return nil, fmt.Errorf("want bearerToken=%v, got=%v", trip.expectBearerToken, bt) + } + return &http.Response{ + StatusCode: trip.returnHTTPStatus, + }, nil +} + +func (t *testRoundTripper) verify() error { + if l := len(t.trips); l > 0 { + return fmt.Errorf("%d uncalled round trips", l) + } + return nil +} + +type testPersist struct { + cfg map[string]string + returnErr error +} + +type testPersister struct { + persists []testPersist +} + +func (t *testPersister) Persist(cfg map[string]string) error { + if len(t.persists) == 0 { + return errors.New("unexpected persist call") + } + + var persist testPersist + persist, t.persists = t.persists[0], t.persists[1:] + + if !reflect.DeepEqual(persist.cfg, cfg) { + return fmt.Errorf("Unexpected cfg: %v", diff.ObjectDiff(persist.cfg, cfg)) + } + + return persist.returnErr +} + +func (t *testPersister) verify() error { + if l := len(t.persists); l > 0 { + return fmt.Errorf("%d uncalled persists", l) + } + return nil +} + +type testRefresh struct { + expectRefreshToken string + + returnErr error + returnTokens oauth2.TokenResponse +} + +type testOIDCClient struct { + refreshes []testRefresh +} + +func (o *testOIDCClient) refreshToken(rt string) (oauth2.TokenResponse, error) { + if len(o.refreshes) == 0 { + return oauth2.TokenResponse{}, errors.New("unexpected refresh request") + } + + var refresh testRefresh + refresh, o.refreshes = o.refreshes[0], o.refreshes[1:] + + if rt != refresh.expectRefreshToken { + return oauth2.TokenResponse{}, fmt.Errorf("want rt=%v, got=%v", + refresh.expectRefreshToken, + rt) + } + + if refresh.returnErr != nil { + return oauth2.TokenResponse{}, refresh.returnErr + } + + return refresh.returnTokens, nil +} + +func (o *testOIDCClient) verifyJWT(jwt jose.JWT) error { + claims, err := jwt.Claims() + if err != nil { + return err + } + claim, _, _ := claims.StringClaim("test") + if claim != "good" { + return errors.New("bad token") + } + return nil +} + +func (t *testOIDCClient) verify() error { + if l := len(t.refreshes); l > 0 { + return fmt.Errorf("%d uncalled refreshes", l) + } + return nil +} + +func compareJWTs(a, b jose.JWT) string { + if a.Encode() == b.Encode() { + return "" + } + + var aClaims, bClaims jose.Claims + for _, j := range []struct { + claims *jose.Claims + jwt jose.JWT + }{ + {&aClaims, a}, + {&bClaims, b}, + } { + var err error + *j.claims, err = j.jwt.Claims() + if err != nil { + *j.claims = jose.Claims(map[string]interface{}{ + "msg": "bad claims", + "err": err, + }) + } + } + + return diff.ObjectDiff(aClaims, bClaims) +} diff --git a/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/plugins.go b/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/plugins.go new file mode 100644 index 000000000000..4be6cc515eb6 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/plugin/pkg/client/auth/plugins.go @@ -0,0 +1,23 @@ +/* +Copyright 2016 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 auth + +import ( + // Initialize all known client auth plugins. + _ "k8s.io/client-go/1.5/plugin/pkg/client/auth/gcp" + _ "k8s.io/client-go/1.5/plugin/pkg/client/auth/oidc" +) diff --git a/staging/src/k8s.io/client-go/1.5/rest/client.go b/staging/src/k8s.io/client-go/1.5/rest/client.go index 09f3dc0ecac1..c1fdf1f09ac4 100644 --- a/staging/src/k8s.io/client-go/1.5/rest/client.go +++ b/staging/src/k8s.io/client-go/1.5/rest/client.go @@ -54,7 +54,7 @@ type RESTClient struct { // contentConfig is the information used to communicate with the server. contentConfig ContentConfig - // serializers contain all serializers for undelying content type. + // serializers contain all serializers for underlying content type. serializers Serializers // creates BackoffManager that is passed to requests. diff --git a/staging/src/k8s.io/client-go/1.5/rest/config.go b/staging/src/k8s.io/client-go/1.5/rest/config.go index bb131aa568a8..5c5e1e038126 100644 --- a/staging/src/k8s.io/client-go/1.5/rest/config.go +++ b/staging/src/k8s.io/client-go/1.5/rest/config.go @@ -31,7 +31,7 @@ import ( "k8s.io/client-go/1.5/pkg/api" "k8s.io/client-go/1.5/pkg/api/unversioned" "k8s.io/client-go/1.5/pkg/runtime" - "k8s.io/client-go/1.5/pkg/util/crypto" + certutil "k8s.io/client-go/1.5/pkg/util/cert" "k8s.io/client-go/1.5/pkg/util/flowcontrol" "k8s.io/client-go/1.5/pkg/version" clientcmdapi "k8s.io/client-go/1.5/tools/clientcmd/api" @@ -261,7 +261,7 @@ func InClusterConfig() (*Config, error) { } tlsClientConfig := TLSClientConfig{} rootCAFile := "/var/run/secrets/kubernetes.io/serviceaccount/" + api.ServiceAccountRootCAKey - if _, err := crypto.CertPoolFromFile(rootCAFile); err != nil { + if _, err := certutil.NewPool(rootCAFile); err != nil { glog.Errorf("Expected to load root CA config from %s, but got err: %v", rootCAFile, err) } else { tlsClientConfig.CAFile = rootCAFile @@ -277,7 +277,7 @@ func InClusterConfig() (*Config, error) { // IsConfigTransportTLS returns true if and only if the provided // config will result in a protected connection to the server when it -// is passed to rest.RESTClientFor(). Use to determine when to +// is passed to restclient.RESTClientFor(). Use to determine when to // send credentials over the wire. // // Note: the Insecure flag is ignored when testing for this value, so MITM attacks are diff --git a/staging/src/k8s.io/client-go/1.5/rest/request.go b/staging/src/k8s.io/client-go/1.5/rest/request.go index 392aff2d19cd..4e57a0cc2774 100644 --- a/staging/src/k8s.io/client-go/1.5/rest/request.go +++ b/staging/src/k8s.io/client-go/1.5/rest/request.go @@ -744,23 +744,11 @@ func (r *Request) Stream() (io.ReadCloser, error) { // ensure we close the body before returning the error defer resp.Body.Close() - // we have a decent shot at taking the object returned, parsing it as a status object and returning a more normal error - bodyBytes, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, fmt.Errorf("%v while accessing %v", resp.Status, url) - } - - // TODO: Check ContentType. - if runtimeObject, err := runtime.Decode(r.serializers.Decoder, bodyBytes); err == nil { - statusError := errors.FromObject(runtimeObject) - - if _, ok := statusError.(errors.APIStatus); ok { - return nil, statusError - } + result := r.transformResponse(resp, req) + if result.err != nil { + return nil, result.err } - - bodyText := string(bodyBytes) - return nil, fmt.Errorf("%s while accessing %v: %s", resp.Status, url, bodyText) + return nil, fmt.Errorf("%d while accessing %v: %s", result.statusCode, url, string(result.body)) } } diff --git a/staging/src/k8s.io/client-go/1.5/testing/fake.go b/staging/src/k8s.io/client-go/1.5/testing/fake.go index dc2d92d0a297..208efec67efd 100644 --- a/staging/src/k8s.io/client-go/1.5/testing/fake.go +++ b/staging/src/k8s.io/client-go/1.5/testing/fake.go @@ -27,17 +27,21 @@ import ( "k8s.io/client-go/1.5/rest" ) -// Fake implements client.Interface. Meant to be embedded into a struct to get a default -// implementation. This makes faking out just the method you want to test easier. +// Fake implements client.Interface. Meant to be embedded into a struct to get +// a default implementation. This makes faking out just the method you want to +// test easier. type Fake struct { sync.RWMutex actions []Action // these may be castable to other types, but "Action" is the minimum - // ReactionChain is the list of reactors that will be attempted for every request in the order they are tried + // ReactionChain is the list of reactors that will be attempted for every + // request in the order they are tried. ReactionChain []Reactor - // WatchReactionChain is the list of watch reactors that will be attempted for every request in the order they are tried + // WatchReactionChain is the list of watch reactors that will be attempted + // for every request in the order they are tried. WatchReactionChain []WatchReactor - // ProxyReactionChain is the list of proxy reactors that will be attempted for every request in the order they are tried + // ProxyReactionChain is the list of proxy reactors that will be attempted + // for every request in the order they are tried. ProxyReactionChain []ProxyReactor Resources map[string]*unversioned.APIResourceList @@ -45,72 +49,85 @@ type Fake struct { // Reactor is an interface to allow the composition of reaction functions. type Reactor interface { - // Handles indicates whether or not this Reactor deals with a given action + // Handles indicates whether or not this Reactor deals with a given + // action. Handles(action Action) bool - // React handles the action and returns results. It may choose to delegate by indicated handled=false + // React handles the action and returns results. It may choose to + // delegate by indicated handled=false. React(action Action) (handled bool, ret runtime.Object, err error) } // WatchReactor is an interface to allow the composition of watch functions. type WatchReactor interface { - // Handles indicates whether or not this Reactor deals with a given action + // Handles indicates whether or not this Reactor deals with a given + // action. Handles(action Action) bool - // React handles a watch action and returns results. It may choose to delegate by indicating handled=false + // React handles a watch action and returns results. It may choose to + // delegate by indicating handled=false. React(action Action) (handled bool, ret watch.Interface, err error) } -// ProxyReactor is an interface to allow the composition of proxy get functions. +// ProxyReactor is an interface to allow the composition of proxy get +// functions. type ProxyReactor interface { - // Handles indicates whether or not this Reactor deals with a given action + // Handles indicates whether or not this Reactor deals with a given + // action. Handles(action Action) bool - // React handles a watch action and returns results. It may choose to delegate by indicating handled=false + // React handles a watch action and returns results. It may choose to + // delegate by indicating handled=false. React(action Action) (handled bool, ret rest.ResponseWrapper, err error) } -// ReactionFunc is a function that returns an object or error for a given Action. If "handled" is false, -// then the test client will ignore the results and continue to the next ReactionFunc +// ReactionFunc is a function that returns an object or error for a given +// Action. If "handled" is false, then the test client will ignore the +// results and continue to the next ReactionFunc. A ReactionFunc can describe +// reactions on subresources by testing the result of the action's +// GetSubresource() method. type ReactionFunc func(action Action) (handled bool, ret runtime.Object, err error) -// WatchReactionFunc is a function that returns a watch interface. If "handled" is false, -// then the test client will ignore the results and continue to the next ReactionFunc +// WatchReactionFunc is a function that returns a watch interface. If +// "handled" is false, then the test client will ignore the results and +// continue to the next ReactionFunc. type WatchReactionFunc func(action Action) (handled bool, ret watch.Interface, err error) -// ProxyReactionFunc is a function that returns a ResponseWrapper interface for a given Action. If "handled" is false, -// then the test client will ignore the results and continue to the next ProxyReactionFunc +// ProxyReactionFunc is a function that returns a ResponseWrapper interface +// for a given Action. If "handled" is false, then the test client will +// ignore the results and continue to the next ProxyReactionFunc. type ProxyReactionFunc func(action Action) (handled bool, ret rest.ResponseWrapper, err error) -// AddReactor appends a reactor to the end of the chain +// AddReactor appends a reactor to the end of the chain. func (c *Fake) AddReactor(verb, resource string, reaction ReactionFunc) { c.ReactionChain = append(c.ReactionChain, &SimpleReactor{verb, resource, reaction}) } -// PrependReactor adds a reactor to the beginning of the chain +// PrependReactor adds a reactor to the beginning of the chain. func (c *Fake) PrependReactor(verb, resource string, reaction ReactionFunc) { c.ReactionChain = append([]Reactor{&SimpleReactor{verb, resource, reaction}}, c.ReactionChain...) } -// AddWatchReactor appends a reactor to the end of the chain +// AddWatchReactor appends a reactor to the end of the chain. func (c *Fake) AddWatchReactor(resource string, reaction WatchReactionFunc) { c.WatchReactionChain = append(c.WatchReactionChain, &SimpleWatchReactor{resource, reaction}) } -// PrependWatchReactor adds a reactor to the beginning of the chain +// PrependWatchReactor adds a reactor to the beginning of the chain. func (c *Fake) PrependWatchReactor(resource string, reaction WatchReactionFunc) { c.WatchReactionChain = append([]WatchReactor{&SimpleWatchReactor{resource, reaction}}, c.WatchReactionChain...) } -// AddProxyReactor appends a reactor to the end of the chain +// AddProxyReactor appends a reactor to the end of the chain. func (c *Fake) AddProxyReactor(resource string, reaction ProxyReactionFunc) { c.ProxyReactionChain = append(c.ProxyReactionChain, &SimpleProxyReactor{resource, reaction}) } -// PrependProxyReactor adds a reactor to the beginning of the chain +// PrependProxyReactor adds a reactor to the beginning of the chain. func (c *Fake) PrependProxyReactor(resource string, reaction ProxyReactionFunc) { c.ProxyReactionChain = append([]ProxyReactor{&SimpleProxyReactor{resource, reaction}}, c.ProxyReactionChain...) } -// Invokes records the provided Action and then invokes the ReactFn (if provided). -// defaultReturnObj is expected to be of the same type a normal call would return. +// Invokes records the provided Action and then invokes the ReactionFunc that +// handles the action if one exists. defaultReturnObj is expected to be of the +// same type a normal call would return. func (c *Fake) Invokes(action Action, defaultReturnObj runtime.Object) (runtime.Object, error) { c.Lock() defer c.Unlock() @@ -132,7 +149,8 @@ func (c *Fake) Invokes(action Action, defaultReturnObj runtime.Object) (runtime. return defaultReturnObj, nil } -// InvokesWatch records the provided Action and then invokes the ReactFn (if provided). +// InvokesWatch records the provided Action and then invokes the ReactionFunc +// that handles the action if one exists. func (c *Fake) InvokesWatch(action Action) (watch.Interface, error) { c.Lock() defer c.Unlock() @@ -154,7 +172,8 @@ func (c *Fake) InvokesWatch(action Action) (watch.Interface, error) { return nil, fmt.Errorf("unhandled watch: %#v", action) } -// InvokesProxy records the provided Action and then invokes the ReactFn (if provided). +// InvokesProxy records the provided Action and then invokes the ReactionFunc +// that handles the action if one exists. func (c *Fake) InvokesProxy(action Action) rest.ResponseWrapper { c.Lock() defer c.Unlock() @@ -176,7 +195,7 @@ func (c *Fake) InvokesProxy(action Action) rest.ResponseWrapper { return nil } -// ClearActions clears the history of actions called on the fake client +// ClearActions clears the history of actions called on the fake client. func (c *Fake) ClearActions() { c.Lock() defer c.Unlock() @@ -184,7 +203,8 @@ func (c *Fake) ClearActions() { c.actions = make([]Action, 0) } -// Actions returns a chronologically ordered slice fake actions called on the fake client. +// Actions returns a chronologically ordered slice fake actions called on the +// fake client. func (c *Fake) Actions() []Action { c.RLock() defer c.RUnlock() diff --git a/staging/src/k8s.io/client-go/1.5/testing/fixture.go b/staging/src/k8s.io/client-go/1.5/testing/fixture.go index 4e15f4d3cd85..996d803fbc14 100644 --- a/staging/src/k8s.io/client-go/1.5/testing/fixture.go +++ b/staging/src/k8s.io/client-go/1.5/testing/fixture.go @@ -60,7 +60,7 @@ type ObjectScheme interface { runtime.ObjectTyper } -// ObjectReaction returns a ReactionFunc that applies testing.Action to +// ObjectReaction returns a ReactionFunc that applies core.Action to // the given tracker. func ObjectReaction(tracker ObjectTracker, mapper meta.RESTMapper) ReactionFunc { return func(action Action) (bool, runtime.Object, error) { diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/controller.go b/staging/src/k8s.io/client-go/1.5/tools/cache/controller.go new file mode 100644 index 000000000000..f17b10d85542 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/controller.go @@ -0,0 +1,325 @@ +/* +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 testing + +import ( + "sync" + "time" + + "k8s.io/client-go/1.5/pkg/runtime" + utilruntime "k8s.io/client-go/1.5/pkg/util/runtime" + "k8s.io/client-go/1.5/pkg/util/wait" +) + +// Config contains all the settings for a Controller. +type Config struct { + // The queue for your objects; either a FIFO or + // a DeltaFIFO. Your Process() function should accept + // the output of this Oueue's Pop() method. + Queue + + // Something that can list and watch your objects. + ListerWatcher + + // Something that can process your objects. + Process ProcessFunc + + // The type of your objects. + ObjectType runtime.Object + + // Reprocess everything at least this often. + // Note that if it takes longer for you to clear the queue than this + // period, you will end up processing items in the order determined + // by FIFO.Replace(). Currently, this is random. If this is a + // problem, we can change that replacement policy to append new + // things to the end of the queue instead of replacing the entire + // queue. + FullResyncPeriod time.Duration + + // If true, when Process() returns an error, re-enqueue the object. + // TODO: add interface to let you inject a delay/backoff or drop + // the object completely if desired. Pass the object in + // question to this interface as a parameter. + RetryOnError bool +} + +// ProcessFunc processes a single object. +type ProcessFunc func(obj interface{}) error + +// Controller is a generic controller framework. +type Controller struct { + config Config + reflector *Reflector + reflectorMutex sync.RWMutex +} + +// TODO make the "Controller" private, and convert all references to use ControllerInterface instead +type ControllerInterface interface { + Run(stopCh <-chan struct{}) + HasSynced() bool +} + +// New makes a new Controller from the given Config. +func New(c *Config) *Controller { + ctlr := &Controller{ + config: *c, + } + return ctlr +} + +// Run begins processing items, and will continue until a value is sent down stopCh. +// It's an error to call Run more than once. +// Run blocks; call via go. +func (c *Controller) Run(stopCh <-chan struct{}) { + defer utilruntime.HandleCrash() + r := NewReflector( + c.config.ListerWatcher, + c.config.ObjectType, + c.config.Queue, + c.config.FullResyncPeriod, + ) + + c.reflectorMutex.Lock() + c.reflector = r + c.reflectorMutex.Unlock() + + r.RunUntil(stopCh) + + wait.Until(c.processLoop, time.Second, stopCh) +} + +// Returns true once this controller has completed an initial resource listing +func (c *Controller) HasSynced() bool { + return c.config.Queue.HasSynced() +} + +// Requeue adds the provided object back into the queue if it does not already exist. +func (c *Controller) Requeue(obj interface{}) error { + return c.config.Queue.AddIfNotPresent(Deltas{ + Delta{ + Type: Sync, + Object: obj, + }, + }) +} + +// processLoop drains the work queue. +// TODO: Consider doing the processing in parallel. This will require a little thought +// to make sure that we don't end up processing the same object multiple times +// concurrently. +func (c *Controller) processLoop() { + for { + obj, err := c.config.Queue.Pop(PopProcessFunc(c.config.Process)) + if err != nil { + if c.config.RetryOnError { + // This is the safe way to re-enqueue. + c.config.Queue.AddIfNotPresent(obj) + } + } + } +} + +// ResourceEventHandler can handle notifications for events that happen to a +// resource. The events are informational only, so you can't return an +// error. +// * OnAdd is called when an object is added. +// * OnUpdate is called when an object is modified. Note that oldObj is the +// last known state of the object-- it is possible that several changes +// were combined together, so you can't use this to see every single +// change. OnUpdate is also called when a re-list happens, and it will +// get called even if nothing changed. This is useful for periodically +// evaluating or syncing something. +// * OnDelete will get the final state of the item if it is known, otherwise +// it will get an object of type DeletedFinalStateUnknown. This can +// happen if the watch is closed and misses the delete event and we don't +// notice the deletion until the subsequent re-list. +type ResourceEventHandler interface { + OnAdd(obj interface{}) + OnUpdate(oldObj, newObj interface{}) + OnDelete(obj interface{}) +} + +// ResourceEventHandlerFuncs is an adaptor to let you easily specify as many or +// as few of the notification functions as you want while still implementing +// ResourceEventHandler. +type ResourceEventHandlerFuncs struct { + AddFunc func(obj interface{}) + UpdateFunc func(oldObj, newObj interface{}) + DeleteFunc func(obj interface{}) +} + +// OnAdd calls AddFunc if it's not nil. +func (r ResourceEventHandlerFuncs) OnAdd(obj interface{}) { + if r.AddFunc != nil { + r.AddFunc(obj) + } +} + +// OnUpdate calls UpdateFunc if it's not nil. +func (r ResourceEventHandlerFuncs) OnUpdate(oldObj, newObj interface{}) { + if r.UpdateFunc != nil { + r.UpdateFunc(oldObj, newObj) + } +} + +// OnDelete calls DeleteFunc if it's not nil. +func (r ResourceEventHandlerFuncs) OnDelete(obj interface{}) { + if r.DeleteFunc != nil { + r.DeleteFunc(obj) + } +} + +// DeletionHandlingMetaNamespaceKeyFunc checks for +// DeletedFinalStateUnknown objects before calling +// MetaNamespaceKeyFunc. +func DeletionHandlingMetaNamespaceKeyFunc(obj interface{}) (string, error) { + if d, ok := obj.(DeletedFinalStateUnknown); ok { + return d.Key, nil + } + return MetaNamespaceKeyFunc(obj) +} + +// NewInformer returns a Store and a controller for populating the store +// while also providing event notifications. You should only used the returned +// Store for Get/List operations; Add/Modify/Deletes will cause the event +// notifications to be faulty. +// +// Parameters: +// * lw is list and watch functions for the source of the resource you want to +// be informed of. +// * objType is an object of the type that you expect to receive. +// * resyncPeriod: if non-zero, will re-list this often (you will get OnUpdate +// calls, even if nothing changed). Otherwise, re-list will be delayed as +// long as possible (until the upstream source closes the watch or times out, +// or you stop the controller). +// * h is the object you want notifications sent to. +// +func NewInformer( + lw ListerWatcher, + objType runtime.Object, + resyncPeriod time.Duration, + h ResourceEventHandler, +) (Store, *Controller) { + // This will hold the client state, as we know it. + clientState := NewStore(DeletionHandlingMetaNamespaceKeyFunc) + + // This will hold incoming changes. Note how we pass clientState in as a + // KeyLister, that way resync operations will result in the correct set + // of update/delete deltas. + fifo := NewDeltaFIFO(MetaNamespaceKeyFunc, nil, clientState) + + cfg := &Config{ + Queue: fifo, + ListerWatcher: lw, + ObjectType: objType, + FullResyncPeriod: resyncPeriod, + RetryOnError: false, + + Process: func(obj interface{}) error { + // from oldest to newest + for _, d := range obj.(Deltas) { + switch d.Type { + case Sync, Added, Updated: + if old, exists, err := clientState.Get(d.Object); err == nil && exists { + if err := clientState.Update(d.Object); err != nil { + return err + } + h.OnUpdate(old, d.Object) + } else { + if err := clientState.Add(d.Object); err != nil { + return err + } + h.OnAdd(d.Object) + } + case Deleted: + if err := clientState.Delete(d.Object); err != nil { + return err + } + h.OnDelete(d.Object) + } + } + return nil + }, + } + return clientState, New(cfg) +} + +// NewIndexerInformer returns a Indexer and a controller for populating the index +// while also providing event notifications. You should only used the returned +// Index for Get/List operations; Add/Modify/Deletes will cause the event +// notifications to be faulty. +// +// Parameters: +// * lw is list and watch functions for the source of the resource you want to +// be informed of. +// * objType is an object of the type that you expect to receive. +// * resyncPeriod: if non-zero, will re-list this often (you will get OnUpdate +// calls, even if nothing changed). Otherwise, re-list will be delayed as +// long as possible (until the upstream source closes the watch or times out, +// or you stop the controller). +// * h is the object you want notifications sent to. +// +func NewIndexerInformer( + lw ListerWatcher, + objType runtime.Object, + resyncPeriod time.Duration, + h ResourceEventHandler, + indexers Indexers, +) (Indexer, *Controller) { + // This will hold the client state, as we know it. + clientState := NewIndexer(DeletionHandlingMetaNamespaceKeyFunc, indexers) + + // This will hold incoming changes. Note how we pass clientState in as a + // KeyLister, that way resync operations will result in the correct set + // of update/delete deltas. + fifo := NewDeltaFIFO(MetaNamespaceKeyFunc, nil, clientState) + + cfg := &Config{ + Queue: fifo, + ListerWatcher: lw, + ObjectType: objType, + FullResyncPeriod: resyncPeriod, + RetryOnError: false, + + Process: func(obj interface{}) error { + // from oldest to newest + for _, d := range obj.(Deltas) { + switch d.Type { + case Sync, Added, Updated: + if old, exists, err := clientState.Get(d.Object); err == nil && exists { + if err := clientState.Update(d.Object); err != nil { + return err + } + h.OnUpdate(old, d.Object) + } else { + if err := clientState.Add(d.Object); err != nil { + return err + } + h.OnAdd(d.Object) + } + case Deleted: + if err := clientState.Delete(d.Object); err != nil { + return err + } + h.OnDelete(d.Object) + } + } + return nil + }, + } + return clientState, New(cfg) +} diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/controller_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/controller_test.go new file mode 100644 index 000000000000..79b50196b242 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/controller_test.go @@ -0,0 +1,401 @@ +/* +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 testing + +import ( + "fmt" + "math/rand" + "sync" + "testing" + "time" + + "k8s.io/client-go/1.5/pkg/api" + "k8s.io/client-go/1.5/pkg/runtime" + "k8s.io/client-go/1.5/pkg/util/sets" + "k8s.io/client-go/1.5/pkg/util/wait" + "k8s.io/client-go/1.5/pkg/watch" + fcache "k8s.io/client-go/1.5/tools/cache/testing" + + "github.com/google/gofuzz" +) + +func Example() { + // source simulates an apiserver object endpoint. + source := fcache.NewFakeControllerSource() + + // This will hold the downstream state, as we know it. + downstream := NewStore(DeletionHandlingMetaNamespaceKeyFunc) + + // This will hold incoming changes. Note how we pass downstream in as a + // KeyLister, that way resync operations will result in the correct set + // of update/delete deltas. + fifo := NewDeltaFIFO(MetaNamespaceKeyFunc, nil, downstream) + + // Let's do threadsafe output to get predictable test results. + deletionCounter := make(chan string, 1000) + + cfg := &Config{ + Queue: fifo, + ListerWatcher: source, + ObjectType: &api.Pod{}, + FullResyncPeriod: time.Millisecond * 100, + RetryOnError: false, + + // Let's implement a simple controller that just deletes + // everything that comes in. + Process: func(obj interface{}) error { + // Obj is from the Pop method of the Queue we make above. + newest := obj.(Deltas).Newest() + + if newest.Type != Deleted { + // Update our downstream store. + err := downstream.Add(newest.Object) + if err != nil { + return err + } + + // Delete this object. + source.Delete(newest.Object.(runtime.Object)) + } else { + // Update our downstream store. + err := downstream.Delete(newest.Object) + if err != nil { + return err + } + + // fifo's KeyOf is easiest, because it handles + // DeletedFinalStateUnknown markers. + key, err := fifo.KeyOf(newest.Object) + if err != nil { + return err + } + + // Report this deletion. + deletionCounter <- key + } + return nil + }, + } + + // Create the controller and run it until we close stop. + stop := make(chan struct{}) + defer close(stop) + go New(cfg).Run(stop) + + // Let's add a few objects to the source. + testIDs := []string{"a-hello", "b-controller", "c-framework"} + for _, name := range testIDs { + // Note that these pods are not valid-- the fake source doesn't + // call validation or anything. + source.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: name}}) + } + + // Let's wait for the controller to process the things we just added. + outputSet := sets.String{} + for i := 0; i < len(testIDs); i++ { + outputSet.Insert(<-deletionCounter) + } + + for _, key := range outputSet.List() { + fmt.Println(key) + } + // Output: + // a-hello + // b-controller + // c-framework +} + +func ExampleNewInformer() { + // source simulates an apiserver object endpoint. + source := fcache.NewFakeControllerSource() + + // Let's do threadsafe output to get predictable test results. + deletionCounter := make(chan string, 1000) + + // Make a controller that immediately deletes anything added to it, and + // logs anything deleted. + _, controller := NewInformer( + source, + &api.Pod{}, + time.Millisecond*100, + ResourceEventHandlerFuncs{ + AddFunc: func(obj interface{}) { + source.Delete(obj.(runtime.Object)) + }, + DeleteFunc: func(obj interface{}) { + key, err := DeletionHandlingMetaNamespaceKeyFunc(obj) + if err != nil { + key = "oops something went wrong with the key" + } + + // Report this deletion. + deletionCounter <- key + }, + }, + ) + + // Run the controller and run it until we close stop. + stop := make(chan struct{}) + defer close(stop) + go controller.Run(stop) + + // Let's add a few objects to the source. + testIDs := []string{"a-hello", "b-controller", "c-framework"} + for _, name := range testIDs { + // Note that these pods are not valid-- the fake source doesn't + // call validation or anything. + source.Add(&api.Pod{ObjectMeta: api.ObjectMeta{Name: name}}) + } + + // Let's wait for the controller to process the things we just added. + outputSet := sets.String{} + for i := 0; i < len(testIDs); i++ { + outputSet.Insert(<-deletionCounter) + } + + for _, key := range outputSet.List() { + fmt.Println(key) + } + // Output: + // a-hello + // b-controller + // c-framework +} + +func TestHammerController(t *testing.T) { + // This test executes a bunch of requests through the fake source and + // controller framework to make sure there's no locking/threading + // errors. If an error happens, it should hang forever or trigger the + // race detector. + + // source simulates an apiserver object endpoint. + source := fcache.NewFakeControllerSource() + + // Let's do threadsafe output to get predictable test results. + outputSetLock := sync.Mutex{} + // map of key to operations done on the key + outputSet := map[string][]string{} + + recordFunc := func(eventType string, obj interface{}) { + key, err := DeletionHandlingMetaNamespaceKeyFunc(obj) + if err != nil { + t.Errorf("something wrong with key: %v", err) + key = "oops something went wrong with the key" + } + + // Record some output when items are deleted. + outputSetLock.Lock() + defer outputSetLock.Unlock() + outputSet[key] = append(outputSet[key], eventType) + } + + // Make a controller which just logs all the changes it gets. + _, controller := NewInformer( + source, + &api.Pod{}, + time.Millisecond*100, + ResourceEventHandlerFuncs{ + AddFunc: func(obj interface{}) { recordFunc("add", obj) }, + UpdateFunc: func(oldObj, newObj interface{}) { recordFunc("update", newObj) }, + DeleteFunc: func(obj interface{}) { recordFunc("delete", obj) }, + }, + ) + + if controller.HasSynced() { + t.Errorf("Expected HasSynced() to return false before we started the controller") + } + + // Run the controller and run it until we close stop. + stop := make(chan struct{}) + go controller.Run(stop) + + // Let's wait for the controller to do its initial sync + wait.Poll(100*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) { + return controller.HasSynced(), nil + }) + if !controller.HasSynced() { + t.Errorf("Expected HasSynced() to return true after the initial sync") + } + + wg := sync.WaitGroup{} + const threads = 3 + wg.Add(threads) + for i := 0; i < threads; i++ { + go func() { + defer wg.Done() + // Let's add a few objects to the source. + currentNames := sets.String{} + rs := rand.NewSource(rand.Int63()) + f := fuzz.New().NilChance(.5).NumElements(0, 2).RandSource(rs) + r := rand.New(rs) // Mustn't use r and f concurrently! + for i := 0; i < 100; i++ { + var name string + var isNew bool + if currentNames.Len() == 0 || r.Intn(3) == 1 { + f.Fuzz(&name) + isNew = true + } else { + l := currentNames.List() + name = l[r.Intn(len(l))] + } + + pod := &api.Pod{} + f.Fuzz(pod) + pod.ObjectMeta.Name = name + pod.ObjectMeta.Namespace = "default" + // Add, update, or delete randomly. + // Note that these pods are not valid-- the fake source doesn't + // call validation or perform any other checking. + if isNew { + currentNames.Insert(name) + source.Add(pod) + continue + } + switch r.Intn(2) { + case 0: + currentNames.Insert(name) + source.Modify(pod) + case 1: + currentNames.Delete(name) + source.Delete(pod) + } + } + }() + } + wg.Wait() + + // Let's wait for the controller to finish processing the things we just added. + // TODO: look in the queue to see how many items need to be processed. + time.Sleep(100 * time.Millisecond) + close(stop) + + outputSetLock.Lock() + t.Logf("got: %#v", outputSet) +} + +func TestUpdate(t *testing.T) { + // This test is going to exercise the various paths that result in a + // call to update. + + // source simulates an apiserver object endpoint. + source := fcache.NewFakeControllerSource() + + const ( + FROM = "from" + TO = "to" + ) + + // These are the transitions we expect to see; because this is + // asynchronous, there are a lot of valid possibilities. + type pair struct{ from, to string } + allowedTransitions := map[pair]bool{ + pair{FROM, TO}: true, + + // Because a resync can happen when we've already observed one + // of the above but before the item is deleted. + pair{TO, TO}: true, + // Because a resync could happen before we observe an update. + pair{FROM, FROM}: true, + } + + pod := func(name, check string, final bool) *api.Pod { + p := &api.Pod{ + ObjectMeta: api.ObjectMeta{ + Name: name, + Labels: map[string]string{"check": check}, + }, + } + if final { + p.Labels["final"] = "true" + } + return p + } + deletePod := func(p *api.Pod) bool { + return p.Labels["final"] == "true" + } + + tests := []func(string){ + func(name string) { + name = "a-" + name + source.Add(pod(name, FROM, false)) + source.Modify(pod(name, TO, true)) + }, + } + + const threads = 3 + + var testDoneWG sync.WaitGroup + testDoneWG.Add(threads * len(tests)) + + // Make a controller that deletes things once it observes an update. + // It calls Done() on the wait group on deletions so we can tell when + // everything we've added has been deleted. + watchCh := make(chan struct{}) + _, controller := NewInformer( + &testLW{ + WatchFunc: func(options api.ListOptions) (watch.Interface, error) { + watch, err := source.Watch(options) + close(watchCh) + return watch, err + }, + ListFunc: func(options api.ListOptions) (runtime.Object, error) { + return source.List(options) + }, + }, + &api.Pod{}, + 0, + ResourceEventHandlerFuncs{ + UpdateFunc: func(oldObj, newObj interface{}) { + o, n := oldObj.(*api.Pod), newObj.(*api.Pod) + from, to := o.Labels["check"], n.Labels["check"] + if !allowedTransitions[pair{from, to}] { + t.Errorf("observed transition %q -> %q for %v", from, to, n.Name) + } + if deletePod(n) { + source.Delete(n) + } + }, + DeleteFunc: func(obj interface{}) { + testDoneWG.Done() + }, + }, + ) + + // Run the controller and run it until we close stop. + // Once Run() is called, calls to testDoneWG.Done() might start, so + // all testDoneWG.Add() calls must happen before this point + stop := make(chan struct{}) + go controller.Run(stop) + <-watchCh + + // run every test a few times, in parallel + var wg sync.WaitGroup + wg.Add(threads * len(tests)) + for i := 0; i < threads; i++ { + for j, f := range tests { + go func(name string, f func(string)) { + defer wg.Done() + f(name) + }(fmt.Sprintf("%v-%v", i, j), f) + } + } + wg.Wait() + + // Let's wait for the controller to process the things we just added. + testDoneWG.Wait() + close(stop) +} diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo.go b/staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo.go index b26eefe6aa7c..bda19deb677b 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "errors" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo_test.go index f1a95573709e..9ae2ebec3880 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo_test.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/delta_fifo_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "fmt" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/doc.go b/staging/src/k8s.io/client-go/1.5/tools/cache/doc.go index 72b39f2f92bc..21913a6c53dc 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/doc.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/doc.go @@ -21,4 +21,4 @@ limitations under the License. // list currently available nodes), and one that additionally acts as // a FIFO queue (for example, to allow a scheduler to process incoming // pods). -package cache // import "k8s.io/client-go/1.5/tools/cache" +package testing // import "k8s.io/client-go/1.5/tools/cache" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache.go b/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache.go index 07f5dee40b2b..448e8cb411b3 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "sync" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache_fakes.go b/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache_fakes.go index 53a346ce46e5..d9a6720d3427 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache_fakes.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache_fakes.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "k8s.io/client-go/1.5/pkg/util/clock" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache_test.go index 9e1ecc0da614..21556cfea357 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache_test.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/expiration_cache_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "reflect" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/fake_custom_store.go b/staging/src/k8s.io/client-go/1.5/tools/cache/fake_custom_store.go index 8d71c247497a..b01b1870bce7 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/fake_custom_store.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/fake_custom_store.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing // FakeStore lets you define custom functions for store operations type FakeCustomStore struct { diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/fifo.go b/staging/src/k8s.io/client-go/1.5/tools/cache/fifo.go index d0c002c5284c..4bddee7ef254 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/fifo.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/fifo.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "sync" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/fifo_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/fifo_test.go index afd311d78802..abd07474f3c0 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/fifo_test.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/fifo_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "fmt" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/index.go b/staging/src/k8s.io/client-go/1.5/tools/cache/index.go index bc257ae03e27..c63177edcf92 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/index.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/index.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "fmt" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/index_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/index_test.go index 438a54311153..bf0e2227a604 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/index_test.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/index_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "strings" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/listers.go b/staging/src/k8s.io/client-go/1.5/tools/cache/listers.go index e715e42cf57f..31e89fdb0caa 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/listers.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/listers.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "fmt" @@ -22,6 +22,7 @@ import ( "github.com/golang/glog" "k8s.io/client-go/1.5/pkg/api" "k8s.io/client-go/1.5/pkg/api/errors" + "k8s.io/client-go/1.5/pkg/api/meta" "k8s.io/client-go/1.5/pkg/api/unversioned" "k8s.io/client-go/1.5/pkg/apis/apps" "k8s.io/client-go/1.5/pkg/apis/batch" @@ -31,104 +32,66 @@ import ( "k8s.io/client-go/1.5/pkg/labels" ) -// TODO: generate these classes and methods for all resources of interest using -// a script. Can use "go generate" once 1.4 is supported by all users. - -// StoreToPodLister makes a Store have the List method of the client.PodInterface -// The Store must contain (only) Pods. -// -// Example: -// s := cache.NewStore() -// lw := cache.ListWatch{Client: c, FieldSelector: sel, Resource: "pods"} -// r := cache.NewReflector(lw, &api.Pod{}, s).Run() -// l := StoreToPodLister{s} -// l.List() -type StoreToPodLister struct { - Indexer -} +type AppendFunc func(interface{}) -// Please note that selector is filtering among the pods that have gotten into -// the store; there may have been some filtering that already happened before -// that. -// We explicitly don't return api.PodList, to avoid expensive allocations, which -// in most cases are unnecessary. -func (s *StoreToPodLister) List(selector labels.Selector) (pods []*api.Pod, err error) { - for _, m := range s.Indexer.List() { - pod := m.(*api.Pod) - if selector.Matches(labels.Set(pod.Labels)) { - pods = append(pods, pod) +func ListAll(store Store, selector labels.Selector, appendFn AppendFunc) error { + for _, m := range store.List() { + metadata, err := meta.Accessor(m) + if err != nil { + return err + } + if selector.Matches(labels.Set(metadata.GetLabels())) { + appendFn(m) } } - return pods, nil + return nil } -// Pods is taking baby steps to be more like the api in pkg/client -func (s *StoreToPodLister) Pods(namespace string) storePodsNamespacer { - return storePodsNamespacer{s.Indexer, namespace} -} - -type storePodsNamespacer struct { - indexer Indexer - namespace string -} - -// Please note that selector is filtering among the pods that have gotten into -// the store; there may have been some filtering that already happened before -// that. -// We explicitly don't return api.PodList, to avoid expensive allocations, which -// in most cases are unnecessary. -func (s storePodsNamespacer) List(selector labels.Selector) (pods []*api.Pod, err error) { - if s.namespace == api.NamespaceAll { - for _, m := range s.indexer.List() { - pod := m.(*api.Pod) - if selector.Matches(labels.Set(pod.Labels)) { - pods = append(pods, pod) +func ListAllByNamespace(indexer Indexer, namespace string, selector labels.Selector, appendFn AppendFunc) error { + if namespace == api.NamespaceAll { + for _, m := range indexer.List() { + metadata, err := meta.Accessor(m) + if err != nil { + return err + } + if selector.Matches(labels.Set(metadata.GetLabels())) { + appendFn(m) } } - return pods, nil + return nil } - key := &api.Pod{ObjectMeta: api.ObjectMeta{Namespace: s.namespace}} - items, err := s.indexer.Index(NamespaceIndex, key) + items, err := indexer.Index(NamespaceIndex, api.ObjectMeta{Namespace: namespace}) if err != nil { // Ignore error; do slow search without index. glog.Warningf("can not retrieve list of objects using index : %v", err) - for _, m := range s.indexer.List() { - pod := m.(*api.Pod) - if s.namespace == pod.Namespace && selector.Matches(labels.Set(pod.Labels)) { - pods = append(pods, pod) + for _, m := range indexer.List() { + metadata, err := meta.Accessor(m) + if err != nil { + return err + } + if metadata.GetNamespace() == namespace && selector.Matches(labels.Set(metadata.GetLabels())) { + appendFn(m) } + } - return pods, nil + return nil } for _, m := range items { - pod := m.(*api.Pod) - if selector.Matches(labels.Set(pod.Labels)) { - pods = append(pods, pod) + metadata, err := meta.Accessor(m) + if err != nil { + return err + } + if selector.Matches(labels.Set(metadata.GetLabels())) { + appendFn(m) } } - return pods, nil -} -func (s storePodsNamespacer) Get(name string) (*api.Pod, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(api.Resource("pod"), name) - } - return obj.(*api.Pod), nil + return nil } -// Exists returns true if a pod matching the namespace/name of the given pod exists in the store. -func (s *StoreToPodLister) Exists(pod *api.Pod) (bool, error) { - _, exists, err := s.Indexer.Get(pod) - if err != nil { - return false, err - } - return exists, nil -} +// TODO: generate these classes and methods for all resources of interest using +// a script. Can use "go generate" once 1.4 is supported by all users. // NodeConditionPredicate is a function that indicates whether the given node's conditions meet // some set of criteria defined by the function. @@ -555,47 +518,6 @@ func (s *StoreToDaemonSetLister) GetPodDaemonSets(pod *api.Pod) (daemonSets []ex return } -// StoreToServiceLister makes a Store that has the List method of the client.ServiceInterface -// The Store must contain (only) Services. -type StoreToServiceLister struct { - Store -} - -func (s *StoreToServiceLister) List() (services api.ServiceList, err error) { - for _, m := range s.Store.List() { - services.Items = append(services.Items, *(m.(*api.Service))) - } - return services, nil -} - -// TODO: Move this back to scheduler as a helper function that takes a Store, -// rather than a method of StoreToServiceLister. -func (s *StoreToServiceLister) GetPodServices(pod *api.Pod) (services []api.Service, err error) { - var selector labels.Selector - var service api.Service - - for _, m := range s.Store.List() { - service = *m.(*api.Service) - // consider only services that are in the same namespace as the pod - if service.Namespace != pod.Namespace { - continue - } - if service.Spec.Selector == nil { - // services with nil selectors match nothing, not everything. - continue - } - selector = labels.Set(service.Spec.Selector).AsSelectorPreValidated() - if selector.Matches(labels.Set(pod.Labels)) { - services = append(services, service) - } - } - if len(services) == 0 { - err = fmt.Errorf("could not find service for pod %s in namespace %s with labels: %v", pod.Name, pod.Namespace, pod.Labels) - } - - return -} - // StoreToEndpointsLister makes a Store that lists endpoints. type StoreToEndpointsLister struct { Store diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/listers_core.go b/staging/src/k8s.io/client-go/1.5/tools/cache/listers_core.go new file mode 100644 index 000000000000..9f856650069c --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/listers_core.go @@ -0,0 +1,135 @@ +/* +Copyright 2016 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 testing + +import ( + "k8s.io/client-go/1.5/pkg/api" + "k8s.io/client-go/1.5/pkg/api/errors" + "k8s.io/client-go/1.5/pkg/labels" +) + +// TODO: generate these classes and methods for all resources of interest using +// a script. Can use "go generate" once 1.4 is supported by all users. + +// StoreToPodLister makes a Store have the List method of the client.PodInterface +// The Store must contain (only) Pods. +// +// Example: +// s := cache.NewStore() +// lw := cache.ListWatch{Client: c, FieldSelector: sel, Resource: "pods"} +// r := cache.NewReflector(lw, &api.Pod{}, s).Run() +// l := StoreToPodLister{s} +// l.List() +type StoreToPodLister struct { + Indexer Indexer +} + +func (s *StoreToPodLister) List(selector labels.Selector) (pods []*api.Pod, err error) { + err = ListAll(s.Indexer, selector, func(m interface{}) { + pods = append(pods, m.(*api.Pod)) + }) + return pods, err +} + +func (s *StoreToPodLister) Pods(namespace string) storePodsNamespacer { + return storePodsNamespacer{Indexer: s.Indexer, namespace: namespace} +} + +type storePodsNamespacer struct { + Indexer Indexer + namespace string +} + +func (s storePodsNamespacer) List(selector labels.Selector) (pods []*api.Pod, err error) { + err = ListAllByNamespace(s.Indexer, s.namespace, selector, func(m interface{}) { + pods = append(pods, m.(*api.Pod)) + }) + return pods, err +} + +func (s storePodsNamespacer) Get(name string) (*api.Pod, error) { + obj, exists, err := s.Indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(api.Resource("pod"), name) + } + return obj.(*api.Pod), nil +} + +// StoreToServiceLister helps list services +type StoreToServiceLister struct { + Indexer Indexer +} + +func (s *StoreToServiceLister) List(selector labels.Selector) (ret []*api.Service, err error) { + err = ListAll(s.Indexer, selector, func(m interface{}) { + ret = append(ret, m.(*api.Service)) + }) + return ret, err +} + +func (s *StoreToServiceLister) Services(namespace string) storeServicesNamespacer { + return storeServicesNamespacer{s.Indexer, namespace} +} + +type storeServicesNamespacer struct { + indexer Indexer + namespace string +} + +func (s storeServicesNamespacer) List(selector labels.Selector) (ret []*api.Service, err error) { + err = ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*api.Service)) + }) + return ret, err +} + +func (s storeServicesNamespacer) Get(name string) (*api.Service, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(api.Resource("service"), name) + } + return obj.(*api.Service), nil +} + +// TODO: Move this back to scheduler as a helper function that takes a Store, +// rather than a method of StoreToServiceLister. +func (s *StoreToServiceLister) GetPodServices(pod *api.Pod) (services []*api.Service, err error) { + allServices, err := s.Services(pod.Namespace).List(labels.Everything()) + if err != nil { + return nil, err + } + + for i := range allServices { + service := allServices[i] + if service.Spec.Selector == nil { + // services with nil selectors match nothing, not everything. + continue + } + selector := labels.Set(service.Spec.Selector).AsSelectorPreValidated() + if selector.Matches(labels.Set(pod.Labels)) { + services = append(services, service) + } + } + + return services, nil +} diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/listers_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/listers_test.go index 6715997b6508..b83f17ab86f7 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/listers_test.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/listers_test.go @@ -14,12 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "testing" "k8s.io/client-go/1.5/pkg/api" + apierrors "k8s.io/client-go/1.5/pkg/api/errors" "k8s.io/client-go/1.5/pkg/api/unversioned" "k8s.io/client-go/1.5/pkg/apis/batch" "k8s.io/client-go/1.5/pkg/apis/extensions" @@ -700,8 +701,9 @@ func TestStoreToPodLister(t *testing.T) { for _, id := range ids { store.Add(&api.Pod{ ObjectMeta: api.ObjectMeta{ - Name: id, - Labels: map[string]string{"name": id}, + Namespace: "other", + Name: id, + Labels: map[string]string{"name": id}, }, }) } @@ -739,27 +741,20 @@ func TestStoreToPodLister(t *testing.T) { continue } - exists, err := spl.Exists(&api.Pod{ObjectMeta: api.ObjectMeta{Name: id}}) + _, err = spl.Pods("other").Get(id) if err != nil { t.Errorf("unexpected error: %v", err) } - if !exists { - t.Errorf("exists returned false for %v", id) - } } - exists, err := spl.Exists(&api.Pod{ObjectMeta: api.ObjectMeta{Name: "qux"}}) - if err != nil { - t.Errorf("unexpected error: %v", err) - } - if exists { + if _, err := spl.Pods("").Get("qux"); !apierrors.IsNotFound(err) { t.Error("Unexpected pod exists") } } } func TestStoreToServiceLister(t *testing.T) { - store := NewStore(MetaNamespaceKeyFunc) + store := NewIndexer(MetaNamespaceKeyFunc, Indexers{NamespaceIndex: MetaNamespaceIndexFunc}) store.Add(&api.Service{ ObjectMeta: api.ObjectMeta{Name: "foo"}, Spec: api.ServiceSpec{ diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/listwatch.go b/staging/src/k8s.io/client-go/1.5/tools/cache/listwatch.go index 4790c9c5c47e..92d585ceae9d 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/listwatch.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/listwatch.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "time" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/processor_listener_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/processor_listener_test.go new file mode 100644 index 000000000000..37a424e67637 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/processor_listener_test.go @@ -0,0 +1,48 @@ +/* +Copyright 2016 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 testing + +import ( + "testing" + "time" + + "k8s.io/client-go/1.5/pkg/util/wait" +) + +// TestPopReleaseLock tests that when processor listener blocks on chan, +// it should release the lock for pendingNotifications. +func TestPopReleaseLock(t *testing.T) { + pl := newProcessListener(nil) + stopCh := make(chan struct{}) + defer close(stopCh) + // make pop() block on nextCh: waiting for receiver to get notification. + pl.add(1) + go pl.pop(stopCh) + + resultCh := make(chan struct{}) + go func() { + pl.lock.Lock() + close(resultCh) + }() + + select { + case <-resultCh: + case <-time.After(wait.ForeverTestTimeout): + t.Errorf("Timeout after %v", wait.ForeverTestTimeout) + } + pl.lock.Unlock() +} diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/reflector.go b/staging/src/k8s.io/client-go/1.5/tools/cache/reflector.go index 8dacf3ac1308..636abffdc5fd 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/reflector.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/reflector.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "errors" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/reflector_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/reflector_test.go index d40c807866a7..8f6984b0e207 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/reflector_test.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/reflector_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "errors" @@ -34,12 +34,12 @@ import ( var nevererrc chan error type testLW struct { - ListFunc func() (runtime.Object, error) + ListFunc func(options api.ListOptions) (runtime.Object, error) WatchFunc func(options api.ListOptions) (watch.Interface, error) } func (t *testLW) List(options api.ListOptions) (runtime.Object, error) { - return t.ListFunc() + return t.ListFunc(options) } func (t *testLW) Watch(options api.ListOptions) (watch.Interface, error) { return t.WatchFunc(options) @@ -53,7 +53,7 @@ func TestCloseWatchChannelOnError(t *testing.T) { WatchFunc: func(options api.ListOptions) (watch.Interface, error) { return fw, nil }, - ListFunc: func() (runtime.Object, error) { + ListFunc: func(options api.ListOptions) (runtime.Object, error) { return &api.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "1"}}, nil }, } @@ -79,7 +79,7 @@ func TestRunUntil(t *testing.T) { WatchFunc: func(options api.ListOptions) (watch.Interface, error) { return fw, nil }, - ListFunc: func() (runtime.Object, error) { + ListFunc: func(options api.ListOptions) (runtime.Object, error) { return &api.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "1"}}, nil }, } @@ -227,7 +227,7 @@ func TestReflectorListAndWatch(t *testing.T) { go func() { createdFakes <- fw }() return fw, nil }, - ListFunc: func() (runtime.Object, error) { + ListFunc: func(options api.ListOptions) (runtime.Object, error) { return &api.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "1"}}, nil }, } @@ -345,7 +345,7 @@ func TestReflectorListAndWatchWithErrors(t *testing.T) { }() return fw, nil }, - ListFunc: func() (runtime.Object, error) { + ListFunc: func(options api.ListOptions) (runtime.Object, error) { return item.list, item.listErr }, } @@ -373,7 +373,7 @@ func TestReflectorResync(t *testing.T) { fw := watch.NewFake() return fw, nil }, - ListFunc: func() (runtime.Object, error) { + ListFunc: func(options api.ListOptions) (runtime.Object, error) { return &api.PodList{ListMeta: unversioned.ListMeta{ResourceVersion: "0"}}, nil }, } diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/shared_informer.go b/staging/src/k8s.io/client-go/1.5/tools/cache/shared_informer.go new file mode 100644 index 000000000000..a980f590f4d1 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/shared_informer.go @@ -0,0 +1,413 @@ +/* +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 testing + +import ( + "fmt" + "sync" + "time" + + "k8s.io/client-go/1.5/pkg/runtime" + utilruntime "k8s.io/client-go/1.5/pkg/util/runtime" + "k8s.io/client-go/1.5/pkg/util/wait" + + "github.com/golang/glog" +) + +// if you use this, there is one behavior change compared to a standard Informer. +// When you receive a notification, the cache will be AT LEAST as fresh as the +// notification, but it MAY be more fresh. You should NOT depend on the contents +// of the cache exactly matching the notification you've received in handler +// functions. If there was a create, followed by a delete, the cache may NOT +// have your item. This has advantages over the broadcaster since it allows us +// to share a common cache across many controllers. Extending the broadcaster +// would have required us keep duplicate caches for each watch. +type SharedInformer interface { + // events to a single handler are delivered sequentially, but there is no coordination between different handlers + // You may NOT add a handler *after* the SharedInformer is running. That will result in an error being returned. + // TODO we should try to remove this restriction eventually. + AddEventHandler(handler ResourceEventHandler) error + GetStore() Store + // GetController gives back a synthetic interface that "votes" to start the informer + GetController() ControllerInterface + Run(stopCh <-chan struct{}) + HasSynced() bool + LastSyncResourceVersion() string +} + +type SharedIndexInformer interface { + SharedInformer + // AddIndexers add indexers to the informer before it starts. + AddIndexers(indexers Indexers) error + GetIndexer() Indexer +} + +// NewSharedInformer creates a new instance for the listwatcher. +// TODO: create a cache/factory of these at a higher level for the list all, watch all of a given resource that can +// be shared amongst all consumers. +func NewSharedInformer(lw ListerWatcher, objType runtime.Object, resyncPeriod time.Duration) SharedInformer { + return NewSharedIndexInformer(lw, objType, resyncPeriod, Indexers{}) +} + +// NewSharedIndexInformer creates a new instance for the listwatcher. +// TODO: create a cache/factory of these at a higher level for the list all, watch all of a given resource that can +// be shared amongst all consumers. +func NewSharedIndexInformer(lw ListerWatcher, objType runtime.Object, resyncPeriod time.Duration, indexers Indexers) SharedIndexInformer { + sharedIndexInformer := &sharedIndexInformer{ + processor: &sharedProcessor{}, + indexer: NewIndexer(DeletionHandlingMetaNamespaceKeyFunc, indexers), + listerWatcher: lw, + objectType: objType, + fullResyncPeriod: resyncPeriod, + } + return sharedIndexInformer +} + +// InformerSynced is a function that can be used to determine if an informer has synced. This is useful for determining if caches have synced. +type InformerSynced func() bool + +// syncedPollPeriod controls how often you look at the status of your sync funcs +const syncedPollPeriod = 100 * time.Millisecond + +// WaitForCacheSync waits for caches to populate. It returns true if it was successful, false +// if the contoller should shutdown +func WaitForCacheSync(stopCh <-chan struct{}, cacheSyncs ...InformerSynced) bool { + err := wait.PollUntil(syncedPollPeriod, + func() (bool, error) { + for _, syncFunc := range cacheSyncs { + if !syncFunc() { + return false, nil + } + } + return true, nil + }, + stopCh) + if err != nil { + glog.V(2).Infof("stop requested") + return false + } + + glog.V(4).Infof("caches populated") + return true +} + +type sharedIndexInformer struct { + indexer Indexer + controller *Controller + + processor *sharedProcessor + + // This block is tracked to handle late initialization of the controller + listerWatcher ListerWatcher + objectType runtime.Object + fullResyncPeriod time.Duration + + started bool + startedLock sync.Mutex + + // blockDeltas gives a way to stop all event distribution so that a late event handler + // can safely join the shared informer. + blockDeltas sync.Mutex + // stopCh is the channel used to stop the main Run process. We have to track it so that + // late joiners can have a proper stop + stopCh <-chan struct{} +} + +// dummyController hides the fact that a SharedInformer is different from a dedicated one +// where a caller can `Run`. The run method is disonnected in this case, because higher +// level logic will decide when to start the SharedInformer and related controller. +// Because returning information back is always asynchronous, the legacy callers shouldn't +// notice any change in behavior. +type dummyController struct { + informer *sharedIndexInformer +} + +func (v *dummyController) Run(stopCh <-chan struct{}) { +} + +func (v *dummyController) HasSynced() bool { + return v.informer.HasSynced() +} + +type updateNotification struct { + oldObj interface{} + newObj interface{} +} + +type addNotification struct { + newObj interface{} +} + +type deleteNotification struct { + oldObj interface{} +} + +func (s *sharedIndexInformer) Run(stopCh <-chan struct{}) { + defer utilruntime.HandleCrash() + + fifo := NewDeltaFIFO(MetaNamespaceKeyFunc, nil, s.indexer) + + cfg := &Config{ + Queue: fifo, + ListerWatcher: s.listerWatcher, + ObjectType: s.objectType, + FullResyncPeriod: s.fullResyncPeriod, + RetryOnError: false, + + Process: s.HandleDeltas, + } + + func() { + s.startedLock.Lock() + defer s.startedLock.Unlock() + + s.controller = New(cfg) + s.started = true + }() + + s.stopCh = stopCh + s.processor.run(stopCh) + s.controller.Run(stopCh) +} + +func (s *sharedIndexInformer) isStarted() bool { + s.startedLock.Lock() + defer s.startedLock.Unlock() + return s.started +} + +func (s *sharedIndexInformer) HasSynced() bool { + s.startedLock.Lock() + defer s.startedLock.Unlock() + + if s.controller == nil { + return false + } + return s.controller.HasSynced() +} + +func (s *sharedIndexInformer) LastSyncResourceVersion() string { + s.startedLock.Lock() + defer s.startedLock.Unlock() + + if s.controller == nil { + return "" + } + return s.controller.reflector.LastSyncResourceVersion() +} + +func (s *sharedIndexInformer) GetStore() Store { + return s.indexer +} + +func (s *sharedIndexInformer) GetIndexer() Indexer { + return s.indexer +} + +func (s *sharedIndexInformer) AddIndexers(indexers Indexers) error { + s.startedLock.Lock() + defer s.startedLock.Unlock() + + if s.started { + return fmt.Errorf("informer has already started") + } + + return s.indexer.AddIndexers(indexers) +} + +func (s *sharedIndexInformer) GetController() ControllerInterface { + return &dummyController{informer: s} +} + +func (s *sharedIndexInformer) AddEventHandler(handler ResourceEventHandler) error { + s.startedLock.Lock() + defer s.startedLock.Unlock() + + if !s.started { + listener := newProcessListener(handler) + s.processor.listeners = append(s.processor.listeners, listener) + return nil + } + + // in order to safely join, we have to + // 1. stop sending add/update/delete notifications + // 2. do a list against the store + // 3. send synthetic "Add" events to the new handler + // 4. unblock + s.blockDeltas.Lock() + defer s.blockDeltas.Unlock() + + listener := newProcessListener(handler) + s.processor.listeners = append(s.processor.listeners, listener) + + go listener.run(s.stopCh) + go listener.pop(s.stopCh) + + items := s.indexer.List() + for i := range items { + listener.add(addNotification{newObj: items[i]}) + } + + return nil +} + +func (s *sharedIndexInformer) HandleDeltas(obj interface{}) error { + s.blockDeltas.Lock() + defer s.blockDeltas.Unlock() + + // from oldest to newest + for _, d := range obj.(Deltas) { + switch d.Type { + case Sync, Added, Updated: + if old, exists, err := s.indexer.Get(d.Object); err == nil && exists { + if err := s.indexer.Update(d.Object); err != nil { + return err + } + s.processor.distribute(updateNotification{oldObj: old, newObj: d.Object}) + } else { + if err := s.indexer.Add(d.Object); err != nil { + return err + } + s.processor.distribute(addNotification{newObj: d.Object}) + } + case Deleted: + if err := s.indexer.Delete(d.Object); err != nil { + return err + } + s.processor.distribute(deleteNotification{oldObj: d.Object}) + } + } + return nil +} + +type sharedProcessor struct { + listeners []*processorListener +} + +func (p *sharedProcessor) distribute(obj interface{}) { + for _, listener := range p.listeners { + listener.add(obj) + } +} + +func (p *sharedProcessor) run(stopCh <-chan struct{}) { + for _, listener := range p.listeners { + go listener.run(stopCh) + go listener.pop(stopCh) + } +} + +type processorListener struct { + // lock/cond protects access to 'pendingNotifications'. + lock sync.RWMutex + cond sync.Cond + + // pendingNotifications is an unbounded slice that holds all notifications not yet distributed + // there is one per listener, but a failing/stalled listener will have infinite pendingNotifications + // added until we OOM. + // TODO This is no worse that before, since reflectors were backed by unbounded DeltaFIFOs, but + // we should try to do something better + pendingNotifications []interface{} + + nextCh chan interface{} + + handler ResourceEventHandler +} + +func newProcessListener(handler ResourceEventHandler) *processorListener { + ret := &processorListener{ + pendingNotifications: []interface{}{}, + nextCh: make(chan interface{}), + handler: handler, + } + + ret.cond.L = &ret.lock + return ret +} + +func (p *processorListener) add(notification interface{}) { + p.lock.Lock() + defer p.lock.Unlock() + + p.pendingNotifications = append(p.pendingNotifications, notification) + p.cond.Broadcast() +} + +func (p *processorListener) pop(stopCh <-chan struct{}) { + defer utilruntime.HandleCrash() + + for { + blockingGet := func() (interface{}, bool) { + p.lock.Lock() + defer p.lock.Unlock() + + for len(p.pendingNotifications) == 0 { + // check if we're shutdown + select { + case <-stopCh: + return nil, true + default: + } + p.cond.Wait() + } + + nt := p.pendingNotifications[0] + p.pendingNotifications = p.pendingNotifications[1:] + return nt, false + } + + notification, stopped := blockingGet() + if stopped { + return + } + + select { + case <-stopCh: + return + case p.nextCh <- notification: + } + } +} + +func (p *processorListener) run(stopCh <-chan struct{}) { + defer utilruntime.HandleCrash() + + for { + var next interface{} + select { + case <-stopCh: + func() { + p.lock.Lock() + defer p.lock.Unlock() + p.cond.Broadcast() + }() + return + case next = <-p.nextCh: + } + + switch notification := next.(type) { + case updateNotification: + p.handler.OnUpdate(notification.oldObj, notification.newObj) + case addNotification: + p.handler.OnAdd(notification.newObj) + case deleteNotification: + p.handler.OnDelete(notification.oldObj) + default: + utilruntime.HandleError(fmt.Errorf("unrecognized notification: %#v", next)) + } + } +} diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/store.go b/staging/src/k8s.io/client-go/1.5/tools/cache/store.go index 6dcf50a66e77..6ec87a3c900e 100755 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/store.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/store.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "fmt" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/store_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/store_test.go index 683cb312613a..911fed6e4572 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/store_test.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/store_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "testing" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/testing/fake_controller_source.go b/staging/src/k8s.io/client-go/1.5/tools/cache/testing/fake_controller_source.go new file mode 100644 index 000000000000..0f5565137f63 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/testing/fake_controller_source.go @@ -0,0 +1,262 @@ +/* +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 framework + +import ( + "errors" + "math/rand" + "strconv" + "sync" + + "k8s.io/client-go/1.5/pkg/api" + "k8s.io/client-go/1.5/pkg/api/meta" + "k8s.io/client-go/1.5/pkg/runtime" + "k8s.io/client-go/1.5/pkg/types" + "k8s.io/client-go/1.5/pkg/watch" +) + +func NewFakeControllerSource() *FakeControllerSource { + return &FakeControllerSource{ + Items: map[nnu]runtime.Object{}, + Broadcaster: watch.NewBroadcaster(100, watch.WaitIfChannelFull), + } +} + +func NewFakePVControllerSource() *FakePVControllerSource { + return &FakePVControllerSource{ + FakeControllerSource{ + Items: map[nnu]runtime.Object{}, + Broadcaster: watch.NewBroadcaster(100, watch.WaitIfChannelFull), + }} +} + +func NewFakePVCControllerSource() *FakePVCControllerSource { + return &FakePVCControllerSource{ + FakeControllerSource{ + Items: map[nnu]runtime.Object{}, + Broadcaster: watch.NewBroadcaster(100, watch.WaitIfChannelFull), + }} +} + +// FakeControllerSource implements listing/watching for testing. +type FakeControllerSource struct { + lock sync.RWMutex + Items map[nnu]runtime.Object + changes []watch.Event // one change per resourceVersion + Broadcaster *watch.Broadcaster +} + +type FakePVControllerSource struct { + FakeControllerSource +} + +type FakePVCControllerSource struct { + FakeControllerSource +} + +// namespace, name, uid to be used as a key. +type nnu struct { + namespace, name string + uid types.UID +} + +// Add adds an object to the set and sends an add event to watchers. +// obj's ResourceVersion is set. +func (f *FakeControllerSource) Add(obj runtime.Object) { + f.Change(watch.Event{Type: watch.Added, Object: obj}, 1) +} + +// Modify updates an object in the set and sends a modified event to watchers. +// obj's ResourceVersion is set. +func (f *FakeControllerSource) Modify(obj runtime.Object) { + f.Change(watch.Event{Type: watch.Modified, Object: obj}, 1) +} + +// Delete deletes an object from the set and sends a delete event to watchers. +// obj's ResourceVersion is set. +func (f *FakeControllerSource) Delete(lastValue runtime.Object) { + f.Change(watch.Event{Type: watch.Deleted, Object: lastValue}, 1) +} + +// AddDropWatch adds an object to the set but forgets to send an add event to +// watchers. +// obj's ResourceVersion is set. +func (f *FakeControllerSource) AddDropWatch(obj runtime.Object) { + f.Change(watch.Event{Type: watch.Added, Object: obj}, 0) +} + +// ModifyDropWatch updates an object in the set but forgets to send a modify +// event to watchers. +// obj's ResourceVersion is set. +func (f *FakeControllerSource) ModifyDropWatch(obj runtime.Object) { + f.Change(watch.Event{Type: watch.Modified, Object: obj}, 0) +} + +// DeleteDropWatch deletes an object from the set but forgets to send a delete +// event to watchers. +// obj's ResourceVersion is set. +func (f *FakeControllerSource) DeleteDropWatch(lastValue runtime.Object) { + f.Change(watch.Event{Type: watch.Deleted, Object: lastValue}, 0) +} + +func (f *FakeControllerSource) key(accessor meta.Object) nnu { + return nnu{accessor.GetNamespace(), accessor.GetName(), accessor.GetUID()} +} + +// Change records the given event (setting the object's resource version) and +// sends a watch event with the specified probability. +func (f *FakeControllerSource) Change(e watch.Event, watchProbability float64) { + f.lock.Lock() + defer f.lock.Unlock() + + accessor, err := meta.Accessor(e.Object) + if err != nil { + panic(err) // this is test code only + } + + resourceVersion := len(f.changes) + 1 + accessor.SetResourceVersion(strconv.Itoa(resourceVersion)) + f.changes = append(f.changes, e) + key := f.key(accessor) + switch e.Type { + case watch.Added, watch.Modified: + f.Items[key] = e.Object + case watch.Deleted: + delete(f.Items, key) + } + + if rand.Float64() < watchProbability { + f.Broadcaster.Action(e.Type, e.Object) + } +} + +func (f *FakeControllerSource) getListItemsLocked() ([]runtime.Object, error) { + list := make([]runtime.Object, 0, len(f.Items)) + for _, obj := range f.Items { + // Must make a copy to allow clients to modify the object. + // Otherwise, if they make a change and write it back, they + // will inadvertently change our canonical copy (in + // addition to racing with other clients). + objCopy, err := api.Scheme.DeepCopy(obj) + if err != nil { + return nil, err + } + list = append(list, objCopy.(runtime.Object)) + } + return list, nil +} + +// List returns a list object, with its resource version set. +func (f *FakeControllerSource) List(options api.ListOptions) (runtime.Object, error) { + f.lock.RLock() + defer f.lock.RUnlock() + list, err := f.getListItemsLocked() + if err != nil { + return nil, err + } + listObj := &api.List{} + if err := meta.SetList(listObj, list); err != nil { + return nil, err + } + objMeta, err := api.ListMetaFor(listObj) + if err != nil { + return nil, err + } + resourceVersion := len(f.changes) + objMeta.ResourceVersion = strconv.Itoa(resourceVersion) + return listObj, nil +} + +// List returns a list object, with its resource version set. +func (f *FakePVControllerSource) List(options api.ListOptions) (runtime.Object, error) { + f.lock.RLock() + defer f.lock.RUnlock() + list, err := f.FakeControllerSource.getListItemsLocked() + if err != nil { + return nil, err + } + listObj := &api.PersistentVolumeList{} + if err := meta.SetList(listObj, list); err != nil { + return nil, err + } + objMeta, err := api.ListMetaFor(listObj) + if err != nil { + return nil, err + } + resourceVersion := len(f.changes) + objMeta.ResourceVersion = strconv.Itoa(resourceVersion) + return listObj, nil +} + +// List returns a list object, with its resource version set. +func (f *FakePVCControllerSource) List(options api.ListOptions) (runtime.Object, error) { + f.lock.RLock() + defer f.lock.RUnlock() + list, err := f.FakeControllerSource.getListItemsLocked() + if err != nil { + return nil, err + } + listObj := &api.PersistentVolumeClaimList{} + if err := meta.SetList(listObj, list); err != nil { + return nil, err + } + objMeta, err := api.ListMetaFor(listObj) + if err != nil { + return nil, err + } + resourceVersion := len(f.changes) + objMeta.ResourceVersion = strconv.Itoa(resourceVersion) + return listObj, nil +} + +// Watch returns a watch, which will be pre-populated with all changes +// after resourceVersion. +func (f *FakeControllerSource) Watch(options api.ListOptions) (watch.Interface, error) { + f.lock.RLock() + defer f.lock.RUnlock() + rc, err := strconv.Atoi(options.ResourceVersion) + if err != nil { + return nil, err + } + if rc < len(f.changes) { + changes := []watch.Event{} + for _, c := range f.changes[rc:] { + // Must make a copy to allow clients to modify the + // object. Otherwise, if they make a change and write + // it back, they will inadvertently change the our + // canonical copy (in addition to racing with other + // clients). + objCopy, err := api.Scheme.DeepCopy(c.Object) + if err != nil { + return nil, err + } + changes = append(changes, watch.Event{Type: c.Type, Object: objCopy.(runtime.Object)}) + } + return f.Broadcaster.WatchWithPrefix(changes), nil + } else if rc > len(f.changes) { + return nil, errors.New("resource version in the future not supported by this fake") + } + return f.Broadcaster.Watch(), nil +} + +// Shutdown closes the underlying broadcaster, waiting for events to be +// delivered. It's an error to call any method after calling shutdown. This is +// enforced by Shutdown() leaving f locked. +func (f *FakeControllerSource) Shutdown() { + f.lock.Lock() // Purposely no unlock. + f.Broadcaster.Shutdown() +} diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/testing/fake_controller_source_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/testing/fake_controller_source_test.go new file mode 100644 index 000000000000..135af37b79f8 --- /dev/null +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/testing/fake_controller_source_test.go @@ -0,0 +1,94 @@ +/* +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 framework + +import ( + "sync" + "testing" + + "k8s.io/client-go/1.5/pkg/api" + "k8s.io/client-go/1.5/pkg/watch" +) + +// ensure the watch delivers the requested and only the requested items. +func consume(t *testing.T, w watch.Interface, rvs []string, done *sync.WaitGroup) { + defer done.Done() + for _, rv := range rvs { + got, ok := <-w.ResultChan() + if !ok { + t.Errorf("%#v: unexpected channel close, wanted %v", rvs, rv) + return + } + gotRV := got.Object.(*api.Pod).ObjectMeta.ResourceVersion + if e, a := rv, gotRV; e != a { + t.Errorf("wanted %v, got %v", e, a) + } else { + t.Logf("Got %v as expected", gotRV) + } + } + // We should not get anything else. + got, open := <-w.ResultChan() + if open { + t.Errorf("%#v: unwanted object %#v", rvs, got) + } +} + +func TestRCNumber(t *testing.T) { + pod := func(name string) *api.Pod { + return &api.Pod{ + ObjectMeta: api.ObjectMeta{ + Name: name, + }, + } + } + + wg := &sync.WaitGroup{} + wg.Add(3) + + source := NewFakeControllerSource() + source.Add(pod("foo")) + source.Modify(pod("foo")) + source.Modify(pod("foo")) + + w, err := source.Watch(api.ListOptions{ResourceVersion: "1"}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + go consume(t, w, []string{"2", "3"}, wg) + + list, err := source.List(api.ListOptions{}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + if e, a := "3", list.(*api.List).ResourceVersion; e != a { + t.Errorf("wanted %v, got %v", e, a) + } + + w2, err := source.Watch(api.ListOptions{ResourceVersion: "2"}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + go consume(t, w2, []string{"3"}, wg) + + w3, err := source.Watch(api.ListOptions{ResourceVersion: "3"}) + if err != nil { + t.Fatalf("Unexpected error: %v", err) + } + go consume(t, w3, []string{}, wg) + source.Shutdown() + wg.Wait() +} diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/thread_safe_store.go b/staging/src/k8s.io/client-go/1.5/tools/cache/thread_safe_store.go index 913a77ac2b84..14e2efbcd549 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/thread_safe_store.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/thread_safe_store.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "fmt" diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/undelta_store.go b/staging/src/k8s.io/client-go/1.5/tools/cache/undelta_store.go index 117df46c48d2..421c1d11f65f 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/undelta_store.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/undelta_store.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing // UndeltaStore listens to incremental updates and sends complete state on every change. // It implements the Store interface so that it can receive a stream of mirrored objects diff --git a/staging/src/k8s.io/client-go/1.5/tools/cache/undelta_store_test.go b/staging/src/k8s.io/client-go/1.5/tools/cache/undelta_store_test.go index 6316442e6805..f9eb849c76a9 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/cache/undelta_store_test.go +++ b/staging/src/k8s.io/client-go/1.5/tools/cache/undelta_store_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package cache +package testing import ( "reflect" diff --git a/staging/src/k8s.io/client-go/1.5/tools/clientcmd/client_config.go b/staging/src/k8s.io/client-go/1.5/tools/clientcmd/client_config.go index c48e8fc636ac..a8b217683319 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/clientcmd/client_config.go +++ b/staging/src/k8s.io/client-go/1.5/tools/clientcmd/client_config.go @@ -34,16 +34,25 @@ import ( ) var ( - // DefaultCluster is the cluster config used when no other config is specified - // TODO: eventually apiserver should start on 443 and be secure by default - DefaultCluster = clientcmdapi.Cluster{Server: "http://localhost:8080"} - - // EnvVarCluster allows overriding the DefaultCluster using an envvar for the server name - EnvVarCluster = clientcmdapi.Cluster{Server: os.Getenv("KUBERNETES_MASTER")} - - DefaultClientConfig = DirectClientConfig{*clientcmdapi.NewConfig(), "", &ConfigOverrides{}, nil, NewDefaultClientConfigLoadingRules()} + // ClusterDefaults has the same behavior as the old EnvVar and DefaultCluster fields + // DEPRECATED will be replaced + ClusterDefaults = clientcmdapi.Cluster{Server: getDefaultServer()} + // DefaultClientConfig represents the legacy behavior of this package for defaulting + // DEPRECATED will be replace + DefaultClientConfig = DirectClientConfig{*clientcmdapi.NewConfig(), "", &ConfigOverrides{ + ClusterDefaults: ClusterDefaults, + }, nil, NewDefaultClientConfigLoadingRules()} ) +// getDefaultServer returns a default setting for DefaultClientConfig +// DEPRECATED +func getDefaultServer() string { + if server := os.Getenv("KUBERNETES_MASTER"); len(server) > 0 { + return server + } + return "http://localhost:8080" +} + // ClientConfig is used to make it easy to get an api server client type ClientConfig interface { // RawConfig returns the merged result of all overrides @@ -347,7 +356,6 @@ func (config *DirectClientConfig) getCluster() clientcmdapi.Cluster { var mergedClusterInfo clientcmdapi.Cluster mergo.Merge(&mergedClusterInfo, config.overrides.ClusterDefaults) - mergo.Merge(&mergedClusterInfo, EnvVarCluster) if configClusterInfo, exists := clusterInfos[clusterInfoName]; exists { mergo.Merge(&mergedClusterInfo, configClusterInfo) } diff --git a/staging/src/k8s.io/client-go/1.5/tools/clientcmd/client_config_test.go b/staging/src/k8s.io/client-go/1.5/tools/clientcmd/client_config_test.go index 8c1352baad44..6471957e4b28 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/clientcmd/client_config_test.go +++ b/staging/src/k8s.io/client-go/1.5/tools/clientcmd/client_config_test.go @@ -293,8 +293,6 @@ func TestCreateCleanWithPrefix(t *testing.T) { {"anything", "anything"}, } - // WARNING: EnvVarCluster.Server is set during package loading time and can not be overridden by os.Setenv inside this test - EnvVarCluster.Server = "" tt = append(tt, struct{ server, host string }{"", "http://localhost:8080"}) for _, tc := range tt { @@ -305,7 +303,7 @@ func TestCreateCleanWithPrefix(t *testing.T) { config.Clusters["clean"] = cleanConfig clientBuilder := NewNonInteractiveClientConfig(*config, "clean", &ConfigOverrides{ - ClusterDefaults: DefaultCluster, + ClusterDefaults: clientcmdapi.Cluster{Server: "http://localhost:8080"}, }, nil) clientConfig, err := clientBuilder.ClientConfig() @@ -334,7 +332,7 @@ func TestCreateCleanDefault(t *testing.T) { func TestCreateCleanDefaultCluster(t *testing.T) { config := createValidTestConfig() clientBuilder := NewDefaultClientConfig(*config, &ConfigOverrides{ - ClusterDefaults: DefaultCluster, + ClusterDefaults: clientcmdapi.Cluster{Server: "http://localhost:8080"}, }) clientConfig, err := clientBuilder.ClientConfig() @@ -362,7 +360,7 @@ func TestCreateMissingContext(t *testing.T) { const expectedErrorContains = "context was not found for specified context: not-present" config := createValidTestConfig() clientBuilder := NewNonInteractiveClientConfig(*config, "not-present", &ConfigOverrides{ - ClusterDefaults: DefaultCluster, + ClusterDefaults: clientcmdapi.Cluster{Server: "http://localhost:8080"}, }, nil) _, err := clientBuilder.ClientConfig() diff --git a/staging/src/k8s.io/client-go/1.5/tools/clientcmd/loader.go b/staging/src/k8s.io/client-go/1.5/tools/clientcmd/loader.go index 82e2422682eb..03020a51adcc 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/clientcmd/loader.go +++ b/staging/src/k8s.io/client-go/1.5/tools/clientcmd/loader.go @@ -23,6 +23,7 @@ import ( "os" "path" "path/filepath" + "reflect" goruntime "runtime" "strings" @@ -33,6 +34,7 @@ import ( "k8s.io/client-go/1.5/pkg/runtime" utilerrors "k8s.io/client-go/1.5/pkg/util/errors" "k8s.io/client-go/1.5/pkg/util/homedir" + "k8s.io/client-go/1.5/rest" clientcmdapi "k8s.io/client-go/1.5/tools/clientcmd/api" clientcmdlatest "k8s.io/client-go/1.5/tools/clientcmd/api/latest" ) @@ -65,6 +67,9 @@ func currentMigrationRules() map[string]string { type ClientConfigLoader interface { ConfigAccess + // IsDefaultConfig returns true if the returned config matches the defaults. + IsDefaultConfig(*rest.Config) bool + // Load returns the latest config Load() (*clientcmdapi.Config, error) } @@ -96,6 +101,9 @@ func (g *ClientConfigGetter) IsExplicitFile() bool { func (g *ClientConfigGetter) GetExplicitFile() string { return "" } +func (g *ClientConfigGetter) IsDefaultConfig(config *rest.Config) bool { + return false +} // ClientConfigLoadingRules is an ExplicitPath and string slice of specific locations that are used for merging together a Config // Callers can put the chain together however they want, but we'd recommend: @@ -112,6 +120,10 @@ type ClientConfigLoadingRules struct { // DoNotResolvePaths indicates whether or not to resolve paths with respect to the originating files. This is phrased as a negative so // that a default object that doesn't set this will usually get the behavior it wants. DoNotResolvePaths bool + + // DefaultClientConfig is an optional field indicating what rules to use to calculate a default configuration. + // This should match the overrides passed in to ClientConfig loader. + DefaultClientConfig ClientConfig } // ClientConfigLoadingRules implements the ClientConfigLoader interface. @@ -192,6 +204,7 @@ func (rules *ClientConfigLoadingRules) Load() (*clientcmdapi.Config, error) { // first merge all of our maps mapConfig := clientcmdapi.NewConfig() + for _, kubeconfig := range kubeconfigs { mergo.Merge(mapConfig, kubeconfig) } @@ -316,6 +329,18 @@ func (rules *ClientConfigLoadingRules) GetExplicitFile() string { return rules.ExplicitPath } +// IsDefaultConfig returns true if the provided configuration matches the default +func (rules *ClientConfigLoadingRules) IsDefaultConfig(config *rest.Config) bool { + if rules.DefaultClientConfig == nil { + return false + } + defaultConfig, err := rules.DefaultClientConfig.ClientConfig() + if err != nil { + return false + } + return reflect.DeepEqual(config, defaultConfig) +} + // LoadFromFile takes a filename and deserializes the contents into Config object func LoadFromFile(filename string) (*clientcmdapi.Config, error) { kubeconfigBytes, err := ioutil.ReadFile(filename) diff --git a/staging/src/k8s.io/client-go/1.5/tools/clientcmd/merged_client_builder.go b/staging/src/k8s.io/client-go/1.5/tools/clientcmd/merged_client_builder.go index 124d3d7c0410..950cb7cd7c97 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/clientcmd/merged_client_builder.go +++ b/staging/src/k8s.io/client-go/1.5/tools/clientcmd/merged_client_builder.go @@ -18,7 +18,6 @@ package clientcmd import ( "io" - "reflect" "sync" "github.com/golang/glog" @@ -105,20 +104,15 @@ func (config *DeferredLoadingClientConfig) ClientConfig() (*rest.Config, error) // content differs from the default config mergedConfig, err := mergedClientConfig.ClientConfig() switch { - case err != nil && !IsEmptyConfig(err): - // return on any error except empty config - return nil, err - case mergedConfig != nil: - // if the configuration has any settings at all, we cannot use ICC - // TODO: we need to discriminate better between "empty due to env" and - // "empty due to defaults" - // TODO: this shouldn't be a global - the client config rules should be - // handling this. - defaultConfig, defErr := DefaultClientConfig.ClientConfig() - if IsConfigurationInvalid(defErr) && !IsEmptyConfig(err) { - return mergedConfig, nil + case err != nil: + if !IsEmptyConfig(err) { + // return on any error except empty config + return nil, err } - if defErr == nil && !reflect.DeepEqual(mergedConfig, defaultConfig) { + case mergedConfig != nil: + // the configuration is valid, but if this is equal to the defaults we should try + // in-cluster configuration + if !config.loader.IsDefaultConfig(mergedConfig) { return mergedConfig, nil } } diff --git a/staging/src/k8s.io/client-go/1.5/tools/clientcmd/merged_client_builder_test.go b/staging/src/k8s.io/client-go/1.5/tools/clientcmd/merged_client_builder_test.go index b950e54e4a10..c17a7aeb9e8c 100644 --- a/staging/src/k8s.io/client-go/1.5/tools/clientcmd/merged_client_builder_test.go +++ b/staging/src/k8s.io/client-go/1.5/tools/clientcmd/merged_client_builder_test.go @@ -70,20 +70,27 @@ func (icc *testICC) Possible() bool { } func TestInClusterConfig(t *testing.T) { - // override direct client config for this run - originalDefault := DefaultClientConfig - defer func() { - DefaultClientConfig = originalDefault - }() - - baseDefault := &DirectClientConfig{ - overrides: &ConfigOverrides{}, - } default1 := &DirectClientConfig{ config: *createValidTestConfig(), contextName: "clean", overrides: &ConfigOverrides{}, } + invalidDefaultConfig := clientcmdapi.NewConfig() + invalidDefaultConfig.Clusters["clean"] = &clientcmdapi.Cluster{ + Server: "http://localhost:8080", + } + invalidDefaultConfig.Contexts["other"] = &clientcmdapi.Context{ + Cluster: "clean", + } + invalidDefaultConfig.CurrentContext = "clean" + + defaultInvalid := &DirectClientConfig{ + config: *invalidDefaultConfig, + overrides: &ConfigOverrides{}, + } + if _, err := defaultInvalid.ClientConfig(); err == nil || !IsConfigurationInvalid(err) { + t.Fatal(err) + } config1, err := default1.ClientConfig() if err != nil { t.Fatal(err) @@ -128,6 +135,16 @@ func TestInClusterConfig(t *testing.T) { err: nil, }, + "in-cluster not checked when default config is invalid": { + defaultConfig: defaultInvalid, + clientConfig: &testClientConfig{config: config1}, + icc: &testICC{}, + + checkedICC: false, + result: config1, + err: nil, + }, + "in-cluster not checked when config is not equal to default": { defaultConfig: default1, clientConfig: &testClientConfig{config: config2}, @@ -175,7 +192,7 @@ func TestInClusterConfig(t *testing.T) { err: nil, }, - "in-cluster not checked when default is invalid": { + "in-cluster not checked when standard default is invalid": { defaultConfig: &DefaultClientConfig, clientConfig: &testClientConfig{config: config2}, icc: &testICC{}, @@ -187,12 +204,8 @@ func TestInClusterConfig(t *testing.T) { } for name, test := range testCases { - if test.defaultConfig != nil { - DefaultClientConfig = *test.defaultConfig - } else { - DefaultClientConfig = *baseDefault - } c := &DeferredLoadingClientConfig{icc: test.icc} + c.loader = &ClientConfigLoadingRules{DefaultClientConfig: test.defaultConfig} c.clientConfig = test.clientConfig cfg, err := c.ClientConfig()