From f0a40d1b4bc4541154a1c4046b22f58f8d00c29d Mon Sep 17 00:00:00 2001 From: Navid Shaikh Date: Wed, 11 Dec 2019 13:51:48 +0530 Subject: [PATCH] Vendor eventing v0.11.0 and run tests against it (#546) - Pin contrib.go.opencensus.io/exporter/stackdriver@59d068f8d8ff5b653916aa30cdc4e13c7f15d56e - Pin knative.dev/pkg@release-0.11 - Move `Destination` from (knative.dev/pkg) v1alpha1 to duckv1beta1 - Run tests against Eventing v0.11.0 --- go.mod | 8 +- go.sum | 59 +- pkg/kn/commands/flags/sink.go | 6 +- .../commands/source/apiserver/create_test.go | 4 +- ...submit-integration-tests-latest-release.sh | 3 +- .../go/compute/metadata/metadata.go | 13 + .../go/internal/version/update_version.sh | 13 + .../go/internal/version/version.go | 2 +- .../monitoring/apiv3/alert_policy_client.go | 2 + .../go/monitoring/apiv3/doc.go | 2 +- .../go/monitoring/apiv3/group_client.go | 2 + .../go/monitoring/apiv3/metric_client.go | 2 + .../apiv3/notification_channel_client.go | 106 +- .../monitoring/apiv3/uptime_check_client.go | 2 + vendor/cloud.google.com/go/trace/apiv2/doc.go | 2 +- .../go/trace/apiv2/trace_client.go | 3 + .../exporter/stackdriver/.gitignore | 7 +- .../exporter/stackdriver/.travis.yml | 20 +- .../exporter/stackdriver/Gopkg.lock | 81 - .../exporter/stackdriver/Gopkg.toml | 62 - .../exporter/stackdriver/Makefile | 52 +- .../exporter/stackdriver/go.mod | 25 +- .../exporter/stackdriver/go.sum | 49 +- .../exporter/stackdriver/metrics.go | 110 +- .../exporter/stackdriver/metrics_batcher.go | 201 +++ .../exporter/stackdriver/metrics_proto.go | 439 ++--- .../stackdriver/metrics_test_utils.go | 62 - .../aws_identity_doc_utils.go | 8 +- .../monitoredresource/gcp_metadata_config.go | 2 +- .../exporter/stackdriver/resource.go | 55 +- .../exporter/stackdriver/stackdriver.go | 87 +- .../exporter/stackdriver/stats.go | 244 +-- .../exporter/stackdriver/trace.go | 2 +- .../aws-sdk-go/aws/client/default_retryer.go | 50 +- .../github.com/aws/aws-sdk-go/aws/config.go | 4 +- .../aws-sdk-go/aws/corehandlers/handlers.go | 60 +- .../aws/credentials/endpointcreds/provider.go | 4 +- .../stscreds/web_identity_provider.go | 7 +- .../aws/aws-sdk-go/aws/csm/metric_chan.go | 11 +- .../aws/aws-sdk-go/aws/ec2metadata/api.go | 29 +- .../aws/aws-sdk-go/aws/ec2metadata/service.go | 4 +- .../aws/aws-sdk-go/aws/endpoints/defaults.go | 763 +++++++- .../aws/aws-sdk-go/aws/request/request.go | 79 +- .../aws/aws-sdk-go/aws/request/retryer.go | 145 +- .../aws/aws-sdk-go/aws/session/env_config.go | 10 +- .../aws/aws-sdk-go/aws/session/session.go | 75 +- .../aws-sdk-go/aws/session/shared_config.go | 33 +- .../github.com/aws/aws-sdk-go/aws/version.go | 2 +- .../aws/aws-sdk-go/internal/sdkmath/floor.go | 15 + .../internal/sdkmath/floor_go1.9.go | 56 + .../private/protocol/rest/unmarshal.go | 24 +- .../aws-sdk-go/private/protocol/timestamp.go | 20 +- .../aws-sdk-go/service/sts/customizations.go | 11 + vendor/github.com/gobuffalo/envy/.env | 5 - vendor/github.com/gobuffalo/envy/.gitignore | 29 - .../gobuffalo/envy/.gometalinter.json | 3 - vendor/github.com/gobuffalo/envy/.travis.yml | 26 - vendor/github.com/gobuffalo/envy/LICENSE.txt | 8 - vendor/github.com/gobuffalo/envy/Makefile | 46 - vendor/github.com/gobuffalo/envy/README.md | 93 - vendor/github.com/gobuffalo/envy/envy.go | 238 --- vendor/github.com/gobuffalo/envy/go.mod | 8 - vendor/github.com/gobuffalo/envy/go.sum | 8 - vendor/github.com/gobuffalo/envy/shoulders.md | 10 - vendor/github.com/gobuffalo/envy/version.go | 3 - vendor/github.com/hashicorp/golang-lru/go.mod | 2 - vendor/github.com/hashicorp/golang-lru/lru.go | 26 +- .../hashicorp/golang-lru/simplelru/lru.go | 16 - .../golang-lru/simplelru/lru_interface.go | 7 +- vendor/github.com/joho/godotenv/.gitignore | 1 - vendor/github.com/joho/godotenv/.travis.yml | 8 - vendor/github.com/joho/godotenv/LICENCE | 23 - vendor/github.com/joho/godotenv/README.md | 163 -- vendor/github.com/joho/godotenv/godotenv.go | 346 ---- .../github.com/markbates/inflect/.gitignore | 29 - .../markbates/inflect/.gometalinter.json | 3 - vendor/github.com/markbates/inflect/.hgignore | 1 - .../github.com/markbates/inflect/.travis.yml | 26 - vendor/github.com/markbates/inflect/LICENCE | 7 - vendor/github.com/markbates/inflect/Makefile | 55 - vendor/github.com/markbates/inflect/README.md | 214 --- vendor/github.com/markbates/inflect/go.mod | 6 - vendor/github.com/markbates/inflect/go.sum | 10 - .../github.com/markbates/inflect/helpers.go | 19 - .../github.com/markbates/inflect/inflect.go | 892 ---------- .../markbates/inflect/inflections.json | 4 - vendor/github.com/markbates/inflect/name.go | 163 -- .../github.com/markbates/inflect/shoulders.md | 12 - .../github.com/markbates/inflect/version.go | 3 - vendor/go.opencensus.io/README.md | 2 +- vendor/go.opencensus.io/go.mod | 6 +- vendor/go.opencensus.io/go.sum | 10 +- vendor/go.opencensus.io/internal/internal.go | 2 +- vendor/go.opencensus.io/opencensus.go | 2 +- .../plugin/ocgrpc/client_stats_handler.go | 4 +- .../plugin/ocgrpc/stats_common.go | 8 +- .../go.opencensus.io/plugin/ochttp/server.go | 4 +- .../go.opencensus.io/plugin/ochttp/stats.go | 18 +- .../go.opencensus.io/plugin/ochttp/trace.go | 2 + .../resource/resourcekeys/const.go | 7 +- .../stats/view/aggregation.go | 2 +- vendor/go.opencensus.io/stats/view/doc.go | 2 +- vendor/go.opencensus.io/stats/view/view.go | 6 +- .../stats/view/view_to_metric.go | 11 +- vendor/go.opencensus.io/tag/key.go | 5 +- vendor/go.opencensus.io/tag/map_codec.go | 2 +- vendor/go.opencensus.io/trace/lrumap.go | 40 +- vendor/go.opencensus.io/trace/trace.go | 6 +- vendor/golang.org/x/net/http2/hpack/encode.go | 2 +- vendor/golang.org/x/net/http2/server.go | 6 +- vendor/golang.org/x/net/http2/transport.go | 26 +- .../x/net/http2/writesched_priority.go | 2 +- vendor/golang.org/x/sync/errgroup/errgroup.go | 66 - vendor/google.golang.org/api/AUTHORS | 1 + vendor/google.golang.org/api/CONTRIBUTORS | 1 + .../api/googleapi/transport/apikey.go | 2 +- .../google.golang.org/api/internal/creds.go | 16 +- vendor/google.golang.org/api/internal/pool.go | 16 +- .../api/internal/settings.go | 43 +- .../api/iterator/iterator.go | 36 +- .../api/option/credentials_go19.go | 16 +- .../api/option/credentials_notgo19.go | 16 +- vendor/google.golang.org/api/option/option.go | 29 +- .../api/support/bundler/bundler.go | 26 +- .../google.golang.org/api/transport/dial.go | 16 +- vendor/google.golang.org/api/transport/doc.go | 16 +- .../google.golang.org/api/transport/go19.go | 16 +- .../api/transport/grpc/dial.go | 23 +- .../api/transport/grpc/dial_appengine.go | 16 +- .../api/transport/grpc/dial_socketopt.go | 16 +- .../api/transport/http/dial.go | 32 +- .../api/transport/http/dial_appengine.go | 16 +- .../http/internal/propagation/http.go | 16 +- .../api/transport/not_go19.go | 16 +- .../api/admission/v1beta1/generated.pb.go | 1573 ----------------- .../api/admission/v1beta1/generated.proto | 160 -- vendor/k8s.io/api/admission/v1beta1/types.go | 162 -- .../v1beta1/types_swagger_doc_generated.go | 77 - .../v1beta1/zz_generated.deepcopy.go | 136 -- .../apis/duck/v1alpha1/channelable_types.go | 36 +- .../pkg/apis/duck/v1alpha1/delivery_types.go | 4 +- .../pkg/apis/duck/v1alpha1/resource_types.go | 1 - .../apis/duck/v1alpha1/subscribable_types.go | 25 +- .../duck/v1alpha1/zz_generated.deepcopy.go | 25 +- .../apis/eventing/v1alpha1/broker_types.go | 5 +- .../eventing/v1alpha1/broker_validation.go | 10 +- .../apis/eventing/v1alpha1/eventtype_types.go | 5 +- .../eventing/v1alpha1/eventtype_validation.go | 9 +- .../pkg/apis/eventing/v1alpha1/test_helper.go | 2 +- .../eventing/v1alpha1/trigger_lifecycle.go | 22 +- .../apis/eventing/v1alpha1/trigger_types.go | 10 +- .../eventing/v1alpha1/trigger_validation.go | 11 +- .../v1alpha1/zz_generated.deepcopy.go | 10 +- .../pkg/apis/flows/register.go} | 7 +- .../eventing/pkg/apis/flows/v1alpha1}/doc.go | 11 +- .../apis/flows/v1alpha1/parallel_defaults.go | 37 + .../apis/flows/v1alpha1/parallel_lifecycle.go | 247 +++ .../pkg/apis/flows/v1alpha1/parallel_types.go | 159 ++ .../flows/v1alpha1/parallel_validation.go | 68 + .../pkg/apis/flows/v1alpha1}/register.go | 30 +- .../apis/flows/v1alpha1/sequence_defaults.go | 37 + .../apis/flows/v1alpha1/sequence_lifecycle.go | 177 ++ .../pkg/apis/flows/v1alpha1/sequence_types.go | 135 ++ .../flows/v1alpha1/sequence_validation.go | 60 + .../pkg/apis/flows/v1alpha1/test_helpers.go | 37 + .../flows/v1alpha1/zz_generated.deepcopy.go | 391 ++++ .../apis/messaging/v1alpha1/channel_types.go | 4 +- .../messaging/v1alpha1/channel_validation.go | 11 +- .../v1alpha1/in_memory_channel_types.go | 4 +- .../v1alpha1/in_memory_channel_validation.go | 2 +- .../messaging/v1alpha1/parallel_lifecycle.go | 2 +- .../apis/messaging/v1alpha1/parallel_types.go | 17 +- .../messaging/v1alpha1/sequence_lifecycle.go | 7 +- .../apis/messaging/v1alpha1/sequence_types.go | 13 +- .../messaging/v1alpha1/subscription_types.go | 26 +- .../v1alpha1/subscription_validation.go | 27 +- .../v1alpha1/zz_generated.deepcopy.go | 35 +- .../sources/v1alpha1/apiserver_lifecycle.go | 16 +- .../apis/sources/v1alpha1/apiserver_types.go | 4 +- .../v1alpha1/containersource_lifecycle.go | 2 +- .../sources/v1alpha1/containersource_types.go | 4 +- .../sources/v1alpha1/cron_job_lifecycle.go | 2 +- .../apis/sources/v1alpha1/cron_job_types.go | 4 +- .../pkg/apis/sources/v1alpha1/register.go | 2 + .../sources/v1alpha1/sinkbinding_context.go | 43 + .../sources/v1alpha1/sinkbinding_defaults.go | 34 + .../sources/v1alpha1/sinkbinding_lifecycle.go | 120 ++ .../sources/v1alpha1/sinkbinding_types.go | 79 + .../v1alpha1/sinkbinding_validation.go | 41 + .../sources/v1alpha1/zz_generated.deepcopy.go | 104 +- .../clientset/versioned/scheme/register.go | 2 + .../sources/v1alpha1/fake/fake_sinkbinding.go | 140 ++ .../v1alpha1/fake/fake_sources_client.go | 4 + .../sources/v1alpha1/generated_expansion.go | 2 + .../typed/sources/v1alpha1/sinkbinding.go | 191 ++ .../typed/sources/v1alpha1/sources_client.go | 5 + .../eventing/pkg/logging/logging.go | 38 + .../knative.dev/pkg/apis/condition_types.go | 1 - vendor/knative.dev/pkg/apis/duck/README.md | 33 + vendor/knative.dev/pkg/apis/duck/const.go | 25 + vendor/knative.dev/pkg/apis/duck/interface.go | 41 + vendor/knative.dev/pkg/apis/duck/typed.go | 6 + .../knative.dev/pkg/apis/duck/unstructured.go | 33 +- .../pkg/apis/duck/v1/addressable_types.go | 5 +- .../pkg/apis/duck/v1/destination.go | 93 + .../pkg/apis/duck/v1/podspec_types.go | 93 + .../knative.dev/pkg/apis/duck/v1/register.go | 4 + .../pkg/apis/duck/v1/source_types.go | 7 +- .../pkg/apis/duck/v1/status_types.go | 4 +- .../pkg/apis/duck/v1/zz_generated.deepcopy.go | 122 ++ .../apis/duck/v1alpha1/addressable_types.go | 5 +- .../pkg/apis/duck/v1alpha1/binding_types.go | 92 + .../apis/duck/v1alpha1/conditions_types.go | 3 +- .../duck/v1alpha1/legacy_targetable_types.go | 5 +- .../duck/v1alpha1/retired_targetable_types.go | 5 +- .../duck/v1alpha1/zz_generated.deepcopy.go | 77 + .../apis/duck/v1beta1/addressable_types.go | 5 +- .../{v1alpha1 => duck/v1beta1}/destination.go | 2 +- .../pkg/apis/duck/v1beta1/source_types.go | 7 +- .../pkg/apis/duck/v1beta1/status_types.go | 4 +- .../duck/v1beta1/zz_generated.deepcopy.go | 27 + vendor/knative.dev/pkg/apis/duck/verify.go | 3 + vendor/knative.dev/pkg/apis/interfaces.go | 9 - vendor/knative.dev/pkg/apis/url.go | 17 + vendor/knative.dev/pkg/apis/volatile_time.go | 1 - .../knative.dev/pkg/controller/controller.go | 19 + .../pkg/controller/stats_reporter.go | 12 +- vendor/knative.dev/pkg/logging/config.go | 8 +- vendor/knative.dev/pkg/metrics/config.go | 111 +- .../pkg/metrics/config_observability.go | 103 ++ vendor/knative.dev/pkg/metrics/exporter.go | 15 +- .../metrics/monitored_resources_eventing.go | 60 +- .../metrics/monitored_resources_serving.go | 24 +- vendor/knative.dev/pkg/metrics/record.go | 38 +- .../pkg/metrics/stackdriver_exporter.go | 127 +- .../pkg/metrics/zz_generated.deepcopy.go | 37 + vendor/knative.dev/pkg/profiling/server.go | 6 +- vendor/knative.dev/pkg/tracker/doc.go | 23 + vendor/knative.dev/pkg/tracker/enqueue.go | 263 +++ vendor/knative.dev/pkg/tracker/interface.go | 170 ++ .../zz_generated.deepcopy.go | 24 +- vendor/knative.dev/pkg/webhook/OWNERS | 4 - vendor/knative.dev/pkg/webhook/certs.go | 165 -- .../webhook/config_validation_controller.go | 184 -- .../webhook/resource_admission_controller.go | 357 ---- .../knative.dev/pkg/webhook/stats_reporter.go | 143 -- vendor/knative.dev/pkg/webhook/user_info.go | 52 - vendor/knative.dev/pkg/webhook/webhook.go | 386 ---- vendor/modules.txt | 51 +- 249 files changed, 6266 insertions(+), 7785 deletions(-) delete mode 100644 vendor/contrib.go.opencensus.io/exporter/stackdriver/Gopkg.lock delete mode 100644 vendor/contrib.go.opencensus.io/exporter/stackdriver/Gopkg.toml create mode 100644 vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_batcher.go delete mode 100644 vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_test_utils.go create mode 100644 vendor/github.com/aws/aws-sdk-go/internal/sdkmath/floor.go create mode 100644 vendor/github.com/aws/aws-sdk-go/internal/sdkmath/floor_go1.9.go create mode 100644 vendor/github.com/aws/aws-sdk-go/service/sts/customizations.go delete mode 100644 vendor/github.com/gobuffalo/envy/.env delete mode 100644 vendor/github.com/gobuffalo/envy/.gitignore delete mode 100644 vendor/github.com/gobuffalo/envy/.gometalinter.json delete mode 100644 vendor/github.com/gobuffalo/envy/.travis.yml delete mode 100644 vendor/github.com/gobuffalo/envy/LICENSE.txt delete mode 100644 vendor/github.com/gobuffalo/envy/Makefile delete mode 100644 vendor/github.com/gobuffalo/envy/README.md delete mode 100644 vendor/github.com/gobuffalo/envy/envy.go delete mode 100644 vendor/github.com/gobuffalo/envy/go.mod delete mode 100644 vendor/github.com/gobuffalo/envy/go.sum delete mode 100644 vendor/github.com/gobuffalo/envy/shoulders.md delete mode 100644 vendor/github.com/gobuffalo/envy/version.go delete mode 100644 vendor/github.com/joho/godotenv/.gitignore delete mode 100644 vendor/github.com/joho/godotenv/.travis.yml delete mode 100644 vendor/github.com/joho/godotenv/LICENCE delete mode 100644 vendor/github.com/joho/godotenv/README.md delete mode 100644 vendor/github.com/joho/godotenv/godotenv.go delete mode 100644 vendor/github.com/markbates/inflect/.gitignore delete mode 100644 vendor/github.com/markbates/inflect/.gometalinter.json delete mode 100644 vendor/github.com/markbates/inflect/.hgignore delete mode 100644 vendor/github.com/markbates/inflect/.travis.yml delete mode 100644 vendor/github.com/markbates/inflect/LICENCE delete mode 100644 vendor/github.com/markbates/inflect/Makefile delete mode 100644 vendor/github.com/markbates/inflect/README.md delete mode 100644 vendor/github.com/markbates/inflect/go.mod delete mode 100644 vendor/github.com/markbates/inflect/go.sum delete mode 100644 vendor/github.com/markbates/inflect/helpers.go delete mode 100644 vendor/github.com/markbates/inflect/inflect.go delete mode 100644 vendor/github.com/markbates/inflect/inflections.json delete mode 100644 vendor/github.com/markbates/inflect/name.go delete mode 100644 vendor/github.com/markbates/inflect/shoulders.md delete mode 100644 vendor/github.com/markbates/inflect/version.go delete mode 100644 vendor/golang.org/x/sync/errgroup/errgroup.go delete mode 100644 vendor/k8s.io/api/admission/v1beta1/generated.pb.go delete mode 100644 vendor/k8s.io/api/admission/v1beta1/generated.proto delete mode 100644 vendor/k8s.io/api/admission/v1beta1/types.go delete mode 100644 vendor/k8s.io/api/admission/v1beta1/types_swagger_doc_generated.go delete mode 100644 vendor/k8s.io/api/admission/v1beta1/zz_generated.deepcopy.go rename vendor/knative.dev/{pkg/apis/v1alpha1/doc.go => eventing/pkg/apis/flows/register.go} (90%) rename vendor/{k8s.io/api/admission/v1beta1 => knative.dev/eventing/pkg/apis/flows/v1alpha1}/doc.go (75%) create mode 100644 vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_defaults.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_lifecycle.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_types.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_validation.go rename vendor/{k8s.io/api/admission/v1beta1 => knative.dev/eventing/pkg/apis/flows/v1alpha1}/register.go (65%) create mode 100644 vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_defaults.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_lifecycle.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_types.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_validation.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/test_helpers.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_context.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_defaults.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_lifecycle.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_types.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_validation.go create mode 100644 vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go create mode 100644 vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go create mode 100644 vendor/knative.dev/eventing/pkg/logging/logging.go create mode 100644 vendor/knative.dev/pkg/apis/duck/const.go create mode 100644 vendor/knative.dev/pkg/apis/duck/v1/destination.go create mode 100644 vendor/knative.dev/pkg/apis/duck/v1/podspec_types.go create mode 100644 vendor/knative.dev/pkg/apis/duck/v1alpha1/binding_types.go rename vendor/knative.dev/pkg/apis/{v1alpha1 => duck/v1beta1}/destination.go (99%) create mode 100644 vendor/knative.dev/pkg/metrics/config_observability.go create mode 100644 vendor/knative.dev/pkg/metrics/zz_generated.deepcopy.go create mode 100644 vendor/knative.dev/pkg/tracker/doc.go create mode 100644 vendor/knative.dev/pkg/tracker/enqueue.go create mode 100644 vendor/knative.dev/pkg/tracker/interface.go rename vendor/knative.dev/pkg/{apis/v1alpha1 => tracker}/zz_generated.deepcopy.go (69%) delete mode 100644 vendor/knative.dev/pkg/webhook/OWNERS delete mode 100644 vendor/knative.dev/pkg/webhook/certs.go delete mode 100644 vendor/knative.dev/pkg/webhook/config_validation_controller.go delete mode 100644 vendor/knative.dev/pkg/webhook/resource_admission_controller.go delete mode 100644 vendor/knative.dev/pkg/webhook/stats_reporter.go delete mode 100644 vendor/knative.dev/pkg/webhook/user_info.go delete mode 100644 vendor/knative.dev/pkg/webhook/webhook.go diff --git a/go.mod b/go.mod index 3c52395086..f01fd062da 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,9 @@ module knative.dev/client require ( contrib.go.opencensus.io/exporter/prometheus v0.1.0 // indirect - contrib.go.opencensus.io/exporter/stackdriver v0.12.5 // indirect; indirect needed by knative serving + contrib.go.opencensus.io/exporter/stackdriver v0.12.9-0.20191108183826-59d068f8d8ff // indirect github.com/google/go-containerregistry v0.0.0-20191029173801-50b26ee28691 // indirect github.com/magiconair/properties v1.8.0 - github.com/markbates/inflect v1.0.4 // indirect github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect github.com/mitchellh/go-homedir v1.1.0 github.com/pkg/errors v0.8.1 @@ -14,13 +13,14 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.4.0 golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 + google.golang.org/api v0.14.0 // indirect gotest.tools v2.2.0+incompatible k8s.io/api v0.0.0-20191016110246-af539daaa43a k8s.io/apimachinery v0.0.0-20191004115701-31ade1b30762 k8s.io/cli-runtime v0.0.0-20191016113937-7693ce2cae74 k8s.io/client-go v0.0.0-20191016110837-54936ba21026 - knative.dev/eventing v0.10.0 - knative.dev/pkg v0.0.0-20191107185656-884d50f09454 + knative.dev/eventing v0.11.0 + knative.dev/pkg v0.0.0-20191203221237-94a34e416c44 knative.dev/serving v0.11.0 knative.dev/test-infra v0.0.0-20191205012837-30f1a1f7b77e sigs.k8s.io/yaml v1.1.0 diff --git a/go.sum b/go.sum index 4568a69e7d..ff6dd4ed13 100644 --- a/go.sum +++ b/go.sum @@ -2,12 +2,16 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.43.0 h1:banaiRPAM8kUVYneOSkhgcDsLzEvL25FinuiSZaH/2w= -cloud.google.com/go v0.43.0/go.mod h1:BOSR3VbTLkk6FDC/TcffxP4NF/FFBGA5ku+jvKOP7pg= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1 h1:lRi0CHyU+ytlvylOlFKKq0af6JncuyoRh1J+QJBqQx0= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= contrib.go.opencensus.io/exporter/prometheus v0.1.0 h1:SByaIoWwNgMdPSgl5sMqM2KDE5H/ukPWBRo314xiDvg= contrib.go.opencensus.io/exporter/prometheus v0.1.0/go.mod h1:cGFniUXGZlKRjzOyuZJ6mgB+PgBcCIa79kEKR8YCW+A= -contrib.go.opencensus.io/exporter/stackdriver v0.12.5 h1:roYxbw//uT5VGVKwTutsI/RShEO11XY8nBOetZEzihI= -contrib.go.opencensus.io/exporter/stackdriver v0.12.5/go.mod h1:8x999/OcIPy5ivx/wDiV7Gx4D+VUPODf0mWRGRc5kSk= +contrib.go.opencensus.io/exporter/stackdriver v0.12.9-0.20191108183826-59d068f8d8ff h1:g4QkFNN0ak+sCs/jqbhYLNkQaF1NVaKVoQ4Xm1RV3wM= +contrib.go.opencensus.io/exporter/stackdriver v0.12.9-0.20191108183826-59d068f8d8ff/go.mod h1:XyyafDnFOsqoxHJgTFycKZMrRUrPThLh2iYTJF6uoO0= github.com/Azure/azure-sdk-for-go v19.1.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest v10.15.5+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= @@ -30,8 +34,8 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/aws/aws-sdk-go v1.15.90/go.mod h1:es1KtYUFs7le0xQ3rOihkuoVD90z7D0fR2Qm4S00/gU= -github.com/aws/aws-sdk-go v1.22.1 h1://WJvJi9iq/i5TWHuK3hIC23xCZYH7Qv7SIN2vZVqxY= -github.com/aws/aws-sdk-go v1.22.1/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.23.20 h1:2CBuL21P0yKdZN5urf2NxKa1ha8fhnY+A3pBCHFeZoA= +github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -104,8 +108,6 @@ github.com/go-openapi/swag v0.17.2/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/ github.com/go-openapi/swag v0.19.2 h1:jvO6bCMBEilGwMfHhrd61zIID4oIFdwb76V17SM88dE= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gobuffalo/envy v1.6.5 h1:X3is06x7v0nW2xiy2yFbbIjwHz57CD6z6MkvqULTCm8= -github.com/gobuffalo/envy v1.6.5/go.mod h1:N+GkhhZ/93bGZc6ZKhJLP6+m+tCNPKwgSpH9kaifseQ= github.com/gogo/protobuf v0.0.0-20171007142547-342cbe0a0415/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= @@ -117,6 +119,8 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef h1:veQD95Isof8w9/WXiA+pa3tz3fJXkt5B7QaRBrM62gk= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -170,8 +174,6 @@ github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCO github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk= -github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= @@ -184,8 +186,6 @@ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be h1:AHimNtVIpiBjPUhEF5KNCkrUyqTSA5zWUl8sQ2bfGBE= @@ -213,8 +213,6 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3 github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63 h1:nTT4s92Dgz2HlrB2NaMgvlfqHH39OgMhA7z3PK7PGD4= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/markbates/inflect v1.0.4 h1:5fh1gzTFhfae06u3hzHYO9xe3l3v3nW5Pwt3naLTP5g= -github.com/markbates/inflect v1.0.4/go.mod h1:1fR9+pO2KHEO9ZRtto13gDwwZaAKstQzferVeWqbgNs= github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a h1:+J2gw7Bw77w/fbK7wnNJJDKmw1IbWft2Ul5BzrG1Qm8= github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a/go.mod h1:M1qoD/MqPgTZIk0EWKB38wE28ACRfVcn+cU08jyArI0= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= @@ -322,9 +320,12 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.opencensus.io v0.21.0 h1:mU6zScU4U1YAFPHEHYk+3JC4SY7JxgkqS10ZOSyksNg= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.1 h1:8dP3SGL7MPB94crU3bEPplMPe83FI4EouesJUeFHv50= +go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= @@ -371,11 +372,12 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc h1:gkKoSkUmnU6bpS/VhkuO27bzQeSA51uaEfbOW5dNb68= golang.org/x/net v0.0.0-20190812203447-cdfb69ac37fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 h1:4dVFTC832rPn4pomLSz1vA+are2+dU19w1H8OngV7nc= +golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= @@ -389,6 +391,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -407,8 +411,7 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa h1:KIDDMLT1O0Nr7TSxp8xM5tJcdn8tgyAONntO829og1M= -golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190912141932-bc967efca4b8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY= golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -452,6 +455,11 @@ gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e/go.mod h1:kS+toOQn6AQKjmK google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0 h1:9sdfJOzWlkqPltHAuzT2Cp+yrBeY1KRVYgms8soxMwM= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.10.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.14.0 h1:uMf5uLi4eQMRrMKhCplNik4U4H8Z6C1br3zOtAa/aDE= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -459,20 +467,23 @@ google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.2 h1:j8RI1yW0SkI+paT6uGwMlrMI/6zwYA6/CFil8rxOzGI= +google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190716160619-c506a9f90610/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64 h1:iKtrH9Y8mcbADOP0YFaEMth7OfuHY9xHOwNj4znpM1A= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51 h1:Ex1mq5jaJof+kRnYi3SlYJ8KKa9Ao3NHyIT5XJ1gF6U= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.1 h1:/7cs52RnTJmD43s3uxzlq2U7nqVTd/37viQwMrMNlOM= -google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= @@ -528,10 +539,10 @@ k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKf k8s.io/kubernetes v1.11.10/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn3b/WPHqD5mBvP4= k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0= -knative.dev/eventing v0.10.0 h1:dDrOjBWWgloOCUjxR8ixUIh8nqCTbmM5BbGo8rvf1bc= -knative.dev/eventing v0.10.0/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58= -knative.dev/pkg v0.0.0-20191107185656-884d50f09454 h1:nkslWFyRWaJp3nPDm+GSQOSvN8NpZg8qIYTR+XssNNg= -knative.dev/pkg v0.0.0-20191107185656-884d50f09454/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q= +knative.dev/eventing v0.11.0 h1:g+vzgmRzYQIrADd8To3MskGdXxIhWXbUhadALPloU10= +knative.dev/eventing v0.11.0/go.mod h1:UxweNv8yXhsdHJitcb9R6rmfNaUD2DFi9GWwNRyIs58= +knative.dev/pkg v0.0.0-20191203221237-94a34e416c44 h1:WzTw8tbzXXHCFk5zOIoIp3H9JgCQb9qcNOfPgucEU4k= +knative.dev/pkg v0.0.0-20191203221237-94a34e416c44/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q= knative.dev/serving v0.11.0 h1:FK8aPpMuiBHZbfBfT+Avxyk11TaIlOMDEw/Va2sw1w0= knative.dev/serving v0.11.0/go.mod h1:x2n255JS2XBI39tmjZ8CwTxIf9EKNMCrkVuiOttLRm0= knative.dev/test-infra v0.0.0-20191205012837-30f1a1f7b77e h1:QTlOxV+M072CNdbKkqn6gmLWPETuLs+EiZ/pOv1jcrw= diff --git a/pkg/kn/commands/flags/sink.go b/pkg/kn/commands/flags/sink.go index f107b10dd5..734895d041 100644 --- a/pkg/kn/commands/flags/sink.go +++ b/pkg/kn/commands/flags/sink.go @@ -20,7 +20,7 @@ import ( "github.com/spf13/cobra" v1 "k8s.io/api/core/v1" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/client/pkg/serving/v1alpha1" ) @@ -33,7 +33,7 @@ func (i *SinkFlags) Add(cmd *cobra.Command) { cmd.Flags().StringVarP(&i.sink, "sink", "s", "", "Addressable sink for events") } -func (i *SinkFlags) ResolveSink(client v1alpha1.KnServingClient) (*apisv1alpha1.Destination, error) { +func (i *SinkFlags) ResolveSink(client v1alpha1.KnServingClient) (*duckv1beta1.Destination, error) { if i.sink == "" { return nil, nil } @@ -44,7 +44,7 @@ func (i *SinkFlags) ResolveSink(client v1alpha1.KnServingClient) (*apisv1alpha1. if err != nil { return nil, err } - return &apisv1alpha1.Destination{ + return &duckv1beta1.Destination{ Ref: &v1.ObjectReference{ Kind: service.Kind, APIVersion: service.APIVersion, diff --git a/pkg/kn/commands/source/apiserver/create_test.go b/pkg/kn/commands/source/apiserver/create_test.go index 9bc2ebf2d8..eabda0817f 100644 --- a/pkg/kn/commands/source/apiserver/create_test.go +++ b/pkg/kn/commands/source/apiserver/create_test.go @@ -27,7 +27,7 @@ import ( "knative.dev/client/pkg/kn/commands" "knative.dev/client/pkg/util" "knative.dev/eventing/pkg/apis/sources/v1alpha1" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) var ( @@ -87,7 +87,7 @@ func TestApiServerSourceCreate(t *testing.T) { }}, ServiceAccountName: "myaccountname", Mode: "Ref", - Sink: &apisv1alpha1.Destination{ + Sink: &duckv1beta1.Destination{ Ref: &v1.ObjectReference{ Kind: "Service", APIVersion: "serving.knative.dev/v1alpha1", diff --git a/test/presubmit-integration-tests-latest-release.sh b/test/presubmit-integration-tests-latest-release.sh index 3d05bda475..3bde02f28b 100755 --- a/test/presubmit-integration-tests-latest-release.sh +++ b/test/presubmit-integration-tests-latest-release.sh @@ -20,5 +20,6 @@ # latest release version. export KNATIVE_SERVING_VERSION="0.11.0" -export KNATIVE_EVENTING_VERSION="0.10.2" +export KNATIVE_EVENTING_VERSION="0.11.0" + $(dirname $0)/presubmit-tests.sh --integration-tests diff --git a/vendor/cloud.google.com/go/compute/metadata/metadata.go b/vendor/cloud.google.com/go/compute/metadata/metadata.go index 125b7033c9..4ff4e2f1ca 100644 --- a/vendor/cloud.google.com/go/compute/metadata/metadata.go +++ b/vendor/cloud.google.com/go/compute/metadata/metadata.go @@ -227,6 +227,9 @@ func InternalIP() (string, error) { return defaultClient.InternalIP() } // ExternalIP returns the instance's primary external (public) IP address. func ExternalIP() (string, error) { return defaultClient.ExternalIP() } +// Email calls Client.Email on the default client. +func Email(serviceAccount string) (string, error) { return defaultClient.Email(serviceAccount) } + // Hostname returns the instance's hostname. This will be of the form // ".c..internal". func Hostname() (string, error) { return defaultClient.Hostname() } @@ -367,6 +370,16 @@ func (c *Client) InternalIP() (string, error) { return c.getTrimmed("instance/network-interfaces/0/ip") } +// Email returns the email address associated with the service account. +// The account may be empty or the string "default" to use the instance's +// main account. +func (c *Client) Email(serviceAccount string) (string, error) { + if serviceAccount == "" { + serviceAccount = "default" + } + return c.getTrimmed("instance/service-accounts/" + serviceAccount + "/email") +} + // ExternalIP returns the instance's primary external (public) IP address. func (c *Client) ExternalIP() (string, error) { return c.getTrimmed("instance/network-interfaces/0/access-configs/0/external-ip") diff --git a/vendor/cloud.google.com/go/internal/version/update_version.sh b/vendor/cloud.google.com/go/internal/version/update_version.sh index fecf1f03fd..d7c5a3e219 100644 --- a/vendor/cloud.google.com/go/internal/version/update_version.sh +++ b/vendor/cloud.google.com/go/internal/version/update_version.sh @@ -1,4 +1,17 @@ #!/bin/bash +# Copyright 2019 Google LLC +# +# 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. today=$(date +%Y%m%d) diff --git a/vendor/cloud.google.com/go/internal/version/version.go b/vendor/cloud.google.com/go/internal/version/version.go index 4a2a8c19ff..d291921b18 100644 --- a/vendor/cloud.google.com/go/internal/version/version.go +++ b/vendor/cloud.google.com/go/internal/version/version.go @@ -26,7 +26,7 @@ import ( // Repo is the current version of the client libraries in this // repo. It should be a date in YYYYMMDD format. -const Repo = "20180226" +const Repo = "20190802" // Go returns the Go runtime version. The returned string // has no whitespace. diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/alert_policy_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/alert_policy_client.go index 5a43fe2b86..836b033321 100644 --- a/vendor/cloud.google.com/go/monitoring/apiv3/alert_policy_client.go +++ b/vendor/cloud.google.com/go/monitoring/apiv3/alert_policy_client.go @@ -47,6 +47,8 @@ func defaultAlertPolicyClientOptions() []option.ClientOption { return []option.ClientOption{ option.WithEndpoint("monitoring.googleapis.com:443"), option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), } } diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/doc.go b/vendor/cloud.google.com/go/monitoring/apiv3/doc.go index 378aa5ccb0..0c9464d712 100644 --- a/vendor/cloud.google.com/go/monitoring/apiv3/doc.go +++ b/vendor/cloud.google.com/go/monitoring/apiv3/doc.go @@ -102,4 +102,4 @@ func versionGo() string { return "UNKNOWN" } -const versionClient = "20190716" +const versionClient = "20190819" diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/group_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/group_client.go index c53719dae3..eecb511e63 100644 --- a/vendor/cloud.google.com/go/monitoring/apiv3/group_client.go +++ b/vendor/cloud.google.com/go/monitoring/apiv3/group_client.go @@ -49,6 +49,8 @@ func defaultGroupClientOptions() []option.ClientOption { return []option.ClientOption{ option.WithEndpoint("monitoring.googleapis.com:443"), option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), } } diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/metric_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/metric_client.go index e9c5cc5817..bce05a4cee 100644 --- a/vendor/cloud.google.com/go/monitoring/apiv3/metric_client.go +++ b/vendor/cloud.google.com/go/monitoring/apiv3/metric_client.go @@ -52,6 +52,8 @@ func defaultMetricClientOptions() []option.ClientOption { return []option.ClientOption{ option.WithEndpoint("monitoring.googleapis.com:443"), option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), } } diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/notification_channel_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/notification_channel_client.go index fa71dd10ab..f97444af2c 100644 --- a/vendor/cloud.google.com/go/monitoring/apiv3/notification_channel_client.go +++ b/vendor/cloud.google.com/go/monitoring/apiv3/notification_channel_client.go @@ -36,19 +36,24 @@ import ( // NotificationChannelCallOptions contains the retry settings for each method of NotificationChannelClient. type NotificationChannelCallOptions struct { - ListNotificationChannelDescriptors []gax.CallOption - GetNotificationChannelDescriptor []gax.CallOption - ListNotificationChannels []gax.CallOption - GetNotificationChannel []gax.CallOption - CreateNotificationChannel []gax.CallOption - UpdateNotificationChannel []gax.CallOption - DeleteNotificationChannel []gax.CallOption + ListNotificationChannelDescriptors []gax.CallOption + GetNotificationChannelDescriptor []gax.CallOption + ListNotificationChannels []gax.CallOption + GetNotificationChannel []gax.CallOption + CreateNotificationChannel []gax.CallOption + UpdateNotificationChannel []gax.CallOption + DeleteNotificationChannel []gax.CallOption + SendNotificationChannelVerificationCode []gax.CallOption + GetNotificationChannelVerificationCode []gax.CallOption + VerifyNotificationChannel []gax.CallOption } func defaultNotificationChannelClientOptions() []option.ClientOption { return []option.ClientOption{ option.WithEndpoint("monitoring.googleapis.com:443"), option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), } } @@ -68,13 +73,16 @@ func defaultNotificationChannelCallOptions() *NotificationChannelCallOptions { }, } return &NotificationChannelCallOptions{ - ListNotificationChannelDescriptors: retry[[2]string{"default", "idempotent"}], - GetNotificationChannelDescriptor: retry[[2]string{"default", "idempotent"}], - ListNotificationChannels: retry[[2]string{"default", "idempotent"}], - GetNotificationChannel: retry[[2]string{"default", "idempotent"}], - CreateNotificationChannel: retry[[2]string{"default", "non_idempotent"}], - UpdateNotificationChannel: retry[[2]string{"default", "non_idempotent"}], - DeleteNotificationChannel: retry[[2]string{"default", "idempotent"}], + ListNotificationChannelDescriptors: retry[[2]string{"default", "idempotent"}], + GetNotificationChannelDescriptor: retry[[2]string{"default", "idempotent"}], + ListNotificationChannels: retry[[2]string{"default", "idempotent"}], + GetNotificationChannel: retry[[2]string{"default", "idempotent"}], + CreateNotificationChannel: retry[[2]string{"default", "non_idempotent"}], + UpdateNotificationChannel: retry[[2]string{"default", "non_idempotent"}], + DeleteNotificationChannel: retry[[2]string{"default", "idempotent"}], + SendNotificationChannelVerificationCode: retry[[2]string{"default", "non_idempotent"}], + GetNotificationChannelVerificationCode: retry[[2]string{"default", "idempotent"}], + VerifyNotificationChannel: retry[[2]string{"default", "idempotent"}], } } @@ -301,6 +309,76 @@ func (c *NotificationChannelClient) DeleteNotificationChannel(ctx context.Contex return err } +// SendNotificationChannelVerificationCode causes a verification code to be delivered to the channel. The code +// can then be supplied in VerifyNotificationChannel to verify the channel. +func (c *NotificationChannelClient) SendNotificationChannelVerificationCode(ctx context.Context, req *monitoringpb.SendNotificationChannelVerificationCodeRequest, opts ...gax.CallOption) error { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.SendNotificationChannelVerificationCode[0:len(c.CallOptions.SendNotificationChannelVerificationCode):len(c.CallOptions.SendNotificationChannelVerificationCode)], opts...) + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + _, err = c.notificationChannelClient.SendNotificationChannelVerificationCode(ctx, req, settings.GRPC...) + return err + }, opts...) + return err +} + +// GetNotificationChannelVerificationCode requests a verification code for an already verified channel that can then +// be used in a call to VerifyNotificationChannel() on a different channel +// with an equivalent identity in the same or in a different project. This +// makes it possible to copy a channel between projects without requiring +// manual reverification of the channel. If the channel is not in the +// verified state, this method will fail (in other words, this may only be +// used if the SendNotificationChannelVerificationCode and +// VerifyNotificationChannel paths have already been used to put the given +// channel into the verified state). +// +// There is no guarantee that the verification codes returned by this method +// will be of a similar structure or form as the ones that are delivered +// to the channel via SendNotificationChannelVerificationCode; while +// VerifyNotificationChannel() will recognize both the codes delivered via +// SendNotificationChannelVerificationCode() and returned from +// GetNotificationChannelVerificationCode(), it is typically the case that +// the verification codes delivered via +// SendNotificationChannelVerificationCode() will be shorter and also +// have a shorter expiration (e.g. codes such as "G-123456") whereas +// GetVerificationCode() will typically return a much longer, websafe base +// 64 encoded string that has a longer expiration time. +func (c *NotificationChannelClient) GetNotificationChannelVerificationCode(ctx context.Context, req *monitoringpb.GetNotificationChannelVerificationCodeRequest, opts ...gax.CallOption) (*monitoringpb.GetNotificationChannelVerificationCodeResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetNotificationChannelVerificationCode[0:len(c.CallOptions.GetNotificationChannelVerificationCode):len(c.CallOptions.GetNotificationChannelVerificationCode)], opts...) + var resp *monitoringpb.GetNotificationChannelVerificationCodeResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.notificationChannelClient.GetNotificationChannelVerificationCode(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// VerifyNotificationChannel verifies a NotificationChannel by proving receipt of the code +// delivered to the channel as a result of calling +// SendNotificationChannelVerificationCode. +func (c *NotificationChannelClient) VerifyNotificationChannel(ctx context.Context, req *monitoringpb.VerifyNotificationChannelRequest, opts ...gax.CallOption) (*monitoringpb.NotificationChannel, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.VerifyNotificationChannel[0:len(c.CallOptions.VerifyNotificationChannel):len(c.CallOptions.VerifyNotificationChannel)], opts...) + var resp *monitoringpb.NotificationChannel + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.notificationChannelClient.VerifyNotificationChannel(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + // NotificationChannelDescriptorIterator manages a stream of *monitoringpb.NotificationChannelDescriptor. type NotificationChannelDescriptorIterator struct { items []*monitoringpb.NotificationChannelDescriptor diff --git a/vendor/cloud.google.com/go/monitoring/apiv3/uptime_check_client.go b/vendor/cloud.google.com/go/monitoring/apiv3/uptime_check_client.go index f0a0501b28..246262c7f7 100644 --- a/vendor/cloud.google.com/go/monitoring/apiv3/uptime_check_client.go +++ b/vendor/cloud.google.com/go/monitoring/apiv3/uptime_check_client.go @@ -48,6 +48,8 @@ func defaultUptimeCheckClientOptions() []option.ClientOption { return []option.ClientOption{ option.WithEndpoint("monitoring.googleapis.com:443"), option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), } } diff --git a/vendor/cloud.google.com/go/trace/apiv2/doc.go b/vendor/cloud.google.com/go/trace/apiv2/doc.go index b07eebf921..51d2778334 100644 --- a/vendor/cloud.google.com/go/trace/apiv2/doc.go +++ b/vendor/cloud.google.com/go/trace/apiv2/doc.go @@ -102,4 +102,4 @@ func versionGo() string { return "UNKNOWN" } -const versionClient = "20190716" +const versionClient = "20190819" diff --git a/vendor/cloud.google.com/go/trace/apiv2/trace_client.go b/vendor/cloud.google.com/go/trace/apiv2/trace_client.go index 1a51184fb2..f1cd452369 100644 --- a/vendor/cloud.google.com/go/trace/apiv2/trace_client.go +++ b/vendor/cloud.google.com/go/trace/apiv2/trace_client.go @@ -19,6 +19,7 @@ package trace import ( "context" "fmt" + "math" "net/url" "time" @@ -41,6 +42,8 @@ func defaultClientOptions() []option.ClientOption { return []option.ClientOption{ option.WithEndpoint("cloudtrace.googleapis.com:443"), option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), } } diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/.gitignore b/vendor/contrib.go.opencensus.io/exporter/stackdriver/.gitignore index c0ee15b59c..c5a54149f0 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/.gitignore +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/.gitignore @@ -1,5 +1,10 @@ -/vendor/ +# GoLand IDEA /.idea/ *.iml +# VS Code +.vscode +# Coverage +coverage.txt +coverage.html diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/.travis.yml b/vendor/contrib.go.opencensus.io/exporter/stackdriver/.travis.yml index babe4eefdc..7da9441128 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/.travis.yml +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - 1.11.x + - 1.12.x go_import_path: contrib.go.opencensus.io/exporter/stackdriver @@ -9,16 +9,12 @@ env: global: GO111MODULE=on -before_script: - - GO_FILES=$(find . -iname '*.go' | grep -v /vendor/) # All the .go files, excluding vendor/ if any - - PKGS=$(go list ./... | grep -v /vendor/) # All the import paths, excluding vendor/ if any +install: + - go mod download + - make install-tools script: - - go build ./... # Ensure dependency updates don't break build - - if [ -n "$(gofmt -s -l $GO_FILES)" ]; then echo "gofmt the following files:"; gofmt -s -l $GO_FILES; exit 1; fi - - go vet ./... - - go test -v -race $PKGS # Run all the tests with the race detector enabled - - GO111MODULE=off go get -t ./... - - GO111MODULE=off go build ./... - - GO111MODULE=off go test -v -race $PKGS # Make sure tests still pass when not using Go modules. - - 'if [[ $TRAVIS_GO_VERSION = 1.8* ]]; then ! golint ./... | grep -vE "(_mock|_string|\.pb)\.go:"; fi' + - make travis-ci + +after_success: + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/Gopkg.lock b/vendor/contrib.go.opencensus.io/exporter/stackdriver/Gopkg.lock deleted file mode 100644 index 3dddafb1af..0000000000 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/Gopkg.lock +++ /dev/null @@ -1,81 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "cloud.google.com/go" - packages = ["compute/metadata","internal/version","monitoring/apiv3","trace/apiv2"] - revision = "0fd7230b2a7505833d5f69b75cbd6c9582401479" - version = "v0.23.0" - -[[projects]] - name = "github.com/golang/protobuf" - packages = ["proto","protoc-gen-go/descriptor","ptypes","ptypes/any","ptypes/duration","ptypes/empty","ptypes/struct","ptypes/timestamp","ptypes/wrappers"] - revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265" - version = "v1.1.0" - -[[projects]] - name = "github.com/googleapis/gax-go" - packages = ["."] - revision = "317e0006254c44a0ac427cc52a0e083ff0b9622f" - version = "v2.0.0" - -[[projects]] - name = "go.opencensus.io" - packages = [".","exporter/stackdriver/propagation","exporterutil","internal","internal/tagencoding","plugin/ocgrpc","plugin/ochttp","plugin/ochttp/propagation/b3","stats","stats/internal","stats/view","tag","trace","trace/internal","trace/propagation"] - revision = "5897c5ce32247fc8af19c7710abd96e3304fb43c" - version = "v0.20.0" - -[[projects]] - branch = "master" - name = "golang.org/x/net" - packages = ["context","context/ctxhttp","http/httpguts","http2","http2/hpack","idna","internal/timeseries","trace"] - revision = "1e491301e022f8f977054da4c2d852decd59571f" - -[[projects]] - branch = "master" - name = "golang.org/x/oauth2" - packages = [".","google","internal","jws","jwt"] - revision = "1e0a3fa8ba9a5c9eb35c271780101fdaf1b205d7" - -[[projects]] - branch = "master" - name = "golang.org/x/sync" - packages = ["semaphore"] - revision = "1d60e4601c6fd243af51cc01ddf169918a5407ca" - -[[projects]] - name = "golang.org/x/text" - packages = ["collate","collate/build","internal/colltab","internal/gen","internal/tag","internal/triegen","internal/ucd","language","secure/bidirule","transform","unicode/bidi","unicode/cldr","unicode/norm","unicode/rangetable"] - revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" - version = "v0.3.0" - -[[projects]] - branch = "master" - name = "google.golang.org/api" - packages = ["googleapi/transport","internal","iterator","option","support/bundler","transport","transport/grpc","transport/http"] - revision = "8e296ef260056b6323d10727db40512dac6d92d5" - -[[projects]] - name = "google.golang.org/appengine" - packages = [".","internal","internal/app_identity","internal/base","internal/datastore","internal/log","internal/modules","internal/remote_api","internal/socket","internal/urlfetch","socket","urlfetch"] - revision = "150dc57a1b433e64154302bdc40b6bb8aefa313a" - version = "v1.0.0" - -[[projects]] - branch = "master" - name = "google.golang.org/genproto" - packages = ["googleapis/api/annotations","googleapis/api/distribution","googleapis/api/label","googleapis/api/metric","googleapis/api/monitoredres","googleapis/devtools/cloudtrace/v2","googleapis/monitoring/v3","googleapis/rpc/code","googleapis/rpc/status","protobuf/field_mask"] - revision = "81158efcc9f219c511e4d3c0d61a0e6e49c01a24" - -[[projects]] - name = "google.golang.org/grpc" - packages = [".","balancer","balancer/base","balancer/roundrobin","channelz","codes","connectivity","credentials","credentials/oauth","encoding","encoding/proto","grpclb/grpc_lb_v1/messages","grpclog","internal","keepalive","metadata","naming","peer","resolver","resolver/dns","resolver/passthrough","stats","status","tap","transport"] - revision = "41344da2231b913fa3d983840a57a6b1b7b631a1" - version = "v1.12.0" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "d587e278f7302f82cb7f5c14e5e7ce831c84f198c05ede6c16a8afa4d6112f9e" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/Gopkg.toml b/vendor/contrib.go.opencensus.io/exporter/stackdriver/Gopkg.toml deleted file mode 100644 index a84b934fcb..0000000000 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/Gopkg.toml +++ /dev/null @@ -1,62 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - - -[[constraint]] - name = "cloud.google.com/go" - version = ">=0.23.0" - -[[constraint]] - name = "github.com/golang/protobuf" - version = "1.1.0" - -[[constraint]] - name = "go.opencensus.io" - version = ">=0.20.0" - -[[constraint]] - branch = "master" - name = "golang.org/x/net" - -[[constraint]] - branch = "master" - name = "golang.org/x/oauth2" - -[[constraint]] - branch = "master" - name = "google.golang.org/api" - -[[constraint]] - branch = "master" - name = "google.golang.org/genproto" - -[[constraint]] - name = "google.golang.org/grpc" - version = "1.12.0" - -[prune] - go-tests = true - unused-packages = true diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/Makefile b/vendor/contrib.go.opencensus.io/exporter/stackdriver/Makefile index 2e11d225c2..cc0818596c 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/Makefile +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/Makefile @@ -1,7 +1,7 @@ # TODO: Fix this on windows. ALL_SRC := $(shell find . -name '*.go' \ - -not -path './vendor/*' \ - -not -path '*/gen-go/*' \ + -not -path '*/internal/testpb/*' \ + -not -name 'tools.go' \ -type f | sort) ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC)))) @@ -10,20 +10,21 @@ GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=a GOTEST=go test GOFMT=gofmt GOLINT=golint +GOIMPORTS=goimports GOVET=go vet EMBEDMD=embedmd +STATICCHECK=staticcheck # TODO decide if we need to change these names. README_FILES := $(shell find . -name '*README.md' | sort | tr '\n' ' ') +.DEFAULT_GOAL := defaul-goal -.DEFAULT_GOAL := fmt-lint-vet-embedmd-test +.PHONY: defaul-goal +defaul-goal: fmt lint vet embedmd goimports staticcheck test -.PHONY: fmt-lint-vet-embedmd-test -fmt-lint-vet-embedmd-test: fmt lint vet embedmd test - -# TODO enable test-with-coverage in tavis +# TODO: enable test-with-cover when find out why "scripts/check-test-files.sh: 4: set: Illegal option -o pipefail" .PHONY: travis-ci -travis-ci: fmt lint vet embedmd test test-386 +travis-ci: fmt lint vet embedmd goimports staticcheck test test-386 test-with-coverage all-pkgs: @echo $(ALL_PKGS) | tr ' ' '\n' | sort @@ -41,7 +42,19 @@ test-386: .PHONY: test-with-coverage test-with-coverage: + @echo pre-compiling tests + @time go test -i $(ALL_PKGS) + $(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) $(ALL_PKGS) + go tool cover -html=coverage.txt -o coverage.html + +.PHONY: test-with-cover +test-with-cover: + @echo Verifying that all packages have test files to count in coverage + @scripts/check-test-files.sh $(subst contrib.go.opencensus.io/exporter/stackdriver,./,$(ALL_PKGS)) + @echo pre-compiling tests + @time go test -i $(ALL_PKGS) $(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) $(ALL_PKGS) + go tool cover -html=coverage.txt -o coverage.html .PHONY: fmt fmt: @@ -88,8 +101,25 @@ embedmd: echo "Embedmd finished successfully"; \ fi +.PHONY: goimports +goimports: + @IMPORTSOUT=`$(GOIMPORTS) -d . 2>&1`; \ + if [ "$$IMPORTSOUT" ]; then \ + echo "$(GOIMPORTS) FAILED => fix the following goimports errors:\n"; \ + echo "$$IMPORTSOUT\n"; \ + exit 1; \ + else \ + echo "Goimports finished successfully"; \ + fi + +.PHONY: staticcheck +staticcheck: + $(STATICCHECK) ./... + .PHONY: install-tools install-tools: - go get -u golang.org/x/tools/cmd/cover - go get -u golang.org/x/lint/golint - go get -u github.com/rakyll/embedmd + GO111MODULE=on go install \ + golang.org/x/lint/golint \ + golang.org/x/tools/cmd/goimports \ + github.com/rakyll/embedmd \ + honnef.co/go/tools/cmd/staticcheck diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/go.mod b/vendor/contrib.go.opencensus.io/exporter/stackdriver/go.mod index df0956d8e2..12bcbace27 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/go.mod +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/go.mod @@ -1,19 +1,26 @@ module contrib.go.opencensus.io/exporter/stackdriver +go 1.12 + require ( - cloud.google.com/go v0.43.0 - github.com/aws/aws-sdk-go v1.22.1 + cloud.google.com/go v0.45.1 + github.com/aws/aws-sdk-go v1.23.20 github.com/census-instrumentation/opencensus-proto v0.2.1 github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.3.2 github.com/google/go-cmp v0.3.1 - github.com/hashicorp/golang-lru v0.5.3 // indirect + github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024 github.com/stretchr/testify v1.3.0 // indirect - go.opencensus.io v0.22.0 - golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 + go.opencensus.io v0.22.1 + golang.org/x/lint v0.0.0-20190409202823-959b441ac422 + golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 - golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa // indirect - google.golang.org/api v0.7.0 - google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64 - google.golang.org/grpc v1.22.1 + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect + golang.org/x/sys v0.0.0-20190912141932-bc967efca4b8 // indirect + golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0 + google.golang.org/api v0.10.0 + google.golang.org/appengine v1.6.2 // indirect + google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51 + google.golang.org/grpc v1.23.1 + honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc ) diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/go.sum b/vendor/contrib.go.opencensus.io/exporter/stackdriver/go.sum index d2cc0c7198..5c5a219b81 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/go.sum +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/go.sum @@ -3,14 +3,20 @@ cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.43.0 h1:banaiRPAM8kUVYneOSkhgcDsLzEvL25FinuiSZaH/2w= -cloud.google.com/go v0.43.0/go.mod h1:BOSR3VbTLkk6FDC/TcffxP4NF/FFBGA5ku+jvKOP7pg= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1 h1:lRi0CHyU+ytlvylOlFKKq0af6JncuyoRh1J+QJBqQx0= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/aws/aws-sdk-go v1.22.1 h1://WJvJi9iq/i5TWHuK3hIC23xCZYH7Qv7SIN2vZVqxY= -github.com/aws/aws-sdk-go v1.22.1/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.23.20 h1:2CBuL21P0yKdZN5urf2NxKa1ha8fhnY+A3pBCHFeZoA= +github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -18,6 +24,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -46,10 +54,9 @@ github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCO github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk= -github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024 h1:rBMNdlhTLzJjJSDIjNEXX1Pz3Hmwmz91v+zycvx9PJc= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -59,6 +66,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.1 h1:8dP3SGL7MPB94crU3bEPplMPe83FI4EouesJUeFHv50= +go.opencensus.io v0.22.1/go.mod h1:Ap50jQcDJrx6rB6VgeeFPtuPIf3wMRvRfrfYDO6+BmA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -68,6 +77,7 @@ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTk golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI= golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -82,8 +92,8 @@ golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 h1:4dVFTC832rPn4pomLSz1vA+are2+dU19w1H8OngV7nc= +golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -98,6 +108,8 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0 golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -107,8 +119,8 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa h1:KIDDMLT1O0Nr7TSxp8xM5tJcdn8tgyAONntO829og1M= -golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190912141932-bc967efca4b8 h1:41hwlulw1prEMBxLQSlMSux1zxJf07B3WPsdjJlKZxE= +golang.org/x/sys v0.0.0-20190912141932-bc967efca4b8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To= @@ -127,17 +139,24 @@ golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0 h1:Dh6fw+p6FyRl5x/FvNswO1ji0lIGzm3KP8Y9VkS9PTE= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= google.golang.org/api v0.4.0 h1:KKgc1aqhV8wDPbDzlDtpvyjZFY3vjz85FP7p4wcQUyI= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0 h1:9sdfJOzWlkqPltHAuzT2Cp+yrBeY1KRVYgms8soxMwM= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.10.0 h1:7tmAxx3oKE98VMZ+SBZzvYYWRQ9HODBxmC8mXUsraSQ= +google.golang.org/api v0.10.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.2 h1:j8RI1yW0SkI+paT6uGwMlrMI/6zwYA6/CFil8rxOzGI= +google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19 h1:Lj2SnHtxkRGJDqnGaSjo+CCdIieEnwVazbOXILwQemk= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -145,19 +164,21 @@ google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb h1:i1Ppqkc3WQXikh8bXiwHqAN5Rv3/qDCcRk0/Otx73BY= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190716160619-c506a9f90610 h1:Ygq9/SRJX9+dU0WCIICM8RkWvDw03lvB77hrhJnpxfU= -google.golang.org/genproto v0.0.0-20190716160619-c506a9f90610/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64 h1:iKtrH9Y8mcbADOP0YFaEMth7OfuHY9xHOwNj4znpM1A= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51 h1:Ex1mq5jaJof+kRnYi3SlYJ8KKa9Ao3NHyIT5XJ1gF6U= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.1 h1:/7cs52RnTJmD43s3uxzlq2U7nqVTd/37viQwMrMNlOM= -google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1 h1:q4XQuHFC6I28BKZpo6IYyb3mNO+l7lSOxRuYTCiDfXk= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics.go index 0e69eb81b7..a2df93f05a 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics.go +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics.go @@ -21,8 +21,9 @@ directly to Stackdriver Metrics. import ( "context" - "errors" "fmt" + "strings" + "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes/any" "github.com/golang/protobuf/ptypes/timestamp" @@ -34,15 +35,11 @@ import ( monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres" monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" + "contrib.go.opencensus.io/exporter/stackdriver/monitoredresource" "go.opencensus.io/metric/metricdata" "go.opencensus.io/resource" ) -var ( - errLableExtraction = errors.New("error extracting labels") - errUnspecifiedMetricKind = errors.New("metric kind is unpsecified") -) - const ( exemplarAttachmentTypeString = "type.googleapis.com/google.protobuf.StringValue" exemplarAttachmentTypeSpanCtx = "type.googleapis.com/google.monitoring.v3.SpanContext" @@ -73,9 +70,11 @@ func (se *statsExporter) handleMetricsUpload(metrics []*metricdata.Metric) { } func (se *statsExporter) uploadMetrics(metrics []*metricdata.Metric) error { - ctx, cancel := se.o.newContextWithTimeout() + ctx, cancel := newContextWithTimeout(se.o.Context, se.o.Timeout) defer cancel() + var errors []error + ctx, span := trace.StartSpan( ctx, "contrib.go.opencensus.io/exporter/stackdriver.uploadMetrics", @@ -87,7 +86,7 @@ func (se *statsExporter) uploadMetrics(metrics []*metricdata.Metric) error { // Now create the metric descriptor remotely. if err := se.createMetricDescriptorFromMetric(ctx, metric); err != nil { span.SetStatus(trace.Status{Code: trace.StatusCodeUnknown, Message: err.Error()}) - //TODO: [rghetia] record error metrics. + errors = append(errors, err) continue } } @@ -97,7 +96,7 @@ func (se *statsExporter) uploadMetrics(metrics []*metricdata.Metric) error { tsl, err := se.metricToMpbTs(ctx, metric) if err != nil { span.SetStatus(trace.Status{Code: trace.StatusCodeUnknown, Message: err.Error()}) - //TODO: [rghetia] record error metrics. + errors = append(errors, err) continue } if tsl != nil { @@ -116,26 +115,35 @@ func (se *statsExporter) uploadMetrics(metrics []*metricdata.Metric) error { for _, ctsreq := range ctsreql { if err := createTimeSeries(ctx, se.c, ctsreq); err != nil { span.SetStatus(trace.Status{Code: trace.StatusCodeUnknown, Message: err.Error()}) - // TODO(@rghetia): record error metrics - // return err + errors = append(errors, err) } } } - return nil + numErrors := len(errors) + if numErrors == 0 { + return nil + } else if numErrors == 1 { + return errors[0] + } + errMsgs := make([]string, 0, numErrors) + for _, err := range errors { + errMsgs = append(errMsgs, err.Error()) + } + return fmt.Errorf("[%s]", strings.Join(errMsgs, "; ")) } // metricToMpbTs converts a metric into a list of Stackdriver Monitoring v3 API TimeSeries // but it doesn't invoke any remote API. func (se *statsExporter) metricToMpbTs(ctx context.Context, metric *metricdata.Metric) ([]*monitoringpb.TimeSeries, error) { if metric == nil { - return nil, errNilMetric + return nil, errNilMetricOrMetricDescriptor } resource := se.metricRscToMpbRsc(metric.Resource) metricName := metric.Descriptor.Name - metricType, _ := se.metricTypeFromProto(metricName) + metricType := se.metricTypeFromProto(metricName) metricLabelKeys := metric.Descriptor.LabelKeys metricKind, _ := metricDescriptorTypeToMetricKind(metric) @@ -159,12 +167,26 @@ func (se *statsExporter) metricToMpbTs(ctx context.Context, metric *metricdata.M // TODO: (@rghetia) perhaps log this error from labels extraction, if non-nil. continue } + + var rsc *monitoredrespb.MonitoredResource + var mr monitoredresource.Interface + if se.o.ResourceByDescriptor != nil { + labels, mr = se.o.ResourceByDescriptor(&metric.Descriptor, labels) + // TODO(rghetia): optimize this. It is inefficient to convert this for all metrics. + rsc = convertMonitoredResourceToPB(mr) + if rsc.Type == "" { + rsc.Type = "global" + rsc.Labels = nil + } + } else { + rsc = resource + } timeSeries = append(timeSeries, &monitoringpb.TimeSeries{ Metric: &googlemetricpb.Metric{ Type: metricType, Labels: labels, }, - Resource: resource, + Resource: rsc, Points: sdPoints, }) } @@ -173,17 +195,21 @@ func (se *statsExporter) metricToMpbTs(ctx context.Context, metric *metricdata.M } func metricLabelsToTsLabels(defaults map[string]labelValue, labelKeys []metricdata.LabelKey, labelValues []metricdata.LabelValue) (map[string]string, error) { + // Perform this sanity check now. + if len(labelKeys) != len(labelValues) { + return nil, fmt.Errorf("length mismatch: len(labelKeys)=%d len(labelValues)=%d", len(labelKeys), len(labelValues)) + } + + if len(defaults)+len(labelKeys) == 0 { + return nil, nil + } + labels := make(map[string]string) // Fill in the defaults firstly, irrespective of if the labelKeys and labelValues are mismatched. for key, label := range defaults { labels[sanitize(key)] = label.val } - // Perform this sanity check now. - if len(labelKeys) != len(labelValues) { - return labels, fmt.Errorf("Length mismatch: len(labelKeys)=%d len(labelValues)=%d", len(labelKeys), len(labelValues)) - } - for i, labelKey := range labelKeys { labelValue := labelValues[i] labels[sanitize(labelKey.Key)] = labelValue.Value @@ -195,6 +221,11 @@ func metricLabelsToTsLabels(defaults map[string]labelValue, labelKeys []metricda // createMetricDescriptorFromMetric creates a metric descriptor from the OpenCensus metric // and then creates it remotely using Stackdriver's API. func (se *statsExporter) createMetricDescriptorFromMetric(ctx context.Context, metric *metricdata.Metric) error { + // Skip create metric descriptor if configured + if se.o.SkipCMD { + return nil + } + se.metricMu.Lock() defer se.metricMu.Unlock() @@ -203,6 +234,11 @@ func (se *statsExporter) createMetricDescriptorFromMetric(ctx context.Context, m return nil } + if builtinMetric(se.metricTypeFromProto(name)) { + se.metricDescriptors[name] = true + return nil + } + // Otherwise, we encountered a cache-miss and // should create the metric descriptor remotely. inMD, err := se.metricToMpbMetricDescriptor(metric) @@ -210,35 +246,21 @@ func (se *statsExporter) createMetricDescriptorFromMetric(ctx context.Context, m return err } - var md *googlemetricpb.MetricDescriptor - if builtinMetric(inMD.Type) { - gmrdesc := &monitoringpb.GetMetricDescriptorRequest{ - Name: inMD.Name, - } - md, err = getMetricDescriptor(ctx, se.c, gmrdesc) - } else { - - cmrdesc := &monitoringpb.CreateMetricDescriptorRequest{ - Name: fmt.Sprintf("projects/%s", se.o.ProjectID), - MetricDescriptor: inMD, - } - md, err = createMetricDescriptor(ctx, se.c, cmrdesc) - } - - if err == nil { - // Now record the metric as having been created. - se.metricDescriptors[name] = md + if err = se.createMetricDescriptor(ctx, inMD); err != nil { + return err } - return err + // Now record the metric as having been created. + se.metricDescriptors[name] = true + return nil } func (se *statsExporter) metricToMpbMetricDescriptor(metric *metricdata.Metric) (*googlemetricpb.MetricDescriptor, error) { if metric == nil { - return nil, errNilMetric + return nil, errNilMetricOrMetricDescriptor } - metricType, _ := se.metricTypeFromProto(metric.Descriptor.Name) + metricType := se.metricTypeFromProto(metric.Descriptor.Name) displayName := se.displayName(metric.Descriptor.Name) metricKind, valueType := metricDescriptorTypeToMetricKind(metric) @@ -466,11 +488,9 @@ func metricExemplarToPbExemplar(exemplar *metricdata.Exemplar, projectID string) func attachmentsToPbAttachments(attachments metricdata.Attachments, projectID string) []*any.Any { var pbAttachments []*any.Any for _, v := range attachments { - switch v.(type) { - case trace.SpanContext: - spanCtx, _ := v.(trace.SpanContext) + if spanCtx, succ := v.(trace.SpanContext); succ { pbAttachments = append(pbAttachments, toPbSpanCtxAttachment(spanCtx, projectID)) - default: + } else { // Treat everything else as plain string for now. // TODO(songy23): add support for dropped label attachments. pbAttachments = append(pbAttachments, toPbStringAttachment(v)) diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_batcher.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_batcher.go new file mode 100644 index 0000000000..ccd6ee4a6f --- /dev/null +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_batcher.go @@ -0,0 +1,201 @@ +// Copyright 2019, OpenCensus 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 stackdriver + +import ( + "context" + "fmt" + "strings" + "sync" + "time" + + monitoring "cloud.google.com/go/monitoring/apiv3" + monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" +) + +const ( + minNumWorkers = 1 + minReqsChanSize = 5 +) + +type metricsBatcher struct { + projectName string + allTss []*monitoringpb.TimeSeries + allErrs []error + + // Counts all dropped TimeSeries by this metricsBatcher. + droppedTimeSeries int + + workers []*worker + // reqsChan, respsChan and wg are shared between metricsBatcher and worker goroutines. + reqsChan chan *monitoringpb.CreateTimeSeriesRequest + respsChan chan *response + wg *sync.WaitGroup +} + +func newMetricsBatcher(ctx context.Context, projectID string, numWorkers int, mc *monitoring.MetricClient, timeout time.Duration) *metricsBatcher { + if numWorkers < minNumWorkers { + numWorkers = minNumWorkers + } + workers := make([]*worker, 0, numWorkers) + reqsChanSize := numWorkers + if reqsChanSize < minReqsChanSize { + reqsChanSize = minReqsChanSize + } + reqsChan := make(chan *monitoringpb.CreateTimeSeriesRequest, reqsChanSize) + respsChan := make(chan *response, numWorkers) + var wg sync.WaitGroup + wg.Add(numWorkers) + for i := 0; i < numWorkers; i++ { + w := newWorker(ctx, mc, reqsChan, respsChan, &wg, timeout) + workers = append(workers, w) + go w.start() + } + return &metricsBatcher{ + projectName: fmt.Sprintf("projects/%s", projectID), + allTss: make([]*monitoringpb.TimeSeries, 0, maxTimeSeriesPerUpload), + droppedTimeSeries: 0, + workers: workers, + wg: &wg, + reqsChan: reqsChan, + respsChan: respsChan, + } +} + +func (mb *metricsBatcher) recordDroppedTimeseries(numTimeSeries int, errs ...error) { + mb.droppedTimeSeries += numTimeSeries + for _, err := range errs { + if err != nil { + mb.allErrs = append(mb.allErrs, err) + } + } +} + +func (mb *metricsBatcher) addTimeSeries(ts *monitoringpb.TimeSeries) { + mb.allTss = append(mb.allTss, ts) + if len(mb.allTss) == maxTimeSeriesPerUpload { + mb.sendReqToChan() + mb.allTss = make([]*monitoringpb.TimeSeries, 0, maxTimeSeriesPerUpload) + } +} + +func (mb *metricsBatcher) close(ctx context.Context) error { + // Send any remaining time series, must be <200 + if len(mb.allTss) > 0 { + mb.sendReqToChan() + } + + close(mb.reqsChan) + mb.wg.Wait() + for i := 0; i < len(mb.workers); i++ { + resp := <-mb.respsChan + mb.recordDroppedTimeseries(resp.droppedTimeSeries, resp.errs...) + } + close(mb.respsChan) + + numErrors := len(mb.allErrs) + if numErrors == 0 { + return nil + } + + if numErrors == 1 { + return mb.allErrs[0] + } + + errMsgs := make([]string, 0, numErrors) + for _, err := range mb.allErrs { + errMsgs = append(errMsgs, err.Error()) + } + return fmt.Errorf("[%s]", strings.Join(errMsgs, "; ")) +} + +// sendReqToChan grabs all the timeseies in this metricsBatcher, puts them +// to a CreateTimeSeriesRequest and sends the request to reqsChan. +func (mb *metricsBatcher) sendReqToChan() { + req := &monitoringpb.CreateTimeSeriesRequest{ + Name: mb.projectName, + TimeSeries: mb.allTss, + } + mb.reqsChan <- req +} + +// sendReq sends create time series requests to Stackdriver, +// and returns the count of dropped time series and error. +func sendReq(ctx context.Context, c *monitoring.MetricClient, req *monitoringpb.CreateTimeSeriesRequest) (int, error) { + if c != nil { // c==nil only happens in unit tests where we don't make real calls to Stackdriver server + err := createTimeSeries(ctx, c, req) + if err != nil { + return len(req.TimeSeries), err + } + } + return 0, nil +} + +type worker struct { + ctx context.Context + timeout time.Duration + mc *monitoring.MetricClient + + resp *response + + respsChan chan *response + reqsChan chan *monitoringpb.CreateTimeSeriesRequest + + wg *sync.WaitGroup +} + +func newWorker( + ctx context.Context, + mc *monitoring.MetricClient, + reqsChan chan *monitoringpb.CreateTimeSeriesRequest, + respsChan chan *response, + wg *sync.WaitGroup, + timeout time.Duration) *worker { + return &worker{ + ctx: ctx, + mc: mc, + resp: &response{}, + reqsChan: reqsChan, + respsChan: respsChan, + wg: wg, + } +} + +func (w *worker) start() { + for req := range w.reqsChan { + w.sendReqWithTimeout(req) + } + w.respsChan <- w.resp + w.wg.Done() +} + +func (w *worker) sendReqWithTimeout(req *monitoringpb.CreateTimeSeriesRequest) { + ctx, cancel := newContextWithTimeout(w.ctx, w.timeout) + defer cancel() + + w.recordDroppedTimeseries(sendReq(ctx, w.mc, req)) +} + +func (w *worker) recordDroppedTimeseries(numTimeSeries int, err error) { + w.resp.droppedTimeSeries += numTimeSeries + if err != nil { + w.resp.errs = append(w.resp.errs, err) + } +} + +type response struct { + droppedTimeSeries int + errs []error +} diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_proto.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_proto.go index 139daad051..bcc1f0ee9f 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_proto.go +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_proto.go @@ -24,81 +24,74 @@ import ( "errors" "fmt" "path" - "sort" "strings" - "github.com/golang/protobuf/ptypes/timestamp" - "go.opencensus.io/stats" - "go.opencensus.io/trace" + "go.opencensus.io/resource" - "cloud.google.com/go/monitoring/apiv3" + commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1" + metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" + resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1" + timestamppb "github.com/golang/protobuf/ptypes/timestamp" distributionpb "google.golang.org/genproto/googleapis/api/distribution" labelpb "google.golang.org/genproto/googleapis/api/label" googlemetricpb "google.golang.org/genproto/googleapis/api/metric" + monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres" monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" - - commonpb "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1" - metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1" - resourcepb "github.com/census-instrumentation/opencensus-proto/gen-go/resource/v1" - "go.opencensus.io/resource" ) -var errNilMetric = errors.New("expecting a non-nil metric") -var errNilMetricDescriptor = errors.New("expecting a non-nil metric descriptor") +var errNilMetricOrMetricDescriptor = errors.New("non-nil metric or metric descriptor") var percentileLabelKey = &metricspb.LabelKey{ Key: "percentile", Description: "the value at a given percentile of a distribution", } +var globalResource = &resource.Resource{Type: "global"} +var domains = []string{"googleapis.com", "kubernetes.io", "istio.io", "knative.dev"} -type metricProtoPayload struct { - node *commonpb.Node - resource *resourcepb.Resource - metric *metricspb.Metric - additionalLabels map[string]labelValue -} - -func (se *statsExporter) addPayload(node *commonpb.Node, rsc *resourcepb.Resource, labels map[string]labelValue, metrics ...*metricspb.Metric) { - for _, metric := range metrics { - payload := &metricProtoPayload{ - metric: metric, - resource: rsc, - node: node, - additionalLabels: labels, - } - se.protoMetricsBundler.Add(payload, 1) - } -} - -// ExportMetricsProto exports OpenCensus Metrics Proto to Stackdriver Monitoring. -func (se *statsExporter) ExportMetricsProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metrics []*metricspb.Metric) error { +// PushMetricsProto exports OpenCensus Metrics Proto to Stackdriver Monitoring synchronously, +// without de-duping or adding proto metrics to the bundler. +func (se *statsExporter) PushMetricsProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metrics []*metricspb.Metric) (int, error) { if len(metrics) == 0 { - return errNilMetric + return 0, errNilMetricOrMetricDescriptor } - additionalLabels := se.defaultLabels - if additionalLabels == nil { - // additionalLabels must be stateless because each node is different - additionalLabels = getDefaultLabelsFromNode(node) - } + // Caches the resources seen so far + seenResources := make(map[*resourcepb.Resource]*monitoredrespb.MonitoredResource) + mb := newMetricsBatcher(ctx, se.o.ProjectID, se.o.NumberOfWorkers, se.c, se.o.Timeout) for _, metric := range metrics { + if len(metric.GetTimeseries()) == 0 { + // No TimeSeries to export, skip this metric. + continue + } + mappedRsc := se.getResource(rsc, metric, seenResources) if metric.GetMetricDescriptor().GetType() == metricspb.MetricDescriptor_SUMMARY { - se.addPayload(node, rsc, additionalLabels, se.convertSummaryMetrics(metric)...) + summaryMtcs := se.convertSummaryMetrics(metric) + for _, summaryMtc := range summaryMtcs { + if err := se.createMetricDescriptorFromMetricProto(ctx, summaryMtc); err != nil { + mb.recordDroppedTimeseries(len(summaryMtc.GetTimeseries()), err) + continue + } + se.protoMetricToTimeSeries(ctx, mappedRsc, summaryMtc, mb) + } } else { - se.addPayload(node, rsc, additionalLabels, metric) + if err := se.createMetricDescriptorFromMetricProto(ctx, metric); err != nil { + mb.recordDroppedTimeseries(len(metric.GetTimeseries()), err) + continue + } + se.protoMetricToTimeSeries(ctx, mappedRsc, metric, mb) } } - return nil + return mb.droppedTimeSeries, mb.close(ctx) } func (se *statsExporter) convertSummaryMetrics(summary *metricspb.Metric) []*metricspb.Metric { var metrics []*metricspb.Metric - var percentileTss []*metricspb.TimeSeries - var countTss []*metricspb.TimeSeries - var sumTss []*metricspb.TimeSeries for _, ts := range summary.Timeseries { + var percentileTss []*metricspb.TimeSeries + var countTss []*metricspb.TimeSeries + var sumTss []*metricspb.TimeSeries lvs := ts.GetLabelValues() startTime := ts.StartTimestamp @@ -141,7 +134,8 @@ func (se *statsExporter) convertSummaryMetrics(summary *metricspb.Metric) []*met for _, percentileValue := range snapshot.GetPercentileValues() { lvsWithPercentile := lvs[0:] lvsWithPercentile = append(lvsWithPercentile, &metricspb.LabelValue{ - Value: fmt.Sprintf("%f", percentileValue.Percentile), + HasValue: true, + Value: fmt.Sprintf("%f", percentileValue.Percentile), }) percentileTs := &metricspb.TimeSeries{ LabelValues: lvsWithPercentile, @@ -207,142 +201,22 @@ func (se *statsExporter) convertSummaryMetrics(summary *metricspb.Metric) []*met return metrics } -func (se *statsExporter) handleMetricsProtoUpload(payloads []*metricProtoPayload) { - err := se.uploadMetricsProto(payloads) - if err != nil { - se.o.handleError(err) - } -} - -func (se *statsExporter) uploadMetricsProto(payloads []*metricProtoPayload) error { - ctx, cancel := se.o.newContextWithTimeout() - defer cancel() - - ctx, span := trace.StartSpan( - ctx, - "contrib.go.opencensus.io/exporter/stackdriver.uploadMetrics", - trace.WithSampler(trace.NeverSample()), - ) - defer span.End() - - for _, payload := range payloads { - // Now create the metric descriptor remotely. - if err := se.createMetricDescriptor(ctx, payload.metric, payload.additionalLabels); err != nil { - span.SetStatus(trace.Status{Code: 2, Message: err.Error()}) - return err - } - } - - var allTimeSeries []*monitoringpb.TimeSeries - for _, payload := range payloads { - tsl, err := se.protoMetricToTimeSeries(ctx, payload.node, payload.resource, payload.metric, payload.additionalLabels) - if err != nil { - span.SetStatus(trace.Status{Code: 2, Message: err.Error()}) - return err - } - allTimeSeries = append(allTimeSeries, tsl...) - } - - // Now batch timeseries up and then export. - for start, end := 0, 0; start < len(allTimeSeries); start = end { - end = start + maxTimeSeriesPerUpload - if end > len(allTimeSeries) { - end = len(allTimeSeries) - } - batch := allTimeSeries[start:end] - ctsreql := se.combineTimeSeriesToCreateTimeSeriesRequest(batch) - for _, ctsreq := range ctsreql { - if err := createTimeSeries(ctx, se.c, ctsreq); err != nil { - span.SetStatus(trace.Status{Code: trace.StatusCodeUnknown, Message: err.Error()}) - // TODO(@odeke-em): Don't fail fast here, perhaps batch errors? - // return err - } - } - } - - return nil -} - -// metricSignature creates a unique signature consisting of a -// metric's type and its lexicographically sorted label values -// See https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/issues/120 -func metricSignature(metric *googlemetricpb.Metric) string { - labels := metric.GetLabels() - labelValues := make([]string, 0, len(labels)) - - for _, labelValue := range labels { - labelValues = append(labelValues, labelValue) - } - sort.Strings(labelValues) - return fmt.Sprintf("%s:%s", metric.GetType(), strings.Join(labelValues, ",")) -} - -func (se *statsExporter) combineTimeSeriesToCreateTimeSeriesRequest(ts []*monitoringpb.TimeSeries) (ctsreql []*monitoringpb.CreateTimeSeriesRequest) { - if len(ts) == 0 { - return nil +func (se *statsExporter) getResource(rsc *resourcepb.Resource, metric *metricspb.Metric, seenRscs map[*resourcepb.Resource]*monitoredrespb.MonitoredResource) *monitoredrespb.MonitoredResource { + var resource = rsc + if metric.Resource != nil { + resource = metric.Resource } - - // Since there are scenarios in which Metrics with the same Type - // can be bunched in the same TimeSeries, we have to ensure that - // we create a unique CreateTimeSeriesRequest with entirely unique Metrics - // per TimeSeries, lest we'll encounter: - // - // err: rpc error: code = InvalidArgument desc = One or more TimeSeries could not be written: - // Field timeSeries[2] had an invalid value: Duplicate TimeSeries encountered. - // Only one point can be written per TimeSeries per request.: timeSeries[2] - // - // This scenario happens when we are using the OpenCensus Agent in which multiple metrics - // are streamed by various client applications. - // See https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/issues/73 - uniqueTimeSeries := make([]*monitoringpb.TimeSeries, 0, len(ts)) - nonUniqueTimeSeries := make([]*monitoringpb.TimeSeries, 0, len(ts)) - seenMetrics := make(map[string]struct{}) - - for _, tti := range ts { - key := metricSignature(tti.Metric) - if _, alreadySeen := seenMetrics[key]; !alreadySeen { - uniqueTimeSeries = append(uniqueTimeSeries, tti) - seenMetrics[key] = struct{}{} - } else { - nonUniqueTimeSeries = append(nonUniqueTimeSeries, tti) - } + mappedRsc, ok := seenRscs[resource] + if !ok { + mappedRsc = se.o.MapResource(resourcepbToResource(resource)) + seenRscs[resource] = mappedRsc } - - // UniqueTimeSeries can be bunched up together - // While for each nonUniqueTimeSeries, we have - // to make a unique CreateTimeSeriesRequest. - ctsreql = append(ctsreql, &monitoringpb.CreateTimeSeriesRequest{ - Name: monitoring.MetricProjectPath(se.o.ProjectID), - TimeSeries: uniqueTimeSeries, - }) - - // Now recursively also combine the non-unique TimeSeries - // that were singly added to nonUniqueTimeSeries. - // The reason is that we need optimal combinations - // for optimal combinations because: - // * "a/b/c" - // * "a/b/c" - // * "x/y/z" - // * "a/b/c" - // * "x/y/z" - // * "p/y/z" - // * "d/y/z" - // - // should produce: - // CreateTimeSeries(uniqueTimeSeries) :: ["a/b/c", "x/y/z", "p/y/z", "d/y/z"] - // CreateTimeSeries(nonUniqueTimeSeries) :: ["a/b/c"] - // CreateTimeSeries(nonUniqueTimeSeries) :: ["a/b/c", "x/y/z"] - nonUniqueRequests := se.combineTimeSeriesToCreateTimeSeriesRequest(nonUniqueTimeSeries) - ctsreql = append(ctsreql, nonUniqueRequests...) - - return ctsreql + return mappedRsc } func resourcepbToResource(rsc *resourcepb.Resource) *resource.Resource { if rsc == nil { - return &resource.Resource{ - Type: "global", - } + return globalResource } res := &resource.Resource{ Type: rsc.Type, @@ -357,92 +231,87 @@ func resourcepbToResource(rsc *resourcepb.Resource) *resource.Resource { // protoMetricToTimeSeries converts a metric into a Stackdriver Monitoring v3 API CreateTimeSeriesRequest // but it doesn't invoke any remote API. -func (se *statsExporter) protoMetricToTimeSeries(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metric *metricspb.Metric, additionalLabels map[string]labelValue) ([]*monitoringpb.TimeSeries, error) { - if metric == nil { - return nil, errNilMetric +func (se *statsExporter) protoMetricToTimeSeries(ctx context.Context, mappedRsc *monitoredrespb.MonitoredResource, metric *metricspb.Metric, mb *metricsBatcher) { + if metric == nil || metric.MetricDescriptor == nil { + mb.recordDroppedTimeseries(len(metric.GetTimeseries()), errNilMetricOrMetricDescriptor) } - var resource = rsc - if metric.Resource != nil { - resource = metric.Resource - } - - mappedRes := se.o.MapResource(resourcepbToResource(resource)) - - metricName, _, _, err := metricProseFromProto(metric) - if err != nil { - return nil, err - } - metricType, _ := se.metricTypeFromProto(metricName) + metricType := se.metricTypeFromProto(metric.GetMetricDescriptor().GetName()) metricLabelKeys := metric.GetMetricDescriptor().GetLabelKeys() - metricKind, _ := protoMetricDescriptorTypeToMetricKind(metric) + metricKind, valueType := protoMetricDescriptorTypeToMetricKind(metric) + labelKeys := make([]string, 0, len(metricLabelKeys)) + for _, key := range metricLabelKeys { + labelKeys = append(labelKeys, sanitize(key.GetKey())) + } - timeSeries := make([]*monitoringpb.TimeSeries, 0, len(metric.Timeseries)) for _, protoTimeSeries := range metric.Timeseries { + if len(protoTimeSeries.Points) == 0 { + // No points to send just move forward. + continue + } + sdPoints, err := se.protoTimeSeriesToMonitoringPoints(protoTimeSeries, metricKind) if err != nil { - return nil, err + mb.recordDroppedTimeseries(1, err) + continue } // Each TimeSeries has labelValues which MUST be correlated // with that from the MetricDescriptor - labels, err := labelsPerTimeSeries(additionalLabels, metricLabelKeys, protoTimeSeries.GetLabelValues()) + labels, err := labelsPerTimeSeries(se.defaultLabels, labelKeys, protoTimeSeries.GetLabelValues()) if err != nil { - // TODO: (@odeke-em) perhaps log this error from labels extraction, if non-nil. + mb.recordDroppedTimeseries(1, err) continue } - timeSeries = append(timeSeries, &monitoringpb.TimeSeries{ + mb.addTimeSeries(&monitoringpb.TimeSeries{ Metric: &googlemetricpb.Metric{ Type: metricType, Labels: labels, }, - Resource: mappedRes, - Points: sdPoints, + MetricKind: metricKind, + ValueType: valueType, + Resource: mappedRsc, + Points: sdPoints, }) } - - return timeSeries, nil } -func labelsPerTimeSeries(defaults map[string]labelValue, labelKeys []*metricspb.LabelKey, labelValues []*metricspb.LabelValue) (map[string]string, error) { +func labelsPerTimeSeries(defaults map[string]labelValue, labelKeys []string, labelValues []*metricspb.LabelValue) (map[string]string, error) { + if len(labelKeys) != len(labelValues) { + return nil, fmt.Errorf("length mismatch: len(labelKeys)=%d len(labelValues)=%d", len(labelKeys), len(labelValues)) + } + + if len(defaults)+len(labelKeys) == 0 { + // No labels for this metric + return nil, nil + } + labels := make(map[string]string) // Fill in the defaults firstly, irrespective of if the labelKeys and labelValues are mismatched. for key, label := range defaults { - labels[sanitize(key)] = label.val - } - - // Perform this sanity check now. - if len(labelKeys) != len(labelValues) { - return labels, fmt.Errorf("Length mismatch: len(labelKeys)=%d len(labelValues)=%d", len(labelKeys), len(labelValues)) + labels[key] = label.val } for i, labelKey := range labelKeys { labelValue := labelValues[i] - labels[sanitize(labelKey.GetKey())] = labelValue.GetValue() + if !labelValue.GetHasValue() { + continue + } + labels[labelKey] = labelValue.GetValue() } return labels, nil } -func (se *statsExporter) protoMetricDescriptorToCreateMetricDescriptorRequest(ctx context.Context, metric *metricspb.Metric, additionalLabels map[string]labelValue) (*monitoringpb.CreateMetricDescriptorRequest, error) { - // Otherwise, we encountered a cache-miss and - // should create the metric descriptor remotely. - inMD, err := se.protoToMonitoringMetricDescriptor(metric, additionalLabels) - if err != nil { - return nil, err - } - - cmrdesc := &monitoringpb.CreateMetricDescriptorRequest{ - Name: fmt.Sprintf("projects/%s", se.o.ProjectID), - MetricDescriptor: inMD, +func (se *statsExporter) createMetricDescriptorFromMetricProto(ctx context.Context, metric *metricspb.Metric) error { + // Skip create metric descriptor if configured + if se.o.SkipCMD { + return nil } - return cmrdesc, nil -} + ctx, cancel := newContextWithTimeout(ctx, se.o.Timeout) + defer cancel() -// createMetricDescriptor creates a metric descriptor from the OpenCensus proto metric -// and then creates it remotely using Stackdriver's API. -func (se *statsExporter) createMetricDescriptor(ctx context.Context, metric *metricspb.Metric, additionalLabels map[string]labelValue) error { se.protoMu.Lock() defer se.protoMu.Unlock() @@ -451,46 +320,35 @@ func (se *statsExporter) createMetricDescriptor(ctx context.Context, metric *met return nil } + if builtinMetric(se.metricTypeFromProto(name)) { + se.protoMetricDescriptors[name] = true + return nil + } + // Otherwise, we encountered a cache-miss and // should create the metric descriptor remotely. - inMD, err := se.protoToMonitoringMetricDescriptor(metric, additionalLabels) + inMD, err := se.protoToMonitoringMetricDescriptor(metric, se.defaultLabels) if err != nil { return err } - var md *googlemetricpb.MetricDescriptor - if builtinMetric(inMD.Type) { - gmrdesc := &monitoringpb.GetMetricDescriptorRequest{ - Name: inMD.Name, - } - md, err = getMetricDescriptor(ctx, se.c, gmrdesc) - } else { - - cmrdesc := &monitoringpb.CreateMetricDescriptorRequest{ - Name: fmt.Sprintf("projects/%s", se.o.ProjectID), - MetricDescriptor: inMD, - } - md, err = createMetricDescriptor(ctx, se.c, cmrdesc) - } - - if err == nil { - // Now record the metric as having been created. - se.protoMetricDescriptors[name] = md + if err = se.createMetricDescriptor(ctx, inMD); err != nil { + return err } - return err + se.protoMetricDescriptors[name] = true + return nil } -func (se *statsExporter) protoTimeSeriesToMonitoringPoints(ts *metricspb.TimeSeries, metricKind googlemetricpb.MetricDescriptor_MetricKind) (sptl []*monitoringpb.Point, err error) { +func (se *statsExporter) protoTimeSeriesToMonitoringPoints(ts *metricspb.TimeSeries, metricKind googlemetricpb.MetricDescriptor_MetricKind) ([]*monitoringpb.Point, error) { + sptl := make([]*monitoringpb.Point, 0, len(ts.Points)) for _, pt := range ts.Points { - // If we have a last value aggregation point i.e. MetricDescriptor_GAUGE // StartTime should be nil. startTime := ts.StartTimestamp if metricKind == googlemetricpb.MetricDescriptor_GAUGE { startTime = nil } - spt, err := fromProtoPoint(startTime, pt) if err != nil { return nil, err @@ -501,15 +359,15 @@ func (se *statsExporter) protoTimeSeriesToMonitoringPoints(ts *metricspb.TimeSer } func (se *statsExporter) protoToMonitoringMetricDescriptor(metric *metricspb.Metric, additionalLabels map[string]labelValue) (*googlemetricpb.MetricDescriptor, error) { - if metric == nil { - return nil, errNilMetric + if metric == nil || metric.MetricDescriptor == nil { + return nil, errNilMetricOrMetricDescriptor } - metricName, description, unit, err := metricProseFromProto(metric) - if err != nil { - return nil, err - } - metricType, _ := se.metricTypeFromProto(metricName) + md := metric.GetMetricDescriptor() + metricName := md.GetName() + unit := md.GetUnit() + description := md.GetDescription() + metricType := se.metricTypeFromProto(metricName) displayName := se.displayName(metricName) metricKind, valueType := protoMetricDescriptorTypeToMetricKind(metric) @@ -550,32 +408,32 @@ func labelDescriptorsFromProto(defaults map[string]labelValue, protoLabelKeys [] return labelDescriptors } -func metricProseFromProto(metric *metricspb.Metric) (name, description, unit string, err error) { - md := metric.GetMetricDescriptor() - if md == nil { - return "", "", "", errNilMetricDescriptor +func (se *statsExporter) metricTypeFromProto(name string) string { + prefix := se.o.MetricPrefix + if se.o.GetMetricPrefix != nil { + prefix = se.o.GetMetricPrefix(name) } - - name = md.GetName() - unit = md.GetUnit() - description = md.GetDescription() - - if md.Type == metricspb.MetricDescriptor_CUMULATIVE_INT64 { - // If the aggregation type is count, which counts the number of recorded measurements, the unit must be "1", - // because this view does not apply to the recorded values. - unit = stats.UnitDimensionless + if prefix != "" { + name = path.Join(prefix, name) } - - return name, description, unit, nil + if !hasDomain(name) { + // Still needed because the name may or may not have a "/" at the beginning. + name = path.Join(defaultDomain, name) + } + return name } -func (se *statsExporter) metricTypeFromProto(name string) (string, bool) { - // TODO: (@odeke-em) support non-"custom.googleapis.com" metrics names. - name = path.Join("custom.googleapis.com", "opencensus", name) - return name, true +// hasDomain checks if the metric name already has a domain in it. +func hasDomain(name string) bool { + for _, domain := range domains { + if strings.Contains(name, domain) { + return true + } + } + return false } -func fromProtoPoint(startTime *timestamp.Timestamp, pt *metricspb.Point) (*monitoringpb.Point, error) { +func fromProtoPoint(startTime *timestamppb.Timestamp, pt *metricspb.Point) (*monitoringpb.Point, error) { if pt == nil { return nil, nil } @@ -585,14 +443,13 @@ func fromProtoPoint(startTime *timestamp.Timestamp, pt *metricspb.Point) (*monit return nil, err } - mpt := &monitoringpb.Point{ + return &monitoringpb.Point{ Value: mptv, Interval: &monitoringpb.TimeInterval{ StartTime: startTime, EndTime: pt.Timestamp, }, - } - return mpt, nil + }, nil } func protoToMetricPoint(value interface{}) (*monitoringpb.TypedValue, error) { @@ -600,8 +457,6 @@ func protoToMetricPoint(value interface{}) (*monitoringpb.TypedValue, error) { return nil, nil } - var err error - var tval *monitoringpb.TypedValue switch v := value.(type) { default: // All the other types are not yet handled. @@ -617,21 +472,21 @@ func protoToMetricPoint(value interface{}) (*monitoringpb.TypedValue, error) { // TODO: Add conversion from SummaryValue when // https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/issues/66 // has been figured out. - err = fmt.Errorf("protoToMetricPoint: unknown Data type: %T", value) + return nil, fmt.Errorf("protoToMetricPoint: unknown Data type: %T", value) case *metricspb.Point_Int64Value: - tval = &monitoringpb.TypedValue{ + return &monitoringpb.TypedValue{ Value: &monitoringpb.TypedValue_Int64Value{ Int64Value: v.Int64Value, }, - } + }, nil case *metricspb.Point_DoubleValue: - tval = &monitoringpb.TypedValue{ + return &monitoringpb.TypedValue{ Value: &monitoringpb.TypedValue_DoubleValue{ DoubleValue: v.DoubleValue, }, - } + }, nil case *metricspb.Point_DistributionValue: dv := v.DistributionValue @@ -669,10 +524,8 @@ func protoToMetricPoint(value interface{}) (*monitoringpb.TypedValue, error) { mv.DistributionValue.BucketCounts = addZeroBucketCountOnCondition(insertZeroBound, bucketCounts(dv.Buckets)...) } - tval = &monitoringpb.TypedValue{Value: mv} + return &monitoringpb.TypedValue{Value: mv}, nil } - - return tval, err } func bucketCounts(buckets []*metricspb.DistributionValue_Bucket) []int64 { @@ -714,13 +567,3 @@ func protoMetricDescriptorTypeToMetricKind(m *metricspb.Metric) (googlemetricpb. return googlemetricpb.MetricDescriptor_METRIC_KIND_UNSPECIFIED, googlemetricpb.MetricDescriptor_VALUE_TYPE_UNSPECIFIED } } - -func getDefaultLabelsFromNode(node *commonpb.Node) map[string]labelValue { - taskValue := fmt.Sprintf("%s-%d@%s", strings.ToLower(node.LibraryInfo.GetLanguage().String()), node.Identifier.Pid, node.Identifier.HostName) - return map[string]labelValue{ - opencensusTaskKey: { - val: taskValue, - desc: opencensusTaskDescription, - }, - } -} diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_test_utils.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_test_utils.go deleted file mode 100644 index bc7a1ff4d2..0000000000 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/metrics_test_utils.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2019, OpenCensus 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 stackdriver - -/* -Common test utilities for comparing Stackdriver metrics. -*/ - -import ( - "github.com/golang/protobuf/ptypes/timestamp" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - - googlemetricpb "google.golang.org/genproto/googleapis/api/metric" - monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres" - monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" - - "time" -) - -func timestampToTime(ts *timestamp.Timestamp) time.Time { - if ts == nil { - return time.Unix(0, 0).UTC() - } - return time.Unix(ts.Seconds, int64(ts.Nanos)).UTC() -} - -func cmpResource(got, want *monitoredrespb.MonitoredResource) string { - return cmp.Diff(got, want, cmpopts.IgnoreUnexported(monitoredrespb.MonitoredResource{})) -} - -func cmpTSReqs(got, want []*monitoringpb.CreateTimeSeriesRequest) string { - return cmp.Diff(got, want, cmpopts.IgnoreUnexported(monitoringpb.CreateTimeSeriesRequest{})) -} - -func cmpMD(got, want *googlemetricpb.MetricDescriptor) string { - return cmp.Diff(got, want, cmpopts.IgnoreUnexported(googlemetricpb.MetricDescriptor{})) -} - -func cmpMDReq(got, want *monitoringpb.CreateMetricDescriptorRequest) string { - return cmp.Diff(got, want, cmpopts.IgnoreUnexported(monitoringpb.CreateMetricDescriptorRequest{})) -} - -func cmpMDReqs(got, want []*monitoringpb.CreateMetricDescriptorRequest) string { - return cmp.Diff(got, want, cmpopts.IgnoreUnexported(monitoringpb.CreateMetricDescriptorRequest{})) -} - -func cmpPoint(got, want *monitoringpb.Point) string { - return cmp.Diff(got, want, cmpopts.IgnoreUnexported(monitoringpb.Point{})) -} diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/aws_identity_doc_utils.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/aws_identity_doc_utils.go index d6a23a8cf7..ee519a4bf3 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/aws_identity_doc_utils.go +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/aws_identity_doc_utils.go @@ -37,8 +37,12 @@ type awsIdentityDocument struct { // This is only done once. func retrieveAWSIdentityDocument() *awsIdentityDocument { awsIdentityDoc := awsIdentityDocument{} - c := ec2metadata.New(session.New()) - if c.Available() == false { + sesion, err := session.NewSession() + if err != nil { + return nil + } + c := ec2metadata.New(sesion) + if !c.Available() { return nil } ec2InstanceIdentifyDocument, err := c.GetInstanceIdentityDocument() diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/gcp_metadata_config.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/gcp_metadata_config.go index 412e347724..f0d88856b9 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/gcp_metadata_config.go +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/monitoredresource/gcp_metadata_config.go @@ -22,7 +22,7 @@ import ( "strings" "cloud.google.com/go/compute/metadata" - "cloud.google.com/go/container/apiv1" + container "cloud.google.com/go/container/apiv1" containerpb "google.golang.org/genproto/googleapis/container/v1" ) diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/resource.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/resource.go index 855007e5eb..782011cb6e 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/resource.go +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/resource.go @@ -22,13 +22,6 @@ import ( monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres" ) -type resourceMap struct { - // Mapping from the input resource type to the monitored resource type in Stackdriver. - srcType, dstType string - // Mapping from Stackdriver monitored resource label to an OpenCensus resource label. - labels map[string]string -} - // Resource labels that are generally internal to the exporter. // Consider exposing these labels and a type identifier in the future to allow // for customization. @@ -41,7 +34,7 @@ const ( ) // Mappings for the well-known OpenCensus resources to applicable Stackdriver resources. -var k8sResourceMap = map[string]string{ +var k8sContainerMap = map[string]string{ "project_id": stackdriverProjectID, "location": resourcekeys.CloudKeyZone, "cluster_name": resourcekeys.K8SKeyClusterName, @@ -50,6 +43,21 @@ var k8sResourceMap = map[string]string{ "container_name": resourcekeys.ContainerKeyName, } +var k8sPodMap = map[string]string{ + "project_id": stackdriverProjectID, + "location": resourcekeys.CloudKeyZone, + "cluster_name": resourcekeys.K8SKeyClusterName, + "namespace_name": resourcekeys.K8SKeyNamespaceName, + "pod_name": resourcekeys.K8SKeyPodName, +} + +var k8sNodeMap = map[string]string{ + "project_id": stackdriverProjectID, + "location": resourcekeys.CloudKeyZone, + "cluster_name": resourcekeys.K8SKeyClusterName, + "node_name": resourcekeys.HostKeyName, +} + var gcpResourceMap = map[string]string{ "project_id": stackdriverProjectID, "instance_id": resourcekeys.HostKeyID, @@ -72,14 +80,20 @@ var genericResourceMap = map[string]string{ "task_id": stackdriverGenericTaskID, } -func transformResource(match, input map[string]string) map[string]string { +// returns transformed label map and true if all labels in match are found +// in input except optional project_id. It returns false if at least one label +// other than project_id is missing. +func transformResource(match, input map[string]string) (map[string]string, bool) { output := make(map[string]string, len(input)) for dst, src := range match { - if v, ok := input[src]; ok { + v, ok := input[src] + if ok { output[dst] = v + } else if dst != "project_id" { + return nil, true } } - return output + return output, false } func defaultMapResource(res *resource.Resource) *monitoredrespb.MonitoredResource { @@ -94,10 +108,13 @@ func defaultMapResource(res *resource.Resource) *monitoredrespb.MonitoredResourc switch { case res.Type == resourcekeys.ContainerType: result.Type = "k8s_container" - match = k8sResourceMap + match = k8sContainerMap case res.Type == resourcekeys.K8SType: result.Type = "k8s_pod" - match = k8sResourceMap + match = k8sPodMap + case res.Type == resourcekeys.HostType && res.Labels[resourcekeys.K8SKeyClusterName] != "": + result.Type = "k8s_node" + match = k8sNodeMap case res.Labels[resourcekeys.CloudKeyProvider] == resourcekeys.CloudProviderGCP: result.Type = "gce_instance" match = gcpResourceMap @@ -106,7 +123,17 @@ func defaultMapResource(res *resource.Resource) *monitoredrespb.MonitoredResourc match = awsResourceMap } - result.Labels = transformResource(match, res.Labels) + var missing bool + result.Labels, missing = transformResource(match, res.Labels) + if missing { + result.Type = "global" + // if project id specified then transform it. + if v, ok := res.Labels[stackdriverProjectID]; ok { + result.Labels = make(map[string]string, 1) + result.Labels["project_id"] = v + } + return result + } if result.Type == "aws_ec2_instance" { if v, ok := result.Labels["region"]; ok { result.Labels["region"] = fmt.Sprintf("aws:%s", v) diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/stackdriver.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/stackdriver.go index 4ae65f4c06..fafd06c282 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/stackdriver.go +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/stackdriver.go @@ -54,6 +54,7 @@ import ( "log" "os" "path" + "strings" "time" metadataapi "cloud.google.com/go/compute/metadata" @@ -61,7 +62,6 @@ import ( "contrib.go.opencensus.io/exporter/stackdriver/monitoredresource" "go.opencensus.io/resource" "go.opencensus.io/stats/view" - "go.opencensus.io/tag" "go.opencensus.io/trace" "golang.org/x/oauth2/google" "google.golang.org/api/option" @@ -186,11 +186,9 @@ type Options struct { // conversions from auto-detected resources to well-known Stackdriver monitored resources. MapResource func(*resource.Resource) *monitoredrespb.MonitoredResource - // MetricPrefix overrides the prefix of a Stackdriver metric display names. - // Optional. If unset defaults to "OpenCensus/". - // Deprecated: Provide GetMetricDisplayName to change the display name of - // the metric. - // If GetMetricDisplayName is non-nil, this option is ignored. + // MetricPrefix overrides the prefix of a Stackdriver metric names. + // Optional. If unset defaults to "custom.googleapis.com/opencensus/". + // If GetMetricPrefix is non-nil, this option is ignored. MetricPrefix string // GetMetricDisplayName allows customizing the display name for the metric @@ -203,8 +201,16 @@ type Options struct { // "custom.googleapis.com/opencensus/" + view.Name // // See: https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors#MetricDescriptor + // Depreacted. Use GetMetricPrefix instead. GetMetricType func(view *view.View) string + // GetMetricPrefix allows customizing the metric prefix for the given metric name. + // If it is not set, MetricPrefix is used. If MetricPrefix is not set, it defaults to: + // "custom.googleapis.com/opencensus/" + // + // See: https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors#MetricDescriptor + GetMetricPrefix func(name string) string + // DefaultTraceAttributes will be appended to every span that is exported to // Stackdriver Trace. DefaultTraceAttributes map[string]interface{} @@ -238,31 +244,47 @@ type Options struct { // If unset, context.Background() will be used. Context context.Context + // SkipCMD enforces to skip all the CreateMetricDescriptor calls. + // These calls are important in order to configure the unit of the metrics, + // but in some cases all the exported metrics are builtin (unit is configured) + // or the unit is not important. + SkipCMD bool + // Timeout for all API calls. If not set, defaults to 5 seconds. Timeout time.Duration - // GetMonitoredResource may be provided to supply the details of the - // monitored resource dynamically based on the tags associated with each - // data point. Most users will not need to set this, but should instead - // set the MonitoredResource field. - // - // GetMonitoredResource may add or remove tags by returning a new set of - // tags. It is safe for the function to mutate its argument and return it. - // - // See the documentation on the MonitoredResource field for guidance on the - // interaction between monitored resources and labels. - // - // The MonitoredResource field is ignored if this field is set to a non-nil - // value. - GetMonitoredResource func(*view.View, []tag.Tag) ([]tag.Tag, monitoredresource.Interface) - // ReportingInterval sets the interval between reporting metrics. // If it is set to zero then default value is used. ReportingInterval time.Duration + + // NumberOfWorkers sets the number of go rountines that send requests + // to Stackdriver Monitoring. This is only used for Proto metrics export + // for now. The minimum number of workers is 1. + NumberOfWorkers int + + // ResourceByDescriptor may be provided to supply monitored resource dynamically + // based on the metric Descriptor. Most users will not need to set this, + // but should instead set ResourceDetector. + // + // The MonitoredResource and ResourceDetector fields are ignored if this + // field is set to a non-nil value. + // + // The ResourceByDescriptor is called to derive monitored resources from + // metric.Descriptor and the label map associated with the time-series. + // If any label is used for the derived resource then it will be removed + // from the label map. The remaining labels in the map are returned to + // be used with the time-series. + // + // If the func set to this field does not return valid resource even for one + // time-series then it will result into an error for the entire CreateTimeSeries request + // which may contain more than one time-series. + ResourceByDescriptor func(*metricdata.Descriptor, map[string]string) (map[string]string, monitoredresource.Interface) } const defaultTimeout = 5 * time.Second +var defaultDomain = path.Join("custom.googleapis.com", "opencensus") + // Exporter is a stats and trace exporter that uploads data to Stackdriver. // // You can create a single Exporter and register it as both a trace exporter @@ -292,10 +314,6 @@ func NewExporter(o Options) (*Exporter, error) { } if o.Location == "" { if metadataapi.OnGCE() { - ctx := o.Context - if ctx == nil { - ctx = context.Background() - } zone, err := metadataapi.Zone() if err != nil { // This error should be logged with a warning level. @@ -336,6 +354,9 @@ func NewExporter(o Options) (*Exporter, error) { o.Resource = o.MapResource(res) } + if o.MetricPrefix != "" && !strings.HasSuffix(o.MetricPrefix, "/") { + o.MetricPrefix = o.MetricPrefix + "/" + } se, err := newStatsExporter(o) if err != nil { @@ -353,13 +374,21 @@ func NewExporter(o Options) (*Exporter, error) { // ExportView exports to the Stackdriver Monitoring if view data // has one or more rows. +// Deprecated: use ExportMetrics and StartMetricsExporter instead. func (e *Exporter) ExportView(vd *view.Data) { e.statsExporter.ExportView(vd) } -// ExportMetricsProto exports OpenCensus Metrics Proto to Stackdriver Monitoring. +// ExportMetricsProto exports OpenCensus Metrics Proto to Stackdriver Monitoring synchronously, +// without de-duping or adding proto metrics to the bundler. func (e *Exporter) ExportMetricsProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metrics []*metricspb.Metric) error { - return e.statsExporter.ExportMetricsProto(ctx, node, rsc, metrics) + _, err := e.statsExporter.PushMetricsProto(ctx, node, rsc, metrics) + return err +} + +// PushMetricsProto simliar with ExportMetricsProto but returns the number of dropped timeseries. +func (e *Exporter) PushMetricsProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metrics []*metricspb.Metric) (int, error) { + return e.statsExporter.PushMetricsProto(ctx, node, rsc, metrics) } // ExportMetrics exports OpenCensus Metrics to Stackdriver Monitoring @@ -427,12 +456,10 @@ func (o Options) handleError(err error) { log.Printf("Failed to export to Stackdriver: %v", err) } -func (o Options) newContextWithTimeout() (context.Context, func()) { - ctx := o.Context +func newContextWithTimeout(ctx context.Context, timeout time.Duration) (context.Context, func()) { if ctx == nil { ctx = context.Background() } - timeout := o.Timeout if timeout <= 0 { timeout = defaultTimeout } diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/stats.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/stats.go index a0565f61ef..e0a02ca9a3 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/stats.go +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/stats.go @@ -20,18 +20,19 @@ import ( "fmt" "os" "path" + "sort" "strconv" "strings" "sync" "time" - "go.opencensus.io" + opencensus "go.opencensus.io" "go.opencensus.io/stats" "go.opencensus.io/stats/view" "go.opencensus.io/tag" "go.opencensus.io/trace" - "cloud.google.com/go/monitoring/apiv3" + monitoring "cloud.google.com/go/monitoring/apiv3" "github.com/golang/protobuf/ptypes/timestamp" "go.opencensus.io/metric/metricdata" "go.opencensus.io/metric/metricexport" @@ -40,6 +41,7 @@ import ( distributionpb "google.golang.org/genproto/googleapis/api/distribution" labelpb "google.golang.org/genproto/googleapis/api/label" "google.golang.org/genproto/googleapis/api/metric" + googlemetricpb "google.golang.org/genproto/googleapis/api/metric" metricpb "google.golang.org/genproto/googleapis/api/metric" monitoredrespb "google.golang.org/genproto/googleapis/api/monitoredres" monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3" @@ -59,18 +61,14 @@ var userAgent = fmt.Sprintf("opencensus-go %s; stackdriver-exporter %s", opencen type statsExporter struct { o Options - viewDataBundler *bundler.Bundler - protoMetricsBundler *bundler.Bundler - metricsBundler *bundler.Bundler - - createdViewsMu sync.Mutex - createdViews map[string]*metricpb.MetricDescriptor // Views already created remotely + viewDataBundler *bundler.Bundler + metricsBundler *bundler.Bundler protoMu sync.Mutex - protoMetricDescriptors map[string]*metricpb.MetricDescriptor // Saves the metric descriptors that were already created remotely + protoMetricDescriptors map[string]bool // Metric descriptors that were already created remotely metricMu sync.Mutex - metricDescriptors map[string]*metricpb.MetricDescriptor // Saves the metric descriptors that were already created remotely + metricDescriptors map[string]bool // Metric descriptors that were already created remotely c *monitoring.MetricClient defaultLabels map[string]labelValue @@ -103,39 +101,39 @@ func newStatsExporter(o Options) (*statsExporter, error) { e := &statsExporter{ c: client, o: o, - createdViews: make(map[string]*metricpb.MetricDescriptor), - protoMetricDescriptors: make(map[string]*metricpb.MetricDescriptor), - metricDescriptors: make(map[string]*metricpb.MetricDescriptor), + protoMetricDescriptors: make(map[string]bool), + metricDescriptors: make(map[string]bool), } + var defaultLablesNotSanitized map[string]labelValue if o.DefaultMonitoringLabels != nil { - e.defaultLabels = o.DefaultMonitoringLabels.m + defaultLablesNotSanitized = o.DefaultMonitoringLabels.m } else { - e.defaultLabels = map[string]labelValue{ + defaultLablesNotSanitized = map[string]labelValue{ opencensusTaskKey: {val: getTaskValue(), desc: opencensusTaskDescription}, } } + e.defaultLabels = make(map[string]labelValue) + // Fill in the defaults firstly, irrespective of if the labelKeys and labelValues are mismatched. + for key, label := range defaultLablesNotSanitized { + e.defaultLabels[sanitize(key)] = label + } + e.viewDataBundler = bundler.NewBundler((*view.Data)(nil), func(bundle interface{}) { vds := bundle.([]*view.Data) e.handleUpload(vds...) }) - e.protoMetricsBundler = bundler.NewBundler((*metricProtoPayload)(nil), func(bundle interface{}) { - payloads := bundle.([]*metricProtoPayload) - e.handleMetricsProtoUpload(payloads) - }) e.metricsBundler = bundler.NewBundler((*metricdata.Metric)(nil), func(bundle interface{}) { metrics := bundle.([]*metricdata.Metric) e.handleMetricsUpload(metrics) }) if delayThreshold := e.o.BundleDelayThreshold; delayThreshold > 0 { e.viewDataBundler.DelayThreshold = delayThreshold - e.protoMetricsBundler.DelayThreshold = delayThreshold e.metricsBundler.DelayThreshold = delayThreshold } if countThreshold := e.o.BundleCountThreshold; countThreshold > 0 { e.viewDataBundler.BundleCountThreshold = countThreshold - e.protoMetricsBundler.BundleCountThreshold = countThreshold e.metricsBundler.BundleCountThreshold = countThreshold } return e, nil @@ -143,7 +141,7 @@ func newStatsExporter(o Options) (*statsExporter, error) { func (e *statsExporter) startMetricsReader() error { e.initReaderOnce.Do(func() { - e.ir, _ = metricexport.NewIntervalReader(&metricexport.Reader{}, e) + e.ir, _ = metricexport.NewIntervalReader(metricexport.NewReader(), e) }) e.ir.ReportingInterval = e.o.ReportingInterval return e.ir.Start() @@ -156,10 +154,6 @@ func (e *statsExporter) stopMetricsReader() { } func (e *statsExporter) getMonitoredResource(v *view.View, tags []tag.Tag) ([]tag.Tag, *monitoredrespb.MonitoredResource) { - if get := e.o.GetMonitoredResource; get != nil { - newTags, mr := get(v, tags) - return newTags, convertMonitoredResourceToPB(mr) - } resource := e.o.Resource if resource == nil { resource = &monitoredrespb.MonitoredResource{ @@ -210,12 +204,11 @@ func (e *statsExporter) handleUpload(vds ...*view.Data) { // want to lose data that hasn't yet been exported. func (e *statsExporter) Flush() { e.viewDataBundler.Flush() - e.protoMetricsBundler.Flush() e.metricsBundler.Flush() } func (e *statsExporter) uploadStats(vds []*view.Data) error { - ctx, cancel := e.o.newContextWithTimeout() + ctx, cancel := newContextWithTimeout(e.o.Context, e.o.Timeout) defer cancel() ctx, span := trace.StartSpan( ctx, @@ -225,7 +218,7 @@ func (e *statsExporter) uploadStats(vds []*view.Data) error { defer span.End() for _, vd := range vds { - if err := e.createMeasure(ctx, vd.View); err != nil { + if err := e.createMetricDescriptorFromView(ctx, vd.View); err != nil { span.SetStatus(trace.Status{Code: 2, Message: err.Error()}) return err } @@ -334,34 +327,27 @@ func (e *statsExporter) viewToMetricDescriptor(ctx context.Context, v *view.View return res, nil } -func (e *statsExporter) viewToCreateMetricDescriptorRequest(ctx context.Context, v *view.View) (*monitoringpb.CreateMetricDescriptorRequest, error) { - inMD, err := e.viewToMetricDescriptor(ctx, v) - if err != nil { - return nil, err - } - - cmrdesc := &monitoringpb.CreateMetricDescriptorRequest{ - Name: fmt.Sprintf("projects/%s", e.o.ProjectID), - MetricDescriptor: inMD, - } - return cmrdesc, nil -} - -// createMeasure creates a MetricDescriptor for the given view data in Stackdriver Monitoring. +// createMetricDescriptorFromView creates a MetricDescriptor for the given view data in Stackdriver Monitoring. // An error will be returned if there is already a metric descriptor created with the same name // but it has a different aggregation or keys. -func (e *statsExporter) createMeasure(ctx context.Context, v *view.View) error { - e.createdViewsMu.Lock() - defer e.createdViewsMu.Unlock() +func (e *statsExporter) createMetricDescriptorFromView(ctx context.Context, v *view.View) error { + // Skip create metric descriptor if configured + if e.o.SkipCMD { + return nil + } + + e.metricMu.Lock() + defer e.metricMu.Unlock() viewName := v.Name - if md, ok := e.createdViews[viewName]; ok { - // [TODO:rghetia] Temporary fix for https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/issues/76#issuecomment-459459091 - if builtinMetric(md.Type) { - return nil - } - return e.equalMeasureAggTagKeys(md, v.Measure, v.Aggregation, v.TagKeys) + if _, created := e.metricDescriptors[viewName]; created { + return nil + } + + if builtinMetric(e.metricType(v)) { + e.metricDescriptors[viewName] = true + return nil } inMD, err := e.viewToMetricDescriptor(ctx, v) @@ -369,34 +355,92 @@ func (e *statsExporter) createMeasure(ctx context.Context, v *view.View) error { return err } - var dmd *metric.MetricDescriptor - if builtinMetric(inMD.Type) { - gmrdesc := &monitoringpb.GetMetricDescriptorRequest{ - Name: inMD.Name, - } - dmd, err = getMetricDescriptor(ctx, e.c, gmrdesc) - } else { - cmrdesc := &monitoringpb.CreateMetricDescriptorRequest{ - Name: fmt.Sprintf("projects/%s", e.o.ProjectID), - MetricDescriptor: inMD, - } - dmd, err = createMetricDescriptor(ctx, e.c, cmrdesc) - } - if err != nil { + if err = e.createMetricDescriptor(ctx, inMD); err != nil { return err } // Now cache the metric descriptor - e.createdViews[viewName] = dmd - return err + e.metricDescriptors[viewName] = true + return nil } func (e *statsExporter) displayName(suffix string) string { - displayNamePrefix := defaultDisplayNamePrefix - if e.o.MetricPrefix != "" { - displayNamePrefix = e.o.MetricPrefix + return path.Join(defaultDisplayNamePrefix, suffix) +} + +func (e *statsExporter) combineTimeSeriesToCreateTimeSeriesRequest(ts []*monitoringpb.TimeSeries) (ctsreql []*monitoringpb.CreateTimeSeriesRequest) { + if len(ts) == 0 { + return nil + } + + // Since there are scenarios in which Metrics with the same Type + // can be bunched in the same TimeSeries, we have to ensure that + // we create a unique CreateTimeSeriesRequest with entirely unique Metrics + // per TimeSeries, lest we'll encounter: + // + // err: rpc error: code = InvalidArgument desc = One or more TimeSeries could not be written: + // Field timeSeries[2] had an invalid value: Duplicate TimeSeries encountered. + // Only one point can be written per TimeSeries per request.: timeSeries[2] + // + // This scenario happens when we are using the OpenCensus Agent in which multiple metrics + // are streamed by various client applications. + // See https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/issues/73 + uniqueTimeSeries := make([]*monitoringpb.TimeSeries, 0, len(ts)) + nonUniqueTimeSeries := make([]*monitoringpb.TimeSeries, 0, len(ts)) + seenMetrics := make(map[string]struct{}) + + for _, tti := range ts { + key := metricSignature(tti.Metric) + if _, alreadySeen := seenMetrics[key]; !alreadySeen { + uniqueTimeSeries = append(uniqueTimeSeries, tti) + seenMetrics[key] = struct{}{} + } else { + nonUniqueTimeSeries = append(nonUniqueTimeSeries, tti) + } + } + + // UniqueTimeSeries can be bunched up together + // While for each nonUniqueTimeSeries, we have + // to make a unique CreateTimeSeriesRequest. + ctsreql = append(ctsreql, &monitoringpb.CreateTimeSeriesRequest{ + Name: fmt.Sprintf("projects/%s", e.o.ProjectID), + TimeSeries: uniqueTimeSeries, + }) + + // Now recursively also combine the non-unique TimeSeries + // that were singly added to nonUniqueTimeSeries. + // The reason is that we need optimal combinations + // for optimal combinations because: + // * "a/b/c" + // * "a/b/c" + // * "x/y/z" + // * "a/b/c" + // * "x/y/z" + // * "p/y/z" + // * "d/y/z" + // + // should produce: + // CreateTimeSeries(uniqueTimeSeries) :: ["a/b/c", "x/y/z", "p/y/z", "d/y/z"] + // CreateTimeSeries(nonUniqueTimeSeries) :: ["a/b/c"] + // CreateTimeSeries(nonUniqueTimeSeries) :: ["a/b/c", "x/y/z"] + nonUniqueRequests := e.combineTimeSeriesToCreateTimeSeriesRequest(nonUniqueTimeSeries) + ctsreql = append(ctsreql, nonUniqueRequests...) + + return ctsreql +} + +// metricSignature creates a unique signature consisting of a +// metric's type and its lexicographically sorted label values +// See https://github.com/census-ecosystem/opencensus-go-exporter-stackdriver/issues/120 +func metricSignature(metric *googlemetricpb.Metric) string { + labels := metric.GetLabels() + labelValues := make([]string, 0, len(labels)) + + for _, labelValue := range labels { + labelValues = append(labelValues, labelValue) } - return path.Join(displayNamePrefix, suffix) + sort.Strings(labelValues) + return fmt.Sprintf("%s:%s", metric.GetType(), strings.Join(labelValues, ",")) } func newPoint(v *view.View, row *view.Row, start, end time.Time) *monitoringpb.Point { @@ -548,61 +592,21 @@ func newLabelDescriptors(defaults map[string]labelValue, keys []tag.Key) []*labe return labelDescriptors } -func (e *statsExporter) equalMeasureAggTagKeys(md *metricpb.MetricDescriptor, m stats.Measure, agg *view.Aggregation, keys []tag.Key) error { - var aggTypeMatch bool - switch md.ValueType { - case metricpb.MetricDescriptor_INT64: - if _, ok := m.(*stats.Int64Measure); !(ok || agg.Type == view.AggTypeCount) { - return fmt.Errorf("stackdriver metric descriptor was not created as int64") - } - aggTypeMatch = agg.Type == view.AggTypeCount || agg.Type == view.AggTypeSum || agg.Type == view.AggTypeLastValue - case metricpb.MetricDescriptor_DOUBLE: - if _, ok := m.(*stats.Float64Measure); !ok { - return fmt.Errorf("stackdriver metric descriptor was not created as double") - } - aggTypeMatch = agg.Type == view.AggTypeSum || agg.Type == view.AggTypeLastValue - case metricpb.MetricDescriptor_DISTRIBUTION: - aggTypeMatch = agg.Type == view.AggTypeDistribution - } - - if !aggTypeMatch { - return fmt.Errorf("stackdriver metric descriptor was not created with aggregation type %T", agg.Type) - } - - labels := make(map[string]struct{}, len(keys)+len(e.defaultLabels)) - for _, k := range keys { - labels[sanitize(k.Name())] = struct{}{} - } - for k := range e.defaultLabels { - labels[sanitize(k)] = struct{}{} - } - - for _, k := range md.Labels { - if _, ok := labels[k.Key]; !ok { - return fmt.Errorf("stackdriver metric descriptor %q was not created with label %q", md.Type, k) - } - delete(labels, k.Key) - } - - if len(labels) > 0 { - extra := make([]string, 0, len(labels)) - for k := range labels { - extra = append(extra, k) - } - return fmt.Errorf("stackdriver metric descriptor %q contains unexpected labels: %s", md.Type, strings.Join(extra, ", ")) +func (e *statsExporter) createMetricDescriptor(ctx context.Context, md *metric.MetricDescriptor) error { + ctx, cancel := newContextWithTimeout(ctx, e.o.Timeout) + defer cancel() + cmrdesc := &monitoringpb.CreateMetricDescriptorRequest{ + Name: fmt.Sprintf("projects/%s", e.o.ProjectID), + MetricDescriptor: md, } - - return nil + _, err := createMetricDescriptor(ctx, e.c, cmrdesc) + return err } var createMetricDescriptor = func(ctx context.Context, c *monitoring.MetricClient, mdr *monitoringpb.CreateMetricDescriptorRequest) (*metric.MetricDescriptor, error) { return c.CreateMetricDescriptor(ctx, mdr) } -var getMetricDescriptor = func(ctx context.Context, c *monitoring.MetricClient, mdr *monitoringpb.GetMetricDescriptorRequest) (*metric.MetricDescriptor, error) { - return c.GetMetricDescriptor(ctx, mdr) -} - var createTimeSeries = func(ctx context.Context, c *monitoring.MetricClient, ts *monitoringpb.CreateTimeSeriesRequest) error { return c.CreateTimeSeries(ctx, ts) } diff --git a/vendor/contrib.go.opencensus.io/exporter/stackdriver/trace.go b/vendor/contrib.go.opencensus.io/exporter/stackdriver/trace.go index 71e7f36d22..ee6535eefc 100644 --- a/vendor/contrib.go.opencensus.io/exporter/stackdriver/trace.go +++ b/vendor/contrib.go.opencensus.io/exporter/stackdriver/trace.go @@ -121,7 +121,7 @@ func (e *traceExporter) uploadSpans(spans []*tracepb.Span) { Spans: spans, } // Create a never-sampled span to prevent traces associated with exporter. - ctx, cancel := e.o.newContextWithTimeout() + ctx, cancel := newContextWithTimeout(e.o.Context, e.o.Timeout) defer cancel() ctx, span := trace.StartSpan( ctx, diff --git a/vendor/github.com/aws/aws-sdk-go/aws/client/default_retryer.go b/vendor/github.com/aws/aws-sdk-go/aws/client/default_retryer.go index a397b0d044..0680e838cd 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/client/default_retryer.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/client/default_retryer.go @@ -14,12 +14,12 @@ import ( // struct and override the specific methods. For example, to override only // the MaxRetries method: // -// type retryer struct { -// client.DefaultRetryer -// } +// type retryer struct { +// client.DefaultRetryer +// } // -// // This implementation always has 100 max retries -// func (d retryer) MaxRetries() int { return 100 } +// // This implementation always has 100 max retries +// func (d retryer) MaxRetries() int { return 100 } type DefaultRetryer struct { NumMaxRetries int } @@ -33,25 +33,28 @@ func (d DefaultRetryer) MaxRetries() int { // RetryRules returns the delay duration before retrying this request again func (d DefaultRetryer) RetryRules(r *request.Request) time.Duration { // Set the upper limit of delay in retrying at ~five minutes - minTime := 30 - throttle := d.shouldThrottle(r) - if throttle { - if delay, ok := getRetryDelay(r); ok { - return delay + var minTime int64 = 30 + var initialDelay time.Duration + + isThrottle := r.IsErrorThrottle() + if isThrottle { + if delay, ok := getRetryAfterDelay(r); ok { + initialDelay = delay } minTime = 500 } retryCount := r.RetryCount - if throttle && retryCount > 8 { + if isThrottle && retryCount > 8 { retryCount = 8 - } else if retryCount > 13 { - retryCount = 13 + } else if retryCount > 12 { + retryCount = 12 } - delay := (1 << uint(retryCount)) * (sdkrand.SeededRand.Intn(minTime) + minTime) - return time.Duration(delay) * time.Millisecond + delay := (1 << uint(retryCount)) * (sdkrand.SeededRand.Int63n(minTime) + minTime) + return (time.Duration(delay) * time.Millisecond) + initialDelay + } // ShouldRetry returns true if the request should be retried. @@ -65,26 +68,13 @@ func (d DefaultRetryer) ShouldRetry(r *request.Request) bool { if r.HTTPResponse.StatusCode >= 500 && r.HTTPResponse.StatusCode != 501 { return true } - return r.IsErrorRetryable() || d.shouldThrottle(r) -} - -// ShouldThrottle returns true if the request should be throttled. -func (d DefaultRetryer) shouldThrottle(r *request.Request) bool { - switch r.HTTPResponse.StatusCode { - case 429: - case 502: - case 503: - case 504: - default: - return r.IsErrorThrottle() - } - return true + return r.IsErrorRetryable() || r.IsErrorThrottle() } // This will look in the Retry-After header, RFC 7231, for how long // it will wait before attempting another request -func getRetryDelay(r *request.Request) (time.Duration, bool) { +func getRetryAfterDelay(r *request.Request) (time.Duration, bool) { if !canUseRetryAfterHeader(r) { return 0, false } diff --git a/vendor/github.com/aws/aws-sdk-go/aws/config.go b/vendor/github.com/aws/aws-sdk-go/aws/config.go index 10634d173d..fd1e240f6e 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/config.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/config.go @@ -20,7 +20,7 @@ type RequestRetryer interface{} // A Config provides service configuration for service clients. By default, // all clients will use the defaults.DefaultConfig structure. // -// // Create Session with MaxRetry configuration to be shared by multiple +// // Create Session with MaxRetries configuration to be shared by multiple // // service clients. // sess := session.Must(session.NewSession(&aws.Config{ // MaxRetries: aws.Int(3), @@ -251,7 +251,7 @@ type Config struct { // NewConfig returns a new Config pointer that can be chained with builder // methods to set multiple configuration values inline without using pointers. // -// // Create Session with MaxRetry configuration to be shared by multiple +// // Create Session with MaxRetries configuration to be shared by multiple // // service clients. // sess := session.Must(session.NewSession(aws.NewConfig(). // WithMaxRetries(3), diff --git a/vendor/github.com/aws/aws-sdk-go/aws/corehandlers/handlers.go b/vendor/github.com/aws/aws-sdk-go/aws/corehandlers/handlers.go index f8853d78af..0c60e612ea 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/corehandlers/handlers.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/corehandlers/handlers.go @@ -159,9 +159,9 @@ func handleSendError(r *request.Request, err error) { Body: ioutil.NopCloser(bytes.NewReader([]byte{})), } } - // Catch all other request errors. + // Catch all request errors, and let the default retrier determine + // if the error is retryable. r.Error = awserr.New("RequestError", "send request failed", err) - r.Retryable = aws.Bool(true) // network errors are retryable // Override the error with a context canceled error, if that was canceled. ctx := r.Context() @@ -184,37 +184,39 @@ var ValidateResponseHandler = request.NamedHandler{Name: "core.ValidateResponseH // AfterRetryHandler performs final checks to determine if the request should // be retried and how long to delay. -var AfterRetryHandler = request.NamedHandler{Name: "core.AfterRetryHandler", Fn: func(r *request.Request) { - // If one of the other handlers already set the retry state - // we don't want to override it based on the service's state - if r.Retryable == nil || aws.BoolValue(r.Config.EnforceShouldRetryCheck) { - r.Retryable = aws.Bool(r.ShouldRetry(r)) - } +var AfterRetryHandler = request.NamedHandler{ + Name: "core.AfterRetryHandler", + Fn: func(r *request.Request) { + // If one of the other handlers already set the retry state + // we don't want to override it based on the service's state + if r.Retryable == nil || aws.BoolValue(r.Config.EnforceShouldRetryCheck) { + r.Retryable = aws.Bool(r.ShouldRetry(r)) + } - if r.WillRetry() { - r.RetryDelay = r.RetryRules(r) + if r.WillRetry() { + r.RetryDelay = r.RetryRules(r) - if sleepFn := r.Config.SleepDelay; sleepFn != nil { - // Support SleepDelay for backwards compatibility and testing - sleepFn(r.RetryDelay) - } else if err := aws.SleepWithContext(r.Context(), r.RetryDelay); err != nil { - r.Error = awserr.New(request.CanceledErrorCode, - "request context canceled", err) - r.Retryable = aws.Bool(false) - return - } + if sleepFn := r.Config.SleepDelay; sleepFn != nil { + // Support SleepDelay for backwards compatibility and testing + sleepFn(r.RetryDelay) + } else if err := aws.SleepWithContext(r.Context(), r.RetryDelay); err != nil { + r.Error = awserr.New(request.CanceledErrorCode, + "request context canceled", err) + r.Retryable = aws.Bool(false) + return + } - // when the expired token exception occurs the credentials - // need to be expired locally so that the next request to - // get credentials will trigger a credentials refresh. - if r.IsErrorExpired() { - r.Config.Credentials.Expire() - } + // when the expired token exception occurs the credentials + // need to be expired locally so that the next request to + // get credentials will trigger a credentials refresh. + if r.IsErrorExpired() { + r.Config.Credentials.Expire() + } - r.RetryCount++ - r.Error = nil - } -}} + r.RetryCount++ + r.Error = nil + } + }} // ValidateEndpointHandler is a request handler to validate a request had the // appropriate Region and Endpoint set. Will set r.Error if the endpoint or diff --git a/vendor/github.com/aws/aws-sdk-go/aws/credentials/endpointcreds/provider.go b/vendor/github.com/aws/aws-sdk-go/aws/credentials/endpointcreds/provider.go index c2b2c5d65c..1a7af53a4d 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/credentials/endpointcreds/provider.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/endpointcreds/provider.go @@ -98,8 +98,8 @@ func NewProviderClient(cfg aws.Config, handlers request.Handlers, endpoint strin return p } -// NewCredentialsClient returns a Credentials wrapper for retrieving credentials -// from an arbitrary endpoint concurrently. The client will request the +// NewCredentialsClient returns a pointer to a new Credentials object +// wrapping the endpoint credentials Provider. func NewCredentialsClient(cfg aws.Config, handlers request.Handlers, endpoint string, options ...func(*Provider)) *credentials.Credentials { return credentials.NewCredentials(NewProviderClient(cfg, handlers, endpoint, options...)) } diff --git a/vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/web_identity_provider.go b/vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/web_identity_provider.go index 20510d9aec..b20b633948 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/web_identity_provider.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/credentials/stscreds/web_identity_provider.go @@ -76,12 +76,15 @@ func (p *WebIdentityRoleProvider) Retrieve() (credentials.Value, error) { // uses unix time in nanoseconds to uniquely identify sessions. sessionName = strconv.FormatInt(now().UnixNano(), 10) } - resp, err := p.client.AssumeRoleWithWebIdentity(&sts.AssumeRoleWithWebIdentityInput{ + req, resp := p.client.AssumeRoleWithWebIdentityRequest(&sts.AssumeRoleWithWebIdentityInput{ RoleArn: &p.roleARN, RoleSessionName: &sessionName, WebIdentityToken: aws.String(string(b)), }) - if err != nil { + // InvalidIdentityToken error is a temporary error that can occur + // when assuming an Role with a JWT web identity token. + req.RetryErrorCodes = append(req.RetryErrorCodes, sts.ErrCodeInvalidIdentityTokenException) + if err := req.Send(); err != nil { return credentials.Value{}, awserr.New(ErrCodeWebIdentity, "failed to retrieve credentials", err) } diff --git a/vendor/github.com/aws/aws-sdk-go/aws/csm/metric_chan.go b/vendor/github.com/aws/aws-sdk-go/aws/csm/metric_chan.go index 514fc3739a..82a3e345e9 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/csm/metric_chan.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/csm/metric_chan.go @@ -16,25 +16,26 @@ var ( type metricChan struct { ch chan metric - paused int64 + paused *int64 } func newMetricChan(size int) metricChan { return metricChan{ - ch: make(chan metric, size), + ch: make(chan metric, size), + paused: new(int64), } } func (ch *metricChan) Pause() { - atomic.StoreInt64(&ch.paused, pausedEnum) + atomic.StoreInt64(ch.paused, pausedEnum) } func (ch *metricChan) Continue() { - atomic.StoreInt64(&ch.paused, runningEnum) + atomic.StoreInt64(ch.paused, runningEnum) } func (ch *metricChan) IsPaused() bool { - v := atomic.LoadInt64(&ch.paused) + v := atomic.LoadInt64(ch.paused) return v == pausedEnum } diff --git a/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go b/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go index 2c8d5f56d0..d126764ce4 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/api.go @@ -152,18 +152,19 @@ type EC2IAMInfo struct { // An EC2InstanceIdentityDocument provides the shape for unmarshaling // an instance identity document type EC2InstanceIdentityDocument struct { - DevpayProductCodes []string `json:"devpayProductCodes"` - AvailabilityZone string `json:"availabilityZone"` - PrivateIP string `json:"privateIp"` - Version string `json:"version"` - Region string `json:"region"` - InstanceID string `json:"instanceId"` - BillingProducts []string `json:"billingProducts"` - InstanceType string `json:"instanceType"` - AccountID string `json:"accountId"` - PendingTime time.Time `json:"pendingTime"` - ImageID string `json:"imageId"` - KernelID string `json:"kernelId"` - RamdiskID string `json:"ramdiskId"` - Architecture string `json:"architecture"` + DevpayProductCodes []string `json:"devpayProductCodes"` + MarketplaceProductCodes []string `json:"marketplaceProductCodes"` + AvailabilityZone string `json:"availabilityZone"` + PrivateIP string `json:"privateIp"` + Version string `json:"version"` + Region string `json:"region"` + InstanceID string `json:"instanceId"` + BillingProducts []string `json:"billingProducts"` + InstanceType string `json:"instanceType"` + AccountID string `json:"accountId"` + PendingTime time.Time `json:"pendingTime"` + ImageID string `json:"imageId"` + KernelID string `json:"kernelId"` + RamdiskID string `json:"ramdiskId"` + Architecture string `json:"architecture"` } diff --git a/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go b/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go index f0c1d31e75..4c5636e350 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/ec2metadata/service.go @@ -123,7 +123,7 @@ func unmarshalHandler(r *request.Request) { defer r.HTTPResponse.Body.Close() b := &bytes.Buffer{} if _, err := io.Copy(b, r.HTTPResponse.Body); err != nil { - r.Error = awserr.New(request.ErrCodeSerialization, "unable to unmarshal EC2 metadata respose", err) + r.Error = awserr.New(request.ErrCodeSerialization, "unable to unmarshal EC2 metadata response", err) return } @@ -136,7 +136,7 @@ func unmarshalError(r *request.Request) { defer r.HTTPResponse.Body.Close() b := &bytes.Buffer{} if _, err := io.Copy(b, r.HTTPResponse.Body); err != nil { - r.Error = awserr.New(request.ErrCodeSerialization, "unable to unmarshal EC2 metadata error respose", err) + r.Error = awserr.New(request.ErrCodeSerialization, "unable to unmarshal EC2 metadata error response", err) return } diff --git a/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go b/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go index 7431a6bf85..d7d98807c1 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/endpoints/defaults.go @@ -11,6 +11,8 @@ const ( AwsPartitionID = "aws" // AWS Standard partition. AwsCnPartitionID = "aws-cn" // AWS China partition. AwsUsGovPartitionID = "aws-us-gov" // AWS GovCloud (US) partition. + AwsIsoPartitionID = "aws-iso" // AWS ISO (US) partition. + AwsIsoBPartitionID = "aws-iso-b" // AWS ISOB (US) partition. ) // AWS Standard partition's regions. @@ -47,8 +49,18 @@ const ( UsGovWest1RegionID = "us-gov-west-1" // AWS GovCloud (US). ) +// AWS ISO (US) partition's regions. +const ( + UsIsoEast1RegionID = "us-iso-east-1" // US ISO East. +) + +// AWS ISOB (US) partition's regions. +const ( + UsIsobEast1RegionID = "us-isob-east-1" // US ISOB East (Ohio). +) + // DefaultResolver returns an Endpoint resolver that will be able -// to resolve endpoints for: AWS Standard, AWS China, and AWS GovCloud (US). +// to resolve endpoints for: AWS Standard, AWS China, AWS GovCloud (US), AWS ISO (US), and AWS ISOB (US). // // Use DefaultPartitions() to get the list of the default partitions. func DefaultResolver() Resolver { @@ -56,7 +68,7 @@ func DefaultResolver() Resolver { } // DefaultPartitions returns a list of the partitions the SDK is bundled -// with. The available partitions are: AWS Standard, AWS China, and AWS GovCloud (US). +// with. The available partitions are: AWS Standard, AWS China, AWS GovCloud (US), AWS ISO (US), and AWS ISOB (US). // // partitions := endpoints.DefaultPartitions // for _, p := range partitions { @@ -70,6 +82,8 @@ var defaultPartitions = partitions{ awsPartition, awscnPartition, awsusgovPartition, + awsisoPartition, + awsisobPartition, } // AwsPartition returns the Resolver for AWS Standard. @@ -320,6 +334,7 @@ var awsPartition = partition{ "ap-northeast-1": endpoint{}, "ap-southeast-1": endpoint{}, "ap-southeast-2": endpoint{}, + "eu-central-1": endpoint{}, "eu-west-1": endpoint{}, "us-east-1": endpoint{}, "us-west-2": endpoint{}, @@ -339,6 +354,7 @@ var awsPartition = partition{ "api.sagemaker": service{ Endpoints: endpoints{ + "ap-east-1": endpoint{}, "ap-northeast-1": endpoint{}, "ap-northeast-2": endpoint{}, "ap-south-1": endpoint{}, @@ -346,8 +362,11 @@ var awsPartition = partition{ "ap-southeast-2": endpoint{}, "ca-central-1": endpoint{}, "eu-central-1": endpoint{}, + "eu-north-1": endpoint{}, "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, + "eu-west-3": endpoint{}, + "sa-east-1": endpoint{}, "us-east-1": endpoint{}, "us-east-1-fips": endpoint{ Hostname: "api-fips.sagemaker.us-east-1.amazonaws.com", @@ -581,6 +600,7 @@ var awsPartition = partition{ "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, "eu-west-3": endpoint{}, + "me-south-1": endpoint{}, "sa-east-1": endpoint{}, "us-east-1": endpoint{}, "us-east-2": endpoint{}, @@ -728,6 +748,7 @@ var awsPartition = partition{ "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, "eu-west-3": endpoint{}, + "me-south-1": endpoint{}, "us-east-1": endpoint{}, "us-east-2": endpoint{}, "us-west-1": endpoint{}, @@ -903,6 +924,7 @@ var awsPartition = partition{ "ap-southeast-2": endpoint{}, "ca-central-1": endpoint{}, "eu-central-1": endpoint{}, + "eu-north-1": endpoint{}, "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, "eu-west-3": endpoint{}, @@ -1093,10 +1115,11 @@ var awsPartition = partition{ Region: "us-west-2", }, }, - "us-east-1": endpoint{}, - "us-east-2": endpoint{}, - "us-west-1": endpoint{}, - "us-west-2": endpoint{}, + "me-south-1": endpoint{}, + "us-east-1": endpoint{}, + "us-east-2": endpoint{}, + "us-west-1": endpoint{}, + "us-west-2": endpoint{}, }, }, "dax": service{ @@ -1124,6 +1147,7 @@ var awsPartition = partition{ "directconnect": service{ Endpoints: endpoints{ + "ap-east-1": endpoint{}, "ap-northeast-1": endpoint{}, "ap-northeast-2": endpoint{}, "ap-south-1": endpoint{}, @@ -1553,11 +1577,12 @@ var awsPartition = partition{ Region: "us-west-1", }, }, - "sa-east-1": endpoint{}, - "us-east-1": endpoint{}, - "us-east-2": endpoint{}, - "us-west-1": endpoint{}, - "us-west-2": endpoint{}, + "me-south-1": endpoint{}, + "sa-east-1": endpoint{}, + "us-east-1": endpoint{}, + "us-east-2": endpoint{}, + "us-west-1": endpoint{}, + "us-west-2": endpoint{}, }, }, "events": service{ @@ -1586,6 +1611,7 @@ var awsPartition = partition{ "firehose": service{ Endpoints: endpoints{ + "ap-east-1": endpoint{}, "ap-northeast-1": endpoint{}, "ap-northeast-2": endpoint{}, "ap-south-1": endpoint{}, @@ -1629,6 +1655,7 @@ var awsPartition = partition{ "ap-southeast-1": endpoint{}, "ap-southeast-2": endpoint{}, "eu-central-1": endpoint{}, + "eu-north-1": endpoint{}, "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, "us-east-1": endpoint{}, @@ -1696,6 +1723,7 @@ var awsPartition = partition{ "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, "eu-west-3": endpoint{}, + "me-south-1": endpoint{}, "sa-east-1": endpoint{}, "us-east-1": endpoint{}, "us-east-2": endpoint{}, @@ -1749,9 +1777,33 @@ var awsPartition = partition{ "eu-west-3": endpoint{}, "sa-east-1": endpoint{}, "us-east-1": endpoint{}, - "us-east-2": endpoint{}, - "us-west-1": endpoint{}, - "us-west-2": endpoint{}, + "us-east-1-fips": endpoint{ + Hostname: "guardduty-fips.us-east-1.amazonaws.com", + CredentialScope: credentialScope{ + Region: "us-east-1", + }, + }, + "us-east-2": endpoint{}, + "us-east-2-fips": endpoint{ + Hostname: "guardduty-fips.us-east-2.amazonaws.com", + CredentialScope: credentialScope{ + Region: "us-east-2", + }, + }, + "us-west-1": endpoint{}, + "us-west-1-fips": endpoint{ + Hostname: "guardduty-fips.us-west-1.amazonaws.com", + CredentialScope: credentialScope{ + Region: "us-west-1", + }, + }, + "us-west-2": endpoint{}, + "us-west-2-fips": endpoint{ + Hostname: "guardduty-fips.us-west-2.amazonaws.com", + CredentialScope: credentialScope{ + Region: "us-west-2", + }, + }, }, }, "health": service{ @@ -1960,11 +2012,14 @@ var awsPartition = partition{ Endpoints: endpoints{ "ap-northeast-1": endpoint{}, "ap-northeast-2": endpoint{}, + "ap-south-1": endpoint{}, "ap-southeast-1": endpoint{}, "ap-southeast-2": endpoint{}, "eu-central-1": endpoint{}, + "eu-north-1": endpoint{}, "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, + "eu-west-3": endpoint{}, "us-east-1": endpoint{}, "us-east-2": endpoint{}, "us-west-2": endpoint{}, @@ -2004,6 +2059,16 @@ var awsPartition = partition{ "us-west-2": endpoint{}, }, }, + "lakeformation": service{ + + Endpoints: endpoints{ + "ap-northeast-1": endpoint{}, + "eu-west-1": endpoint{}, + "us-east-1": endpoint{}, + "us-east-2": endpoint{}, + "us-west-2": endpoint{}, + }, + }, "lambda": service{ Endpoints: endpoints{ @@ -2042,6 +2107,7 @@ var awsPartition = partition{ "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, "eu-west-3": endpoint{}, + "me-south-1": endpoint{}, "sa-east-1": endpoint{}, "us-east-1": endpoint{}, "us-east-2": endpoint{}, @@ -2112,6 +2178,7 @@ var awsPartition = partition{ "ap-southeast-1": endpoint{}, "ap-southeast-2": endpoint{}, "eu-central-1": endpoint{}, + "eu-north-1": endpoint{}, "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, "eu-west-3": endpoint{}, @@ -2465,6 +2532,16 @@ var awsPartition = partition{ "us-west-2": endpoint{}, }, }, + "qldb": service{ + + Endpoints: endpoints{ + "ap-northeast-1": endpoint{}, + "eu-west-1": endpoint{}, + "us-east-1": endpoint{}, + "us-east-2": endpoint{}, + "us-west-2": endpoint{}, + }, + }, "ram": service{ Endpoints: endpoints{ @@ -2640,6 +2717,7 @@ var awsPartition = partition{ "runtime.sagemaker": service{ Endpoints: endpoints{ + "ap-east-1": endpoint{}, "ap-northeast-1": endpoint{}, "ap-northeast-2": endpoint{}, "ap-south-1": endpoint{}, @@ -2647,8 +2725,11 @@ var awsPartition = partition{ "ap-southeast-2": endpoint{}, "ca-central-1": endpoint{}, "eu-central-1": endpoint{}, + "eu-north-1": endpoint{}, "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, + "eu-west-3": endpoint{}, + "sa-east-1": endpoint{}, "us-east-1": endpoint{}, "us-east-1-fips": endpoint{ Hostname: "runtime-fips.sagemaker.us-east-1.amazonaws.com", @@ -3097,6 +3178,16 @@ var awsPartition = partition{ "us-west-2": endpoint{}, }, }, + "session.qldb": service{ + + Endpoints: endpoints{ + "ap-northeast-1": endpoint{}, + "eu-west-1": endpoint{}, + "us-east-1": endpoint{}, + "us-east-2": endpoint{}, + "us-west-2": endpoint{}, + }, + }, "shield": service{ IsRegionalized: boxedFalse, Defaults: endpoint{ @@ -3122,6 +3213,7 @@ var awsPartition = partition{ "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, "eu-west-3": endpoint{}, + "me-south-1": endpoint{}, "sa-east-1": endpoint{}, "us-east-1": endpoint{}, "us-east-2": endpoint{}, @@ -3275,6 +3367,7 @@ var awsPartition = partition{ "storagegateway": service{ Endpoints: endpoints{ + "ap-east-1": endpoint{}, "ap-northeast-1": endpoint{}, "ap-northeast-2": endpoint{}, "ap-south-1": endpoint{}, @@ -3495,9 +3588,11 @@ var awsPartition = partition{ "ap-southeast-2": endpoint{}, "ca-central-1": endpoint{}, "eu-central-1": endpoint{}, + "eu-north-1": endpoint{}, "eu-west-1": endpoint{}, "eu-west-2": endpoint{}, "eu-west-3": endpoint{}, + "sa-east-1": endpoint{}, "us-east-1": endpoint{}, "us-east-2": endpoint{}, "us-west-1": endpoint{}, @@ -3920,7 +4015,8 @@ var awscnPartition = partition{ }, }, Endpoints: endpoints{ - "cn-north-1": endpoint{}, + "cn-north-1": endpoint{}, + "cn-northwest-1": endpoint{}, }, }, "kinesis": service{ @@ -4500,6 +4596,13 @@ var awsusgovPartition = partition{ "us-gov-west-1": endpoint{}, }, }, + "health": service{ + + Endpoints: endpoints{ + "us-gov-east-1": endpoint{}, + "us-gov-west-1": endpoint{}, + }, + }, "iam": service{ PartitionEndpoint: "aws-us-gov-global", IsRegionalized: boxedFalse, @@ -4595,6 +4698,23 @@ var awsusgovPartition = partition{ "us-gov-west-1": endpoint{}, }, }, + "neptune": service{ + + Endpoints: endpoints{ + "us-gov-east-1": endpoint{ + Hostname: "rds.us-gov-east-1.amazonaws.com", + CredentialScope: credentialScope{ + Region: "us-gov-east-1", + }, + }, + "us-gov-west-1": endpoint{ + Hostname: "rds.us-gov-west-1.amazonaws.com", + CredentialScope: credentialScope{ + Region: "us-gov-west-1", + }, + }, + }, + }, "organizations": service{ PartitionEndpoint: "aws-us-gov-global", IsRegionalized: boxedFalse, @@ -4617,6 +4737,7 @@ var awsusgovPartition = partition{ "ram": service{ Endpoints: endpoints{ + "us-gov-east-1": endpoint{}, "us-gov-west-1": endpoint{}, }, }, @@ -4640,6 +4761,19 @@ var awsusgovPartition = partition{ "us-gov-west-1": endpoint{}, }, }, + "route53": service{ + PartitionEndpoint: "aws-us-gov-global", + IsRegionalized: boxedFalse, + + Endpoints: endpoints{ + "aws-us-gov-global": endpoint{ + Hostname: "route53.us-gov.amazonaws.com", + CredentialScope: credentialScope{ + Region: "us-gov-west-1", + }, + }, + }, + }, "runtime.sagemaker": service{ Endpoints: endpoints{ @@ -4720,6 +4854,9 @@ var awsusgovPartition = partition{ Protocols: []string{"https"}, }, Endpoints: endpoints{ + "us-gov-east-1": endpoint{ + Protocols: []string{"https"}, + }, "us-gov-west-1": endpoint{ Protocols: []string{"https"}, }, @@ -4850,3 +4987,599 @@ var awsusgovPartition = partition{ }, }, } + +// AwsIsoPartition returns the Resolver for AWS ISO (US). +func AwsIsoPartition() Partition { + return awsisoPartition.Partition() +} + +var awsisoPartition = partition{ + ID: "aws-iso", + Name: "AWS ISO (US)", + DNSSuffix: "c2s.ic.gov", + RegionRegex: regionRegex{ + Regexp: func() *regexp.Regexp { + reg, _ := regexp.Compile("^us\\-iso\\-\\w+\\-\\d+$") + return reg + }(), + }, + Defaults: endpoint{ + Hostname: "{service}.{region}.{dnsSuffix}", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + Regions: regions{ + "us-iso-east-1": region{ + Description: "US ISO East", + }, + }, + Services: services{ + "api.ecr": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{ + Hostname: "api.ecr.us-iso-east-1.c2s.ic.gov", + CredentialScope: credentialScope{ + Region: "us-iso-east-1", + }, + }, + }, + }, + "application-autoscaling": service{ + Defaults: endpoint{ + Hostname: "autoscaling.{region}.amazonaws.com", + Protocols: []string{"http", "https"}, + CredentialScope: credentialScope{ + Service: "application-autoscaling", + }, + }, + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "autoscaling": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{ + Protocols: []string{"http", "https"}, + }, + }, + }, + "cloudformation": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "cloudtrail": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "codedeploy": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "config": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "datapipeline": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "directconnect": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "dms": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "ds": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "dynamodb": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{ + Protocols: []string{"http", "https"}, + }, + }, + }, + "ec2": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "ec2metadata": service{ + PartitionEndpoint: "aws-global", + IsRegionalized: boxedFalse, + + Endpoints: endpoints{ + "aws-global": endpoint{ + Hostname: "169.254.169.254/latest", + Protocols: []string{"http"}, + }, + }, + }, + "ecs": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "elasticache": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "elasticloadbalancing": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{ + Protocols: []string{"http", "https"}, + }, + }, + }, + "elasticmapreduce": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{ + Protocols: []string{"https"}, + }, + }, + }, + "events": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "glacier": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{ + Protocols: []string{"http", "https"}, + }, + }, + }, + "health": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "iam": service{ + PartitionEndpoint: "aws-iso-global", + IsRegionalized: boxedFalse, + + Endpoints: endpoints{ + "aws-iso-global": endpoint{ + Hostname: "iam.us-iso-east-1.c2s.ic.gov", + CredentialScope: credentialScope{ + Region: "us-iso-east-1", + }, + }, + }, + }, + "kinesis": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "kms": service{ + + Endpoints: endpoints{ + "ProdFips": endpoint{ + Hostname: "kms-fips.us-iso-east-1.c2s.ic.gov", + CredentialScope: credentialScope{ + Region: "us-iso-east-1", + }, + }, + "us-iso-east-1": endpoint{}, + }, + }, + "lambda": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "logs": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "monitoring": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "rds": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "redshift": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "s3": service{ + Defaults: endpoint{ + SignatureVersions: []string{"s3v4"}, + }, + Endpoints: endpoints{ + "us-iso-east-1": endpoint{ + Protocols: []string{"http", "https"}, + SignatureVersions: []string{"s3v4"}, + }, + }, + }, + "snowball": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "sns": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{ + Protocols: []string{"http", "https"}, + }, + }, + }, + "sqs": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{ + Protocols: []string{"http", "https"}, + }, + }, + }, + "states": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "streams.dynamodb": service{ + Defaults: endpoint{ + Protocols: []string{"http", "https"}, + CredentialScope: credentialScope{ + Service: "dynamodb", + }, + }, + Endpoints: endpoints{ + "us-iso-east-1": endpoint{ + Protocols: []string{"http", "https"}, + }, + }, + }, + "sts": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "support": service{ + PartitionEndpoint: "aws-iso-global", + + Endpoints: endpoints{ + "aws-iso-global": endpoint{ + Hostname: "support.us-iso-east-1.c2s.ic.gov", + CredentialScope: credentialScope{ + Region: "us-iso-east-1", + }, + }, + }, + }, + "swf": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + "workspaces": service{ + + Endpoints: endpoints{ + "us-iso-east-1": endpoint{}, + }, + }, + }, +} + +// AwsIsoBPartition returns the Resolver for AWS ISOB (US). +func AwsIsoBPartition() Partition { + return awsisobPartition.Partition() +} + +var awsisobPartition = partition{ + ID: "aws-iso-b", + Name: "AWS ISOB (US)", + DNSSuffix: "sc2s.sgov.gov", + RegionRegex: regionRegex{ + Regexp: func() *regexp.Regexp { + reg, _ := regexp.Compile("^us\\-isob\\-\\w+\\-\\d+$") + return reg + }(), + }, + Defaults: endpoint{ + Hostname: "{service}.{region}.{dnsSuffix}", + Protocols: []string{"https"}, + SignatureVersions: []string{"v4"}, + }, + Regions: regions{ + "us-isob-east-1": region{ + Description: "US ISOB East (Ohio)", + }, + }, + Services: services{ + "application-autoscaling": service{ + Defaults: endpoint{ + Hostname: "autoscaling.{region}.amazonaws.com", + Protocols: []string{"http", "https"}, + CredentialScope: credentialScope{ + Service: "application-autoscaling", + }, + }, + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "autoscaling": service{ + Defaults: endpoint{ + Protocols: []string{"http", "https"}, + }, + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "cloudformation": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "cloudtrail": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "config": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "directconnect": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "dms": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "dynamodb": service{ + Defaults: endpoint{ + Protocols: []string{"http", "https"}, + }, + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "ec2": service{ + Defaults: endpoint{ + Protocols: []string{"http", "https"}, + }, + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "ec2metadata": service{ + PartitionEndpoint: "aws-global", + IsRegionalized: boxedFalse, + + Endpoints: endpoints{ + "aws-global": endpoint{ + Hostname: "169.254.169.254/latest", + Protocols: []string{"http"}, + }, + }, + }, + "elasticache": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "elasticloadbalancing": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{ + Protocols: []string{"https"}, + }, + }, + }, + "elasticmapreduce": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "events": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "glacier": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "health": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "iam": service{ + PartitionEndpoint: "aws-iso-b-global", + IsRegionalized: boxedFalse, + + Endpoints: endpoints{ + "aws-iso-b-global": endpoint{ + Hostname: "iam.us-isob-east-1.sc2s.sgov.gov", + CredentialScope: credentialScope{ + Region: "us-isob-east-1", + }, + }, + }, + }, + "kinesis": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "kms": service{ + + Endpoints: endpoints{ + "ProdFips": endpoint{ + Hostname: "kms-fips.us-isob-east-1.sc2s.sgov.gov", + CredentialScope: credentialScope{ + Region: "us-isob-east-1", + }, + }, + "us-isob-east-1": endpoint{}, + }, + }, + "logs": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "monitoring": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "rds": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "redshift": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "s3": service{ + Defaults: endpoint{ + Protocols: []string{"http", "https"}, + SignatureVersions: []string{"s3v4"}, + }, + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "snowball": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "sns": service{ + Defaults: endpoint{ + Protocols: []string{"http", "https"}, + }, + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "sqs": service{ + Defaults: endpoint{ + SSLCommonName: "{region}.queue.{dnsSuffix}", + Protocols: []string{"http", "https"}, + }, + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "states": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "streams.dynamodb": service{ + Defaults: endpoint{ + Protocols: []string{"http", "https"}, + CredentialScope: credentialScope{ + Service: "dynamodb", + }, + }, + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "sts": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + "support": service{ + PartitionEndpoint: "aws-iso-b-global", + + Endpoints: endpoints{ + "aws-iso-b-global": endpoint{ + Hostname: "support.us-isob-east-1.sc2s.sgov.gov", + CredentialScope: credentialScope{ + Region: "us-isob-east-1", + }, + }, + }, + }, + "swf": service{ + + Endpoints: endpoints{ + "us-isob-east-1": endpoint{}, + }, + }, + }, +} diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/request.go b/vendor/github.com/aws/aws-sdk-go/aws/request/request.go index e7c9b2b61a..8e332cce6a 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/request/request.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/request.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "net" "net/http" "net/url" "reflect" @@ -65,6 +64,15 @@ type Request struct { LastSignedAt time.Time DisableFollowRedirects bool + // Additional API error codes that should be retried. IsErrorRetryable + // will consider these codes in addition to its built in cases. + RetryErrorCodes []string + + // Additional API error codes that should be retried with throttle backoff + // delay. IsErrorThrottle will consider these codes in addition to its + // built in cases. + ThrottleErrorCodes []string + // A value greater than 0 instructs the request to be signed as Presigned URL // You should not set this field directly. Instead use Request's // Presign or PresignRequest methods. @@ -498,21 +506,17 @@ func (r *Request) Send() error { if err := r.sendRequest(); err == nil { return nil - } else if !shouldRetryError(r.Error) { + } + r.Handlers.Retry.Run(r) + r.Handlers.AfterRetry.Run(r) + + if r.Error != nil || !aws.BoolValue(r.Retryable) { + return r.Error + } + + if err := r.prepareRetry(); err != nil { + r.Error = err return err - } else { - r.Handlers.Retry.Run(r) - r.Handlers.AfterRetry.Run(r) - - if r.Error != nil || !aws.BoolValue(r.Retryable) { - return r.Error - } - - if err := r.prepareRetry(); err != nil { - r.Error = err - return err - } - continue } } } @@ -596,51 +600,6 @@ func AddToUserAgent(r *Request, s string) { r.HTTPRequest.Header.Set("User-Agent", s) } -type temporary interface { - Temporary() bool -} - -func shouldRetryError(origErr error) bool { - switch err := origErr.(type) { - case awserr.Error: - if err.Code() == CanceledErrorCode { - return false - } - return shouldRetryError(err.OrigErr()) - case *url.Error: - if strings.Contains(err.Error(), "connection refused") { - // Refused connections should be retried as the service may not yet - // be running on the port. Go TCP dial considers refused - // connections as not temporary. - return true - } - // *url.Error only implements Temporary after golang 1.6 but since - // url.Error only wraps the error: - return shouldRetryError(err.Err) - case temporary: - if netErr, ok := err.(*net.OpError); ok && netErr.Op == "dial" { - return true - } - // If the error is temporary, we want to allow continuation of the - // retry process - return err.Temporary() || isErrConnectionReset(origErr) - case nil: - // `awserr.Error.OrigErr()` can be nil, meaning there was an error but - // because we don't know the cause, it is marked as retryable. See - // TestRequest4xxUnretryable for an example. - return true - default: - switch err.Error() { - case "net/http: request canceled", - "net/http: request canceled while waiting for connection": - // known 1.5 error case when an http request is cancelled - return false - } - // here we don't know the error; so we allow a retry. - return true - } -} - // SanitizeHostForHeader removes default port from host and updates request.Host func SanitizeHostForHeader(r *http.Request) { host := getHost(r) diff --git a/vendor/github.com/aws/aws-sdk-go/aws/request/retryer.go b/vendor/github.com/aws/aws-sdk-go/aws/request/retryer.go index d0aa54c6d1..c4e659b01d 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/request/retryer.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/request/retryer.go @@ -1,23 +1,41 @@ package request import ( + "net" + "net/url" + "strings" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" ) -// Retryer is an interface to control retry logic for a given service. -// The default implementation used by most services is the client.DefaultRetryer -// structure, which contains basic retry logic using exponential backoff. +// Retryer provides the interface drive the SDK's request retry behavior. The +// Retryer implementation is responsible for implementing exponential backoff, +// and determine if a request API error should be retried. +// +// client.DefaultRetryer is the SDK's default implementation of the Retryer. It +// uses the which uses the Request.IsErrorRetryable and Request.IsErrorThrottle +// methods to determine if the request is retried. type Retryer interface { + // RetryRules return the retry delay that should be used by the SDK before + // making another request attempt for the failed request. RetryRules(*Request) time.Duration + + // ShouldRetry returns if the failed request is retryable. + // + // Implementations may consider request attempt count when determining if a + // request is retryable, but the SDK will use MaxRetries to limit the + // number of attempts a request are made. ShouldRetry(*Request) bool + + // MaxRetries is the number of times a request may be retried before + // failing. MaxRetries() int } -// WithRetryer sets a config Retryer value to the given Config returning it -// for chaining. +// WithRetryer sets a Retryer value to the given Config returning the Config +// value for chaining. func WithRetryer(cfg *aws.Config, retryer Retryer) *aws.Config { cfg.Retryer = retryer return cfg @@ -108,32 +126,90 @@ func isNestedErrorRetryable(parentErr awserr.Error) bool { // IsErrorRetryable returns whether the error is retryable, based on its Code. // Returns false if error is nil. func IsErrorRetryable(err error) bool { - if err != nil { - if aerr, ok := err.(awserr.Error); ok { - return isCodeRetryable(aerr.Code()) || isNestedErrorRetryable(aerr) + if err == nil { + return false + } + return shouldRetryError(err) +} + +type temporary interface { + Temporary() bool +} + +func shouldRetryError(origErr error) bool { + switch err := origErr.(type) { + case awserr.Error: + if err.Code() == CanceledErrorCode { + return false + } + if isNestedErrorRetryable(err) { + return true + } + + origErr := err.OrigErr() + var shouldRetry bool + if origErr != nil { + shouldRetry := shouldRetryError(origErr) + if err.Code() == "RequestError" && !shouldRetry { + return false + } + } + if isCodeRetryable(err.Code()) { + return true + } + return shouldRetry + + case *url.Error: + if strings.Contains(err.Error(), "connection refused") { + // Refused connections should be retried as the service may not yet + // be running on the port. Go TCP dial considers refused + // connections as not temporary. + return true + } + // *url.Error only implements Temporary after golang 1.6 but since + // url.Error only wraps the error: + return shouldRetryError(err.Err) + + case temporary: + if netErr, ok := err.(*net.OpError); ok && netErr.Op == "dial" { + return true + } + // If the error is temporary, we want to allow continuation of the + // retry process + return err.Temporary() || isErrConnectionReset(origErr) + + case nil: + // `awserr.Error.OrigErr()` can be nil, meaning there was an error but + // because we don't know the cause, it is marked as retryable. See + // TestRequest4xxUnretryable for an example. + return true + + default: + switch err.Error() { + case "net/http: request canceled", + "net/http: request canceled while waiting for connection": + // known 1.5 error case when an http request is cancelled + return false } + // here we don't know the error; so we allow a retry. + return true } - return false } // IsErrorThrottle returns whether the error is to be throttled based on its code. // Returns false if error is nil. func IsErrorThrottle(err error) bool { - if err != nil { - if aerr, ok := err.(awserr.Error); ok { - return isCodeThrottle(aerr.Code()) - } + if aerr, ok := err.(awserr.Error); ok && aerr != nil { + return isCodeThrottle(aerr.Code()) } return false } -// IsErrorExpiredCreds returns whether the error code is a credential expiry error. -// Returns false if error is nil. +// IsErrorExpiredCreds returns whether the error code is a credential expiry +// error. Returns false if error is nil. func IsErrorExpiredCreds(err error) bool { - if err != nil { - if aerr, ok := err.(awserr.Error); ok { - return isCodeExpiredCreds(aerr.Code()) - } + if aerr, ok := err.(awserr.Error); ok && aerr != nil { + return isCodeExpiredCreds(aerr.Code()) } return false } @@ -143,17 +219,44 @@ func IsErrorExpiredCreds(err error) bool { // // Alias for the utility function IsErrorRetryable func (r *Request) IsErrorRetryable() bool { + if isErrCode(r.Error, r.RetryErrorCodes) { + return true + } + return IsErrorRetryable(r.Error) } -// IsErrorThrottle returns whether the error is to be throttled based on its code. -// Returns false if the request has no Error set +// IsErrorThrottle returns whether the error is to be throttled based on its +// code. Returns false if the request has no Error set. // // Alias for the utility function IsErrorThrottle func (r *Request) IsErrorThrottle() bool { + if isErrCode(r.Error, r.ThrottleErrorCodes) { + return true + } + + if r.HTTPResponse != nil { + switch r.HTTPResponse.StatusCode { + case 429, 502, 503, 504: + return true + } + } + return IsErrorThrottle(r.Error) } +func isErrCode(err error, codes []string) bool { + if aerr, ok := err.(awserr.Error); ok && aerr != nil { + for _, code := range codes { + if code == aerr.Code() { + return true + } + } + } + + return false +} + // IsErrorExpired returns whether the error code is a credential expiry error. // Returns false if the request has no Error set. // diff --git a/vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go b/vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go index 3a998d5bd6..60a6f9ce2a 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/session/env_config.go @@ -99,10 +99,10 @@ type envConfig struct { CustomCABundle string csmEnabled string - CSMEnabled bool + CSMEnabled *bool CSMPort string - CSMClientID string CSMHost string + CSMClientID string // Enables endpoint discovery via environment variables. // @@ -230,7 +230,11 @@ func envConfigLoad(enableSharedConfig bool) envConfig { setFromEnvVal(&cfg.CSMHost, csmHostEnvKey) setFromEnvVal(&cfg.CSMPort, csmPortEnvKey) setFromEnvVal(&cfg.CSMClientID, csmClientIDEnvKey) - cfg.CSMEnabled = len(cfg.csmEnabled) > 0 + + if len(cfg.csmEnabled) != 0 { + v, _ := strconv.ParseBool(cfg.csmEnabled) + cfg.CSMEnabled = &v + } regionKeys := regionEnvKeys profileKeys := profileEnvKeys diff --git a/vendor/github.com/aws/aws-sdk-go/aws/session/session.go b/vendor/github.com/aws/aws-sdk-go/aws/session/session.go index 1b4fcdb10e..fa1362ff74 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/session/session.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/session/session.go @@ -104,9 +104,13 @@ func New(cfgs ...*aws.Config) *Session { } s := deprecatedNewSession(cfgs...) - if envCfg.CSMEnabled { - err := enableCSM(&s.Handlers, envCfg.CSMClientID, - envCfg.CSMHost, envCfg.CSMPort, s.Config.Logger) + + if csmCfg, err := loadCSMConfig(envCfg, []string{}); err != nil { + if l := s.Config.Logger; l != nil { + l.Log(fmt.Sprintf("ERROR: failed to load CSM configuration, %v", err)) + } + } else if csmCfg.Enabled { + err := enableCSM(&s.Handlers, csmCfg, s.Config.Logger) if err != nil { err = fmt.Errorf("failed to enable CSM, %v", err) s.Config.Logger.Log("ERROR:", err.Error()) @@ -347,15 +351,12 @@ func deprecatedNewSession(cfgs ...*aws.Config) *Session { return s } -func enableCSM(handlers *request.Handlers, - clientID, host, port string, - logger aws.Logger, -) error { +func enableCSM(handlers *request.Handlers, cfg csmConfig, logger aws.Logger) error { if logger != nil { logger.Log("Enabling CSM") } - r, err := csm.Start(clientID, csm.AddressWithDefaults(host, port)) + r, err := csm.Start(cfg.ClientID, csm.AddressWithDefaults(cfg.Host, cfg.Port)) if err != nil { return err } @@ -395,7 +396,13 @@ func newSession(opts Options, envCfg envConfig, cfgs ...*aws.Config) (*Session, // Load additional config from file(s) sharedCfg, err := loadSharedConfig(envCfg.Profile, cfgFiles, envCfg.EnableSharedConfig) if err != nil { - if _, ok := err.(SharedConfigProfileNotExistsError); !ok { + if len(envCfg.Profile) == 0 && !envCfg.EnableSharedConfig && (envCfg.Creds.HasKeys() || userCfg.Credentials != nil) { + // Special case where the user has not explicitly specified an AWS_PROFILE, + // or session.Options.profile, shared config is not enabled, and the + // environment has credentials, allow the shared config file to fail to + // load since the user has already provided credentials, and nothing else + // is required to be read file. Github(aws/aws-sdk-go#2455) + } else if _, ok := err.(SharedConfigProfileNotExistsError); !ok { return nil, err } } @@ -410,9 +417,13 @@ func newSession(opts Options, envCfg envConfig, cfgs ...*aws.Config) (*Session, } initHandlers(s) - if envCfg.CSMEnabled { - err := enableCSM(&s.Handlers, envCfg.CSMClientID, - envCfg.CSMHost, envCfg.CSMPort, s.Config.Logger) + + if csmCfg, err := loadCSMConfig(envCfg, cfgFiles); err != nil { + if l := s.Config.Logger; l != nil { + l.Log(fmt.Sprintf("ERROR: failed to load CSM configuration, %v", err)) + } + } else if csmCfg.Enabled { + err = enableCSM(&s.Handlers, csmCfg, s.Config.Logger) if err != nil { return nil, err } @@ -428,6 +439,46 @@ func newSession(opts Options, envCfg envConfig, cfgs ...*aws.Config) (*Session, return s, nil } +type csmConfig struct { + Enabled bool + Host string + Port string + ClientID string +} + +var csmProfileName = "aws_csm" + +func loadCSMConfig(envCfg envConfig, cfgFiles []string) (csmConfig, error) { + if envCfg.CSMEnabled != nil { + if *envCfg.CSMEnabled { + return csmConfig{ + Enabled: true, + ClientID: envCfg.CSMClientID, + Host: envCfg.CSMHost, + Port: envCfg.CSMPort, + }, nil + } + return csmConfig{}, nil + } + + sharedCfg, err := loadSharedConfig(csmProfileName, cfgFiles, false) + if err != nil { + if _, ok := err.(SharedConfigProfileNotExistsError); !ok { + return csmConfig{}, err + } + } + if sharedCfg.CSMEnabled != nil && *sharedCfg.CSMEnabled == true { + return csmConfig{ + Enabled: true, + ClientID: sharedCfg.CSMClientID, + Host: sharedCfg.CSMHost, + Port: sharedCfg.CSMPort, + }, nil + } + + return csmConfig{}, nil +} + func loadCustomCABundle(s *Session, bundle io.Reader) error { var t *http.Transport switch v := s.Config.HTTPClient.Transport.(type) { diff --git a/vendor/github.com/aws/aws-sdk-go/aws/session/shared_config.go b/vendor/github.com/aws/aws-sdk-go/aws/session/shared_config.go index 5170b4982e..d91ac93a54 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/session/shared_config.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/session/shared_config.go @@ -22,6 +22,12 @@ const ( mfaSerialKey = `mfa_serial` // optional roleSessionNameKey = `role_session_name` // optional + // CSM options + csmEnabledKey = `csm_enabled` + csmHostKey = `csm_host` + csmPortKey = `csm_port` + csmClientIDKey = `csm_client_id` + // Additional Config fields regionKey = `region` @@ -76,6 +82,12 @@ type sharedConfig struct { // // endpoint_discovery_enabled = true EnableEndpointDiscovery *bool + + // CSM Options + CSMEnabled *bool + CSMHost string + CSMPort string + CSMClientID string } type sharedConfigFile struct { @@ -251,10 +263,13 @@ func (cfg *sharedConfig) setFromIniFile(profile string, file sharedConfigFile, e } // Endpoint discovery - if section.Has(enableEndpointDiscoveryKey) { - v := section.Bool(enableEndpointDiscoveryKey) - cfg.EnableEndpointDiscovery = &v - } + updateBoolPtr(&cfg.EnableEndpointDiscovery, section, enableEndpointDiscoveryKey) + + // CSM options + updateBoolPtr(&cfg.CSMEnabled, section, csmEnabledKey) + updateString(&cfg.CSMHost, section, csmHostKey) + updateString(&cfg.CSMPort, section, csmPortKey) + updateString(&cfg.CSMClientID, section, csmClientIDKey) return nil } @@ -348,6 +363,16 @@ func updateString(dst *string, section ini.Section, key string) { *dst = section.String(key) } +// updateBoolPtr will only update the dst with the value in the section key, +// key is present in the section. +func updateBoolPtr(dst **bool, section ini.Section, key string) { + if !section.Has(key) { + return + } + *dst = new(bool) + **dst = section.Bool(key) +} + // SharedConfigLoadError is an error for the shared config file failed to load. type SharedConfigLoadError struct { Filename string diff --git a/vendor/github.com/aws/aws-sdk-go/aws/version.go b/vendor/github.com/aws/aws-sdk-go/aws/version.go index 973b1a4a8d..536ac0c996 100644 --- a/vendor/github.com/aws/aws-sdk-go/aws/version.go +++ b/vendor/github.com/aws/aws-sdk-go/aws/version.go @@ -5,4 +5,4 @@ package aws const SDKName = "aws-sdk-go" // SDKVersion is the version of this SDK -const SDKVersion = "1.22.1" +const SDKVersion = "1.23.20" diff --git a/vendor/github.com/aws/aws-sdk-go/internal/sdkmath/floor.go b/vendor/github.com/aws/aws-sdk-go/internal/sdkmath/floor.go new file mode 100644 index 0000000000..44898eed0f --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/internal/sdkmath/floor.go @@ -0,0 +1,15 @@ +// +build go1.10 + +package sdkmath + +import "math" + +// Round returns the nearest integer, rounding half away from zero. +// +// Special cases are: +// Round(±0) = ±0 +// Round(±Inf) = ±Inf +// Round(NaN) = NaN +func Round(x float64) float64 { + return math.Round(x) +} diff --git a/vendor/github.com/aws/aws-sdk-go/internal/sdkmath/floor_go1.9.go b/vendor/github.com/aws/aws-sdk-go/internal/sdkmath/floor_go1.9.go new file mode 100644 index 0000000000..810ec7f08b --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/internal/sdkmath/floor_go1.9.go @@ -0,0 +1,56 @@ +// +build !go1.10 + +package sdkmath + +import "math" + +// Copied from the Go standard library's (Go 1.12) math/floor.go for use in +// Go version prior to Go 1.10. +const ( + uvone = 0x3FF0000000000000 + mask = 0x7FF + shift = 64 - 11 - 1 + bias = 1023 + signMask = 1 << 63 + fracMask = 1<= 0.5 { + // return t + Copysign(1, x) + // } + // return t + // } + bits := math.Float64bits(x) + e := uint(bits>>shift) & mask + if e < bias { + // Round abs(x) < 1 including denormals. + bits &= signMask // +-0 + if e == bias-1 { + bits |= uvone // +-1 + } + } else if e < bias+shift { + // Round any abs(x) >= 1 containing a fractional component [0,1). + // + // Numbers with larger exponents are returned unchanged since they + // must be either an integer, infinity, or NaN. + const half = 1 << (shift - 1) + e -= bias + bits += half >> e + bits &^= fracMask >> e + } + return math.Float64frombits(bits) +} diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go index de021367da..74e361e070 100644 --- a/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/rest/unmarshal.go @@ -146,6 +146,9 @@ func unmarshalStatusCode(v reflect.Value, statusCode int) { } func unmarshalHeaderMap(r reflect.Value, headers http.Header, prefix string) error { + if len(headers) == 0 { + return nil + } switch r.Interface().(type) { case map[string]*string: // we only support string map value types out := map[string]*string{} @@ -155,19 +158,28 @@ func unmarshalHeaderMap(r reflect.Value, headers http.Header, prefix string) err out[k[len(prefix):]] = &v[0] } } - r.Set(reflect.ValueOf(out)) + if len(out) != 0 { + r.Set(reflect.ValueOf(out)) + } + } return nil } func unmarshalHeader(v reflect.Value, header string, tag reflect.StructTag) error { - isJSONValue := tag.Get("type") == "jsonvalue" - if isJSONValue { + switch tag.Get("type") { + case "jsonvalue": if len(header) == 0 { return nil } - } else if !v.IsValid() || (header == "" && v.Elem().Kind() != reflect.String) { - return nil + case "blob": + if len(header) == 0 { + return nil + } + default: + if !v.IsValid() || (header == "" && v.Elem().Kind() != reflect.String) { + return nil + } } switch v.Interface().(type) { @@ -178,7 +190,7 @@ func unmarshalHeader(v reflect.Value, header string, tag reflect.StructTag) erro if err != nil { return err } - v.Set(reflect.ValueOf(&b)) + v.Set(reflect.ValueOf(b)) case *bool: b, err := strconv.ParseBool(header) if err != nil { diff --git a/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go b/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go index b7ed6c6f81..05d4ff5192 100644 --- a/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go +++ b/vendor/github.com/aws/aws-sdk-go/private/protocol/timestamp.go @@ -1,8 +1,11 @@ package protocol import ( + "math" "strconv" "time" + + "github.com/aws/aws-sdk-go/internal/sdkmath" ) // Names of time formats supported by the SDK @@ -13,12 +16,19 @@ const ( ) // Time formats supported by the SDK +// Output time is intended to not contain decimals const ( // RFC 7231#section-7.1.1.1 timetamp format. e.g Tue, 29 Apr 2014 18:30:38 GMT RFC822TimeFormat = "Mon, 2 Jan 2006 15:04:05 GMT" + // This format is used for output time without seconds precision + RFC822OutputTimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT" + // RFC3339 a subset of the ISO8601 timestamp format. e.g 2014-04-29T18:30:38Z - ISO8601TimeFormat = "2006-01-02T15:04:05Z" + ISO8601TimeFormat = "2006-01-02T15:04:05.999999999Z" + + // This format is used for output time without seconds precision + ISO8601OutputTimeFormat = "2006-01-02T15:04:05Z" ) // IsKnownTimestampFormat returns if the timestamp format name @@ -42,9 +52,9 @@ func FormatTime(name string, t time.Time) string { switch name { case RFC822TimeFormatName: - return t.Format(RFC822TimeFormat) + return t.Format(RFC822OutputTimeFormat) case ISO8601TimeFormatName: - return t.Format(ISO8601TimeFormat) + return t.Format(ISO8601OutputTimeFormat) case UnixTimeFormatName: return strconv.FormatInt(t.Unix(), 10) default: @@ -62,10 +72,12 @@ func ParseTime(formatName, value string) (time.Time, error) { return time.Parse(ISO8601TimeFormat, value) case UnixTimeFormatName: v, err := strconv.ParseFloat(value, 64) + _, dec := math.Modf(v) + dec = sdkmath.Round(dec*1e3) / 1e3 //Rounds 0.1229999 to 0.123 if err != nil { return time.Time{}, err } - return time.Unix(int64(v), 0), nil + return time.Unix(int64(v), int64(dec*(1e9))), nil default: panic("unknown timestamp format name, " + formatName) } diff --git a/vendor/github.com/aws/aws-sdk-go/service/sts/customizations.go b/vendor/github.com/aws/aws-sdk-go/service/sts/customizations.go new file mode 100644 index 0000000000..d5307fcaa0 --- /dev/null +++ b/vendor/github.com/aws/aws-sdk-go/service/sts/customizations.go @@ -0,0 +1,11 @@ +package sts + +import "github.com/aws/aws-sdk-go/aws/request" + +func init() { + initRequest = customizeRequest +} + +func customizeRequest(r *request.Request) { + r.RetryErrorCodes = append(r.RetryErrorCodes, ErrCodeIDPCommunicationErrorException) +} diff --git a/vendor/github.com/gobuffalo/envy/.env b/vendor/github.com/gobuffalo/envy/.env deleted file mode 100644 index 33eeb3b13b..0000000000 --- a/vendor/github.com/gobuffalo/envy/.env +++ /dev/null @@ -1,5 +0,0 @@ -# This is a comment -# We can use equal or colon notation -DIR: root -FLAVOUR: none -INSIDE_FOLDER=false \ No newline at end of file diff --git a/vendor/github.com/gobuffalo/envy/.gitignore b/vendor/github.com/gobuffalo/envy/.gitignore deleted file mode 100644 index 3689718594..0000000000 --- a/vendor/github.com/gobuffalo/envy/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -*.log -.DS_Store -doc -tmp -pkg -*.gem -*.pid -coverage -coverage.data -build/* -*.pbxuser -*.mode1v3 -.svn -profile -.console_history -.sass-cache/* -.rake_tasks~ -*.log.lck -solr/ -.jhw-cache/ -jhw.* -*.sublime* -node_modules/ -dist/ -generated/ -.vendor/ -bin/* -gin-bin -.idea/ diff --git a/vendor/github.com/gobuffalo/envy/.gometalinter.json b/vendor/github.com/gobuffalo/envy/.gometalinter.json deleted file mode 100644 index e4f65a36e8..0000000000 --- a/vendor/github.com/gobuffalo/envy/.gometalinter.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Enable": ["vet", "golint", "goimports", "deadcode", "gotype", "ineffassign", "misspell", "nakedret", "unconvert", "megacheck", "varcheck"] -} diff --git a/vendor/github.com/gobuffalo/envy/.travis.yml b/vendor/github.com/gobuffalo/envy/.travis.yml deleted file mode 100644 index cf1d2c7d42..0000000000 --- a/vendor/github.com/gobuffalo/envy/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: go - -sudo: false - -matrix: - include: - - go: "1.9.x" - - go: "1.10.x" - - go: "1.11.x" - env: - - GO111MODULE=off - - go: "1.11.x" - env: - - GO111MODULE=on - - go: "tip" - env: - - GO111MODULE=off - - go: "tip" - env: - - GO111MODULE=on - allow_failures: - - go: "tip" - -install: make deps - -script: make ci-test diff --git a/vendor/github.com/gobuffalo/envy/LICENSE.txt b/vendor/github.com/gobuffalo/envy/LICENSE.txt deleted file mode 100644 index 123ddc0d80..0000000000 --- a/vendor/github.com/gobuffalo/envy/LICENSE.txt +++ /dev/null @@ -1,8 +0,0 @@ -The MIT License (MIT) -Copyright (c) 2018 Mark Bates - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/gobuffalo/envy/Makefile b/vendor/github.com/gobuffalo/envy/Makefile deleted file mode 100644 index b0db1c4f88..0000000000 --- a/vendor/github.com/gobuffalo/envy/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -TAGS ?= "sqlite" -GO_BIN ?= go - -install: - packr - $(GO_BIN) install -v . - -deps: - $(GO_BIN) get github.com/gobuffalo/release - $(GO_BIN) get github.com/gobuffalo/packr/packr - $(GO_BIN) get -tags ${TAGS} -t ./... -ifeq ($(GO111MODULE),on) - $(GO_BIN) mod tidy -endif - -build: - packr - $(GO_BIN) build -v . - -test: - packr - $(GO_BIN) test -tags ${TAGS} ./... - -ci-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - -lint: - gometalinter --vendor ./... --deadline=1m --skip=internal - -update: - $(GO_BIN) get -u -tags ${TAGS} -ifeq ($(GO111MODULE),on) - $(GO_BIN) mod tidy -endif - packr - make test - make install -ifeq ($(GO111MODULE),on) - $(GO_BIN) mod tidy -endif - -release-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - -release: - release -y -f version.go diff --git a/vendor/github.com/gobuffalo/envy/README.md b/vendor/github.com/gobuffalo/envy/README.md deleted file mode 100644 index f54462a773..0000000000 --- a/vendor/github.com/gobuffalo/envy/README.md +++ /dev/null @@ -1,93 +0,0 @@ -# envy -[![Build Status](https://travis-ci.org/gobuffalo/envy.svg?branch=master)](https://travis-ci.org/gobuffalo/envy) - -Envy makes working with ENV variables in Go trivial. - -* Get ENV variables with default values. -* Set ENV variables safely without affecting the underlying system. -* Temporarily change ENV vars; useful for testing. -* Map all of the key/values in the ENV. -* Loads .env files (by using [godotenv](https://github.com/joho/godotenv/)) -* More! - -## Installation - -```text -$ go get -u github.com/gobuffalo/envy -``` - -## Usage - -```go -func Test_Get(t *testing.T) { - r := require.New(t) - r.NotZero(os.Getenv("GOPATH")) - r.Equal(os.Getenv("GOPATH"), envy.Get("GOPATH", "foo")) - r.Equal("bar", envy.Get("IDONTEXIST", "bar")) -} - -func Test_MustGet(t *testing.T) { - r := require.New(t) - r.NotZero(os.Getenv("GOPATH")) - v, err := envy.MustGet("GOPATH") - r.NoError(err) - r.Equal(os.Getenv("GOPATH"), v) - - _, err = envy.MustGet("IDONTEXIST") - r.Error(err) -} - -func Test_Set(t *testing.T) { - r := require.New(t) - _, err := envy.MustGet("FOO") - r.Error(err) - - envy.Set("FOO", "foo") - r.Equal("foo", envy.Get("FOO", "bar")) -} - -func Test_Temp(t *testing.T) { - r := require.New(t) - - _, err := envy.MustGet("BAR") - r.Error(err) - - envy.Temp(func() { - envy.Set("BAR", "foo") - r.Equal("foo", envy.Get("BAR", "bar")) - _, err = envy.MustGet("BAR") - r.NoError(err) - }) - - _, err = envy.MustGet("BAR") - r.Error(err) -} -``` -## .env files support - -Envy now supports loading `.env` files by using the [godotenv library](https://github.com/joho/godotenv/). -That means one can use and define multiple `.env` files which will be loaded on-demand. By default, no env files will be loaded. To load one or more, you need to call the `envy.Load` function in one of the following ways: - -```go -envy.Load() // 1 - -envy.Load("MY_ENV_FILE") // 2 - -envy.Load(".env", ".env.prod") // 3 - -envy.Load(".env", "NON_EXISTING_FILE") // 4 - -// 5 -envy.Load(".env") -envy.Load("NON_EXISTING_FILE") - -// 6 -envy.Load(".env", "NON_EXISTING_FILE", ".env.prod") -``` - -1. Will load the default `.env` file -2. Will load the file `MY_ENV_FILE`, **but not** `.env` -3. Will load the file `.env`, and after that will load the `.env.prod` file. If any variable is redefined in `. env.prod` it will be overwritten (will contain the `env.prod` value) -4. Will load the `.env` file and return an error as the second file does not exist. The values in `.env` will be loaded and available. -5. Same as 4 -6. Will load the `.env` file and return an error as the second file does not exist. The values in `.env` will be loaded and available, **but the ones in** `.env.prod` **won't**. diff --git a/vendor/github.com/gobuffalo/envy/envy.go b/vendor/github.com/gobuffalo/envy/envy.go deleted file mode 100644 index 2b6eae1bc3..0000000000 --- a/vendor/github.com/gobuffalo/envy/envy.go +++ /dev/null @@ -1,238 +0,0 @@ -/* -package envy makes working with ENV variables in Go trivial. - -* Get ENV variables with default values. -* Set ENV variables safely without affecting the underlying system. -* Temporarily change ENV vars; useful for testing. -* Map all of the key/values in the ENV. -* Loads .env files (by using [godotenv](https://github.com/joho/godotenv/)) -* More! -*/ -package envy - -import ( - "flag" - "fmt" - "os" - "os/exec" - "path/filepath" - "runtime" - "strconv" - "strings" - "sync" - - "github.com/joho/godotenv" -) - -var gil = &sync.RWMutex{} -var env = map[string]string{} - -func init() { - Load() - loadEnv() -} - -// Load the ENV variables to the env map -func loadEnv() { - gil.Lock() - defer gil.Unlock() - // Detect the Go version on the user system, not the one that was used to compile the binary - v := "" - out, err := exec.Command("go", "version").Output() - if err == nil { - // This will break when Go 2 lands - v = strings.Split(string(out), " ")[2][4:] - } else { - v = runtime.Version()[4:] - } - - goRuntimeVersion, _ := strconv.ParseFloat(runtime.Version()[4:], 64) - - goVersion, err := strconv.ParseFloat(v, 64) - if err != nil { - goVersion = goRuntimeVersion - } - - if os.Getenv("GO_ENV") == "" { - // if the flag "test.v" is *defined*, we're running as a unit test. Note that we don't care - // about v.Value (verbose test mode); we just want to know if the test environment has defined - // it. It's also possible that the flags are not yet fully parsed (i.e. flag.Parsed() == false), - // so we could not depend on v.Value anyway. - // - if v := flag.Lookup("test.v"); v != nil { - env["GO_ENV"] = "test" - } - } - - // set the GOPATH if using >= 1.8 and the GOPATH isn't set - if goVersion >= 8 && os.Getenv("GOPATH") == "" { - out, err := exec.Command("go", "env", "GOPATH").Output() - if err == nil { - gp := strings.TrimSpace(string(out)) - os.Setenv("GOPATH", gp) - } - } - - for _, e := range os.Environ() { - pair := strings.Split(e, "=") - env[pair[0]] = os.Getenv(pair[0]) - } -} - -// Reload the ENV variables. Useful if -// an external ENV manager has been used -func Reload() { - env = map[string]string{} - loadEnv() -} - -// Load .env files. Files will be loaded in the same order that are received. -// Redefined vars will override previously existing values. -// IE: envy.Load(".env", "test_env/.env") will result in DIR=test_env -// If no arg passed, it will try to load a .env file. -func Load(files ...string) error { - - // If no files received, load the default one - if len(files) == 0 { - err := godotenv.Overload() - if err == nil { - Reload() - } - return err - } - - // We received a list of files - for _, file := range files { - - // Check if it exists or we can access - if _, err := os.Stat(file); err != nil { - // It does not exist or we can not access. - // Return and stop loading - return err - } - - // It exists and we have permission. Load it - if err := godotenv.Overload(file); err != nil { - return err - } - - // Reload the env so all new changes are noticed - Reload() - - } - return nil -} - -// Get a value from the ENV. If it doesn't exist the -// default value will be returned. -func Get(key string, value string) string { - gil.RLock() - defer gil.RUnlock() - if v, ok := env[key]; ok { - return v - } - return value -} - -// Get a value from the ENV. If it doesn't exist -// an error will be returned -func MustGet(key string) (string, error) { - gil.RLock() - defer gil.RUnlock() - if v, ok := env[key]; ok { - return v, nil - } - return "", fmt.Errorf("could not find ENV var with %s", key) -} - -// Set a value into the ENV. This is NOT permanent. It will -// only affect values accessed through envy. -func Set(key string, value string) { - gil.Lock() - defer gil.Unlock() - env[key] = value -} - -// MustSet the value into the underlying ENV, as well as envy. -// This may return an error if there is a problem setting the -// underlying ENV value. -func MustSet(key string, value string) error { - gil.Lock() - defer gil.Unlock() - err := os.Setenv(key, value) - if err != nil { - return err - } - env[key] = value - return nil -} - -// Map all of the keys/values set in envy. -func Map() map[string]string { - gil.RLock() - defer gil.RUnlock() - cp := map[string]string{} - for k, v := range env { - cp[k] = v - } - return env -} - -// Temp makes a copy of the values and allows operation on -// those values temporarily during the run of the function. -// At the end of the function run the copy is discarded and -// the original values are replaced. This is useful for testing. -// Warning: This function is NOT safe to use from a goroutine or -// from code which may access any Get or Set function from a goroutine -func Temp(f func()) { - oenv := env - env = map[string]string{} - for k, v := range oenv { - env[k] = v - } - defer func() { env = oenv }() - f() -} - -func GoPath() string { - return Get("GOPATH", "") -} - -// GoPaths returns all possible GOPATHS that are set. -func GoPaths() []string { - gp := Get("GOPATH", "") - if runtime.GOOS == "windows" { - return strings.Split(gp, ";") // Windows uses a different separator - } - return strings.Split(gp, ":") -} - -func importPath(path string) string { - for _, gopath := range GoPaths() { - srcpath := filepath.Join(gopath, "src") - rel, err := filepath.Rel(srcpath, path) - if err == nil { - return filepath.ToSlash(rel) - } - } - - // fallback to trim - rel := strings.TrimPrefix(path, filepath.Join(GoPath(), "src")) - rel = strings.TrimPrefix(rel, string(filepath.Separator)) - return filepath.ToSlash(rel) -} - -func CurrentPackage() string { - pwd, _ := os.Getwd() - return importPath(pwd) -} - -func Environ() []string { - gil.RLock() - defer gil.RUnlock() - var e []string - for k, v := range env { - e = append(e, fmt.Sprintf("%s=%s", k, v)) - } - return e -} diff --git a/vendor/github.com/gobuffalo/envy/go.mod b/vendor/github.com/gobuffalo/envy/go.mod deleted file mode 100644 index 149e25a459..0000000000 --- a/vendor/github.com/gobuffalo/envy/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module github.com/gobuffalo/envy - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/joho/godotenv v1.3.0 - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.2.2 -) diff --git a/vendor/github.com/gobuffalo/envy/go.sum b/vendor/github.com/gobuffalo/envy/go.sum deleted file mode 100644 index 868dbe8d81..0000000000 --- a/vendor/github.com/gobuffalo/envy/go.sum +++ /dev/null @@ -1,8 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/vendor/github.com/gobuffalo/envy/shoulders.md b/vendor/github.com/gobuffalo/envy/shoulders.md deleted file mode 100644 index 0b22abc2a1..0000000000 --- a/vendor/github.com/gobuffalo/envy/shoulders.md +++ /dev/null @@ -1,10 +0,0 @@ -# github.com/gobuffalo/envy Stands on the Shoulders of Giants - -github.com/gobuffalo/envy does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants this project would not be possible. Please make sure to check them out and thank them for all of their hard work. - -Thank you to the following **GIANTS**: - - -* [github.com/gobuffalo/envy](https://godoc.org/github.com/gobuffalo/envy) - -* [github.com/joho/godotenv](https://godoc.org/github.com/joho/godotenv) diff --git a/vendor/github.com/gobuffalo/envy/version.go b/vendor/github.com/gobuffalo/envy/version.go deleted file mode 100644 index 8a3632fb18..0000000000 --- a/vendor/github.com/gobuffalo/envy/version.go +++ /dev/null @@ -1,3 +0,0 @@ -package envy - -const Version = "v1.6.5" diff --git a/vendor/github.com/hashicorp/golang-lru/go.mod b/vendor/github.com/hashicorp/golang-lru/go.mod index 8ad8826b36..824cb97e83 100644 --- a/vendor/github.com/hashicorp/golang-lru/go.mod +++ b/vendor/github.com/hashicorp/golang-lru/go.mod @@ -1,3 +1 @@ module github.com/hashicorp/golang-lru - -go 1.12 diff --git a/vendor/github.com/hashicorp/golang-lru/lru.go b/vendor/github.com/hashicorp/golang-lru/lru.go index 052a38b4c4..1cbe04b7d0 100644 --- a/vendor/github.com/hashicorp/golang-lru/lru.go +++ b/vendor/github.com/hashicorp/golang-lru/lru.go @@ -86,35 +86,17 @@ func (c *Cache) ContainsOrAdd(key, value interface{}) (ok, evicted bool) { } // Remove removes the provided key from the cache. -func (c *Cache) Remove(key interface{}) (present bool) { +func (c *Cache) Remove(key interface{}) { c.lock.Lock() - present = c.lru.Remove(key) + c.lru.Remove(key) c.lock.Unlock() - return -} - -// Resize changes the cache size. -func (c *Cache) Resize(size int) (evicted int) { - c.lock.Lock() - evicted = c.lru.Resize(size) - c.lock.Unlock() - return evicted } // RemoveOldest removes the oldest item from the cache. -func (c *Cache) RemoveOldest() (key interface{}, value interface{}, ok bool) { - c.lock.Lock() - key, value, ok = c.lru.RemoveOldest() - c.lock.Unlock() - return -} - -// GetOldest returns the oldest entry -func (c *Cache) GetOldest() (key interface{}, value interface{}, ok bool) { +func (c *Cache) RemoveOldest() { c.lock.Lock() - key, value, ok = c.lru.GetOldest() + c.lru.RemoveOldest() c.lock.Unlock() - return } // Keys returns a slice of the keys in the cache, from oldest to newest. diff --git a/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go b/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go index a86c8539e0..5673773b22 100644 --- a/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go +++ b/vendor/github.com/hashicorp/golang-lru/simplelru/lru.go @@ -73,9 +73,6 @@ func (c *LRU) Add(key, value interface{}) (evicted bool) { func (c *LRU) Get(key interface{}) (value interface{}, ok bool) { if ent, ok := c.items[key]; ok { c.evictList.MoveToFront(ent) - if ent.Value.(*entry) == nil { - return nil, false - } return ent.Value.(*entry).value, true } return @@ -145,19 +142,6 @@ func (c *LRU) Len() int { return c.evictList.Len() } -// Resize changes the cache size. -func (c *LRU) Resize(size int) (evicted int) { - diff := c.Len() - size - if diff < 0 { - diff = 0 - } - for i := 0; i < diff; i++ { - c.removeOldest() - } - c.size = size - return diff -} - // removeOldest removes the oldest item from the cache. func (c *LRU) removeOldest() { ent := c.evictList.Back() diff --git a/vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go b/vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go index 92d70934d6..74c7077440 100644 --- a/vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go +++ b/vendor/github.com/hashicorp/golang-lru/simplelru/lru_interface.go @@ -10,7 +10,7 @@ type LRUCache interface { // updates the "recently used"-ness of the key. #value, isFound Get(key interface{}) (value interface{}, ok bool) - // Checks if a key exists in cache without updating the recent-ness. + // Check if a key exsists in cache without updating the recent-ness. Contains(key interface{}) (ok bool) // Returns key's value without updating the "recently used"-ness of the key. @@ -31,9 +31,6 @@ type LRUCache interface { // Returns the number of items in the cache. Len() int - // Clears all cache entries. + // Clear all cache entries Purge() - - // Resizes cache, returning number evicted - Resize(int) int } diff --git a/vendor/github.com/joho/godotenv/.gitignore b/vendor/github.com/joho/godotenv/.gitignore deleted file mode 100644 index e43b0f9889..0000000000 --- a/vendor/github.com/joho/godotenv/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/vendor/github.com/joho/godotenv/.travis.yml b/vendor/github.com/joho/godotenv/.travis.yml deleted file mode 100644 index f0db1adcdb..0000000000 --- a/vendor/github.com/joho/godotenv/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go - -go: - - 1.x - -os: - - linux - - osx diff --git a/vendor/github.com/joho/godotenv/LICENCE b/vendor/github.com/joho/godotenv/LICENCE deleted file mode 100644 index e7ddd51be9..0000000000 --- a/vendor/github.com/joho/godotenv/LICENCE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright (c) 2013 John Barton - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/vendor/github.com/joho/godotenv/README.md b/vendor/github.com/joho/godotenv/README.md deleted file mode 100644 index 4e8fcf2e9c..0000000000 --- a/vendor/github.com/joho/godotenv/README.md +++ /dev/null @@ -1,163 +0,0 @@ -# GoDotEnv [![Build Status](https://travis-ci.org/joho/godotenv.svg?branch=master)](https://travis-ci.org/joho/godotenv) [![Build status](https://ci.appveyor.com/api/projects/status/9v40vnfvvgde64u4?svg=true)](https://ci.appveyor.com/project/joho/godotenv) [![Go Report Card](https://goreportcard.com/badge/github.com/joho/godotenv)](https://goreportcard.com/report/github.com/joho/godotenv) - -A Go (golang) port of the Ruby dotenv project (which loads env vars from a .env file) - -From the original Library: - -> Storing configuration in the environment is one of the tenets of a twelve-factor app. Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables. -> -> But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. Dotenv load variables from a .env file into ENV when the environment is bootstrapped. - -It can be used as a library (for loading in env for your own daemons etc) or as a bin command. - -There is test coverage and CI for both linuxish and windows environments, but I make no guarantees about the bin version working on windows. - -## Installation - -As a library - -```shell -go get github.com/joho/godotenv -``` - -or if you want to use it as a bin command -```shell -go get github.com/joho/godotenv/cmd/godotenv -``` - -## Usage - -Add your application configuration to your `.env` file in the root of your project: - -```shell -S3_BUCKET=YOURS3BUCKET -SECRET_KEY=YOURSECRETKEYGOESHERE -``` - -Then in your Go app you can do something like - -```go -package main - -import ( - "github.com/joho/godotenv" - "log" - "os" -) - -func main() { - err := godotenv.Load() - if err != nil { - log.Fatal("Error loading .env file") - } - - s3Bucket := os.Getenv("S3_BUCKET") - secretKey := os.Getenv("SECRET_KEY") - - // now do something with s3 or whatever -} -``` - -If you're even lazier than that, you can just take advantage of the autoload package which will read in `.env` on import - -```go -import _ "github.com/joho/godotenv/autoload" -``` - -While `.env` in the project root is the default, you don't have to be constrained, both examples below are 100% legit - -```go -_ = godotenv.Load("somerandomfile") -_ = godotenv.Load("filenumberone.env", "filenumbertwo.env") -``` - -If you want to be really fancy with your env file you can do comments and exports (below is a valid env file) - -```shell -# I am a comment and that is OK -SOME_VAR=someval -FOO=BAR # comments at line end are OK too -export BAR=BAZ -``` - -Or finally you can do YAML(ish) style - -```yaml -FOO: bar -BAR: baz -``` - -as a final aside, if you don't want godotenv munging your env you can just get a map back instead - -```go -var myEnv map[string]string -myEnv, err := godotenv.Read() - -s3Bucket := myEnv["S3_BUCKET"] -``` - -... or from an `io.Reader` instead of a local file - -```go -reader := getRemoteFile() -myEnv, err := godotenv.Parse(reader) -``` - -... or from a `string` if you so desire - -```go -content := getRemoteFileContent() -myEnv, err := godotenv.Unmarshal(content) -``` - -### Command Mode - -Assuming you've installed the command as above and you've got `$GOPATH/bin` in your `$PATH` - -``` -godotenv -f /some/path/to/.env some_command with some args -``` - -If you don't specify `-f` it will fall back on the default of loading `.env` in `PWD` - -### Writing Env Files - -Godotenv can also write a map representing the environment to a correctly-formatted and escaped file - -```go -env, err := godotenv.Unmarshal("KEY=value") -err := godotenv.Write(env, "./.env") -``` - -... or to a string - -```go -env, err := godotenv.Unmarshal("KEY=value") -content, err := godotenv.Marshal(env) -``` - -## Contributing - -Contributions are most welcome! The parser itself is pretty stupidly naive and I wouldn't be surprised if it breaks with edge cases. - -*code changes without tests will not be accepted* - -1. Fork it -2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Added some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create new Pull Request - -## Releases - -Releases should follow [Semver](http://semver.org/) though the first couple of releases are `v1` and `v1.1`. - -Use [annotated tags for all releases](https://github.com/joho/godotenv/issues/30). Example `git tag -a v1.2.1` - -## CI - -Linux: [![Build Status](https://travis-ci.org/joho/godotenv.svg?branch=master)](https://travis-ci.org/joho/godotenv) Windows: [![Build status](https://ci.appveyor.com/api/projects/status/9v40vnfvvgde64u4)](https://ci.appveyor.com/project/joho/godotenv) - -## Who? - -The original library [dotenv](https://github.com/bkeepers/dotenv) was written by [Brandon Keepers](http://opensoul.org/), and this port was done by [John Barton](https://johnbarton.co/) based off the tests/fixtures in the original library. diff --git a/vendor/github.com/joho/godotenv/godotenv.go b/vendor/github.com/joho/godotenv/godotenv.go deleted file mode 100644 index 29b436c77c..0000000000 --- a/vendor/github.com/joho/godotenv/godotenv.go +++ /dev/null @@ -1,346 +0,0 @@ -// Package godotenv is a go port of the ruby dotenv library (https://github.com/bkeepers/dotenv) -// -// Examples/readme can be found on the github page at https://github.com/joho/godotenv -// -// The TL;DR is that you make a .env file that looks something like -// -// SOME_ENV_VAR=somevalue -// -// and then in your go code you can call -// -// godotenv.Load() -// -// and all the env vars declared in .env will be available through os.Getenv("SOME_ENV_VAR") -package godotenv - -import ( - "bufio" - "errors" - "fmt" - "io" - "os" - "os/exec" - "regexp" - "sort" - "strings" -) - -const doubleQuoteSpecialChars = "\\\n\r\"!$`" - -// Load will read your env file(s) and load them into ENV for this process. -// -// Call this function as close as possible to the start of your program (ideally in main) -// -// If you call Load without any args it will default to loading .env in the current path -// -// You can otherwise tell it which files to load (there can be more than one) like -// -// godotenv.Load("fileone", "filetwo") -// -// It's important to note that it WILL NOT OVERRIDE an env variable that already exists - consider the .env file to set dev vars or sensible defaults -func Load(filenames ...string) (err error) { - filenames = filenamesOrDefault(filenames) - - for _, filename := range filenames { - err = loadFile(filename, false) - if err != nil { - return // return early on a spazout - } - } - return -} - -// Overload will read your env file(s) and load them into ENV for this process. -// -// Call this function as close as possible to the start of your program (ideally in main) -// -// If you call Overload without any args it will default to loading .env in the current path -// -// You can otherwise tell it which files to load (there can be more than one) like -// -// godotenv.Overload("fileone", "filetwo") -// -// It's important to note this WILL OVERRIDE an env variable that already exists - consider the .env file to forcefilly set all vars. -func Overload(filenames ...string) (err error) { - filenames = filenamesOrDefault(filenames) - - for _, filename := range filenames { - err = loadFile(filename, true) - if err != nil { - return // return early on a spazout - } - } - return -} - -// Read all env (with same file loading semantics as Load) but return values as -// a map rather than automatically writing values into env -func Read(filenames ...string) (envMap map[string]string, err error) { - filenames = filenamesOrDefault(filenames) - envMap = make(map[string]string) - - for _, filename := range filenames { - individualEnvMap, individualErr := readFile(filename) - - if individualErr != nil { - err = individualErr - return // return early on a spazout - } - - for key, value := range individualEnvMap { - envMap[key] = value - } - } - - return -} - -// Parse reads an env file from io.Reader, returning a map of keys and values. -func Parse(r io.Reader) (envMap map[string]string, err error) { - envMap = make(map[string]string) - - var lines []string - scanner := bufio.NewScanner(r) - for scanner.Scan() { - lines = append(lines, scanner.Text()) - } - - if err = scanner.Err(); err != nil { - return - } - - for _, fullLine := range lines { - if !isIgnoredLine(fullLine) { - var key, value string - key, value, err = parseLine(fullLine, envMap) - - if err != nil { - return - } - envMap[key] = value - } - } - return -} - -//Unmarshal reads an env file from a string, returning a map of keys and values. -func Unmarshal(str string) (envMap map[string]string, err error) { - return Parse(strings.NewReader(str)) -} - -// Exec loads env vars from the specified filenames (empty map falls back to default) -// then executes the cmd specified. -// -// Simply hooks up os.Stdin/err/out to the command and calls Run() -// -// If you want more fine grained control over your command it's recommended -// that you use `Load()` or `Read()` and the `os/exec` package yourself. -func Exec(filenames []string, cmd string, cmdArgs []string) error { - Load(filenames...) - - command := exec.Command(cmd, cmdArgs...) - command.Stdin = os.Stdin - command.Stdout = os.Stdout - command.Stderr = os.Stderr - return command.Run() -} - -// Write serializes the given environment and writes it to a file -func Write(envMap map[string]string, filename string) error { - content, error := Marshal(envMap) - if error != nil { - return error - } - file, error := os.Create(filename) - if error != nil { - return error - } - _, err := file.WriteString(content) - return err -} - -// Marshal outputs the given environment as a dotenv-formatted environment file. -// Each line is in the format: KEY="VALUE" where VALUE is backslash-escaped. -func Marshal(envMap map[string]string) (string, error) { - lines := make([]string, 0, len(envMap)) - for k, v := range envMap { - lines = append(lines, fmt.Sprintf(`%s="%s"`, k, doubleQuoteEscape(v))) - } - sort.Strings(lines) - return strings.Join(lines, "\n"), nil -} - -func filenamesOrDefault(filenames []string) []string { - if len(filenames) == 0 { - return []string{".env"} - } - return filenames -} - -func loadFile(filename string, overload bool) error { - envMap, err := readFile(filename) - if err != nil { - return err - } - - currentEnv := map[string]bool{} - rawEnv := os.Environ() - for _, rawEnvLine := range rawEnv { - key := strings.Split(rawEnvLine, "=")[0] - currentEnv[key] = true - } - - for key, value := range envMap { - if !currentEnv[key] || overload { - os.Setenv(key, value) - } - } - - return nil -} - -func readFile(filename string) (envMap map[string]string, err error) { - file, err := os.Open(filename) - if err != nil { - return - } - defer file.Close() - - return Parse(file) -} - -func parseLine(line string, envMap map[string]string) (key string, value string, err error) { - if len(line) == 0 { - err = errors.New("zero length string") - return - } - - // ditch the comments (but keep quoted hashes) - if strings.Contains(line, "#") { - segmentsBetweenHashes := strings.Split(line, "#") - quotesAreOpen := false - var segmentsToKeep []string - for _, segment := range segmentsBetweenHashes { - if strings.Count(segment, "\"") == 1 || strings.Count(segment, "'") == 1 { - if quotesAreOpen { - quotesAreOpen = false - segmentsToKeep = append(segmentsToKeep, segment) - } else { - quotesAreOpen = true - } - } - - if len(segmentsToKeep) == 0 || quotesAreOpen { - segmentsToKeep = append(segmentsToKeep, segment) - } - } - - line = strings.Join(segmentsToKeep, "#") - } - - firstEquals := strings.Index(line, "=") - firstColon := strings.Index(line, ":") - splitString := strings.SplitN(line, "=", 2) - if firstColon != -1 && (firstColon < firstEquals || firstEquals == -1) { - //this is a yaml-style line - splitString = strings.SplitN(line, ":", 2) - } - - if len(splitString) != 2 { - err = errors.New("Can't separate key from value") - return - } - - // Parse the key - key = splitString[0] - if strings.HasPrefix(key, "export") { - key = strings.TrimPrefix(key, "export") - } - key = strings.Trim(key, " ") - - // Parse the value - value = parseValue(splitString[1], envMap) - return -} - -func parseValue(value string, envMap map[string]string) string { - - // trim - value = strings.Trim(value, " ") - - // check if we've got quoted values or possible escapes - if len(value) > 1 { - rs := regexp.MustCompile(`\A'(.*)'\z`) - singleQuotes := rs.FindStringSubmatch(value) - - rd := regexp.MustCompile(`\A"(.*)"\z`) - doubleQuotes := rd.FindStringSubmatch(value) - - if singleQuotes != nil || doubleQuotes != nil { - // pull the quotes off the edges - value = value[1 : len(value)-1] - } - - if doubleQuotes != nil { - // expand newlines - escapeRegex := regexp.MustCompile(`\\.`) - value = escapeRegex.ReplaceAllStringFunc(value, func(match string) string { - c := strings.TrimPrefix(match, `\`) - switch c { - case "n": - return "\n" - case "r": - return "\r" - default: - return match - } - }) - // unescape characters - e := regexp.MustCompile(`\\([^$])`) - value = e.ReplaceAllString(value, "$1") - } - - if singleQuotes == nil { - value = expandVariables(value, envMap) - } - } - - return value -} - -func expandVariables(v string, m map[string]string) string { - r := regexp.MustCompile(`(\\)?(\$)(\()?\{?([A-Z0-9_]+)?\}?`) - - return r.ReplaceAllStringFunc(v, func(s string) string { - submatch := r.FindStringSubmatch(s) - - if submatch == nil { - return s - } - if submatch[1] == "\\" || submatch[2] == "(" { - return submatch[0][1:] - } else if submatch[4] != "" { - return m[submatch[4]] - } - return s - }) -} - -func isIgnoredLine(line string) bool { - trimmedLine := strings.Trim(line, " \n\t") - return len(trimmedLine) == 0 || strings.HasPrefix(trimmedLine, "#") -} - -func doubleQuoteEscape(line string) string { - for _, c := range doubleQuoteSpecialChars { - toReplace := "\\" + string(c) - if c == '\n' { - toReplace = `\n` - } - if c == '\r' { - toReplace = `\r` - } - line = strings.Replace(line, string(c), toReplace, -1) - } - return line -} diff --git a/vendor/github.com/markbates/inflect/.gitignore b/vendor/github.com/markbates/inflect/.gitignore deleted file mode 100644 index 3689718594..0000000000 --- a/vendor/github.com/markbates/inflect/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -*.log -.DS_Store -doc -tmp -pkg -*.gem -*.pid -coverage -coverage.data -build/* -*.pbxuser -*.mode1v3 -.svn -profile -.console_history -.sass-cache/* -.rake_tasks~ -*.log.lck -solr/ -.jhw-cache/ -jhw.* -*.sublime* -node_modules/ -dist/ -generated/ -.vendor/ -bin/* -gin-bin -.idea/ diff --git a/vendor/github.com/markbates/inflect/.gometalinter.json b/vendor/github.com/markbates/inflect/.gometalinter.json deleted file mode 100644 index e4f65a36e8..0000000000 --- a/vendor/github.com/markbates/inflect/.gometalinter.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Enable": ["vet", "golint", "goimports", "deadcode", "gotype", "ineffassign", "misspell", "nakedret", "unconvert", "megacheck", "varcheck"] -} diff --git a/vendor/github.com/markbates/inflect/.hgignore b/vendor/github.com/markbates/inflect/.hgignore deleted file mode 100644 index 6cc3d7ce11..0000000000 --- a/vendor/github.com/markbates/inflect/.hgignore +++ /dev/null @@ -1 +0,0 @@ -swp$ diff --git a/vendor/github.com/markbates/inflect/.travis.yml b/vendor/github.com/markbates/inflect/.travis.yml deleted file mode 100644 index cf1d2c7d42..0000000000 --- a/vendor/github.com/markbates/inflect/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: go - -sudo: false - -matrix: - include: - - go: "1.9.x" - - go: "1.10.x" - - go: "1.11.x" - env: - - GO111MODULE=off - - go: "1.11.x" - env: - - GO111MODULE=on - - go: "tip" - env: - - GO111MODULE=off - - go: "tip" - env: - - GO111MODULE=on - allow_failures: - - go: "tip" - -install: make deps - -script: make ci-test diff --git a/vendor/github.com/markbates/inflect/LICENCE b/vendor/github.com/markbates/inflect/LICENCE deleted file mode 100644 index 8a36b944a5..0000000000 --- a/vendor/github.com/markbates/inflect/LICENCE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2011 Chris Farmiloe - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/markbates/inflect/Makefile b/vendor/github.com/markbates/inflect/Makefile deleted file mode 100644 index e0e2f3baa4..0000000000 --- a/vendor/github.com/markbates/inflect/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -TAGS ?= "sqlite" -GO_BIN ?= go - -install: - packr - $(GO_BIN) install -tags ${TAGS} -v . - make tidy - -tidy: -ifeq ($(GO111MODULE),on) - $(GO_BIN) mod tidy -else - echo skipping go mod tidy -endif - -deps: - $(GO_BIN) get github.com/gobuffalo/release - $(GO_BIN) get github.com/gobuffalo/packr/packr - $(GO_BIN) get -tags ${TAGS} -t ./... - make tidy - -build: - packr - $(GO_BIN) build -v . - make tidy - -test: - packr - $(GO_BIN) test -tags ${TAGS} ./... - make tidy - -ci-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - make tidy - -lint: - gometalinter --vendor ./... --deadline=1m --skip=internal - make tidy - -update: - $(GO_BIN) get -u -tags ${TAGS} - make tidy - packr - make test - make install - make tidy - -release-test: - $(GO_BIN) test -tags ${TAGS} -race ./... - make tidy - -release: - make tidy - release -y -f version.go - make tidy diff --git a/vendor/github.com/markbates/inflect/README.md b/vendor/github.com/markbates/inflect/README.md deleted file mode 100644 index 9b62b1d9a4..0000000000 --- a/vendor/github.com/markbates/inflect/README.md +++ /dev/null @@ -1,214 +0,0 @@ -[![Build Status](https://travis-ci.org/markbates/inflect.svg?branch=master)](https://travis-ci.org/markbates/inflect) - -#### INSTALLATION - -go get github.com/markbates/inflect - -#### PACKAGE -package inflect - - -#### FUNCTIONS -```go -func AddAcronym(word string) -func AddHuman(suffix, replacement string) -func AddIrregular(singular, plural string) -func AddPlural(suffix, replacement string) -func AddSingular(suffix, replacement string) -func AddUncountable(word string) -func Asciify(word string) string -func Camelize(word string) string -func CamelizeDownFirst(word string) string -func Capitalize(word string) string -func Dasherize(word string) string -func ForeignKey(word string) string -func ForeignKeyCondensed(word string) string -func Humanize(word string) string -func Ordinalize(word string) string -func Parameterize(word string) string -func ParameterizeJoin(word, sep string) string -func Pluralize(word string) string -func Singularize(word string) string -func Tableize(word string) string -func Titleize(word string) string -func Typeify(word string) string -func Uncountables() map[string]bool -func Underscore(word string) string -``` - -#### TYPES -```go -type Rule struct { - // contains filtered or unexported fields -} -``` - -used by rulesets - -```go -type Ruleset struct { - // contains filtered or unexported fields -} -``` - -a Ruleset is the config of pluralization rules -you can extend the rules with the Add* methods - -``` -func NewDefaultRuleset() *Ruleset -``` -create a new ruleset and load it with the default -set of common English pluralization rules - -``` -func NewRuleset() *Ruleset -``` - -create a blank ruleset. Unless you are going to -build your own rules from scratch you probably -won't need this and can just use the defaultRuleset -via the global inflect.* methods - -``` -func (rs *Ruleset) AddAcronym(word string) -``` -if you use acronym you may need to add them to the ruleset -to prevent Underscored words of things like "HTML" coming out -as "h_t_m_l" - -``` -func (rs *Ruleset) AddHuman(suffix, replacement string) -``` - -Human rules are applied by humanize to show more friendly -versions of words - -``` -func (rs *Ruleset) AddIrregular(singular, plural string) -``` - -Add any inconsistent pluralizing/singularizing rules -to the set here. - -``` -func (rs *Ruleset) AddPlural(suffix, replacement string) -``` - -add a pluralization rule - -``` -func (rs *Ruleset) AddPluralExact(suffix, replacement string, exact bool) -``` - -add a pluralization rule with full string match - -``` -func (rs *Ruleset) AddSingular(suffix, replacement string) -``` - -add a singular rule - -``` -func (rs *Ruleset) AddSingularExact(suffix, replacement string, exact bool) -``` -same as AddSingular but you can set `exact` to force -a full string match - -``` -func (rs *Ruleset) AddUncountable(word string) -``` -add a word to this ruleset that has the same singular and plural form -for example: "rice" - -``` -func (rs *Ruleset) Asciify(word string) string -``` -transforms Latin characters like é -> e - -``` -func (rs *Ruleset) Camelize(word string) string -``` -"dino_party" -> "DinoParty" - -``` -func (rs *Ruleset) CamelizeDownFirst(word string) string -``` -same as Camelcase but with first letter downcased - -``` -func (rs *Ruleset) Capitalize(word string) string -``` -uppercase first character - -``` -func (rs *Ruleset) Dasherize(word string) string -``` -"SomeText" -> "some-text" - -``` -func (rs *Ruleset) ForeignKey(word string) string -``` -an underscored foreign key name "Person" -> "person_id" - -``` -func (rs *Ruleset) ForeignKeyCondensed(word string) string -``` -a foreign key (with an underscore) "Person" -> "personid" - -``` -func (rs *Ruleset) Humanize(word string) string -``` -First letter of sentence capitalized -Uses custom friendly replacements via AddHuman() - -``` -func (rs *Ruleset) Ordinalize(str string) string -``` -"1031" -> "1031st" - -``` -func (rs *Ruleset) Parameterize(word string) string -``` -param safe dasherized names like "my-param" - -``` -func (rs *Ruleset) ParameterizeJoin(word, sep string) string -``` -param safe dasherized names with custom separator - -``` -func (rs *Ruleset) Pluralize(word string) string -``` -returns the plural form of a singular word - -``` -func (rs *Ruleset) Singularize(word string) string -``` -returns the singular form of a plural word - -``` -func (rs *Ruleset) Tableize(word string) string -``` -Rails style pluralized table names: "SuperPerson" -> "super_people" - -``` -func (rs *Ruleset) Titleize(word string) string -``` -Capitalize every word in sentence "hello there" -> "Hello There" - -``` -func (rs *Ruleset) Typeify(word string) string -``` -"something_like_this" -> "SomethingLikeThis" - -``` -func (rs *Ruleset) Uncountables() map[string]bool -``` - -``` -func (rs *Ruleset) Underscore(word string) string -``` - -lowercase underscore version "BigBen" -> "big_ben" - - diff --git a/vendor/github.com/markbates/inflect/go.mod b/vendor/github.com/markbates/inflect/go.mod deleted file mode 100644 index 3d7baa77f7..0000000000 --- a/vendor/github.com/markbates/inflect/go.mod +++ /dev/null @@ -1,6 +0,0 @@ -module github.com/markbates/inflect - -require ( - github.com/gobuffalo/envy v1.6.5 - github.com/stretchr/testify v1.2.2 -) diff --git a/vendor/github.com/markbates/inflect/go.sum b/vendor/github.com/markbates/inflect/go.sum deleted file mode 100644 index 6d42090d0a..0000000000 --- a/vendor/github.com/markbates/inflect/go.sum +++ /dev/null @@ -1,10 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gobuffalo/envy v1.6.5 h1:X3is06x7v0nW2xiy2yFbbIjwHz57CD6z6MkvqULTCm8= -github.com/gobuffalo/envy v1.6.5/go.mod h1:N+GkhhZ/93bGZc6ZKhJLP6+m+tCNPKwgSpH9kaifseQ= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/vendor/github.com/markbates/inflect/helpers.go b/vendor/github.com/markbates/inflect/helpers.go deleted file mode 100644 index 24050c70a0..0000000000 --- a/vendor/github.com/markbates/inflect/helpers.go +++ /dev/null @@ -1,19 +0,0 @@ -package inflect - -//Helpers is a map of the helper names with its corresponding inflect function -var Helpers = map[string]interface{}{ - "asciffy": Asciify, - "camelize": Camelize, - "camelize_down_first": CamelizeDownFirst, - "capitalize": Capitalize, - "dasherize": Dasherize, - "humanize": Humanize, - "ordinalize": Ordinalize, - "parameterize": Parameterize, - "pluralize": Pluralize, - "pluralize_with_size": PluralizeWithSize, - "singularize": Singularize, - "tableize": Tableize, - "typeify": Typeify, - "underscore": Underscore, -} diff --git a/vendor/github.com/markbates/inflect/inflect.go b/vendor/github.com/markbates/inflect/inflect.go deleted file mode 100644 index 9b6776c191..0000000000 --- a/vendor/github.com/markbates/inflect/inflect.go +++ /dev/null @@ -1,892 +0,0 @@ -package inflect - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "regexp" - "strconv" - "strings" - "unicode" - "unicode/utf8" -) - -// baseAcronyms comes from https://en.wikipedia.org/wiki/List_of_information_technology_acronymss -const baseAcronyms = `JSON,JWT,ID,UUID,SQL,ACK,ACL,ADSL,AES,ANSI,API,ARP,ATM,BGP,BSS,CAT,CCITT,CHAP,CIDR,CIR,CLI,CPE,CPU,CRC,CRT,CSMA,CMOS,DCE,DEC,DES,DHCP,DNS,DRAM,DSL,DSLAM,DTE,DMI,EHA,EIA,EIGRP,EOF,ESS,FCC,FCS,FDDI,FTP,GBIC,gbps,GEPOF,HDLC,HTTP,HTTPS,IANA,ICMP,IDF,IDS,IEEE,IETF,IMAP,IP,IPS,ISDN,ISP,kbps,LACP,LAN,LAPB,LAPF,LLC,MAC,MAN,Mbps,MC,MDF,MIB,MoCA,MPLS,MTU,NAC,NAT,NBMA,NIC,NRZ,NRZI,NVRAM,OSI,OSPF,OUI,PAP,PAT,PC,PIM,PIM,PCM,PDU,POP3,POP,POTS,PPP,PPTP,PTT,PVST,RADIUS,RAM,RARP,RFC,RIP,RLL,ROM,RSTP,RTP,RCP,SDLC,SFD,SFP,SLARP,SLIP,SMTP,SNA,SNAP,SNMP,SOF,SRAM,SSH,SSID,STP,SYN,TDM,TFTP,TIA,TOFU,UDP,URL,URI,USB,UTP,VC,VLAN,VLSM,VPN,W3C,WAN,WEP,WiFi,WPA,WWW` - -// Rule used by rulesets -type Rule struct { - suffix string - replacement string - exact bool -} - -// Ruleset a Ruleset is the config of pluralization rules -// you can extend the rules with the Add* methods -type Ruleset struct { - uncountables map[string]bool - plurals []*Rule - singulars []*Rule - humans []*Rule - acronyms []*Rule -} - -// NewRuleset creates a blank ruleset. Unless you are going to -// build your own rules from scratch you probably -// won't need this and can just use the defaultRuleset -// via the global inflect.* methods -func NewRuleset() *Ruleset { - rs := new(Ruleset) - rs.uncountables = make(map[string]bool) - rs.plurals = make([]*Rule, 0) - rs.singulars = make([]*Rule, 0) - rs.humans = make([]*Rule, 0) - rs.acronyms = make([]*Rule, 0) - return rs -} - -// NewDefaultRuleset creates a new ruleset and load it with the default -// set of common English pluralization rules -func NewDefaultRuleset() *Ruleset { - rs := NewRuleset() - rs.AddPlural("movie", "movies") - rs.AddPlural("s", "s") - rs.AddPlural("testis", "testes") - rs.AddPlural("axis", "axes") - rs.AddPlural("octopus", "octopi") - rs.AddPlural("virus", "viri") - rs.AddPlural("octopi", "octopi") - rs.AddPlural("viri", "viri") - rs.AddPlural("alias", "aliases") - rs.AddPlural("status", "statuses") - rs.AddPlural("Status", "Statuses") - rs.AddPlural("campus", "campuses") - rs.AddPlural("bus", "buses") - rs.AddPlural("buffalo", "buffaloes") - rs.AddPlural("tomato", "tomatoes") - rs.AddPlural("tum", "ta") - rs.AddPlural("ium", "ia") - rs.AddPlural("ta", "ta") - rs.AddPlural("ia", "ia") - rs.AddPlural("sis", "ses") - rs.AddPlural("lf", "lves") - rs.AddPlural("rf", "rves") - rs.AddPlural("afe", "aves") - rs.AddPlural("bfe", "bves") - rs.AddPlural("cfe", "cves") - rs.AddPlural("dfe", "dves") - rs.AddPlural("efe", "eves") - rs.AddPlural("gfe", "gves") - rs.AddPlural("hfe", "hves") - rs.AddPlural("ife", "ives") - rs.AddPlural("jfe", "jves") - rs.AddPlural("kfe", "kves") - rs.AddPlural("lfe", "lves") - rs.AddPlural("mfe", "mves") - rs.AddPlural("nfe", "nves") - rs.AddPlural("ofe", "oves") - rs.AddPlural("pfe", "pves") - rs.AddPlural("qfe", "qves") - rs.AddPlural("rfe", "rves") - rs.AddPlural("sfe", "sves") - rs.AddPlural("tfe", "tves") - rs.AddPlural("ufe", "uves") - rs.AddPlural("vfe", "vves") - rs.AddPlural("wfe", "wves") - rs.AddPlural("xfe", "xves") - rs.AddPlural("yfe", "yves") - rs.AddPlural("zfe", "zves") - rs.AddPlural("hive", "hives") - rs.AddPlural("quy", "quies") - rs.AddPlural("by", "bies") - rs.AddPlural("cy", "cies") - rs.AddPlural("dy", "dies") - rs.AddPlural("fy", "fies") - rs.AddPlural("gy", "gies") - rs.AddPlural("hy", "hies") - rs.AddPlural("jy", "jies") - rs.AddPlural("ky", "kies") - rs.AddPlural("ly", "lies") - rs.AddPlural("my", "mies") - rs.AddPlural("ny", "nies") - rs.AddPlural("py", "pies") - rs.AddPlural("qy", "qies") - rs.AddPlural("ry", "ries") - rs.AddPlural("sy", "sies") - rs.AddPlural("ty", "ties") - rs.AddPlural("vy", "vies") - rs.AddPlural("wy", "wies") - rs.AddPlural("xy", "xies") - rs.AddPlural("zy", "zies") - rs.AddPlural("x", "xes") - rs.AddPlural("ch", "ches") - rs.AddPlural("ss", "sses") - rs.AddPlural("sh", "shes") - rs.AddPlural("matrix", "matrices") - rs.AddPlural("vertix", "vertices") - rs.AddPlural("indix", "indices") - rs.AddPlural("matrex", "matrices") - rs.AddPlural("vertex", "vertices") - rs.AddPlural("index", "indices") - rs.AddPlural("mouse", "mice") - rs.AddPlural("louse", "lice") - rs.AddPlural("mice", "mice") - rs.AddPlural("lice", "lice") - rs.AddPlural("ress", "resses") - rs.AddPluralExact("ox", "oxen", true) - rs.AddPluralExact("oxen", "oxen", true) - rs.AddPluralExact("quiz", "quizzes", true) - rs.AddSingular("s", "") - rs.AddSingular("ss", "ss") - rs.AddSingular("news", "news") - rs.AddSingular("ta", "tum") - rs.AddSingular("ia", "ium") - rs.AddSingular("analyses", "analysis") - rs.AddSingular("bases", "basis") - rs.AddSingularExact("basis", "basis", true) - rs.AddSingular("diagnoses", "diagnosis") - rs.AddSingularExact("diagnosis", "diagnosis", true) - rs.AddSingular("parentheses", "parenthesis") - rs.AddSingular("prognoses", "prognosis") - rs.AddSingular("synopses", "synopsis") - rs.AddSingular("theses", "thesis") - rs.AddSingular("analyses", "analysis") - rs.AddSingularExact("analysis", "analysis", true) - rs.AddSingular("ovies", "ovie") - rs.AddSingular("aves", "afe") - rs.AddSingular("bves", "bfe") - rs.AddSingular("cves", "cfe") - rs.AddSingular("dves", "dfe") - rs.AddSingular("eves", "efe") - rs.AddSingular("gves", "gfe") - rs.AddSingular("hves", "hfe") - rs.AddSingular("ives", "ife") - rs.AddSingular("jves", "jfe") - rs.AddSingular("kves", "kfe") - rs.AddSingular("lves", "lfe") - rs.AddSingular("mves", "mfe") - rs.AddSingular("nves", "nfe") - rs.AddSingular("oves", "ofe") - rs.AddSingular("pves", "pfe") - rs.AddSingular("qves", "qfe") - rs.AddSingular("rves", "rfe") - rs.AddSingular("sves", "sfe") - rs.AddSingular("tves", "tfe") - rs.AddSingular("uves", "ufe") - rs.AddSingular("vves", "vfe") - rs.AddSingular("wves", "wfe") - rs.AddSingular("xves", "xfe") - rs.AddSingular("yves", "yfe") - rs.AddSingular("zves", "zfe") - rs.AddSingular("hives", "hive") - rs.AddSingular("tives", "tive") - rs.AddSingular("lves", "lf") - rs.AddSingular("rves", "rf") - rs.AddSingular("quies", "quy") - rs.AddSingular("bies", "by") - rs.AddSingular("cies", "cy") - rs.AddSingular("dies", "dy") - rs.AddSingular("fies", "fy") - rs.AddSingular("gies", "gy") - rs.AddSingular("hies", "hy") - rs.AddSingular("jies", "jy") - rs.AddSingular("kies", "ky") - rs.AddSingular("lies", "ly") - rs.AddSingular("mies", "my") - rs.AddSingular("nies", "ny") - rs.AddSingular("pies", "py") - rs.AddSingular("qies", "qy") - rs.AddSingular("ries", "ry") - rs.AddSingular("sies", "sy") - rs.AddSingular("ties", "ty") - // rs.AddSingular("vies", "vy") - rs.AddSingular("wies", "wy") - rs.AddSingular("xies", "xy") - rs.AddSingular("zies", "zy") - rs.AddSingular("series", "series") - rs.AddSingular("xes", "x") - rs.AddSingular("ches", "ch") - rs.AddSingular("sses", "ss") - rs.AddSingular("shes", "sh") - rs.AddSingular("mice", "mouse") - rs.AddSingular("lice", "louse") - rs.AddSingular("buses", "bus") - rs.AddSingularExact("bus", "bus", true) - rs.AddSingular("oes", "o") - rs.AddSingular("shoes", "shoe") - rs.AddSingular("crises", "crisis") - rs.AddSingularExact("crisis", "crisis", true) - rs.AddSingular("axes", "axis") - rs.AddSingularExact("axis", "axis", true) - rs.AddSingular("testes", "testis") - rs.AddSingularExact("testis", "testis", true) - rs.AddSingular("octopi", "octopus") - rs.AddSingularExact("octopus", "octopus", true) - rs.AddSingular("viri", "virus") - rs.AddSingularExact("virus", "virus", true) - rs.AddSingular("statuses", "status") - rs.AddSingular("Statuses", "Status") - rs.AddSingular("campuses", "campus") - rs.AddSingularExact("status", "status", true) - rs.AddSingularExact("Status", "Status", true) - rs.AddSingularExact("campus", "campus", true) - rs.AddSingular("aliases", "alias") - rs.AddSingularExact("alias", "alias", true) - rs.AddSingularExact("oxen", "ox", true) - rs.AddSingular("vertices", "vertex") - rs.AddSingular("indices", "index") - rs.AddSingular("matrices", "matrix") - rs.AddSingularExact("quizzes", "quiz", true) - rs.AddSingular("databases", "database") - rs.AddSingular("resses", "ress") - rs.AddSingular("ress", "ress") - rs.AddIrregular("person", "people") - rs.AddIrregular("man", "men") - rs.AddIrregular("child", "children") - rs.AddIrregular("sex", "sexes") - rs.AddIrregular("move", "moves") - rs.AddIrregular("zombie", "zombies") - rs.AddIrregular("Status", "Statuses") - rs.AddIrregular("status", "statuses") - rs.AddIrregular("campus", "campuses") - rs.AddIrregular("human", "humans") - rs.AddUncountable("equipment") - rs.AddUncountable("information") - rs.AddUncountable("rice") - rs.AddUncountable("money") - rs.AddUncountable("species") - rs.AddUncountable("series") - rs.AddUncountable("fish") - rs.AddUncountable("sheep") - rs.AddUncountable("jeans") - rs.AddUncountable("police") - - acronyms := strings.Split(baseAcronyms, ",") - for _, acr := range acronyms { - rs.AddAcronym(acr) - } - - return rs -} - -// Uncountables returns a map of uncountables in the ruleset -func (rs *Ruleset) Uncountables() map[string]bool { - return rs.uncountables -} - -// AddPlural add a pluralization rule -func (rs *Ruleset) AddPlural(suffix, replacement string) { - rs.AddPluralExact(suffix, replacement, false) -} - -// AddPluralExact add a pluralization rule with full string match -func (rs *Ruleset) AddPluralExact(suffix, replacement string, exact bool) { - // remove uncountable - delete(rs.uncountables, suffix) - // create rule - r := new(Rule) - r.suffix = suffix - r.replacement = replacement - r.exact = exact - // prepend - rs.plurals = append([]*Rule{r}, rs.plurals...) -} - -// AddSingular add a singular rule -func (rs *Ruleset) AddSingular(suffix, replacement string) { - rs.AddSingularExact(suffix, replacement, false) -} - -// AddSingularExact same as AddSingular but you can set `exact` to force -// a full string match -func (rs *Ruleset) AddSingularExact(suffix, replacement string, exact bool) { - // remove from uncountable - delete(rs.uncountables, suffix) - // create rule - r := new(Rule) - r.suffix = suffix - r.replacement = replacement - r.exact = exact - rs.singulars = append([]*Rule{r}, rs.singulars...) -} - -// AddHuman Human rules are applied by humanize to show more friendly -// versions of words -func (rs *Ruleset) AddHuman(suffix, replacement string) { - r := new(Rule) - r.suffix = suffix - r.replacement = replacement - rs.humans = append([]*Rule{r}, rs.humans...) -} - -// AddIrregular Add any inconsistent pluralizing/singularizing rules -// to the set here. -func (rs *Ruleset) AddIrregular(singular, plural string) { - delete(rs.uncountables, singular) - delete(rs.uncountables, plural) - rs.AddPlural(singular, plural) - rs.AddPlural(plural, plural) - rs.AddSingular(plural, singular) -} - -// AddAcronym if you use acronym you may need to add them to the ruleset -// to prevent Underscored words of things like "HTML" coming out -// as "h_t_m_l" -func (rs *Ruleset) AddAcronym(word string) { - r := new(Rule) - r.suffix = word - r.replacement = rs.Titleize(strings.ToLower(word)) - rs.acronyms = append(rs.acronyms, r) -} - -// AddUncountable add a word to this ruleset that has the same singular and plural form -// for example: "rice" -func (rs *Ruleset) AddUncountable(word string) { - rs.uncountables[strings.ToLower(word)] = true -} - -func (rs *Ruleset) isUncountable(word string) bool { - // handle multiple words by using the last one - words := strings.Split(word, " ") - if _, exists := rs.uncountables[strings.ToLower(words[len(words)-1])]; exists { - return true - } - return false -} - -//isAcronym returns if a word is acronym or not. -func (rs *Ruleset) isAcronym(word string) bool { - for _, rule := range rs.acronyms { - if strings.ToUpper(rule.suffix) == strings.ToUpper(word) { - return true - } - } - - return false -} - -//PluralizeWithSize pluralize with taking number into account -func (rs *Ruleset) PluralizeWithSize(word string, size int) string { - if size == 1 { - return rs.Singularize(word) - } - return rs.Pluralize(word) -} - -// Pluralize returns the plural form of a singular word -func (rs *Ruleset) Pluralize(word string) string { - if len(word) == 0 { - return word - } - lWord := strings.ToLower(word) - if rs.isUncountable(lWord) { - return word - } - - var candidate string - for _, rule := range rs.plurals { - if rule.exact { - if lWord == rule.suffix { - // Capitalized word - if lWord[0] != word[0] && lWord[1:] == word[1:] { - return rs.Capitalize(rule.replacement) - } - return rule.replacement - } - continue - } - - if strings.EqualFold(word, rule.suffix) { - candidate = rule.replacement - } - - if strings.HasSuffix(word, rule.suffix) { - return replaceLast(word, rule.suffix, rule.replacement) - } - } - - if candidate != "" { - return candidate - } - return word + "s" -} - -//Singularize returns the singular form of a plural word -func (rs *Ruleset) Singularize(word string) string { - if len(word) <= 1 { - return word - } - lWord := strings.ToLower(word) - if rs.isUncountable(lWord) { - return word - } - - var candidate string - - for _, rule := range rs.singulars { - if rule.exact { - if lWord == rule.suffix { - // Capitalized word - if lWord[0] != word[0] && lWord[1:] == word[1:] { - return rs.Capitalize(rule.replacement) - } - return rule.replacement - } - continue - } - - if strings.EqualFold(word, rule.suffix) { - candidate = rule.replacement - } - - if strings.HasSuffix(word, rule.suffix) { - return replaceLast(word, rule.suffix, rule.replacement) - } - } - - if candidate != "" { - return candidate - } - - return word -} - -//Capitalize uppercase first character -func (rs *Ruleset) Capitalize(word string) string { - if rs.isAcronym(word) { - return strings.ToUpper(word) - } - return strings.ToUpper(word[:1]) + word[1:] -} - -//Camelize "dino_party" -> "DinoParty" -func (rs *Ruleset) Camelize(word string) string { - if rs.isAcronym(word) { - return strings.ToUpper(word) - } - words := splitAtCaseChangeWithTitlecase(word) - return strings.Join(words, "") -} - -//CamelizeDownFirst same as Camelcase but with first letter downcased -func (rs *Ruleset) CamelizeDownFirst(word string) string { - word = Camelize(word) - return strings.ToLower(word[:1]) + word[1:] -} - -//Titleize Capitalize every word in sentence "hello there" -> "Hello There" -func (rs *Ruleset) Titleize(word string) string { - words := splitAtCaseChangeWithTitlecase(word) - result := strings.Join(words, " ") - - var acronymWords []string - for index, word := range words { - if len(word) == 1 { - acronymWords = append(acronymWords, word) - } - - if len(word) > 1 || index == len(words)-1 || len(acronymWords) > 1 { - acronym := strings.Join(acronymWords, "") - if !rs.isAcronym(acronym) { - acronymWords = acronymWords[:len(acronymWords)] - continue - } - - result = strings.Replace(result, strings.Join(acronymWords, " "), acronym, 1) - acronymWords = []string{} - } - } - - return result -} - -func (rs *Ruleset) safeCaseAcronyms(word string) string { - // convert an acronym like HTML into Html - for _, rule := range rs.acronyms { - word = strings.Replace(word, rule.suffix, rule.replacement, -1) - } - return word -} - -func (rs *Ruleset) separatedWords(word, sep string) string { - word = rs.safeCaseAcronyms(word) - words := splitAtCaseChange(word) - return strings.Join(words, sep) -} - -//Underscore lowercase underscore version "BigBen" -> "big_ben" -func (rs *Ruleset) Underscore(word string) string { - return rs.separatedWords(word, "_") -} - -//Humanize First letter of sentence capitalized -// Uses custom friendly replacements via AddHuman() -func (rs *Ruleset) Humanize(word string) string { - word = replaceLast(word, "_id", "") // strip foreign key kinds - // replace and strings in humans list - for _, rule := range rs.humans { - word = strings.Replace(word, rule.suffix, rule.replacement, -1) - } - sentence := rs.separatedWords(word, " ") - - r, n := utf8.DecodeRuneInString(sentence) - return string(unicode.ToUpper(r)) + sentence[n:] -} - -//ForeignKey an underscored foreign key name "Person" -> "person_id" -func (rs *Ruleset) ForeignKey(word string) string { - return rs.Underscore(rs.Singularize(word)) + "_id" -} - -//ForeignKeyCondensed a foreign key (with an underscore) "Person" -> "personid" -func (rs *Ruleset) ForeignKeyCondensed(word string) string { - return rs.Underscore(word) + "id" -} - -//Tableize Rails style pluralized table names: "SuperPerson" -> "super_people" -func (rs *Ruleset) Tableize(word string) string { - return rs.Pluralize(rs.Underscore(rs.Typeify(word))) -} - -var notUrlSafe *regexp.Regexp = regexp.MustCompile(`[^\w\d\-_ ]`) - -//Parameterize param safe dasherized names like "my-param" -func (rs *Ruleset) Parameterize(word string) string { - return ParameterizeJoin(word, "-") -} - -//ParameterizeJoin param safe dasherized names with custom separator -func (rs *Ruleset) ParameterizeJoin(word, sep string) string { - word = strings.ToLower(word) - word = rs.Asciify(word) - word = notUrlSafe.ReplaceAllString(word, "") - word = strings.Replace(word, " ", sep, -1) - if len(sep) > 0 { - squash, err := regexp.Compile(sep + "+") - if err == nil { - word = squash.ReplaceAllString(word, sep) - } - } - word = strings.Trim(word, sep+" ") - return word -} - -var lookalikes = map[string]*regexp.Regexp{ - "A": regexp.MustCompile(`À|Á|Â|Ã|Ä|Å`), - "AE": regexp.MustCompile(`Æ`), - "C": regexp.MustCompile(`Ç`), - "E": regexp.MustCompile(`È|É|Ê|Ë`), - "G": regexp.MustCompile(`Ğ`), - "I": regexp.MustCompile(`Ì|Í|Î|Ï|İ`), - "N": regexp.MustCompile(`Ñ`), - "O": regexp.MustCompile(`Ò|Ó|Ô|Õ|Ö|Ø`), - "S": regexp.MustCompile(`Ş`), - "U": regexp.MustCompile(`Ù|Ú|Û|Ü`), - "Y": regexp.MustCompile(`Ý`), - "ss": regexp.MustCompile(`ß`), - "a": regexp.MustCompile(`à|á|â|ã|ä|å`), - "ae": regexp.MustCompile(`æ`), - "c": regexp.MustCompile(`ç`), - "e": regexp.MustCompile(`è|é|ê|ë`), - "g": regexp.MustCompile(`ğ`), - "i": regexp.MustCompile(`ì|í|î|ï|ı`), - "n": regexp.MustCompile(`ñ`), - "o": regexp.MustCompile(`ò|ó|ô|õ|ö|ø`), - "s": regexp.MustCompile(`ş`), - "u": regexp.MustCompile(`ù|ú|û|ü|ũ|ū|ŭ|ů|ű|ų`), - "y": regexp.MustCompile(`ý|ÿ`), -} - -//Asciify transforms Latin characters like é -> e -func (rs *Ruleset) Asciify(word string) string { - for repl, regex := range lookalikes { - word = regex.ReplaceAllString(word, repl) - } - return word -} - -var tablePrefix = regexp.MustCompile(`^[^.]*\.`) - -//Typeify "something_like_this" -> "SomethingLikeThis" -func (rs *Ruleset) Typeify(word string) string { - word = tablePrefix.ReplaceAllString(word, "") - return rs.Camelize(rs.Singularize(word)) -} - -//Dasherize "SomeText" -> "some-text" -func (rs *Ruleset) Dasherize(word string) string { - return rs.separatedWords(word, "-") -} - -//Ordinalize "1031" -> "1031st" -func (rs *Ruleset) Ordinalize(str string) string { - number, err := strconv.Atoi(str) - if err != nil { - return str - } - switch abs(number) % 100 { - case 11, 12, 13: - return fmt.Sprintf("%dth", number) - default: - switch abs(number) % 10 { - case 1: - return fmt.Sprintf("%dst", number) - case 2: - return fmt.Sprintf("%dnd", number) - case 3: - return fmt.Sprintf("%drd", number) - } - } - return fmt.Sprintf("%dth", number) -} - -//ForeignKeyToAttribute returns the attribute name from the foreign key -func (rs *Ruleset) ForeignKeyToAttribute(str string) string { - w := rs.Camelize(str) - if strings.HasSuffix(w, "Id") { - return strings.TrimSuffix(w, "Id") + "ID" - } - return w -} - -//LoadReader loads rules from io.Reader param -func (rs *Ruleset) LoadReader(r io.Reader) error { - m := map[string]string{} - err := json.NewDecoder(r).Decode(&m) - if err != nil { - return fmt.Errorf("could not decode inflection JSON from reader: %s", err) - } - for s, p := range m { - defaultRuleset.AddIrregular(s, p) - } - return nil -} - -///////////////////////////////////////// -// the default global ruleset -////////////////////////////////////////// - -var defaultRuleset *Ruleset - -//LoadReader loads rules from io.Reader param -func LoadReader(r io.Reader) error { - return defaultRuleset.LoadReader(r) -} - -func init() { - defaultRuleset = NewDefaultRuleset() - - pwd, _ := os.Getwd() - cfg := filepath.Join(pwd, "inflections.json") - if p := os.Getenv("INFLECT_PATH"); p != "" { - cfg = p - } - if _, err := os.Stat(cfg); err == nil { - b, err := ioutil.ReadFile(cfg) - if err != nil { - fmt.Printf("could not read inflection file %s (%s)\n", cfg, err) - return - } - if err = defaultRuleset.LoadReader(bytes.NewReader(b)); err != nil { - fmt.Println(err) - } - } -} - -//Uncountables returns a list of uncountables rules -func Uncountables() map[string]bool { - return defaultRuleset.Uncountables() -} - -//AddPlural adds plural to the ruleset -func AddPlural(suffix, replacement string) { - defaultRuleset.AddPlural(suffix, replacement) -} - -//AddSingular adds singular to the ruleset -func AddSingular(suffix, replacement string) { - defaultRuleset.AddSingular(suffix, replacement) -} - -//AddHuman adds human -func AddHuman(suffix, replacement string) { - defaultRuleset.AddHuman(suffix, replacement) -} - -func AddIrregular(singular, plural string) { - defaultRuleset.AddIrregular(singular, plural) -} - -func AddAcronym(word string) { - defaultRuleset.AddAcronym(word) -} - -func AddUncountable(word string) { - defaultRuleset.AddUncountable(word) -} - -func Pluralize(word string) string { - return defaultRuleset.Pluralize(word) -} - -func PluralizeWithSize(word string, size int) string { - return defaultRuleset.PluralizeWithSize(word, size) -} - -func Singularize(word string) string { - return defaultRuleset.Singularize(word) -} - -func Capitalize(word string) string { - return defaultRuleset.Capitalize(word) -} - -func Camelize(word string) string { - return defaultRuleset.Camelize(word) -} - -func CamelizeDownFirst(word string) string { - return defaultRuleset.CamelizeDownFirst(word) -} - -func Titleize(word string) string { - return defaultRuleset.Titleize(word) -} - -func Underscore(word string) string { - return defaultRuleset.Underscore(word) -} - -func Humanize(word string) string { - return defaultRuleset.Humanize(word) -} - -func ForeignKey(word string) string { - return defaultRuleset.ForeignKey(word) -} - -func ForeignKeyCondensed(word string) string { - return defaultRuleset.ForeignKeyCondensed(word) -} - -func Tableize(word string) string { - return defaultRuleset.Tableize(word) -} - -func Parameterize(word string) string { - return defaultRuleset.Parameterize(word) -} - -func ParameterizeJoin(word, sep string) string { - return defaultRuleset.ParameterizeJoin(word, sep) -} - -func Typeify(word string) string { - return defaultRuleset.Typeify(word) -} - -func Dasherize(word string) string { - return defaultRuleset.Dasherize(word) -} - -func Ordinalize(word string) string { - return defaultRuleset.Ordinalize(word) -} - -func Asciify(word string) string { - return defaultRuleset.Asciify(word) -} - -func ForeignKeyToAttribute(word string) string { - return defaultRuleset.ForeignKeyToAttribute(word) -} - -// helper funcs - -func reverse(s string) string { - o := make([]rune, utf8.RuneCountInString(s)) - i := len(o) - for _, c := range s { - i-- - o[i] = c - } - return string(o) -} - -func isSpacerChar(c rune) bool { - switch { - case c == rune("_"[0]): - return true - case c == rune(" "[0]): - return true - case c == rune(":"[0]): - return true - case c == rune("-"[0]): - return true - } - return false -} - -func splitAtCaseChange(s string) []string { - words := make([]string, 0) - word := make([]rune, 0) - for _, c := range s { - spacer := isSpacerChar(c) - if len(word) > 0 { - if unicode.IsUpper(c) || spacer { - words = append(words, string(word)) - word = make([]rune, 0) - } - } - if !spacer { - word = append(word, unicode.ToLower(c)) - } - } - words = append(words, string(word)) - return words -} - -func splitAtCaseChangeWithTitlecase(s string) []string { - words := make([]string, 0) - word := make([]rune, 0) - - for _, c := range s { - spacer := isSpacerChar(c) - if len(word) > 0 { - if unicode.IsUpper(c) || spacer { - words = append(words, string(word)) - word = make([]rune, 0) - } - } - if !spacer { - if len(word) > 0 { - word = append(word, unicode.ToLower(c)) - } else { - word = append(word, unicode.ToUpper(c)) - } - } - } - - words = append(words, string(word)) - return words -} - -func replaceLast(s, match, repl string) string { - // reverse strings - srev := reverse(s) - mrev := reverse(match) - rrev := reverse(repl) - // match first and reverse back - return reverse(strings.Replace(srev, mrev, rrev, 1)) -} - -func abs(x int) int { - if x < 0 { - return -x - } - return x -} diff --git a/vendor/github.com/markbates/inflect/inflections.json b/vendor/github.com/markbates/inflect/inflections.json deleted file mode 100644 index 5fd3cbf279..0000000000 --- a/vendor/github.com/markbates/inflect/inflections.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "feedback": "feedback", - "buffalo!": "buffalos!" -} diff --git a/vendor/github.com/markbates/inflect/name.go b/vendor/github.com/markbates/inflect/name.go deleted file mode 100644 index e6863e28a6..0000000000 --- a/vendor/github.com/markbates/inflect/name.go +++ /dev/null @@ -1,163 +0,0 @@ -package inflect - -import ( - "fmt" - "path/filepath" - "strings" - - "github.com/gobuffalo/envy" -) - -// Name is a string that represents the "name" of a thing, like an app, model, etc... -type Name string - -// Title version of a name. ie. "foo_bar" => "Foo Bar" -func (n Name) Title() string { - x := strings.Split(string(n), "/") - for i, s := range x { - x[i] = Titleize(s) - } - - return strings.Join(x, " ") -} - -// Underscore version of a name. ie. "FooBar" => "foo_bar" -func (n Name) Underscore() string { - w := string(n) - if strings.ToUpper(w) == w { - return strings.ToLower(w) - } - return Underscore(w) -} - -// Plural version of a name -func (n Name) Plural() string { - return Pluralize(string(n)) -} - -// Singular version of a name -func (n Name) Singular() string { - return Singularize(string(n)) -} - -// Camel version of a name -func (n Name) Camel() string { - c := Camelize(string(n)) - if strings.HasSuffix(c, "Id") { - c = strings.TrimSuffix(c, "Id") - c += "ID" - } - return c -} - -// Model version of a name. ie. "user" => "User" -func (n Name) Model() string { - x := strings.Split(string(n), "/") - for i, s := range x { - x[i] = Camelize(Singularize(s)) - } - - return strings.Join(x, "") -} - -// Resource version of a name -func (n Name) Resource() string { - name := n.Underscore() - x := strings.FieldsFunc(name, func(r rune) bool { - return r == '_' || r == '/' - }) - - for i, w := range x { - if i == len(x)-1 { - x[i] = Camelize(Pluralize(strings.ToLower(w))) - continue - } - - x[i] = Camelize(w) - } - - return strings.Join(x, "") -} - -// ModelPlural version of a name. ie. "user" => "Users" -func (n Name) ModelPlural() string { - return Camelize(Pluralize(n.Model())) -} - -// File version of a name -func (n Name) File() string { - return Underscore(Camelize(string(n))) -} - -// Table version of a name -func (n Name) Table() string { - return Underscore(Pluralize(string(n))) -} - -// UnderSingular version of a name -func (n Name) UnderSingular() string { - return Underscore(Singularize(string(n))) -} - -// PluralCamel version of a name -func (n Name) PluralCamel() string { - return Pluralize(Camelize(string(n))) -} - -// PluralUnder version of a name -func (n Name) PluralUnder() string { - return Pluralize(Underscore(string(n))) -} - -// URL version of a name -func (n Name) URL() string { - return n.PluralUnder() -} - -// CamelSingular version of a name -func (n Name) CamelSingular() string { - return Camelize(Singularize(string(n))) -} - -// VarCaseSingular version of a name. ie. "FooBar" => "fooBar" -func (n Name) VarCaseSingular() string { - return CamelizeDownFirst(Singularize(Underscore(n.Resource()))) -} - -// VarCasePlural version of a name. ie. "FooBar" => "fooBar" -func (n Name) VarCasePlural() string { - return CamelizeDownFirst(n.Resource()) -} - -// Lower case version of a string -func (n Name) Lower() string { - return strings.ToLower(string(n)) -} - -// ParamID returns foo_bar_id -func (n Name) ParamID() string { - return fmt.Sprintf("%s_id", strings.Replace(n.UnderSingular(), "/", "_", -1)) -} - -// Package returns go package -func (n Name) Package() string { - key := string(n) - - for _, gp := range envy.GoPaths() { - key = strings.TrimPrefix(key, filepath.Join(gp, "src")) - key = strings.TrimPrefix(key, gp) - } - key = strings.TrimPrefix(key, string(filepath.Separator)) - - key = strings.Replace(key, "\\", "/", -1) - return key -} - -// Char returns first character in lower case, this is useful for methods inside a struct. -func (n Name) Char() string { - return strings.ToLower(string(n[0])) -} - -func (n Name) String() string { - return string(n) -} diff --git a/vendor/github.com/markbates/inflect/shoulders.md b/vendor/github.com/markbates/inflect/shoulders.md deleted file mode 100644 index 619e7892f7..0000000000 --- a/vendor/github.com/markbates/inflect/shoulders.md +++ /dev/null @@ -1,12 +0,0 @@ -# github.com/markbates/inflect Stands on the Shoulders of Giants - -github.com/markbates/inflect does not try to reinvent the wheel! Instead, it uses the already great wheels developed by the Go community and puts them all together in the best way possible. Without these giants this project would not be possible. Please make sure to check them out and thank them for all of their hard work. - -Thank you to the following **GIANTS**: - - -* [github.com/gobuffalo/envy](https://godoc.org/github.com/gobuffalo/envy) - -* [github.com/joho/godotenv](https://godoc.org/github.com/joho/godotenv) - -* [github.com/markbates/inflect](https://godoc.org/github.com/markbates/inflect) diff --git a/vendor/github.com/markbates/inflect/version.go b/vendor/github.com/markbates/inflect/version.go deleted file mode 100644 index a167449841..0000000000 --- a/vendor/github.com/markbates/inflect/version.go +++ /dev/null @@ -1,3 +0,0 @@ -package inflect - -const Version = "v1.0.4" diff --git a/vendor/go.opencensus.io/README.md b/vendor/go.opencensus.io/README.md index fabab2e060..a8cd09eafb 100644 --- a/vendor/go.opencensus.io/README.md +++ b/vendor/go.opencensus.io/README.md @@ -78,7 +78,7 @@ Package `tag` allows adding or modifying tags in the current context. [embedmd]:# (internal/readme/tags.go new) ```go -ctx, err = tag.New(ctx, +ctx, err := tag.New(ctx, tag.Insert(osKey, "macOS-10.12.5"), tag.Upsert(userIDKey, "cde36753ed"), ) diff --git a/vendor/go.opencensus.io/go.mod b/vendor/go.opencensus.io/go.mod index cb4de80f3b..7c1886e9ef 100644 --- a/vendor/go.opencensus.io/go.mod +++ b/vendor/go.opencensus.io/go.mod @@ -1,12 +1,14 @@ module go.opencensus.io require ( + github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 github.com/golang/protobuf v1.3.1 github.com/google/go-cmp v0.3.0 - github.com/hashicorp/golang-lru v0.5.1 - golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09 + golang.org/x/net v0.0.0-20190620200207-3b0461eec859 golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd // indirect golang.org/x/text v0.3.2 // indirect google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb // indirect google.golang.org/grpc v1.20.1 ) + +go 1.13 diff --git a/vendor/go.opencensus.io/go.sum b/vendor/go.opencensus.io/go.sum index 0b948c2b40..212b6b73be 100644 --- a/vendor/go.opencensus.io/go.sum +++ b/vendor/go.opencensus.io/go.sum @@ -3,6 +3,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -10,20 +12,19 @@ github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09 h1:KaQtG+aDELoNmXYas3TVkGNYRuq8JQ1aa7LJt8EXVyo= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -45,6 +46,7 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd h1:/e+gpKk9r3dJobndpTytxS2gOy6m5uvpg+ISQoEcusQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/vendor/go.opencensus.io/internal/internal.go b/vendor/go.opencensus.io/internal/internal.go index 9a638781cf..81dc7183ec 100644 --- a/vendor/go.opencensus.io/internal/internal.go +++ b/vendor/go.opencensus.io/internal/internal.go @@ -33,5 +33,5 @@ var UserAgent = fmt.Sprintf("opencensus-go/%s", opencensus.Version()) // end as a monotonic time. // See https://golang.org/pkg/time/#hdr-Monotonic_Clocks func MonotonicEndTime(start time.Time) time.Time { - return start.Add(time.Now().Sub(start)) + return start.Add(time.Since(start)) } diff --git a/vendor/go.opencensus.io/opencensus.go b/vendor/go.opencensus.io/opencensus.go index 626d73645d..e5e4b4368c 100644 --- a/vendor/go.opencensus.io/opencensus.go +++ b/vendor/go.opencensus.io/opencensus.go @@ -17,5 +17,5 @@ package opencensus // import "go.opencensus.io" // Version is the current release version of OpenCensus in use. func Version() string { - return "0.22.0" + return "0.23.0" } diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/client_stats_handler.go b/vendor/go.opencensus.io/plugin/ocgrpc/client_stats_handler.go index 18821c7f57..b36349820d 100644 --- a/vendor/go.opencensus.io/plugin/ocgrpc/client_stats_handler.go +++ b/vendor/go.opencensus.io/plugin/ocgrpc/client_stats_handler.go @@ -16,9 +16,9 @@ package ocgrpc import ( + "context" "time" - "context" "go.opencensus.io/tag" "google.golang.org/grpc/grpclog" "google.golang.org/grpc/stats" @@ -30,7 +30,7 @@ func (h *ClientHandler) statsTagRPC(ctx context.Context, info *stats.RPCTagInfo) startTime := time.Now() if info == nil { if grpclog.V(2) { - grpclog.Infof("clientHandler.TagRPC called with nil info.", info.FullMethodName) + grpclog.Info("clientHandler.TagRPC called with nil info.") } return ctx } diff --git a/vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go b/vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go index 0ae5691822..89cac9c4ec 100644 --- a/vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go +++ b/vendor/go.opencensus.io/plugin/ocgrpc/stats_common.go @@ -61,14 +61,14 @@ var ( // Server tags are applied to the context used to process each RPC, as well as // the measures at the end of each RPC. var ( - KeyServerMethod, _ = tag.NewKey("grpc_server_method") - KeyServerStatus, _ = tag.NewKey("grpc_server_status") + KeyServerMethod = tag.MustNewKey("grpc_server_method") + KeyServerStatus = tag.MustNewKey("grpc_server_status") ) // Client tags are applied to measures at the end of each RPC. var ( - KeyClientMethod, _ = tag.NewKey("grpc_client_method") - KeyClientStatus, _ = tag.NewKey("grpc_client_status") + KeyClientMethod = tag.MustNewKey("grpc_client_method") + KeyClientStatus = tag.MustNewKey("grpc_client_status") ) var ( diff --git a/vendor/go.opencensus.io/plugin/ochttp/server.go b/vendor/go.opencensus.io/plugin/ochttp/server.go index 4f6404fa79..dc6563a15d 100644 --- a/vendor/go.opencensus.io/plugin/ochttp/server.go +++ b/vendor/go.opencensus.io/plugin/ochttp/server.go @@ -128,7 +128,7 @@ func (h *Handler) startTrace(w http.ResponseWriter, r *http.Request) (*http.Requ // TODO: Handle cases where ContentLength is not set. } else if r.ContentLength > 0 { span.AddMessageReceiveEvent(0, /* TODO: messageID */ - int64(r.ContentLength), -1) + r.ContentLength, -1) } return r.WithContext(ctx), span.End } @@ -174,8 +174,6 @@ type trackingResponseWriter struct { // Compile time assertion for ResponseWriter interface var _ http.ResponseWriter = (*trackingResponseWriter)(nil) -var logTagsErrorOnce sync.Once - func (t *trackingResponseWriter) end(tags *addedTags) { t.endOnce.Do(func() { if t.statusCode == 0 { diff --git a/vendor/go.opencensus.io/plugin/ochttp/stats.go b/vendor/go.opencensus.io/plugin/ochttp/stats.go index 63bbcda5e3..ee3729040d 100644 --- a/vendor/go.opencensus.io/plugin/ochttp/stats.go +++ b/vendor/go.opencensus.io/plugin/ochttp/stats.go @@ -92,38 +92,38 @@ var ( // The value of this tag can be controlled by the HTTP client, so you need // to watch out for potentially generating high-cardinality labels in your // metrics backend if you use this tag in views. - Host, _ = tag.NewKey("http.host") + Host = tag.MustNewKey("http.host") // StatusCode is the numeric HTTP response status code, // or "error" if a transport error occurred and no status code was read. - StatusCode, _ = tag.NewKey("http.status") + StatusCode = tag.MustNewKey("http.status") // Path is the URL path (not including query string) in the request. // // The value of this tag can be controlled by the HTTP client, so you need // to watch out for potentially generating high-cardinality labels in your // metrics backend if you use this tag in views. - Path, _ = tag.NewKey("http.path") + Path = tag.MustNewKey("http.path") // Method is the HTTP method of the request, capitalized (GET, POST, etc.). - Method, _ = tag.NewKey("http.method") + Method = tag.MustNewKey("http.method") // KeyServerRoute is a low cardinality string representing the logical // handler of the request. This is usually the pattern registered on the a // ServeMux (or similar string). - KeyServerRoute, _ = tag.NewKey("http_server_route") + KeyServerRoute = tag.MustNewKey("http_server_route") ) // Client tag keys. var ( // KeyClientMethod is the HTTP method, capitalized (i.e. GET, POST, PUT, DELETE, etc.). - KeyClientMethod, _ = tag.NewKey("http_client_method") + KeyClientMethod = tag.MustNewKey("http_client_method") // KeyClientPath is the URL path (not including query string). - KeyClientPath, _ = tag.NewKey("http_client_path") + KeyClientPath = tag.MustNewKey("http_client_path") // KeyClientStatus is the HTTP status code as an integer (e.g. 200, 404, 500.), or "error" if no response status line was received. - KeyClientStatus, _ = tag.NewKey("http_client_status") + KeyClientStatus = tag.MustNewKey("http_client_status") // KeyClientHost is the value of the request Host header. - KeyClientHost, _ = tag.NewKey("http_client_host") + KeyClientHost = tag.MustNewKey("http_client_host") ) // Default distributions used by views in this package. diff --git a/vendor/go.opencensus.io/plugin/ochttp/trace.go b/vendor/go.opencensus.io/plugin/ochttp/trace.go index c23b97fb1f..53e71305a5 100644 --- a/vendor/go.opencensus.io/plugin/ochttp/trace.go +++ b/vendor/go.opencensus.io/plugin/ochttp/trace.go @@ -186,6 +186,8 @@ func TraceStatus(httpStatusCode int, statusLine string) trace.Status { code = trace.StatusCodeCancelled case http.StatusBadRequest: code = trace.StatusCodeInvalidArgument + case http.StatusUnprocessableEntity: + code = trace.StatusCodeInvalidArgument case http.StatusGatewayTimeout: code = trace.StatusCodeDeadlineExceeded case http.StatusNotFound: diff --git a/vendor/go.opencensus.io/resource/resourcekeys/const.go b/vendor/go.opencensus.io/resource/resourcekeys/const.go index c8b7b2938f..1f2246662f 100644 --- a/vendor/go.opencensus.io/resource/resourcekeys/const.go +++ b/vendor/go.opencensus.io/resource/resourcekeys/const.go @@ -23,9 +23,10 @@ const ( // does not have cluster names as an internal concept so this may be // set to any meaningful value within the environment. For example, // GKE clusters have a name which can be used for this label. - K8SKeyClusterName = "k8s.cluster.name" - K8SKeyNamespaceName = "k8s.namespace.name" - K8SKeyPodName = "k8s.pod.name" + K8SKeyClusterName = "k8s.cluster.name" + K8SKeyNamespaceName = "k8s.namespace.name" + K8SKeyPodName = "k8s.pod.name" + K8SKeyDeploymentName = "k8s.deployment.name" ) // Constants for Container resources. diff --git a/vendor/go.opencensus.io/stats/view/aggregation.go b/vendor/go.opencensus.io/stats/view/aggregation.go index b7f169b4a5..8bd25314e2 100644 --- a/vendor/go.opencensus.io/stats/view/aggregation.go +++ b/vendor/go.opencensus.io/stats/view/aggregation.go @@ -82,7 +82,7 @@ func Sum() *Aggregation { // Distribution indicates that the desired aggregation is // a histogram distribution. // -// An distribution aggregation may contain a histogram of the values in the +// A distribution aggregation may contain a histogram of the values in the // population. The bucket boundaries for that histogram are described // by the bounds. This defines len(bounds)+1 buckets. // diff --git a/vendor/go.opencensus.io/stats/view/doc.go b/vendor/go.opencensus.io/stats/view/doc.go index dced225c3d..7bbedfe1ff 100644 --- a/vendor/go.opencensus.io/stats/view/doc.go +++ b/vendor/go.opencensus.io/stats/view/doc.go @@ -29,7 +29,7 @@ // LastValue just keeps track of the most recently recorded measurement value. // All aggregations are cumulative. // -// Views can be registerd and unregistered at any time during program execution. +// Views can be registered and unregistered at any time during program execution. // // Libraries can define views but it is recommended that in most cases registering // views be left up to applications. diff --git a/vendor/go.opencensus.io/stats/view/view.go b/vendor/go.opencensus.io/stats/view/view.go index 37f88e1d9f..293b54ecbe 100644 --- a/vendor/go.opencensus.io/stats/view/view.go +++ b/vendor/go.opencensus.io/stats/view/view.go @@ -30,7 +30,7 @@ import ( ) // View allows users to aggregate the recorded stats.Measurements. -// Views need to be passed to the Register function to be before data will be +// Views need to be passed to the Register function before data will be // collected and sent to Exporters. type View struct { Name string // Name of View. Must be unique. If unset, will default to the name of the Measure. @@ -43,7 +43,7 @@ type View struct { // Measure is a stats.Measure to aggregate in this view. Measure stats.Measure - // Aggregation is the aggregation function tp apply to the set of Measurements. + // Aggregation is the aggregation function to apply to the set of Measurements. Aggregation *Aggregation } @@ -189,7 +189,7 @@ func (r *Row) String() string { } // Equal returns true if both rows are equal. Tags are expected to be ordered -// by the key name. Even both rows have the same tags but the tags appear in +// by the key name. Even if both rows have the same tags but the tags appear in // different orders it will return false. func (r *Row) Equal(other *Row) bool { if r == other { diff --git a/vendor/go.opencensus.io/stats/view/view_to_metric.go b/vendor/go.opencensus.io/stats/view/view_to_metric.go index f67b5c4643..293c1646df 100644 --- a/vendor/go.opencensus.io/stats/view/view_to_metric.go +++ b/vendor/go.opencensus.io/stats/view/view_to_metric.go @@ -85,12 +85,21 @@ func viewToMetricDescriptor(v *View) *metricdata.Descriptor { return &metricdata.Descriptor{ Name: v.Name, Description: v.Description, - Unit: getUnit(v.Measure.Unit()), + Unit: convertUnit(v), Type: getType(v), LabelKeys: getLabelKeys(v), } } +func convertUnit(v *View) metricdata.Unit { + switch v.Aggregation.Type { + case AggTypeCount: + return metricdata.UnitDimensionless + default: + return getUnit(v.Measure.Unit()) + } +} + func toLabelValues(row *Row, expectedKeys []metricdata.LabelKey) []metricdata.LabelValue { labelValues := []metricdata.LabelValue{} tagMap := make(map[string]string) diff --git a/vendor/go.opencensus.io/tag/key.go b/vendor/go.opencensus.io/tag/key.go index 4e63d08c93..71ec913657 100644 --- a/vendor/go.opencensus.io/tag/key.go +++ b/vendor/go.opencensus.io/tag/key.go @@ -21,7 +21,7 @@ type Key struct { } // NewKey creates or retrieves a string key identified by name. -// Calling NewKey consequently with the same name returns the same key. +// Calling NewKey more than once with the same name returns the same key. func NewKey(name string) (Key, error) { if !checkKeyName(name) { return Key{}, errInvalidKeyName @@ -29,8 +29,7 @@ func NewKey(name string) (Key, error) { return Key{name: name}, nil } -// MustNewKey creates or retrieves a string key identified by name. -// An invalid key name raises a panic. +// MustNewKey returns a key with the given name, and panics if name is an invalid key name. func MustNewKey(name string) Key { k, err := NewKey(name) if err != nil { diff --git a/vendor/go.opencensus.io/tag/map_codec.go b/vendor/go.opencensus.io/tag/map_codec.go index f8b5827615..c242e695c8 100644 --- a/vendor/go.opencensus.io/tag/map_codec.go +++ b/vendor/go.opencensus.io/tag/map_codec.go @@ -168,7 +168,7 @@ func Encode(m *Map) []byte { eg := &encoderGRPC{ buf: make([]byte, len(m.m)), } - eg.writeByte(byte(tagsVersionID)) + eg.writeByte(tagsVersionID) for k, v := range m.m { if v.m.ttl.ttl == valueTTLUnlimitedPropagation { eg.writeByte(byte(keyTypeString)) diff --git a/vendor/go.opencensus.io/trace/lrumap.go b/vendor/go.opencensus.io/trace/lrumap.go index 3f80a33681..dc7a295c77 100644 --- a/vendor/go.opencensus.io/trace/lrumap.go +++ b/vendor/go.opencensus.io/trace/lrumap.go @@ -15,23 +15,47 @@ package trace import ( - "github.com/hashicorp/golang-lru/simplelru" + "github.com/golang/groupcache/lru" ) +// A simple lru.Cache wrapper that tracks the keys of the current contents and +// the cumulative number of evicted items. type lruMap struct { - simpleLruMap *simplelru.LRU + cacheKeys map[lru.Key]bool + cache *lru.Cache droppedCount int } func newLruMap(size int) *lruMap { - lm := &lruMap{} - lm.simpleLruMap, _ = simplelru.NewLRU(size, nil) + lm := &lruMap{ + cacheKeys: make(map[lru.Key]bool), + cache: lru.New(size), + droppedCount: 0, + } + lm.cache.OnEvicted = func(key lru.Key, value interface{}) { + delete(lm.cacheKeys, key) + lm.droppedCount++ + } return lm } -func (lm *lruMap) add(key, value interface{}) { - evicted := lm.simpleLruMap.Add(key, value) - if evicted { - lm.droppedCount++ +func (lm lruMap) len() int { + return lm.cache.Len() +} + +func (lm lruMap) keys() []interface{} { + keys := []interface{}{} + for k := range lm.cacheKeys { + keys = append(keys, k) } + return keys +} + +func (lm *lruMap) add(key, value interface{}) { + lm.cacheKeys[lru.Key(key)] = true + lm.cache.Add(lru.Key(key), value) +} + +func (lm *lruMap) get(key interface{}) (interface{}, bool) { + return lm.cache.Get(key) } diff --git a/vendor/go.opencensus.io/trace/trace.go b/vendor/go.opencensus.io/trace/trace.go index 38ead7bf0a..3f8977b41b 100644 --- a/vendor/go.opencensus.io/trace/trace.go +++ b/vendor/go.opencensus.io/trace/trace.go @@ -296,7 +296,7 @@ func (s *Span) makeSpanData() *SpanData { var sd SpanData s.mu.Lock() sd = *s.data - if s.lruAttributes.simpleLruMap.Len() > 0 { + if s.lruAttributes.len() > 0 { sd.Attributes = s.lruAttributesToAttributeMap() sd.DroppedAttributeCount = s.lruAttributes.droppedCount } @@ -370,8 +370,8 @@ func (s *Span) interfaceArrayToAnnotationArray() []Annotation { func (s *Span) lruAttributesToAttributeMap() map[string]interface{} { attributes := make(map[string]interface{}) - for _, key := range s.lruAttributes.simpleLruMap.Keys() { - value, ok := s.lruAttributes.simpleLruMap.Get(key) + for _, key := range s.lruAttributes.keys() { + value, ok := s.lruAttributes.get(key) if ok { keyStr := key.(string) attributes[keyStr] = value diff --git a/vendor/golang.org/x/net/http2/hpack/encode.go b/vendor/golang.org/x/net/http2/hpack/encode.go index 1565cf2702..97f17831fc 100644 --- a/vendor/golang.org/x/net/http2/hpack/encode.go +++ b/vendor/golang.org/x/net/http2/hpack/encode.go @@ -150,7 +150,7 @@ func appendIndexed(dst []byte, i uint64) []byte { // extended buffer. // // If f.Sensitive is true, "Never Indexed" representation is used. If -// f.Sensitive is false and indexing is true, "Inremental Indexing" +// f.Sensitive is false and indexing is true, "Incremental Indexing" // representation is used. func appendNewName(dst []byte, f HeaderField, indexing bool) []byte { dst = append(dst, encodeTypeByte(indexing, f.Sensitive)) diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go index 5e01ce9ab0..b7524ba268 100644 --- a/vendor/golang.org/x/net/http2/server.go +++ b/vendor/golang.org/x/net/http2/server.go @@ -322,7 +322,7 @@ type ServeConnOpts struct { } func (o *ServeConnOpts) context() context.Context { - if o.Context != nil { + if o != nil && o.Context != nil { return o.Context } return context.Background() @@ -2524,7 +2524,7 @@ const TrailerPrefix = "Trailer:" // trailers. That worked for a while, until we found the first major // user of Trailers in the wild: gRPC (using them only over http2), // and gRPC libraries permit setting trailers mid-stream without -// predeclarnig them. So: change of plans. We still permit the old +// predeclaring them. So: change of plans. We still permit the old // way, but we also permit this hack: if a Header() key begins with // "Trailer:", the suffix of that key is a Trailer. Because ':' is an // invalid token byte anyway, there is no ambiguity. (And it's already @@ -2824,7 +2824,7 @@ func (sc *serverConn) startPush(msg *startPushRequest) { // PUSH_PROMISE frames MUST only be sent on a peer-initiated stream that // is in either the "open" or "half-closed (remote)" state. if msg.parent.state != stateOpen && msg.parent.state != stateHalfClosedRemote { - // responseWriter.Push checks that the stream is peer-initiaed. + // responseWriter.Push checks that the stream is peer-initiated. msg.done <- errStreamClosed return } diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index aeac7d8a51..c51a73c069 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -1216,6 +1216,8 @@ var ( // abort request body write, but send stream reset of cancel. errStopReqBodyWriteAndCancel = errors.New("http2: canceling request") + + errReqBodyTooLong = errors.New("http2: request body larger than specified content length") ) func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) (err error) { @@ -1238,10 +1240,32 @@ func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) ( req := cs.req hasTrailers := req.Trailer != nil + remainLen := actualContentLength(req) + hasContentLen := remainLen != -1 var sawEOF bool for !sawEOF { - n, err := body.Read(buf) + n, err := body.Read(buf[:len(buf)-1]) + if hasContentLen { + remainLen -= int64(n) + if remainLen == 0 && err == nil { + // The request body's Content-Length was predeclared and + // we just finished reading it all, but the underlying io.Reader + // returned the final chunk with a nil error (which is one of + // the two valid things a Reader can do at EOF). Because we'd prefer + // to send the END_STREAM bit early, double-check that we're actually + // at EOF. Subsequent reads should return (0, EOF) at this point. + // If either value is different, we return an error in one of two ways below. + var n1 int + n1, err = body.Read(buf[n:]) + remainLen -= int64(n1) + } + if remainLen < 0 { + err = errReqBodyTooLong + cc.writeStreamReset(cs.ID, ErrCodeCancel, err) + return err + } + } if err == io.EOF { sawEOF = true err = nil diff --git a/vendor/golang.org/x/net/http2/writesched_priority.go b/vendor/golang.org/x/net/http2/writesched_priority.go index 848fed6ec7..2618b2c11d 100644 --- a/vendor/golang.org/x/net/http2/writesched_priority.go +++ b/vendor/golang.org/x/net/http2/writesched_priority.go @@ -149,7 +149,7 @@ func (n *priorityNode) addBytes(b int64) { } // walkReadyInOrder iterates over the tree in priority order, calling f for each node -// with a non-empty write queue. When f returns true, this funcion returns true and the +// with a non-empty write queue. When f returns true, this function returns true and the // walk halts. tmp is used as scratch space for sorting. // // f(n, openParent) takes two arguments: the node to visit, n, and a bool that is true diff --git a/vendor/golang.org/x/sync/errgroup/errgroup.go b/vendor/golang.org/x/sync/errgroup/errgroup.go deleted file mode 100644 index 9857fe53d3..0000000000 --- a/vendor/golang.org/x/sync/errgroup/errgroup.go +++ /dev/null @@ -1,66 +0,0 @@ -// 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. - -// Package errgroup provides synchronization, error propagation, and Context -// cancelation for groups of goroutines working on subtasks of a common task. -package errgroup - -import ( - "context" - "sync" -) - -// A Group is a collection of goroutines working on subtasks that are part of -// the same overall task. -// -// A zero Group is valid and does not cancel on error. -type Group struct { - cancel func() - - wg sync.WaitGroup - - errOnce sync.Once - err error -} - -// WithContext returns a new Group and an associated Context derived from ctx. -// -// The derived Context is canceled the first time a function passed to Go -// returns a non-nil error or the first time Wait returns, whichever occurs -// first. -func WithContext(ctx context.Context) (*Group, context.Context) { - ctx, cancel := context.WithCancel(ctx) - return &Group{cancel: cancel}, ctx -} - -// Wait blocks until all function calls from the Go method have returned, then -// returns the first non-nil error (if any) from them. -func (g *Group) Wait() error { - g.wg.Wait() - if g.cancel != nil { - g.cancel() - } - return g.err -} - -// Go calls the given function in a new goroutine. -// -// The first call to return a non-nil error cancels the group; its error will be -// returned by Wait. -func (g *Group) Go(f func() error) { - g.wg.Add(1) - - go func() { - defer g.wg.Done() - - if err := f(); err != nil { - g.errOnce.Do(func() { - g.err = err - if g.cancel != nil { - g.cancel() - } - }) - } - }() -} diff --git a/vendor/google.golang.org/api/AUTHORS b/vendor/google.golang.org/api/AUTHORS index f73b725745..f07029059d 100644 --- a/vendor/google.golang.org/api/AUTHORS +++ b/vendor/google.golang.org/api/AUTHORS @@ -8,3 +8,4 @@ # Please keep the list sorted. Google Inc. +LightStep Inc. diff --git a/vendor/google.golang.org/api/CONTRIBUTORS b/vendor/google.golang.org/api/CONTRIBUTORS index fe55ebff07..788677b8f0 100644 --- a/vendor/google.golang.org/api/CONTRIBUTORS +++ b/vendor/google.golang.org/api/CONTRIBUTORS @@ -45,6 +45,7 @@ Jason Hall Johan Euphrosine Kostik Shtoyk Kunpei Sakai +Matthew Dolan Matthew Whisenhunt Michael McGreevy Nick Craig-Wood diff --git a/vendor/google.golang.org/api/googleapi/transport/apikey.go b/vendor/google.golang.org/api/googleapi/transport/apikey.go index eca1ea2507..4b6c0d527e 100644 --- a/vendor/google.golang.org/api/googleapi/transport/apikey.go +++ b/vendor/google.golang.org/api/googleapi/transport/apikey.go @@ -1,4 +1,4 @@ -// Copyright 2012 Google Inc. All rights reserved. +// Copyright 2012 Google LLC. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/vendor/google.golang.org/api/internal/creds.go b/vendor/google.golang.org/api/internal/creds.go index 69b8659fdd..a6f9a2dea1 100644 --- a/vendor/google.golang.org/api/internal/creds.go +++ b/vendor/google.golang.org/api/internal/creds.go @@ -1,16 +1,6 @@ -// Copyright 2017 Google LLC -// -// 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. +// Copyright 2017 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. package internal diff --git a/vendor/google.golang.org/api/internal/pool.go b/vendor/google.golang.org/api/internal/pool.go index a4426dcb70..0680dd9901 100644 --- a/vendor/google.golang.org/api/internal/pool.go +++ b/vendor/google.golang.org/api/internal/pool.go @@ -1,16 +1,6 @@ -// Copyright 2016 Google LLC -// -// 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. +// Copyright 2016 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. package internal diff --git a/vendor/google.golang.org/api/internal/settings.go b/vendor/google.golang.org/api/internal/settings.go index 062301c65f..544d715c87 100644 --- a/vendor/google.golang.org/api/internal/settings.go +++ b/vendor/google.golang.org/api/internal/settings.go @@ -1,16 +1,6 @@ -// Copyright 2017 Google LLC -// -// 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. +// Copyright 2017 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // Package internal supports the options and transport packages. package internal @@ -27,19 +17,20 @@ import ( // DialSettings holds information needed to establish a connection with a // Google API service. type DialSettings struct { - Endpoint string - Scopes []string - TokenSource oauth2.TokenSource - Credentials *google.Credentials - CredentialsFile string // if set, Token Source is ignored. - CredentialsJSON []byte - UserAgent string - APIKey string - Audiences []string - HTTPClient *http.Client - GRPCDialOpts []grpc.DialOption - GRPCConn *grpc.ClientConn - NoAuth bool + Endpoint string + Scopes []string + TokenSource oauth2.TokenSource + Credentials *google.Credentials + CredentialsFile string // if set, Token Source is ignored. + CredentialsJSON []byte + UserAgent string + APIKey string + Audiences []string + HTTPClient *http.Client + GRPCDialOpts []grpc.DialOption + GRPCConn *grpc.ClientConn + NoAuth bool + TelemetryDisabled bool // Google API system parameters. For more information please read: // https://cloud.google.com/apis/docs/system-parameters diff --git a/vendor/google.golang.org/api/iterator/iterator.go b/vendor/google.golang.org/api/iterator/iterator.go index 3c8ea7732a..1799b5d9af 100644 --- a/vendor/google.golang.org/api/iterator/iterator.go +++ b/vendor/google.golang.org/api/iterator/iterator.go @@ -1,16 +1,6 @@ -// Copyright 2016 Google LLC -// -// 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. +// Copyright 2016 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // Package iterator provides support for standard Google API iterators. // See https://github.com/GoogleCloudPlatform/gcloud-golang/wiki/Iterator-Guidelines. @@ -82,17 +72,23 @@ type PageInfo struct { // It is not a stable interface. var NewPageInfo = newPageInfo -// If an iterator can support paging, its iterator-creating method should call -// this (via the NewPageInfo variable above). +// newPageInfo creates and returns a PageInfo and a next func. If an iterator can +// support paging, its iterator-creating method should call this. Each time the +// iterator's Next is called, it should call the returned next fn to determine +// whether a next item exists, and if so it should pop an item from the buffer. // -// The fetch, bufLen and takeBuf arguments provide access to the -// iterator's internal slice of buffered items. They behave as described in -// PageInfo, above. +// The fetch, bufLen and takeBuf arguments provide access to the iterator's +// internal slice of buffered items. They behave as described in PageInfo, above. // // The return value is the PageInfo.next method bound to the returned PageInfo value. // (Returning it avoids exporting PageInfo.next.) -func newPageInfo(fetch func(int, string) (string, error), bufLen func() int, takeBuf func() interface{}) (*PageInfo, func() error) { - pi := &PageInfo{ +// +// Note: the returned PageInfo and next fn do not remove items from the buffer. +// It is up to the iterator using these to remove items from the buffer: +// typically by performing a pop in its Next. If items are not removed from the +// buffer, memory may grow unbounded. +func newPageInfo(fetch func(int, string) (string, error), bufLen func() int, takeBuf func() interface{}) (pi *PageInfo, next func() error) { + pi = &PageInfo{ fetch: fetch, bufLen: bufLen, takeBuf: takeBuf, diff --git a/vendor/google.golang.org/api/option/credentials_go19.go b/vendor/google.golang.org/api/option/credentials_go19.go index 0636a82945..d06f918b0e 100644 --- a/vendor/google.golang.org/api/option/credentials_go19.go +++ b/vendor/google.golang.org/api/option/credentials_go19.go @@ -1,16 +1,6 @@ -// Copyright 2018 Google LLC -// -// 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. +// Copyright 2018 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // +build go1.9 diff --git a/vendor/google.golang.org/api/option/credentials_notgo19.go b/vendor/google.golang.org/api/option/credentials_notgo19.go index 74d3a4b5b9..0ce107a624 100644 --- a/vendor/google.golang.org/api/option/credentials_notgo19.go +++ b/vendor/google.golang.org/api/option/credentials_notgo19.go @@ -1,16 +1,6 @@ -// Copyright 2018 Google LLC -// -// 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. +// Copyright 2018 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // +build !go1.9 diff --git a/vendor/google.golang.org/api/option/option.go b/vendor/google.golang.org/api/option/option.go index 0a1c2dba9e..8a4cd166ca 100644 --- a/vendor/google.golang.org/api/option/option.go +++ b/vendor/google.golang.org/api/option/option.go @@ -1,16 +1,6 @@ -// Copyright 2017 Google LLC -// -// 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. +// Copyright 2017 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // Package option contains options for Google API clients. package option @@ -233,3 +223,16 @@ type withRequestReason string func (w withRequestReason) Apply(o *internal.DialSettings) { o.RequestReason = string(w) } + +// WithTelemetryDisabled returns a ClientOption that disables default telemetry (OpenCensus) +// settings on gRPC and HTTP clients. +// An example reason would be to bind custom telemetry that overrides the defaults. +func WithTelemetryDisabled() ClientOption { + return withTelemetryDisabledOption{} +} + +type withTelemetryDisabledOption struct{} + +func (w withTelemetryDisabledOption) Apply(o *internal.DialSettings) { + o.TelemetryDisabled = true +} diff --git a/vendor/google.golang.org/api/support/bundler/bundler.go b/vendor/google.golang.org/api/support/bundler/bundler.go index c553271190..8c9693b84b 100644 --- a/vendor/google.golang.org/api/support/bundler/bundler.go +++ b/vendor/google.golang.org/api/support/bundler/bundler.go @@ -1,16 +1,6 @@ -// Copyright 2016 Google LLC -// -// 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. +// Copyright 2016 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // Package bundler supports bundling (batching) of items. Bundling amortizes an // action with fixed costs over multiple items. For example, if an API provides @@ -192,7 +182,7 @@ func (b *Bundler) add(item interface{}, size int) { // (We could try to call Reset on the timer instead, but that would add a lot // of complexity to the code just to save one small allocation.) if b.flushTimer == nil { - b.flushTimer = time.AfterFunc(b.DelayThreshold, b.Flush) + b.flushTimer = time.AfterFunc(b.DelayThreshold, b.flushWithoutWait) } // If the current bundle equals the count threshold, close it. @@ -236,6 +226,14 @@ func (b *Bundler) AddWait(ctx context.Context, item interface{}, size int) error return nil } +// flushWithoutWait forces the current bundle to be be flushed if non-empty (but +// doesn't wait for any bundles to actually be handled). +func (b *Bundler) flushWithoutWait() { + b.mu.Lock() + b.startFlushLocked() + b.mu.Unlock() +} + // Flush invokes the handler for all remaining items in the Bundler and waits // for it to return. func (b *Bundler) Flush() { diff --git a/vendor/google.golang.org/api/transport/dial.go b/vendor/google.golang.org/api/transport/dial.go index 1fb7cf905d..2c495ad538 100644 --- a/vendor/google.golang.org/api/transport/dial.go +++ b/vendor/google.golang.org/api/transport/dial.go @@ -1,16 +1,6 @@ -// Copyright 2015 Google LLC -// -// 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. +// Copyright 2015 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. package transport diff --git a/vendor/google.golang.org/api/transport/doc.go b/vendor/google.golang.org/api/transport/doc.go index 4915036c35..7143abee45 100644 --- a/vendor/google.golang.org/api/transport/doc.go +++ b/vendor/google.golang.org/api/transport/doc.go @@ -1,16 +1,6 @@ -// Copyright 2019 Google LLC -// -// 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. +// Copyright 2019 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // Package transport provides utility methods for creating authenticated // transports to Google's HTTP and gRPC APIs. It is intended to be used in diff --git a/vendor/google.golang.org/api/transport/go19.go b/vendor/google.golang.org/api/transport/go19.go index 3e89f93287..abaa633f4e 100644 --- a/vendor/google.golang.org/api/transport/go19.go +++ b/vendor/google.golang.org/api/transport/go19.go @@ -1,16 +1,6 @@ -// Copyright 2018 Google LLC -// -// 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. +// Copyright 2018 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // +build go1.9 diff --git a/vendor/google.golang.org/api/transport/grpc/dial.go b/vendor/google.golang.org/api/transport/grpc/dial.go index b850246ce2..7526e6820c 100644 --- a/vendor/google.golang.org/api/transport/grpc/dial.go +++ b/vendor/google.golang.org/api/transport/grpc/dial.go @@ -1,16 +1,6 @@ -// Copyright 2015 Google LLC -// -// 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. +// Copyright 2015 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // Package grpc supports network connections to GRPC servers. // This package is not intended for use by end developers. Use the @@ -118,7 +108,7 @@ func dial(ctx context.Context, insecure bool, opts []option.ClientOption) (*grpc // Add tracing, but before the other options, so that clients can override the // gRPC stats handler. // This assumes that gRPC options are processed in order, left to right. - grpcOpts = addOCStatsHandler(grpcOpts) + grpcOpts = addOCStatsHandler(grpcOpts, o) grpcOpts = append(grpcOpts, o.GRPCDialOpts...) if o.UserAgent != "" { grpcOpts = append(grpcOpts, grpc.WithUserAgent(o.UserAgent)) @@ -135,7 +125,10 @@ func dial(ctx context.Context, insecure bool, opts []option.ClientOption) (*grpc return grpc.DialContext(ctx, o.Endpoint, grpcOpts...) } -func addOCStatsHandler(opts []grpc.DialOption) []grpc.DialOption { +func addOCStatsHandler(opts []grpc.DialOption, settings internal.DialSettings) []grpc.DialOption { + if settings.TelemetryDisabled { + return opts + } return append(opts, grpc.WithStatsHandler(&ocgrpc.ClientHandler{})) } diff --git a/vendor/google.golang.org/api/transport/grpc/dial_appengine.go b/vendor/google.golang.org/api/transport/grpc/dial_appengine.go index 87819d4e10..2c6aef2264 100644 --- a/vendor/google.golang.org/api/transport/grpc/dial_appengine.go +++ b/vendor/google.golang.org/api/transport/grpc/dial_appengine.go @@ -1,16 +1,6 @@ -// Copyright 2016 Google LLC -// -// 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. +// Copyright 2016 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // +build appengine diff --git a/vendor/google.golang.org/api/transport/grpc/dial_socketopt.go b/vendor/google.golang.org/api/transport/grpc/dial_socketopt.go index 2b1d9e99b1..0e4f388968 100644 --- a/vendor/google.golang.org/api/transport/grpc/dial_socketopt.go +++ b/vendor/google.golang.org/api/transport/grpc/dial_socketopt.go @@ -1,16 +1,6 @@ -// Copyright 2019 Google LLC -// -// 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. +// Copyright 2019 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // +build go1.11,linux diff --git a/vendor/google.golang.org/api/transport/http/dial.go b/vendor/google.golang.org/api/transport/http/dial.go index c0d8bf20b0..1ef67cefb7 100644 --- a/vendor/google.golang.org/api/transport/http/dial.go +++ b/vendor/google.golang.org/api/transport/http/dial.go @@ -1,16 +1,6 @@ -// Copyright 2015 Google LLC -// -// 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. +// Copyright 2015 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // Package http supports network connections to HTTP servers. // This package is not intended for use by end developers. Use the @@ -70,7 +60,7 @@ func newTransport(ctx context.Context, base http.RoundTripper, settings *interna quotaProject: settings.QuotaProject, requestReason: settings.RequestReason, } - trans = addOCTransport(trans) + trans = addOCTransport(trans, settings) switch { case settings.NoAuth: // Do nothing. @@ -119,16 +109,15 @@ func (t parameterTransport) RoundTrip(req *http.Request) (*http.Response, error) if rt == nil { return nil, errors.New("transport: no Transport specified") } - if t.userAgent == "" { - return rt.RoundTrip(req) - } newReq := *req newReq.Header = make(http.Header) for k, vv := range req.Header { newReq.Header[k] = vv } - // TODO(cbro): append to existing User-Agent header? - newReq.Header.Set("User-Agent", t.userAgent) + if t.userAgent != "" { + // TODO(cbro): append to existing User-Agent header? + newReq.Header.Set("User-Agent", t.userAgent) + } // Attach system parameters into the header if t.quotaProject != "" { @@ -153,7 +142,10 @@ func defaultBaseTransport(ctx context.Context) http.RoundTripper { return http.DefaultTransport } -func addOCTransport(trans http.RoundTripper) http.RoundTripper { +func addOCTransport(trans http.RoundTripper, settings *internal.DialSettings) http.RoundTripper { + if settings.TelemetryDisabled { + return trans + } return &ochttp.Transport{ Base: trans, Propagation: &propagation.HTTPFormat{}, diff --git a/vendor/google.golang.org/api/transport/http/dial_appengine.go b/vendor/google.golang.org/api/transport/http/dial_appengine.go index 04c81413c5..baee9f27af 100644 --- a/vendor/google.golang.org/api/transport/http/dial_appengine.go +++ b/vendor/google.golang.org/api/transport/http/dial_appengine.go @@ -1,16 +1,6 @@ -// Copyright 2016 Google LLC -// -// 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. +// Copyright 2016 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // +build appengine diff --git a/vendor/google.golang.org/api/transport/http/internal/propagation/http.go b/vendor/google.golang.org/api/transport/http/internal/propagation/http.go index 24b4f0d291..fb951bb162 100644 --- a/vendor/google.golang.org/api/transport/http/internal/propagation/http.go +++ b/vendor/google.golang.org/api/transport/http/internal/propagation/http.go @@ -1,16 +1,6 @@ -// Copyright 2018 Google LLC -// -// 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. +// Copyright 2018 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // +build go1.8 diff --git a/vendor/google.golang.org/api/transport/not_go19.go b/vendor/google.golang.org/api/transport/not_go19.go index 0cb6275944..657bb6b2e9 100644 --- a/vendor/google.golang.org/api/transport/not_go19.go +++ b/vendor/google.golang.org/api/transport/not_go19.go @@ -1,16 +1,6 @@ -// Copyright 2018 Google LLC -// -// 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. +// Copyright 2018 Google LLC. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. // +build !go1.9 diff --git a/vendor/k8s.io/api/admission/v1beta1/generated.pb.go b/vendor/k8s.io/api/admission/v1beta1/generated.pb.go deleted file mode 100644 index 3bf0d1c622..0000000000 --- a/vendor/k8s.io/api/admission/v1beta1/generated.pb.go +++ /dev/null @@ -1,1573 +0,0 @@ -/* -Copyright 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. -*/ - -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: k8s.io/kubernetes/vendor/k8s.io/api/admission/v1beta1/generated.proto - -/* - Package v1beta1 is a generated protocol buffer package. - - It is generated from these files: - k8s.io/kubernetes/vendor/k8s.io/api/admission/v1beta1/generated.proto - - It has these top-level messages: - AdmissionRequest - AdmissionResponse - AdmissionReview -*/ -package v1beta1 - -import ( - fmt "fmt" - - proto "github.com/gogo/protobuf/proto" - - math "math" - - k8s_io_apimachinery_pkg_apis_meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - k8s_io_apimachinery_pkg_types "k8s.io/apimachinery/pkg/types" - - github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" - - strings "strings" - - reflect "reflect" - - io "io" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package - -func (m *AdmissionRequest) Reset() { *m = AdmissionRequest{} } -func (*AdmissionRequest) ProtoMessage() {} -func (*AdmissionRequest) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{0} } - -func (m *AdmissionResponse) Reset() { *m = AdmissionResponse{} } -func (*AdmissionResponse) ProtoMessage() {} -func (*AdmissionResponse) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{1} } - -func (m *AdmissionReview) Reset() { *m = AdmissionReview{} } -func (*AdmissionReview) ProtoMessage() {} -func (*AdmissionReview) Descriptor() ([]byte, []int) { return fileDescriptorGenerated, []int{2} } - -func init() { - proto.RegisterType((*AdmissionRequest)(nil), "k8s.io.api.admission.v1beta1.AdmissionRequest") - proto.RegisterType((*AdmissionResponse)(nil), "k8s.io.api.admission.v1beta1.AdmissionResponse") - proto.RegisterType((*AdmissionReview)(nil), "k8s.io.api.admission.v1beta1.AdmissionReview") -} -func (m *AdmissionRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *AdmissionRequest) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.UID))) - i += copy(dAtA[i:], m.UID) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Kind.Size())) - n1, err := m.Kind.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n1 - dAtA[i] = 0x1a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Resource.Size())) - n2, err := m.Resource.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n2 - dAtA[i] = 0x22 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.SubResource))) - i += copy(dAtA[i:], m.SubResource) - dAtA[i] = 0x2a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) - dAtA[i] = 0x32 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Namespace))) - i += copy(dAtA[i:], m.Namespace) - dAtA[i] = 0x3a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Operation))) - i += copy(dAtA[i:], m.Operation) - dAtA[i] = 0x42 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.UserInfo.Size())) - n3, err := m.UserInfo.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n3 - dAtA[i] = 0x4a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Object.Size())) - n4, err := m.Object.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n4 - dAtA[i] = 0x52 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.OldObject.Size())) - n5, err := m.OldObject.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n5 - if m.DryRun != nil { - dAtA[i] = 0x58 - i++ - if *m.DryRun { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ - } - dAtA[i] = 0x62 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Options.Size())) - n6, err := m.Options.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n6 - if m.RequestKind != nil { - dAtA[i] = 0x6a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.RequestKind.Size())) - n7, err := m.RequestKind.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n7 - } - if m.RequestResource != nil { - dAtA[i] = 0x72 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.RequestResource.Size())) - n8, err := m.RequestResource.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n8 - } - dAtA[i] = 0x7a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.RequestSubResource))) - i += copy(dAtA[i:], m.RequestSubResource) - return i, nil -} - -func (m *AdmissionResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *AdmissionResponse) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.UID))) - i += copy(dAtA[i:], m.UID) - dAtA[i] = 0x10 - i++ - if m.Allowed { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i++ - if m.Result != nil { - dAtA[i] = 0x1a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Result.Size())) - n9, err := m.Result.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n9 - } - if m.Patch != nil { - dAtA[i] = 0x22 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(m.Patch))) - i += copy(dAtA[i:], m.Patch) - } - if m.PatchType != nil { - dAtA[i] = 0x2a - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(*m.PatchType))) - i += copy(dAtA[i:], *m.PatchType) - } - if len(m.AuditAnnotations) > 0 { - keysForAuditAnnotations := make([]string, 0, len(m.AuditAnnotations)) - for k := range m.AuditAnnotations { - keysForAuditAnnotations = append(keysForAuditAnnotations, string(k)) - } - github_com_gogo_protobuf_sortkeys.Strings(keysForAuditAnnotations) - for _, k := range keysForAuditAnnotations { - dAtA[i] = 0x32 - i++ - v := m.AuditAnnotations[string(k)] - mapSize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + len(v) + sovGenerated(uint64(len(v))) - i = encodeVarintGenerated(dAtA, i, uint64(mapSize)) - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(k))) - i += copy(dAtA[i:], k) - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(len(v))) - i += copy(dAtA[i:], v) - } - } - return i, nil -} - -func (m *AdmissionReview) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *AdmissionReview) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Request != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Request.Size())) - n10, err := m.Request.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n10 - } - if m.Response != nil { - dAtA[i] = 0x12 - i++ - i = encodeVarintGenerated(dAtA, i, uint64(m.Response.Size())) - n11, err := m.Response.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n11 - } - return i, nil -} - -func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int { - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return offset + 1 -} -func (m *AdmissionRequest) Size() (n int) { - var l int - _ = l - l = len(m.UID) - n += 1 + l + sovGenerated(uint64(l)) - l = m.Kind.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = m.Resource.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.SubResource) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Name) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Namespace) - n += 1 + l + sovGenerated(uint64(l)) - l = len(m.Operation) - n += 1 + l + sovGenerated(uint64(l)) - l = m.UserInfo.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = m.Object.Size() - n += 1 + l + sovGenerated(uint64(l)) - l = m.OldObject.Size() - n += 1 + l + sovGenerated(uint64(l)) - if m.DryRun != nil { - n += 2 - } - l = m.Options.Size() - n += 1 + l + sovGenerated(uint64(l)) - if m.RequestKind != nil { - l = m.RequestKind.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if m.RequestResource != nil { - l = m.RequestResource.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - l = len(m.RequestSubResource) - n += 1 + l + sovGenerated(uint64(l)) - return n -} - -func (m *AdmissionResponse) Size() (n int) { - var l int - _ = l - l = len(m.UID) - n += 1 + l + sovGenerated(uint64(l)) - n += 2 - if m.Result != nil { - l = m.Result.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if m.Patch != nil { - l = len(m.Patch) - n += 1 + l + sovGenerated(uint64(l)) - } - if m.PatchType != nil { - l = len(*m.PatchType) - n += 1 + l + sovGenerated(uint64(l)) - } - if len(m.AuditAnnotations) > 0 { - for k, v := range m.AuditAnnotations { - _ = k - _ = v - mapEntrySize := 1 + len(k) + sovGenerated(uint64(len(k))) + 1 + len(v) + sovGenerated(uint64(len(v))) - n += mapEntrySize + 1 + sovGenerated(uint64(mapEntrySize)) - } - } - return n -} - -func (m *AdmissionReview) Size() (n int) { - var l int - _ = l - if m.Request != nil { - l = m.Request.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - if m.Response != nil { - l = m.Response.Size() - n += 1 + l + sovGenerated(uint64(l)) - } - return n -} - -func sovGenerated(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n -} -func sozGenerated(x uint64) (n int) { - return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (this *AdmissionRequest) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&AdmissionRequest{`, - `UID:` + fmt.Sprintf("%v", this.UID) + `,`, - `Kind:` + strings.Replace(strings.Replace(this.Kind.String(), "GroupVersionKind", "k8s_io_apimachinery_pkg_apis_meta_v1.GroupVersionKind", 1), `&`, ``, 1) + `,`, - `Resource:` + strings.Replace(strings.Replace(this.Resource.String(), "GroupVersionResource", "k8s_io_apimachinery_pkg_apis_meta_v1.GroupVersionResource", 1), `&`, ``, 1) + `,`, - `SubResource:` + fmt.Sprintf("%v", this.SubResource) + `,`, - `Name:` + fmt.Sprintf("%v", this.Name) + `,`, - `Namespace:` + fmt.Sprintf("%v", this.Namespace) + `,`, - `Operation:` + fmt.Sprintf("%v", this.Operation) + `,`, - `UserInfo:` + strings.Replace(strings.Replace(this.UserInfo.String(), "UserInfo", "k8s_io_api_authentication_v1.UserInfo", 1), `&`, ``, 1) + `,`, - `Object:` + strings.Replace(strings.Replace(this.Object.String(), "RawExtension", "k8s_io_apimachinery_pkg_runtime.RawExtension", 1), `&`, ``, 1) + `,`, - `OldObject:` + strings.Replace(strings.Replace(this.OldObject.String(), "RawExtension", "k8s_io_apimachinery_pkg_runtime.RawExtension", 1), `&`, ``, 1) + `,`, - `DryRun:` + valueToStringGenerated(this.DryRun) + `,`, - `Options:` + strings.Replace(strings.Replace(this.Options.String(), "RawExtension", "k8s_io_apimachinery_pkg_runtime.RawExtension", 1), `&`, ``, 1) + `,`, - `RequestKind:` + strings.Replace(fmt.Sprintf("%v", this.RequestKind), "GroupVersionKind", "k8s_io_apimachinery_pkg_apis_meta_v1.GroupVersionKind", 1) + `,`, - `RequestResource:` + strings.Replace(fmt.Sprintf("%v", this.RequestResource), "GroupVersionResource", "k8s_io_apimachinery_pkg_apis_meta_v1.GroupVersionResource", 1) + `,`, - `RequestSubResource:` + fmt.Sprintf("%v", this.RequestSubResource) + `,`, - `}`, - }, "") - return s -} -func (this *AdmissionResponse) String() string { - if this == nil { - return "nil" - } - keysForAuditAnnotations := make([]string, 0, len(this.AuditAnnotations)) - for k := range this.AuditAnnotations { - keysForAuditAnnotations = append(keysForAuditAnnotations, k) - } - github_com_gogo_protobuf_sortkeys.Strings(keysForAuditAnnotations) - mapStringForAuditAnnotations := "map[string]string{" - for _, k := range keysForAuditAnnotations { - mapStringForAuditAnnotations += fmt.Sprintf("%v: %v,", k, this.AuditAnnotations[k]) - } - mapStringForAuditAnnotations += "}" - s := strings.Join([]string{`&AdmissionResponse{`, - `UID:` + fmt.Sprintf("%v", this.UID) + `,`, - `Allowed:` + fmt.Sprintf("%v", this.Allowed) + `,`, - `Result:` + strings.Replace(fmt.Sprintf("%v", this.Result), "Status", "k8s_io_apimachinery_pkg_apis_meta_v1.Status", 1) + `,`, - `Patch:` + valueToStringGenerated(this.Patch) + `,`, - `PatchType:` + valueToStringGenerated(this.PatchType) + `,`, - `AuditAnnotations:` + mapStringForAuditAnnotations + `,`, - `}`, - }, "") - return s -} -func (this *AdmissionReview) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&AdmissionReview{`, - `Request:` + strings.Replace(fmt.Sprintf("%v", this.Request), "AdmissionRequest", "AdmissionRequest", 1) + `,`, - `Response:` + strings.Replace(fmt.Sprintf("%v", this.Response), "AdmissionResponse", "AdmissionResponse", 1) + `,`, - `}`, - }, "") - return s -} -func valueToStringGenerated(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) -} -func (m *AdmissionRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AdmissionRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AdmissionRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UID = k8s_io_apimachinery_pkg_types.UID(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Kind.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Resource", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Resource.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SubResource", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SubResource = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Namespace = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Operation", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Operation = Operation(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserInfo", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.UserInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Object", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Object.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OldObject", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OldObject.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DryRun", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - b := bool(v != 0) - m.DryRun = &b - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestKind", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RequestKind == nil { - m.RequestKind = &k8s_io_apimachinery_pkg_apis_meta_v1.GroupVersionKind{} - } - if err := m.RequestKind.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestResource", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.RequestResource == nil { - m.RequestResource = &k8s_io_apimachinery_pkg_apis_meta_v1.GroupVersionResource{} - } - if err := m.RequestResource.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 15: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestSubResource", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RequestSubResource = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AdmissionResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AdmissionResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AdmissionResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UID", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UID = k8s_io_apimachinery_pkg_types.UID(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Allowed", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - m.Allowed = bool(v != 0) - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Result == nil { - m.Result = &k8s_io_apimachinery_pkg_apis_meta_v1.Status{} - } - if err := m.Result.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Patch", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + byteLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Patch = append(m.Patch[:0], dAtA[iNdEx:postIndex]...) - if m.Patch == nil { - m.Patch = []byte{} - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PatchType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - s := PatchType(dAtA[iNdEx:postIndex]) - m.PatchType = &s - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AuditAnnotations", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.AuditAnnotations == nil { - m.AuditAnnotations = make(map[string]string) - } - var mapkey string - var mapvalue string - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthGenerated - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var stringLenmapvalue uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapvalue |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapvalue := int(stringLenmapvalue) - if intStringLenmapvalue < 0 { - return ErrInvalidLengthGenerated - } - postStringIndexmapvalue := iNdEx + intStringLenmapvalue - if postStringIndexmapvalue > l { - return io.ErrUnexpectedEOF - } - mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) - iNdEx = postStringIndexmapvalue - } else { - iNdEx = entryPreIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.AuditAnnotations[mapkey] = mapvalue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AdmissionReview) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AdmissionReview: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AdmissionReview: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Request", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Request == nil { - m.Request = &AdmissionRequest{} - } - if err := m.Request.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Response", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Response == nil { - m.Response = &AdmissionResponse{} - } - if err := m.Response.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenerated(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - return iNdEx, nil - case 1: - iNdEx += 8 - return iNdEx, nil - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - iNdEx += length - if length < 0 { - return 0, ErrInvalidLengthGenerated - } - return iNdEx, nil - case 3: - for { - var innerWire uint64 - var start int = iNdEx - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - innerWire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - innerWireType := int(innerWire & 0x7) - if innerWireType == 4 { - break - } - next, err := skipGenerated(dAtA[start:]) - if err != nil { - return 0, err - } - iNdEx = start + next - } - return iNdEx, nil - case 4: - return iNdEx, nil - case 5: - iNdEx += 4 - return iNdEx, nil - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - } - panic("unreachable") -} - -var ( - ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") -) - -func init() { - proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/api/admission/v1beta1/generated.proto", fileDescriptorGenerated) -} - -var fileDescriptorGenerated = []byte{ - // 905 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4d, 0x6f, 0x23, 0x35, - 0x18, 0xce, 0x6c, 0xd2, 0x24, 0xe3, 0x94, 0x4d, 0xd6, 0x0b, 0xd2, 0x28, 0x42, 0x93, 0xd0, 0x03, - 0x2a, 0xd2, 0xd6, 0x43, 0x2b, 0x58, 0x55, 0x2b, 0x2e, 0x1d, 0x5a, 0xa1, 0x82, 0xb4, 0xad, 0xbc, - 0x1b, 0xb4, 0x70, 0x40, 0x72, 0x32, 0xde, 0x64, 0x48, 0x62, 0x0f, 0x63, 0x4f, 0x4a, 0x6e, 0x88, - 0x2b, 0x17, 0xfe, 0x01, 0x3f, 0x86, 0x4b, 0x8f, 0x7b, 0xdc, 0x53, 0x44, 0xc3, 0xbf, 0xe8, 0x09, - 0xd9, 0xe3, 0xc9, 0xcc, 0x26, 0x2d, 0xec, 0x07, 0xa7, 0x99, 0xf7, 0xe3, 0x79, 0x5e, 0xfb, 0x79, - 0x5f, 0xdb, 0xe0, 0x64, 0x7c, 0x28, 0x50, 0xc8, 0xbd, 0x71, 0xd2, 0xa7, 0x31, 0xa3, 0x92, 0x0a, - 0x6f, 0x46, 0x59, 0xc0, 0x63, 0xcf, 0x04, 0x48, 0x14, 0x7a, 0x24, 0x98, 0x86, 0x42, 0x84, 0x9c, - 0x79, 0xb3, 0xfd, 0x3e, 0x95, 0x64, 0xdf, 0x1b, 0x52, 0x46, 0x63, 0x22, 0x69, 0x80, 0xa2, 0x98, - 0x4b, 0x0e, 0x3f, 0x4c, 0xb3, 0x11, 0x89, 0x42, 0xb4, 0xca, 0x46, 0x26, 0xbb, 0xbd, 0x37, 0x0c, - 0xe5, 0x28, 0xe9, 0xa3, 0x01, 0x9f, 0x7a, 0x43, 0x3e, 0xe4, 0x9e, 0x06, 0xf5, 0x93, 0xe7, 0xda, - 0xd2, 0x86, 0xfe, 0x4b, 0xc9, 0xda, 0x0f, 0x8a, 0xa5, 0x13, 0x39, 0xa2, 0x4c, 0x86, 0x03, 0x22, - 0xd3, 0xfa, 0xeb, 0xa5, 0xdb, 0x9f, 0xe5, 0xd9, 0x53, 0x32, 0x18, 0x85, 0x8c, 0xc6, 0x73, 0x2f, - 0x1a, 0x0f, 0x95, 0x43, 0x78, 0x53, 0x2a, 0xc9, 0x4d, 0x28, 0xef, 0x36, 0x54, 0x9c, 0x30, 0x19, - 0x4e, 0xe9, 0x06, 0xe0, 0xe1, 0x7f, 0x01, 0xc4, 0x60, 0x44, 0xa7, 0x64, 0x1d, 0xb7, 0xf3, 0x87, - 0x0d, 0x5a, 0x47, 0x99, 0x22, 0x98, 0xfe, 0x94, 0x50, 0x21, 0xa1, 0x0f, 0xca, 0x49, 0x18, 0x38, - 0x56, 0xd7, 0xda, 0xb5, 0xfd, 0x4f, 0x2f, 0x17, 0x9d, 0xd2, 0x72, 0xd1, 0x29, 0xf7, 0x4e, 0x8f, - 0xaf, 0x17, 0x9d, 0x8f, 0x6e, 0x2b, 0x24, 0xe7, 0x11, 0x15, 0xa8, 0x77, 0x7a, 0x8c, 0x15, 0x18, - 0x3e, 0x03, 0x95, 0x71, 0xc8, 0x02, 0xe7, 0x4e, 0xd7, 0xda, 0x6d, 0x1c, 0x3c, 0x44, 0x79, 0x07, - 0x56, 0x30, 0x14, 0x8d, 0x87, 0xca, 0x21, 0x90, 0x92, 0x01, 0xcd, 0xf6, 0xd1, 0x57, 0x31, 0x4f, - 0xa2, 0x6f, 0x69, 0xac, 0x16, 0xf3, 0x4d, 0xc8, 0x02, 0x7f, 0xdb, 0x14, 0xaf, 0x28, 0x0b, 0x6b, - 0x46, 0x38, 0x02, 0xf5, 0x98, 0x0a, 0x9e, 0xc4, 0x03, 0xea, 0x94, 0x35, 0xfb, 0xa3, 0x37, 0x67, - 0xc7, 0x86, 0xc1, 0x6f, 0x99, 0x0a, 0xf5, 0xcc, 0x83, 0x57, 0xec, 0xf0, 0x73, 0xd0, 0x10, 0x49, - 0x3f, 0x0b, 0x38, 0x15, 0xad, 0xc7, 0x7d, 0x03, 0x68, 0x3c, 0xc9, 0x43, 0xb8, 0x98, 0x07, 0xbb, - 0xa0, 0xc2, 0xc8, 0x94, 0x3a, 0x5b, 0x3a, 0x7f, 0xb5, 0x85, 0xc7, 0x64, 0x4a, 0xb1, 0x8e, 0x40, - 0x0f, 0xd8, 0xea, 0x2b, 0x22, 0x32, 0xa0, 0x4e, 0x55, 0xa7, 0xdd, 0x33, 0x69, 0xf6, 0xe3, 0x2c, - 0x80, 0xf3, 0x1c, 0xf8, 0x05, 0xb0, 0x79, 0xa4, 0x1a, 0x17, 0x72, 0xe6, 0xd4, 0x34, 0xc0, 0xcd, - 0x00, 0x67, 0x59, 0xe0, 0xba, 0x68, 0xe0, 0x1c, 0x00, 0x9f, 0x82, 0x7a, 0x22, 0x68, 0x7c, 0xca, - 0x9e, 0x73, 0xa7, 0xae, 0x15, 0xfb, 0x18, 0x15, 0x4f, 0xc4, 0x2b, 0x43, 0xac, 0x94, 0xea, 0x99, - 0xec, 0x5c, 0x9d, 0xcc, 0x83, 0x57, 0x4c, 0xb0, 0x07, 0xaa, 0xbc, 0xff, 0x23, 0x1d, 0x48, 0xc7, - 0xd6, 0x9c, 0x7b, 0xb7, 0x76, 0xc1, 0xcc, 0x20, 0xc2, 0xe4, 0xe2, 0xe4, 0x67, 0x49, 0x99, 0x6a, - 0x80, 0x7f, 0xd7, 0x50, 0x57, 0xcf, 0x34, 0x09, 0x36, 0x64, 0xf0, 0x07, 0x60, 0xf3, 0x49, 0x90, - 0x3a, 0x1d, 0xf0, 0x36, 0xcc, 0x2b, 0x29, 0xcf, 0x32, 0x1e, 0x9c, 0x53, 0xc2, 0x1d, 0x50, 0x0d, - 0xe2, 0x39, 0x4e, 0x98, 0xd3, 0xe8, 0x5a, 0xbb, 0x75, 0x1f, 0xa8, 0x35, 0x1c, 0x6b, 0x0f, 0x36, - 0x11, 0xf8, 0x0c, 0xd4, 0x78, 0xa4, 0xc4, 0x10, 0xce, 0xf6, 0xdb, 0xac, 0xa0, 0x69, 0x56, 0x50, - 0x3b, 0x4b, 0x59, 0x70, 0x46, 0x07, 0x43, 0xd0, 0x88, 0xd3, 0x53, 0xa6, 0x26, 0xda, 0x79, 0xef, - 0x9d, 0x4e, 0x47, 0x53, 0x8d, 0x21, 0xce, 0xe9, 0x70, 0x91, 0x1b, 0xce, 0x41, 0xd3, 0x98, 0xab, - 0x09, 0xbe, 0xfb, 0xce, 0xc7, 0xe5, 0xfe, 0x72, 0xd1, 0x69, 0xe2, 0x57, 0x69, 0xf1, 0x7a, 0x1d, - 0xf8, 0x35, 0x80, 0xc6, 0x55, 0x38, 0x24, 0x4e, 0x53, 0xcf, 0x6d, 0xdb, 0x68, 0x03, 0xf1, 0x46, - 0x06, 0xbe, 0x01, 0xb5, 0xf3, 0x6b, 0x05, 0xdc, 0x2b, 0xdc, 0x50, 0x22, 0xe2, 0x4c, 0xd0, 0xff, - 0xe5, 0x8a, 0xfa, 0x04, 0xd4, 0xc8, 0x64, 0xc2, 0x2f, 0x68, 0x7a, 0x4b, 0xd5, 0xf3, 0xb6, 0x1d, - 0xa5, 0x6e, 0x9c, 0xc5, 0xe1, 0x39, 0xa8, 0x0a, 0x49, 0x64, 0x22, 0xcc, 0x8d, 0xf3, 0xe0, 0xf5, - 0x24, 0x7c, 0xa2, 0x31, 0xe9, 0x88, 0x61, 0x2a, 0x92, 0x89, 0xc4, 0x86, 0x07, 0x76, 0xc0, 0x56, - 0x44, 0xe4, 0x60, 0xa4, 0x6f, 0x95, 0x6d, 0xdf, 0x5e, 0x2e, 0x3a, 0x5b, 0xe7, 0xca, 0x81, 0x53, - 0x3f, 0x3c, 0x04, 0xb6, 0xfe, 0x79, 0x3a, 0x8f, 0xb2, 0xab, 0xa4, 0xad, 0x86, 0xfa, 0x3c, 0x73, - 0x5e, 0x17, 0x0d, 0x9c, 0x27, 0xc3, 0xdf, 0x2c, 0xd0, 0x22, 0x49, 0x10, 0xca, 0x23, 0xc6, 0xb8, - 0x24, 0xe9, 0x1c, 0x57, 0xbb, 0xe5, 0xdd, 0xc6, 0xc1, 0x09, 0xfa, 0xb7, 0x97, 0x10, 0x6d, 0xe8, - 0x8c, 0x8e, 0xd6, 0x78, 0x4e, 0x98, 0x8c, 0xe7, 0xbe, 0x63, 0x84, 0x6a, 0xad, 0x87, 0xf1, 0x46, - 0xe1, 0xf6, 0x97, 0xe0, 0x83, 0x1b, 0x49, 0x60, 0x0b, 0x94, 0xc7, 0x74, 0x9e, 0xb6, 0x10, 0xab, - 0x5f, 0xf8, 0x3e, 0xd8, 0x9a, 0x91, 0x49, 0x42, 0x75, 0x3b, 0x6c, 0x9c, 0x1a, 0x8f, 0xee, 0x1c, - 0x5a, 0x3b, 0x7f, 0x5a, 0xa0, 0x59, 0x58, 0xdc, 0x2c, 0xa4, 0x17, 0xb0, 0x07, 0x6a, 0x66, 0x5c, - 0x34, 0x47, 0xe3, 0x00, 0xbd, 0xf6, 0xe6, 0x34, 0xca, 0x6f, 0xa8, 0x56, 0x67, 0xb3, 0x9c, 0x71, - 0xc1, 0xef, 0xf4, 0xf3, 0xa2, 0x77, 0x6f, 0x1e, 0x2f, 0xef, 0x0d, 0x45, 0xf3, 0xb7, 0xcd, 0x7b, - 0xa2, 0x2d, 0xbc, 0xa2, 0xf3, 0xf7, 0x2e, 0xaf, 0xdc, 0xd2, 0x8b, 0x2b, 0xb7, 0xf4, 0xf2, 0xca, - 0x2d, 0xfd, 0xb2, 0x74, 0xad, 0xcb, 0xa5, 0x6b, 0xbd, 0x58, 0xba, 0xd6, 0xcb, 0xa5, 0x6b, 0xfd, - 0xb5, 0x74, 0xad, 0xdf, 0xff, 0x76, 0x4b, 0xdf, 0xd7, 0x0c, 0xf1, 0x3f, 0x01, 0x00, 0x00, 0xff, - 0xff, 0xda, 0xe1, 0x0b, 0x41, 0xfd, 0x08, 0x00, 0x00, -} diff --git a/vendor/k8s.io/api/admission/v1beta1/generated.proto b/vendor/k8s.io/api/admission/v1beta1/generated.proto deleted file mode 100644 index 59f92a70d2..0000000000 --- a/vendor/k8s.io/api/admission/v1beta1/generated.proto +++ /dev/null @@ -1,160 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -// This file was autogenerated by go-to-protobuf. Do not edit it manually! - -syntax = 'proto2'; - -package k8s.io.api.admission.v1beta1; - -import "k8s.io/api/authentication/v1/generated.proto"; -import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto"; -import "k8s.io/apimachinery/pkg/runtime/generated.proto"; -import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto"; - -// Package-wide variables from generator "generated". -option go_package = "v1beta1"; - -// AdmissionRequest describes the admission.Attributes for the admission request. -message AdmissionRequest { - // UID is an identifier for the individual request/response. It allows us to distinguish instances of requests which are - // otherwise identical (parallel requests, requests when earlier requests did not modify etc) - // The UID is meant to track the round trip (request/response) between the KAS and the WebHook, not the user request. - // It is suitable for correlating log entries between the webhook and apiserver, for either auditing or debugging. - optional string uid = 1; - - // Kind is the fully-qualified type of object being submitted (for example, v1.Pod or autoscaling.v1.Scale) - optional k8s.io.apimachinery.pkg.apis.meta.v1.GroupVersionKind kind = 2; - - // Resource is the fully-qualified resource being requested (for example, v1.pods) - optional k8s.io.apimachinery.pkg.apis.meta.v1.GroupVersionResource resource = 3; - - // SubResource is the subresource being requested, if any (for example, "status" or "scale") - // +optional - optional string subResource = 4; - - // RequestKind is the fully-qualified type of the original API request (for example, v1.Pod or autoscaling.v1.Scale). - // If this is specified and differs from the value in "kind", an equivalent match and conversion was performed. - // - // For example, if deployments can be modified via apps/v1 and apps/v1beta1, and a webhook registered a rule of - // `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]` and `matchPolicy: Equivalent`, - // an API request to apps/v1beta1 deployments would be converted and sent to the webhook - // with `kind: {group:"apps", version:"v1", kind:"Deployment"}` (matching the rule the webhook registered for), - // and `requestKind: {group:"apps", version:"v1beta1", kind:"Deployment"}` (indicating the kind of the original API request). - // - // See documentation for the "matchPolicy" field in the webhook configuration type for more details. - // +optional - optional k8s.io.apimachinery.pkg.apis.meta.v1.GroupVersionKind requestKind = 13; - - // RequestResource is the fully-qualified resource of the original API request (for example, v1.pods). - // If this is specified and differs from the value in "resource", an equivalent match and conversion was performed. - // - // For example, if deployments can be modified via apps/v1 and apps/v1beta1, and a webhook registered a rule of - // `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]` and `matchPolicy: Equivalent`, - // an API request to apps/v1beta1 deployments would be converted and sent to the webhook - // with `resource: {group:"apps", version:"v1", resource:"deployments"}` (matching the resource the webhook registered for), - // and `requestResource: {group:"apps", version:"v1beta1", resource:"deployments"}` (indicating the resource of the original API request). - // - // See documentation for the "matchPolicy" field in the webhook configuration type. - // +optional - optional k8s.io.apimachinery.pkg.apis.meta.v1.GroupVersionResource requestResource = 14; - - // RequestSubResource is the name of the subresource of the original API request, if any (for example, "status" or "scale") - // If this is specified and differs from the value in "subResource", an equivalent match and conversion was performed. - // See documentation for the "matchPolicy" field in the webhook configuration type. - // +optional - optional string requestSubResource = 15; - - // Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and - // rely on the server to generate the name. If that is the case, this method will return the empty string. - // +optional - optional string name = 5; - - // Namespace is the namespace associated with the request (if any). - // +optional - optional string namespace = 6; - - // Operation is the operation being performed. This may be different than the operation - // requested. e.g. a patch can result in either a CREATE or UPDATE Operation. - optional string operation = 7; - - // UserInfo is information about the requesting user - optional k8s.io.api.authentication.v1.UserInfo userInfo = 8; - - // Object is the object from the incoming request prior to default values being applied - // +optional - optional k8s.io.apimachinery.pkg.runtime.RawExtension object = 9; - - // OldObject is the existing object. Only populated for UPDATE requests. - // +optional - optional k8s.io.apimachinery.pkg.runtime.RawExtension oldObject = 10; - - // DryRun indicates that modifications will definitely not be persisted for this request. - // Defaults to false. - // +optional - optional bool dryRun = 11; - - // Options is the operation option structure of the operation being performed. - // e.g. `meta.k8s.io/v1.DeleteOptions` or `meta.k8s.io/v1.CreateOptions`. This may be - // different than the options the caller provided. e.g. for a patch request the performed - // Operation might be a CREATE, in which case the Options will a - // `meta.k8s.io/v1.CreateOptions` even though the caller provided `meta.k8s.io/v1.PatchOptions`. - // +optional - optional k8s.io.apimachinery.pkg.runtime.RawExtension options = 12; -} - -// AdmissionResponse describes an admission response. -message AdmissionResponse { - // UID is an identifier for the individual request/response. - // This should be copied over from the corresponding AdmissionRequest. - optional string uid = 1; - - // Allowed indicates whether or not the admission request was permitted. - optional bool allowed = 2; - - // Result contains extra details into why an admission request was denied. - // This field IS NOT consulted in any way if "Allowed" is "true". - // +optional - optional k8s.io.apimachinery.pkg.apis.meta.v1.Status status = 3; - - // The patch body. Currently we only support "JSONPatch" which implements RFC 6902. - // +optional - optional bytes patch = 4; - - // The type of Patch. Currently we only allow "JSONPatch". - // +optional - optional string patchType = 5; - - // AuditAnnotations is an unstructured key value map set by remote admission controller (e.g. error=image-blacklisted). - // MutatingAdmissionWebhook and ValidatingAdmissionWebhook admission controller will prefix the keys with - // admission webhook name (e.g. imagepolicy.example.com/error=image-blacklisted). AuditAnnotations will be provided by - // the admission webhook to add additional context to the audit log for this request. - // +optional - map auditAnnotations = 6; -} - -// AdmissionReview describes an admission review request/response. -message AdmissionReview { - // Request describes the attributes for the admission request. - // +optional - optional AdmissionRequest request = 1; - - // Response describes the attributes for the admission response. - // +optional - optional AdmissionResponse response = 2; -} - diff --git a/vendor/k8s.io/api/admission/v1beta1/types.go b/vendor/k8s.io/api/admission/v1beta1/types.go deleted file mode 100644 index e968720e71..0000000000 --- a/vendor/k8s.io/api/admission/v1beta1/types.go +++ /dev/null @@ -1,162 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1beta1 - -import ( - authenticationv1 "k8s.io/api/authentication/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// AdmissionReview describes an admission review request/response. -type AdmissionReview struct { - metav1.TypeMeta `json:",inline"` - // Request describes the attributes for the admission request. - // +optional - Request *AdmissionRequest `json:"request,omitempty" protobuf:"bytes,1,opt,name=request"` - // Response describes the attributes for the admission response. - // +optional - Response *AdmissionResponse `json:"response,omitempty" protobuf:"bytes,2,opt,name=response"` -} - -// AdmissionRequest describes the admission.Attributes for the admission request. -type AdmissionRequest struct { - // UID is an identifier for the individual request/response. It allows us to distinguish instances of requests which are - // otherwise identical (parallel requests, requests when earlier requests did not modify etc) - // The UID is meant to track the round trip (request/response) between the KAS and the WebHook, not the user request. - // It is suitable for correlating log entries between the webhook and apiserver, for either auditing or debugging. - UID types.UID `json:"uid" protobuf:"bytes,1,opt,name=uid"` - // Kind is the fully-qualified type of object being submitted (for example, v1.Pod or autoscaling.v1.Scale) - Kind metav1.GroupVersionKind `json:"kind" protobuf:"bytes,2,opt,name=kind"` - // Resource is the fully-qualified resource being requested (for example, v1.pods) - Resource metav1.GroupVersionResource `json:"resource" protobuf:"bytes,3,opt,name=resource"` - // SubResource is the subresource being requested, if any (for example, "status" or "scale") - // +optional - SubResource string `json:"subResource,omitempty" protobuf:"bytes,4,opt,name=subResource"` - - // RequestKind is the fully-qualified type of the original API request (for example, v1.Pod or autoscaling.v1.Scale). - // If this is specified and differs from the value in "kind", an equivalent match and conversion was performed. - // - // For example, if deployments can be modified via apps/v1 and apps/v1beta1, and a webhook registered a rule of - // `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]` and `matchPolicy: Equivalent`, - // an API request to apps/v1beta1 deployments would be converted and sent to the webhook - // with `kind: {group:"apps", version:"v1", kind:"Deployment"}` (matching the rule the webhook registered for), - // and `requestKind: {group:"apps", version:"v1beta1", kind:"Deployment"}` (indicating the kind of the original API request). - // - // See documentation for the "matchPolicy" field in the webhook configuration type for more details. - // +optional - RequestKind *metav1.GroupVersionKind `json:"requestKind,omitempty" protobuf:"bytes,13,opt,name=requestKind"` - // RequestResource is the fully-qualified resource of the original API request (for example, v1.pods). - // If this is specified and differs from the value in "resource", an equivalent match and conversion was performed. - // - // For example, if deployments can be modified via apps/v1 and apps/v1beta1, and a webhook registered a rule of - // `apiGroups:["apps"], apiVersions:["v1"], resources: ["deployments"]` and `matchPolicy: Equivalent`, - // an API request to apps/v1beta1 deployments would be converted and sent to the webhook - // with `resource: {group:"apps", version:"v1", resource:"deployments"}` (matching the resource the webhook registered for), - // and `requestResource: {group:"apps", version:"v1beta1", resource:"deployments"}` (indicating the resource of the original API request). - // - // See documentation for the "matchPolicy" field in the webhook configuration type. - // +optional - RequestResource *metav1.GroupVersionResource `json:"requestResource,omitempty" protobuf:"bytes,14,opt,name=requestResource"` - // RequestSubResource is the name of the subresource of the original API request, if any (for example, "status" or "scale") - // If this is specified and differs from the value in "subResource", an equivalent match and conversion was performed. - // See documentation for the "matchPolicy" field in the webhook configuration type. - // +optional - RequestSubResource string `json:"requestSubResource,omitempty" protobuf:"bytes,15,opt,name=requestSubResource"` - - // Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and - // rely on the server to generate the name. If that is the case, this method will return the empty string. - // +optional - Name string `json:"name,omitempty" protobuf:"bytes,5,opt,name=name"` - // Namespace is the namespace associated with the request (if any). - // +optional - Namespace string `json:"namespace,omitempty" protobuf:"bytes,6,opt,name=namespace"` - // Operation is the operation being performed. This may be different than the operation - // requested. e.g. a patch can result in either a CREATE or UPDATE Operation. - Operation Operation `json:"operation" protobuf:"bytes,7,opt,name=operation"` - // UserInfo is information about the requesting user - UserInfo authenticationv1.UserInfo `json:"userInfo" protobuf:"bytes,8,opt,name=userInfo"` - // Object is the object from the incoming request prior to default values being applied - // +optional - Object runtime.RawExtension `json:"object,omitempty" protobuf:"bytes,9,opt,name=object"` - // OldObject is the existing object. Only populated for UPDATE requests. - // +optional - OldObject runtime.RawExtension `json:"oldObject,omitempty" protobuf:"bytes,10,opt,name=oldObject"` - // DryRun indicates that modifications will definitely not be persisted for this request. - // Defaults to false. - // +optional - DryRun *bool `json:"dryRun,omitempty" protobuf:"varint,11,opt,name=dryRun"` - // Options is the operation option structure of the operation being performed. - // e.g. `meta.k8s.io/v1.DeleteOptions` or `meta.k8s.io/v1.CreateOptions`. This may be - // different than the options the caller provided. e.g. for a patch request the performed - // Operation might be a CREATE, in which case the Options will a - // `meta.k8s.io/v1.CreateOptions` even though the caller provided `meta.k8s.io/v1.PatchOptions`. - // +optional - Options runtime.RawExtension `json:"options,omitempty" protobuf:"bytes,12,opt,name=options"` -} - -// AdmissionResponse describes an admission response. -type AdmissionResponse struct { - // UID is an identifier for the individual request/response. - // This should be copied over from the corresponding AdmissionRequest. - UID types.UID `json:"uid" protobuf:"bytes,1,opt,name=uid"` - - // Allowed indicates whether or not the admission request was permitted. - Allowed bool `json:"allowed" protobuf:"varint,2,opt,name=allowed"` - - // Result contains extra details into why an admission request was denied. - // This field IS NOT consulted in any way if "Allowed" is "true". - // +optional - Result *metav1.Status `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` - - // The patch body. Currently we only support "JSONPatch" which implements RFC 6902. - // +optional - Patch []byte `json:"patch,omitempty" protobuf:"bytes,4,opt,name=patch"` - - // The type of Patch. Currently we only allow "JSONPatch". - // +optional - PatchType *PatchType `json:"patchType,omitempty" protobuf:"bytes,5,opt,name=patchType"` - - // AuditAnnotations is an unstructured key value map set by remote admission controller (e.g. error=image-blacklisted). - // MutatingAdmissionWebhook and ValidatingAdmissionWebhook admission controller will prefix the keys with - // admission webhook name (e.g. imagepolicy.example.com/error=image-blacklisted). AuditAnnotations will be provided by - // the admission webhook to add additional context to the audit log for this request. - // +optional - AuditAnnotations map[string]string `json:"auditAnnotations,omitempty" protobuf:"bytes,6,opt,name=auditAnnotations"` -} - -// PatchType is the type of patch being used to represent the mutated object -type PatchType string - -// PatchType constants. -const ( - PatchTypeJSONPatch PatchType = "JSONPatch" -) - -// Operation is the type of resource operation being checked for admission control -type Operation string - -// Operation constants -const ( - Create Operation = "CREATE" - Update Operation = "UPDATE" - Delete Operation = "DELETE" - Connect Operation = "CONNECT" -) diff --git a/vendor/k8s.io/api/admission/v1beta1/types_swagger_doc_generated.go b/vendor/k8s.io/api/admission/v1beta1/types_swagger_doc_generated.go deleted file mode 100644 index 727080d0d4..0000000000 --- a/vendor/k8s.io/api/admission/v1beta1/types_swagger_doc_generated.go +++ /dev/null @@ -1,77 +0,0 @@ -/* -Copyright 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 - -// 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. DO NOT EDIT. -var map_AdmissionRequest = map[string]string{ - "": "AdmissionRequest describes the admission.Attributes for the admission request.", - "uid": "UID is an identifier for the individual request/response. It allows us to distinguish instances of requests which are otherwise identical (parallel requests, requests when earlier requests did not modify etc) The UID is meant to track the round trip (request/response) between the KAS and the WebHook, not the user request. It is suitable for correlating log entries between the webhook and apiserver, for either auditing or debugging.", - "kind": "Kind is the fully-qualified type of object being submitted (for example, v1.Pod or autoscaling.v1.Scale)", - "resource": "Resource is the fully-qualified resource being requested (for example, v1.pods)", - "subResource": "SubResource is the subresource being requested, if any (for example, \"status\" or \"scale\")", - "requestKind": "RequestKind is the fully-qualified type of the original API request (for example, v1.Pod or autoscaling.v1.Scale). If this is specified and differs from the value in \"kind\", an equivalent match and conversion was performed.\n\nFor example, if deployments can be modified via apps/v1 and apps/v1beta1, and a webhook registered a rule of `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]` and `matchPolicy: Equivalent`, an API request to apps/v1beta1 deployments would be converted and sent to the webhook with `kind: {group:\"apps\", version:\"v1\", kind:\"Deployment\"}` (matching the rule the webhook registered for), and `requestKind: {group:\"apps\", version:\"v1beta1\", kind:\"Deployment\"}` (indicating the kind of the original API request).\n\nSee documentation for the \"matchPolicy\" field in the webhook configuration type for more details.", - "requestResource": "RequestResource is the fully-qualified resource of the original API request (for example, v1.pods). If this is specified and differs from the value in \"resource\", an equivalent match and conversion was performed.\n\nFor example, if deployments can be modified via apps/v1 and apps/v1beta1, and a webhook registered a rule of `apiGroups:[\"apps\"], apiVersions:[\"v1\"], resources: [\"deployments\"]` and `matchPolicy: Equivalent`, an API request to apps/v1beta1 deployments would be converted and sent to the webhook with `resource: {group:\"apps\", version:\"v1\", resource:\"deployments\"}` (matching the resource the webhook registered for), and `requestResource: {group:\"apps\", version:\"v1beta1\", resource:\"deployments\"}` (indicating the resource of the original API request).\n\nSee documentation for the \"matchPolicy\" field in the webhook configuration type.", - "requestSubResource": "RequestSubResource is the name of the subresource of the original API request, if any (for example, \"status\" or \"scale\") If this is specified and differs from the value in \"subResource\", an equivalent match and conversion was performed. See documentation for the \"matchPolicy\" field in the webhook configuration type.", - "name": "Name is the name of the object as presented in the request. On a CREATE operation, the client may omit name and rely on the server to generate the name. If that is the case, this method will return the empty string.", - "namespace": "Namespace is the namespace associated with the request (if any).", - "operation": "Operation is the operation being performed. This may be different than the operation requested. e.g. a patch can result in either a CREATE or UPDATE Operation.", - "userInfo": "UserInfo is information about the requesting user", - "object": "Object is the object from the incoming request prior to default values being applied", - "oldObject": "OldObject is the existing object. Only populated for UPDATE requests.", - "dryRun": "DryRun indicates that modifications will definitely not be persisted for this request. Defaults to false.", - "options": "Options is the operation option structure of the operation being performed. e.g. `meta.k8s.io/v1.DeleteOptions` or `meta.k8s.io/v1.CreateOptions`. This may be different than the options the caller provided. e.g. for a patch request the performed Operation might be a CREATE, in which case the Options will a `meta.k8s.io/v1.CreateOptions` even though the caller provided `meta.k8s.io/v1.PatchOptions`.", -} - -func (AdmissionRequest) SwaggerDoc() map[string]string { - return map_AdmissionRequest -} - -var map_AdmissionResponse = map[string]string{ - "": "AdmissionResponse describes an admission response.", - "uid": "UID is an identifier for the individual request/response. This should be copied over from the corresponding AdmissionRequest.", - "allowed": "Allowed indicates whether or not the admission request was permitted.", - "status": "Result contains extra details into why an admission request was denied. This field IS NOT consulted in any way if \"Allowed\" is \"true\".", - "patch": "The patch body. Currently we only support \"JSONPatch\" which implements RFC 6902.", - "patchType": "The type of Patch. Currently we only allow \"JSONPatch\".", - "auditAnnotations": "AuditAnnotations is an unstructured key value map set by remote admission controller (e.g. error=image-blacklisted). MutatingAdmissionWebhook and ValidatingAdmissionWebhook admission controller will prefix the keys with admission webhook name (e.g. imagepolicy.example.com/error=image-blacklisted). AuditAnnotations will be provided by the admission webhook to add additional context to the audit log for this request.", -} - -func (AdmissionResponse) SwaggerDoc() map[string]string { - return map_AdmissionResponse -} - -var map_AdmissionReview = map[string]string{ - "": "AdmissionReview describes an admission review request/response.", - "request": "Request describes the attributes for the admission request.", - "response": "Response describes the attributes for the admission response.", -} - -func (AdmissionReview) SwaggerDoc() map[string]string { - return map_AdmissionReview -} - -// AUTO-GENERATED FUNCTIONS END HERE diff --git a/vendor/k8s.io/api/admission/v1beta1/zz_generated.deepcopy.go b/vendor/k8s.io/api/admission/v1beta1/zz_generated.deepcopy.go deleted file mode 100644 index e4704c86dd..0000000000 --- a/vendor/k8s.io/api/admission/v1beta1/zz_generated.deepcopy.go +++ /dev/null @@ -1,136 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright 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. -*/ - -// Code generated by deepcopy-gen. DO NOT EDIT. - -package v1beta1 - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AdmissionRequest) DeepCopyInto(out *AdmissionRequest) { - *out = *in - out.Kind = in.Kind - out.Resource = in.Resource - if in.RequestKind != nil { - in, out := &in.RequestKind, &out.RequestKind - *out = new(v1.GroupVersionKind) - **out = **in - } - if in.RequestResource != nil { - in, out := &in.RequestResource, &out.RequestResource - *out = new(v1.GroupVersionResource) - **out = **in - } - in.UserInfo.DeepCopyInto(&out.UserInfo) - in.Object.DeepCopyInto(&out.Object) - in.OldObject.DeepCopyInto(&out.OldObject) - if in.DryRun != nil { - in, out := &in.DryRun, &out.DryRun - *out = new(bool) - **out = **in - } - in.Options.DeepCopyInto(&out.Options) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmissionRequest. -func (in *AdmissionRequest) DeepCopy() *AdmissionRequest { - if in == nil { - return nil - } - out := new(AdmissionRequest) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AdmissionResponse) DeepCopyInto(out *AdmissionResponse) { - *out = *in - if in.Result != nil { - in, out := &in.Result, &out.Result - *out = new(v1.Status) - (*in).DeepCopyInto(*out) - } - if in.Patch != nil { - in, out := &in.Patch, &out.Patch - *out = make([]byte, len(*in)) - copy(*out, *in) - } - if in.PatchType != nil { - in, out := &in.PatchType, &out.PatchType - *out = new(PatchType) - **out = **in - } - if in.AuditAnnotations != nil { - in, out := &in.AuditAnnotations, &out.AuditAnnotations - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmissionResponse. -func (in *AdmissionResponse) DeepCopy() *AdmissionResponse { - if in == nil { - return nil - } - out := new(AdmissionResponse) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AdmissionReview) DeepCopyInto(out *AdmissionReview) { - *out = *in - out.TypeMeta = in.TypeMeta - if in.Request != nil { - in, out := &in.Request, &out.Request - *out = new(AdmissionRequest) - (*in).DeepCopyInto(*out) - } - if in.Response != nil { - in, out := &in.Response, &out.Response - *out = new(AdmissionResponse) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmissionReview. -func (in *AdmissionReview) DeepCopy() *AdmissionReview { - if in == nil { - return nil - } - out := new(AdmissionReview) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AdmissionReview) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/channelable_types.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/channelable_types.go index 778ec808d9..f6b558f9ed 100644 --- a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/channelable_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/channelable_types.go @@ -25,10 +25,9 @@ import ( duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/apis/duck/v1alpha1" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" ) -// +genclient +// +genduck // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Channelable is a skeleton type wrapping Subscribable and Addressable in the manner we expect resource writers @@ -70,8 +69,9 @@ type ChannelableStatus struct { var ( // Verify Channelable resources meet duck contracts. - _ duck.Populatable = (*Channelable)(nil) - _ apis.Listable = (*Channelable)(nil) + _ duck.Populatable = (*Channelable)(nil) + _ duck.Implementable = (*Channelable)(nil) + _ apis.Listable = (*Channelable)(nil) ) // Populate implements duck.Populatable @@ -81,20 +81,20 @@ func (c *Channelable) Populate() { Subscribers: []SubscriberSpec{{ UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", Generation: 1, - SubscriberURI: "call1", - ReplyURI: "sink2", + SubscriberURI: apis.HTTP("call1"), + ReplyURI: apis.HTTP("sink2"), }, { UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", Generation: 2, - SubscriberURI: "call2", - ReplyURI: "sink2", + SubscriberURI: apis.HTTP("call2"), + ReplyURI: apis.HTTP("sink2"), }}, } retry := int32(5) linear := BackoffPolicyLinear delay := "5s" c.Spec.Delivery = &DeliverySpec{ - DeadLetterSink: &apisv1alpha1.Destination{ + DeadLetterSink: &duckv1beta1.Destination{ Ref: &corev1.ObjectReference{ Name: "aname", }, @@ -121,19 +121,6 @@ func (c *Channelable) Populate() { }, }, SubscribableTypeStatus: SubscribableTypeStatus{ - DeprecatedSubscribableStatus: &SubscribableStatus{ - Subscribers: []SubscriberStatus{{ - UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", - ObservedGeneration: 1, - Ready: corev1.ConditionTrue, - Message: "Some message", - }, { - UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", - ObservedGeneration: 2, - Ready: corev1.ConditionFalse, - Message: "Some message", - }}, - }, SubscribableStatus: &SubscribableStatus{ Subscribers: []SubscriberStatus{{ UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", @@ -151,6 +138,11 @@ func (c *Channelable) Populate() { } } +// GetFullType implements duck.Implementable +func (s *Channelable) GetFullType() duck.Populatable { + return &Channelable{} +} + // GetListType implements apis.Listable func (c *Channelable) GetListType() runtime.Object { return &ChannelableList{} diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/delivery_types.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/delivery_types.go index 8a829be7ab..f2b99e6ce1 100644 --- a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/delivery_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/delivery_types.go @@ -18,7 +18,7 @@ package v1alpha1 import ( corev1 "k8s.io/api/core/v1" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // DeliverySpec contains the delivery options for event senders, @@ -27,7 +27,7 @@ type DeliverySpec struct { // DeadLetterSink is the sink receiving event that couldn't be sent to // a destination. // +optional - DeadLetterSink *apisv1alpha1.Destination `json:"deadLetterSink,omitempty"` + DeadLetterSink *duckv1beta1.Destination `json:"deadLetterSink,omitempty"` // Retry is the minimum number of retries the sender should attempt when // sending an event before moving it to the dead letter sink. diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/resource_types.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/resource_types.go index f49877b959..10f232d49f 100644 --- a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/resource_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/resource_types.go @@ -22,7 +22,6 @@ import ( "knative.dev/pkg/apis" ) -// +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Resource is a skeleton type wrapping all Kubernetes resources. It is typically used to watch diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go index bed80fc395..3feb096e66 100644 --- a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/subscribable_types.go @@ -25,6 +25,8 @@ import ( "knative.dev/pkg/apis/duck" ) +// +genduck + // Subscribable is the schema for the subscribable portion of the spec // section of the resource. type Subscribable struct { @@ -53,9 +55,11 @@ type SubscriberSpec struct { // +optional Generation int64 `json:"generation,omitempty"` // +optional - SubscriberURI string `json:"subscriberURI,omitempty"` + SubscriberURI *apis.URL `json:"subscriberURI,omitempty"` + // +optional + ReplyURI *apis.URL `json:"replyURI,omitempty"` // +optional - ReplyURI string `json:"replyURI,omitempty"` + DeadLetterSinkURI *apis.URL `json:"deadLetterSink,omitempty"` } // SubscribableStatus is the schema for the subscribable's status portion of the status @@ -83,7 +87,6 @@ type SubscriberStatus struct { Message string `json:"message,omitempty"` } -// +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // SubscribableType is a skeleton type wrapping Subscribable in the manner we expect resource writers @@ -109,8 +112,7 @@ type SubscribableTypeSpec struct { // SubscribableTypeStatus shows how we expect folks to embed Subscribable in their Status field. type SubscribableTypeStatus struct { - DeprecatedSubscribableStatus *SubscribableStatus `json:"subscribablestatus,omitempty"` - SubscribableStatus *SubscribableStatus `json:"subscribableStatus,omitempty"` + SubscribableStatus *SubscribableStatus `json:"subscribableStatus,omitempty"` } var ( @@ -125,9 +127,6 @@ var ( // where we read the V2 value first and if the value is absent then we read the V1 value, // Having this function here makes it convinient to read the default value at runtime. func (s *SubscribableTypeStatus) GetSubscribableTypeStatus() *SubscribableStatus { - if s.SubscribableStatus == nil { - return s.DeprecatedSubscribableStatus - } return s.SubscribableStatus } @@ -136,7 +135,6 @@ func (s *SubscribableTypeStatus) GetSubscribableTypeStatus() *SubscribableStatus // This helper function ensures that we set both the values (SubscribableStatus and DeprecatedSubscribableStatus) func (s *SubscribableTypeStatus) SetSubscribableTypeStatus(subscriberStatus SubscribableStatus) { s.SubscribableStatus = &subscriberStatus - s.DeprecatedSubscribableStatus = &subscriberStatus } // AddSubscriberToSubscribableStatus method is a Helper method for type SubscribableTypeStatus, if Subscribable Status needs to be appended @@ -145,7 +143,6 @@ func (s *SubscribableTypeStatus) SetSubscribableTypeStatus(subscriberStatus Subs func (s *SubscribableTypeStatus) AddSubscriberToSubscribableStatus(subscriberStatus SubscriberStatus) { subscribers := append(s.GetSubscribableTypeStatus().Subscribers, subscriberStatus) s.SubscribableStatus.Subscribers = subscribers - s.DeprecatedSubscribableStatus.Subscribers = subscribers } // GetFullType implements duck.Implementable @@ -160,13 +157,13 @@ func (c *SubscribableType) Populate() { Subscribers: []SubscriberSpec{{ UID: "2f9b5e8e-deb6-11e8-9f32-f2801f1b9fd1", Generation: 1, - SubscriberURI: "call1", - ReplyURI: "sink2", + SubscriberURI: apis.HTTP("call1"), + ReplyURI: apis.HTTP("sink2"), }, { UID: "34c5aec8-deb6-11e8-9f32-f2801f1b9fd1", Generation: 2, - SubscriberURI: "call2", - ReplyURI: "sink2", + SubscriberURI: apis.HTTP("call2"), + ReplyURI: apis.HTTP("sink2"), }}, } c.Status.SetSubscribableTypeStatus(SubscribableStatus{ diff --git a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go index 93dcab3ce3..2e18dbf58c 100644 --- a/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/eventing/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go @@ -23,7 +23,8 @@ package v1alpha1 import ( v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + apis "knative.dev/pkg/apis" + v1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -199,7 +200,7 @@ func (in *DeliverySpec) DeepCopyInto(out *DeliverySpec) { *out = *in if in.DeadLetterSink != nil { in, out := &in.DeadLetterSink, &out.DeadLetterSink - *out = new(apisv1alpha1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } if in.Retry != nil { @@ -439,11 +440,6 @@ func (in *SubscribableTypeSpec) DeepCopy() *SubscribableTypeSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *SubscribableTypeStatus) DeepCopyInto(out *SubscribableTypeStatus) { *out = *in - if in.DeprecatedSubscribableStatus != nil { - in, out := &in.DeprecatedSubscribableStatus, &out.DeprecatedSubscribableStatus - *out = new(SubscribableStatus) - (*in).DeepCopyInto(*out) - } if in.SubscribableStatus != nil { in, out := &in.SubscribableStatus, &out.SubscribableStatus *out = new(SubscribableStatus) @@ -470,6 +466,21 @@ func (in *SubscriberSpec) DeepCopyInto(out *SubscriberSpec) { *out = new(v1.ObjectReference) **out = **in } + if in.SubscriberURI != nil { + in, out := &in.SubscriberURI, &out.SubscriberURI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + if in.ReplyURI != nil { + in, out := &in.ReplyURI, &out.ReplyURI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + if in.DeadLetterSinkURI != nil { + in, out := &in.DeadLetterSinkURI, &out.DeadLetterSinkURI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } return } diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_types.go index f650da4243..7b2e1b9f95 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_types.go @@ -26,7 +26,6 @@ import ( duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" "knative.dev/pkg/kmeta" - "knative.dev/pkg/webhook" ) // +genclient @@ -55,13 +54,11 @@ var ( // Check that Broker can be validated, can be defaulted, and has immutable fields. _ apis.Validatable = (*Broker)(nil) _ apis.Defaultable = (*Broker)(nil) - _ apis.Immutable = (*Broker)(nil) // Check that Broker can return its spec untyped. _ apis.HasSpec = (*Broker)(nil) - _ runtime.Object = (*Broker)(nil) - _ webhook.GenericCRD = (*Broker)(nil) + _ runtime.Object = (*Broker)(nil) // Check that we can create OwnerReferences to a Broker. _ kmeta.OwnerRefable = (*Broker)(nil) diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_validation.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_validation.go index 837091e9b4..7340a8a348 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/broker_validation.go @@ -36,7 +36,7 @@ func (bs *BrokerSpec) Validate(ctx context.Context) *apis.FieldError { errs = errs.Also(cte.ViaField("channelTemplateSpec")) } - // TODO validate that the channelTemplate only specifies the provisioner and arguments. + // TODO validate that the channelTemplate only specifies the channel and arguments. return errs } @@ -54,14 +54,10 @@ func isValidChannelTemplate(dct *eventingduckv1alpha1.ChannelTemplateSpec) *apis return errs } -func (b *Broker) CheckImmutableFields(ctx context.Context, og apis.Immutable) *apis.FieldError { - if og == nil { +func (b *Broker) CheckImmutableFields(ctx context.Context, original *Broker) *apis.FieldError { + if original == nil { return nil } - original, ok := og.(*Broker) - if !ok { - return &apis.FieldError{Message: "The provided original was not a Broker"} - } if diff, err := kmp.ShortDiff(original.Spec.ChannelTemplate, b.Spec.ChannelTemplate); err != nil { return &apis.FieldError{ diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go index 67a0179ab1..7f65276286 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_types.go @@ -23,7 +23,6 @@ import ( "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/kmeta" - "knative.dev/pkg/webhook" ) // +genclient @@ -47,13 +46,11 @@ var ( // Check that EventType can be validated, can be defaulted, and has immutable fields. _ apis.Validatable = (*EventType)(nil) _ apis.Defaultable = (*EventType)(nil) - _ apis.Immutable = (*EventType)(nil) // Check that EventType can return its spec untyped. _ apis.HasSpec = (*EventType)(nil) - _ runtime.Object = (*EventType)(nil) - _ webhook.GenericCRD = (*EventType)(nil) + _ runtime.Object = (*EventType)(nil) // Check that we can create OwnerReferences to an EventType. _ kmeta.OwnerRefable = (*EventType)(nil) diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go index 83efc7594f..8bc9fa6f7c 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/eventtype_validation.go @@ -48,16 +48,11 @@ func (ets *EventTypeSpec) Validate(ctx context.Context) *apis.FieldError { return errs } -func (et *EventType) CheckImmutableFields(ctx context.Context, og apis.Immutable) *apis.FieldError { - if og == nil { +func (et *EventType) CheckImmutableFields(ctx context.Context, original *EventType) *apis.FieldError { + if original == nil { return nil } - original, ok := og.(*EventType) - if !ok { - return &apis.FieldError{Message: "The provided original was not an EventType"} - } - // All but Description field immutable. ignoreArguments := cmpopts.IgnoreFields(EventTypeSpec{}, "Description") if diff, err := kmp.ShortDiff(original.Spec, et.Spec, ignoreArguments); err != nil { diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/test_helper.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/test_helper.go index ffbf04a18c..62095f731d 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/test_helper.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/test_helper.go @@ -86,7 +86,7 @@ func (t testHelper) NotReadyBrokerStatus() *BrokerStatus { func (t testHelper) ReadyTriggerStatus() *TriggerStatus { ts := &TriggerStatus{} ts.InitializeConditions() - ts.SubscriberURI = "http://foo/" + ts.SubscriberURI = &apis.URL{Scheme: "http", Host: "foo"} ts.PropagateBrokerStatus(t.ReadyBrokerStatus()) ts.PropagateSubscriptionStatus(t.ReadySubscriptionStatus()) return ts diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go index 7c75d5af03..093f589412 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_lifecycle.go @@ -19,10 +19,10 @@ package v1alpha1 import ( messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" "knative.dev/pkg/apis" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1 "knative.dev/pkg/apis/duck/v1" ) -var triggerCondSet = apis.NewLivingConditionSet(TriggerConditionBroker, TriggerConditionSubscribed, TriggerConditionDependency) +var triggerCondSet = apis.NewLivingConditionSet(TriggerConditionBroker, TriggerConditionSubscribed, TriggerConditionDependency, TriggerConditionSubscriberResolved) const ( // TriggerConditionReady has status True when all subconditions below have been set to True. @@ -34,6 +34,8 @@ const ( TriggerConditionDependency apis.ConditionType = "Dependency" + TriggerConditionSubscriberResolved apis.ConditionType = "SubscriberResolved" + // TriggerAnyFilter Constant to represent that we should allow anything. TriggerAnyFilter = "" ) @@ -89,6 +91,18 @@ func (ts *TriggerStatus) MarkSubscriptionNotOwned(sub *messagingv1alpha1.Subscri triggerCondSet.Manage(ts).MarkFalse(TriggerConditionSubscribed, "SubscriptionNotOwned", "Subscription %q is not owned by this Trigger.", sub.Name) } +func (ts *TriggerStatus) MarkSubscriberResolvedSucceeded() { + triggerCondSet.Manage(ts).MarkTrue(TriggerConditionSubscriberResolved) +} + +func (ts *TriggerStatus) MarkSubscriberResolvedFailed(reason, messageFormat string, messageA ...interface{}) { + triggerCondSet.Manage(ts).MarkFalse(TriggerConditionSubscriberResolved, reason, messageFormat, messageA...) +} + +func (ts *TriggerStatus) MarkSubscriberResolvedUnknown(reason, messageFormat string, messageA ...interface{}) { + triggerCondSet.Manage(ts).MarkUnknown(TriggerConditionSubscriberResolved, reason, messageFormat, messageA...) +} + func (ts *TriggerStatus) MarkDependencySucceeded() { triggerCondSet.Manage(ts).MarkTrue(TriggerConditionDependency) } @@ -101,8 +115,8 @@ func (ts *TriggerStatus) MarkDependencyUnknown(reason, messageFormat string, mes triggerCondSet.Manage(ts).MarkUnknown(TriggerConditionDependency, reason, messageFormat, messageA...) } -func (ts *TriggerStatus) PropagateDependencyStatus(ks *duckv1alpha1.KResource) { - kc := ks.Status.GetCondition(duckv1alpha1.ConditionReady) +func (ts *TriggerStatus) PropagateDependencyStatus(ks *duckv1.KResource) { + kc := ks.Status.GetCondition(apis.ConditionReady) if kc != nil && kc.IsTrue() { ts.MarkDependencySucceeded() } else { diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go index 97669f601e..f5a028b950 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_types.go @@ -22,9 +22,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" "knative.dev/pkg/kmeta" - "knative.dev/pkg/webhook" ) const ( @@ -59,13 +57,11 @@ var ( // Check that Trigger can be validated, can be defaulted, and has immutable fields. _ apis.Validatable = (*Trigger)(nil) _ apis.Defaultable = (*Trigger)(nil) - _ apis.Immutable = (*Trigger)(nil) // Check that Trigger can return its spec untyped. _ apis.HasSpec = (*Trigger)(nil) - _ runtime.Object = (*Trigger)(nil) - _ webhook.GenericCRD = (*Trigger)(nil) + _ runtime.Object = (*Trigger)(nil) // Check that we can create OwnerReferences to a Trigger. _ kmeta.OwnerRefable = (*Trigger)(nil) @@ -84,7 +80,7 @@ type TriggerSpec struct { // Subscriber is the addressable that receives events from the Broker that pass the Filter. It // is required. - Subscriber *apisv1alpha1.Destination `json:"subscriber,omitempty"` + Subscriber *duckv1.Destination `json:"subscriber,omitempty"` } type TriggerFilter struct { @@ -127,7 +123,7 @@ type TriggerStatus struct { duckv1.Status `json:",inline"` // SubscriberURI is the resolved URI of the receiver for this Trigger. - SubscriberURI string `json:"subscriberURI,omitempty"` + SubscriberURI *apis.URL `json:"subscriberURI,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_validation.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_validation.go index 38ec543340..92335f779a 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_validation.go @@ -92,7 +92,7 @@ func (ts *TriggerSpec) Validate(ctx context.Context) *apis.FieldError { if ts.Subscriber == nil { fe := apis.ErrMissingField("subscriber") errs = errs.Also(fe) - } else if fe := ts.Subscriber.ValidateDisallowDeprecated(ctx); fe != nil { + } else if fe := ts.Subscriber.Validate(ctx); fe != nil { errs = errs.Also(fe.ViaField("subscriber")) } @@ -100,16 +100,11 @@ func (ts *TriggerSpec) Validate(ctx context.Context) *apis.FieldError { } // CheckImmutableFields checks that any immutable fields were not changed. -func (t *Trigger) CheckImmutableFields(ctx context.Context, og apis.Immutable) *apis.FieldError { - if og == nil { +func (t *Trigger) CheckImmutableFields(ctx context.Context, original *Trigger) *apis.FieldError { + if original == nil { return nil } - original, ok := og.(*Trigger) - if !ok { - return &apis.FieldError{Message: "The provided original was not a Trigger"} - } - if diff, err := kmp.ShortDiff(original.Spec.Broker, t.Spec.Broker); err != nil { return &apis.FieldError{ Message: "Failed to diff Trigger", diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go index f519bfe53b..cf74e288c2 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go @@ -24,7 +24,8 @@ import ( v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + apis "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -372,7 +373,7 @@ func (in *TriggerSpec) DeepCopyInto(out *TriggerSpec) { } if in.Subscriber != nil { in, out := &in.Subscriber, &out.Subscriber - *out = new(apisv1alpha1.Destination) + *out = new(duckv1.Destination) (*in).DeepCopyInto(*out) } return @@ -392,6 +393,11 @@ func (in *TriggerSpec) DeepCopy() *TriggerSpec { func (in *TriggerStatus) DeepCopyInto(out *TriggerStatus) { *out = *in in.Status.DeepCopyInto(&out.Status) + if in.SubscriberURI != nil { + in, out := &in.SubscriberURI, &out.SubscriberURI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } return } diff --git a/vendor/knative.dev/pkg/apis/v1alpha1/doc.go b/vendor/knative.dev/eventing/pkg/apis/flows/register.go similarity index 90% rename from vendor/knative.dev/pkg/apis/v1alpha1/doc.go rename to vendor/knative.dev/eventing/pkg/apis/flows/register.go index 9fb4a2a85e..d356ace39b 100644 --- a/vendor/knative.dev/pkg/apis/v1alpha1/doc.go +++ b/vendor/knative.dev/eventing/pkg/apis/flows/register.go @@ -14,5 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -// +k8s:deepcopy-gen=package -package v1alpha1 +package flows + +const ( + GroupName = "flows.knative.dev" +) diff --git a/vendor/k8s.io/api/admission/v1beta1/doc.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/doc.go similarity index 75% rename from vendor/k8s.io/api/admission/v1beta1/doc.go rename to vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/doc.go index 92f7c19d26..a1ad889960 100644 --- a/vendor/k8s.io/api/admission/v1beta1/doc.go +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2019 The Knative Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,10 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package v1alpha1 is the v1alpha1 version of the API. // +k8s:deepcopy-gen=package -// +k8s:protobuf-gen=package -// +k8s:openapi-gen=false - -// +groupName=admission.k8s.io - -package v1beta1 // import "k8s.io/api/admission/v1beta1" +// +groupName=flows.knative.dev +package v1alpha1 diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_defaults.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_defaults.go new file mode 100644 index 0000000000..21461dff7c --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_defaults.go @@ -0,0 +1,37 @@ +/* +Copyright 2019 The Knative 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 ( + "context" + + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" +) + +func (s *Parallel) SetDefaults(ctx context.Context) { + if s != nil && s.Spec.ChannelTemplate == nil { + // The singleton may not have been set, if so ignore it and validation will reject the + // Channel. + if cd := eventingduckv1alpha1.ChannelDefaulterSingleton; cd != nil { + channelTemplate := cd.GetDefault(s.Namespace) + s.Spec.ChannelTemplate = channelTemplate + } + } + s.Spec.SetDefaults(ctx) +} + +func (ss *ParallelSpec) SetDefaults(ctx context.Context) {} diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_lifecycle.go new file mode 100644 index 0000000000..064151f589 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_lifecycle.go @@ -0,0 +1,247 @@ +/* + * Copyright 2019 The Knative 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 ( + "context" + "time" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" + "knative.dev/pkg/apis" + pkgduckv1 "knative.dev/pkg/apis/duck/v1" + pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" +) + +var pParallelCondSet = apis.NewLivingConditionSet(ParallelConditionReady, ParallelConditionChannelsReady, ParallelConditionSubscriptionsReady, ParallelConditionAddressable) + +const ( + // StatusConditionTypeDeprecated is the status.conditions.type used to provide deprecation + // warnings. + StatusConditionTypeDeprecated = "Deprecated" +) + +const ( + // ParallelConditionReady has status True when all subconditions below have been set to True. + ParallelConditionReady = apis.ConditionReady + + // ParallelConditionChannelsReady has status True when all the channels created as part of + // this parallel are ready. + ParallelConditionChannelsReady apis.ConditionType = "ChannelsReady" + + // ParallelConditionSubscriptionsReady has status True when all the subscriptions created as part of + // this parallel are ready. + ParallelConditionSubscriptionsReady apis.ConditionType = "SubscriptionsReady" + + // ParallelConditionAddressable has status true when this Parallel meets + // the Addressable contract and has a non-empty hostname. + ParallelConditionAddressable apis.ConditionType = "Addressable" +) + +// GetCondition returns the condition currently associated with the given type, or nil. +func (ps *ParallelStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return pParallelCondSet.Manage(ps).GetCondition(t) +} + +// IsReady returns true if the resource is ready overall. +func (ps *ParallelStatus) IsReady() bool { + return pParallelCondSet.Manage(ps).IsHappy() +} + +// InitializeConditions sets relevant unset conditions to Unknown state. +func (ps *ParallelStatus) InitializeConditions() { + pParallelCondSet.Manage(ps).InitializeConditions() +} + +// PropagateSubscriptionStatuses sets the ParallelConditionSubscriptionsReady based on +// the status of the incoming subscriptions. +func (ps *ParallelStatus) PropagateSubscriptionStatuses(filterSubscriptions []*messagingv1alpha1.Subscription, subscriptions []*messagingv1alpha1.Subscription) { + if ps.BranchStatuses == nil { + ps.BranchStatuses = make([]ParallelBranchStatus, len(subscriptions)) + } + allReady := true + // If there are no subscriptions, treat that as a False branch. Could go either way, but this seems right. + if len(subscriptions) == 0 { + allReady = false + } + + for i, s := range subscriptions { + ps.BranchStatuses[i].SubscriptionStatus = ParallelSubscriptionStatus{ + Subscription: corev1.ObjectReference{ + APIVersion: s.APIVersion, + Kind: s.Kind, + Name: s.Name, + Namespace: s.Namespace, + }, + } + + readyCondition := s.Status.GetCondition(messagingv1alpha1.SubscriptionConditionReady) + if readyCondition != nil { + ps.BranchStatuses[i].SubscriptionStatus.ReadyCondition = *readyCondition + if readyCondition.Status != corev1.ConditionTrue { + allReady = false + } + } else { + allReady = false + } + + fs := filterSubscriptions[i] + ps.BranchStatuses[i].FilterSubscriptionStatus = ParallelSubscriptionStatus{ + Subscription: corev1.ObjectReference{ + APIVersion: fs.APIVersion, + Kind: fs.Kind, + Name: fs.Name, + Namespace: fs.Namespace, + }, + } + readyCondition = fs.Status.GetCondition(messagingv1alpha1.SubscriptionConditionReady) + if readyCondition != nil { + ps.BranchStatuses[i].FilterSubscriptionStatus.ReadyCondition = *readyCondition + if readyCondition.Status != corev1.ConditionTrue { + allReady = false + } + } else { + allReady = false + } + + } + if allReady { + pParallelCondSet.Manage(ps).MarkTrue(ParallelConditionSubscriptionsReady) + } else { + ps.MarkSubscriptionsNotReady("SubscriptionsNotReady", "Subscriptions are not ready yet, or there are none") + } +} + +// PropagateChannelStatuses sets the ChannelStatuses and ParallelConditionChannelsReady based on the +// status of the incoming channels. +func (ps *ParallelStatus) PropagateChannelStatuses(ingressChannel *duckv1alpha1.Channelable, channels []*duckv1alpha1.Channelable) { + if ps.BranchStatuses == nil { + ps.BranchStatuses = make([]ParallelBranchStatus, len(channels)) + } + allReady := true + + ps.IngressChannelStatus.Channel = corev1.ObjectReference{ + APIVersion: ingressChannel.APIVersion, + Kind: ingressChannel.Kind, + Name: ingressChannel.Name, + Namespace: ingressChannel.Namespace, + } + + address := ingressChannel.Status.AddressStatus.Address + if address != nil { + ps.IngressChannelStatus.ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionTrue} + } else { + ps.IngressChannelStatus.ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionFalse, Reason: "NotAddressable", Message: "Channel is not addressable"} + allReady = false + } + ps.setAddress(address) + + for i, c := range channels { + ps.BranchStatuses[i].FilterChannelStatus = ParallelChannelStatus{ + Channel: corev1.ObjectReference{ + APIVersion: c.APIVersion, + Kind: c.Kind, + Name: c.Name, + Namespace: c.Namespace, + }, + } + // TODO: Once the addressable has a real status to dig through, use that here instead of + // addressable, because it might be addressable but not ready. + address := c.Status.AddressStatus.Address + if address != nil { + ps.BranchStatuses[i].FilterChannelStatus.ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionTrue} + } else { + ps.BranchStatuses[i].FilterChannelStatus.ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionFalse, Reason: "NotAddressable", Message: "Channel is not addressable"} + allReady = false + } + } + if allReady { + pParallelCondSet.Manage(ps).MarkTrue(ParallelConditionChannelsReady) + } else { + ps.MarkChannelsNotReady("ChannelsNotReady", "Channels are not ready yet, or there are none") + } +} + +func (ps *ParallelStatus) MarkChannelsNotReady(reason, messageFormat string, messageA ...interface{}) { + pParallelCondSet.Manage(ps).MarkFalse(ParallelConditionChannelsReady, reason, messageFormat, messageA...) +} + +func (ps *ParallelStatus) MarkSubscriptionsNotReady(reason, messageFormat string, messageA ...interface{}) { + pParallelCondSet.Manage(ps).MarkFalse(ParallelConditionSubscriptionsReady, reason, messageFormat, messageA...) +} + +func (ps *ParallelStatus) MarkAddressableNotReady(reason, messageFormat string, messageA ...interface{}) { + pParallelCondSet.Manage(ps).MarkFalse(ParallelConditionAddressable, reason, messageFormat, messageA...) +} + +func (ps *ParallelStatus) setAddress(address *pkgduckv1alpha1.Addressable) { + if address == nil { + pParallelCondSet.Manage(ps).MarkFalse(ParallelConditionAddressable, "emptyAddress", "addressable is nil") + ps.Address = nil + return + } + if address.URL != nil || address.Hostname != "" { + // But, first, convert it to V1, since Channel Status + // is using v1alpha1 Address. Note that ConvertUp does + // not do anything with the passed in Context, so + // just make one up here. + v1Address := pkgduckv1.Addressable{} + if err := address.ConvertUp(context.TODO(), &v1Address); err != nil { + pCondSet.Manage(ps).MarkFalse(SequenceConditionAddressable, "emptyAddress", "unable to convert channel address up to v1") + return + } + ps.Address = &v1Address + pParallelCondSet.Manage(ps).MarkTrue(ParallelConditionAddressable) + } else { + ps.Address = nil + pCondSet.Manage(ps).MarkFalse(SequenceConditionAddressable, "emptyHostname", "channel addressable is nil and/or no hostname") + } +} + +// MarkDeprecated adds a warning condition that this object's spec is using deprecated fields +// and will stop working in the future. Note that this does not affect the Ready condition. +func (ps *ParallelStatus) MarkDestinationDeprecatedRef(reason, msg string) { + dc := apis.Condition{ + Type: StatusConditionTypeDeprecated, + Reason: reason, + Status: corev1.ConditionTrue, + Severity: apis.ConditionSeverityWarning, + Message: msg, + LastTransitionTime: apis.VolatileTime{Inner: metav1.NewTime(time.Now())}, + } + for i, c := range ps.Conditions { + if c.Type == dc.Type { + ps.Conditions[i] = dc + return + } + } + ps.Conditions = append(ps.Conditions, dc) +} + +// ClearDeprecated removes the StatusConditionTypeDeprecated warning condition. Note that this does not +// affect the Ready condition. +func (ps *ParallelStatus) ClearDeprecated() { + conds := make([]apis.Condition, 0, len(ps.Conditions)) + for _, c := range ps.Conditions { + if c.Type != StatusConditionTypeDeprecated { + conds = append(conds, c) + } + } + ps.Conditions = conds +} diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_types.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_types.go new file mode 100644 index 0000000000..4eeec20a0d --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_types.go @@ -0,0 +1,159 @@ +/* + * Copyright 2019 The Knative 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 ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// Parallel defines conditional branches that will be wired in +// series through Channels and Subscriptions. +type Parallel struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of the Parallel. + Spec ParallelSpec `json:"spec,omitempty"` + + // Status represents the current state of the Parallel. This data may be out of + // date. + // +optional + Status ParallelStatus `json:"status,omitempty"` +} + +var ( + // Check that Parallel can be validated and defaulted. + _ apis.Validatable = (*Parallel)(nil) + _ apis.Defaultable = (*Parallel)(nil) + + // Check that Parallel can return its spec untyped. + _ apis.HasSpec = (*Parallel)(nil) + + // TODO: make appropriate fields immutable. + //_ apis.Immutable = (*Parallel)(nil) + + _ runtime.Object = (*Parallel)(nil) + + // Check that we can create OwnerReferences to a Parallel. + _ kmeta.OwnerRefable = (*Parallel)(nil) +) + +type ParallelSpec struct { + // Branches is the list of Filter/Subscribers pairs. + Branches []ParallelBranch `json:"branches"` + + // ChannelTemplate specifies which Channel CRD to use. If left unspecified, it is set to the default Channel CRD + // for the namespace (or cluster, in case there are no defaults for the namespace). + // +optional + ChannelTemplate *eventingduckv1alpha1.ChannelTemplateSpec `json:"channelTemplate"` + + // Reply is a Reference to where the result of a case Subscriber gets sent to + // when the case does not have a Reply + // +optional + Reply *duckv1.Destination `json:"reply,omitempty"` +} + +type ParallelBranch struct { + // Filter is the expression guarding the branch + Filter *duckv1.Destination `json:"filter,omitempty"` + + // Subscriber receiving the event when the filter passes + Subscriber duckv1.Destination `json:"subscriber"` + + // Reply is a Reference to where the result of Subscriber of this case gets sent to. + // If not specified, sent the result to the Parallel Reply + // +optional + Reply *duckv1.Destination `json:"reply,omitempty"` +} + +// ParallelStatus represents the current state of a Parallel. +type ParallelStatus struct { + // inherits duck/v1 Status, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. + // * Conditions - the latest available observations of a resource's current state. + duckv1.Status `json:",inline"` + + // IngressChannelStatus corresponds to the ingress channel status. + IngressChannelStatus ParallelChannelStatus `json:"ingressChannelStatus"` + + // BranchStatuses is an array of corresponding to branch statuses. + // Matches the Spec.Branches array in the order. + BranchStatuses []ParallelBranchStatus `json:"branchStatuses"` + + // AddressStatus is the starting point to this Parallel. Sending to this + // will target the first subscriber. + // It generally has the form {channel}.{namespace}.svc.{cluster domain name} + duckv1.AddressStatus `json:",inline"` +} + +// ParallelBranchStatus represents the current state of a Parallel branch +type ParallelBranchStatus struct { + // FilterSubscriptionStatus corresponds to the filter subscription status. + FilterSubscriptionStatus ParallelSubscriptionStatus `json:"filterSubscriptionStatus"` + + // FilterChannelStatus corresponds to the filter channel status. + FilterChannelStatus ParallelChannelStatus `json:"filterChannelStatus"` + + // SubscriptionStatus corresponds to the subscriber subscription status. + SubscriptionStatus ParallelSubscriptionStatus `json:"subscriberSubscriptionStatus"` +} + +type ParallelChannelStatus struct { + // Channel is the reference to the underlying channel. + Channel corev1.ObjectReference `json:"channel"` + + // ReadyCondition indicates whether the Channel is ready or not. + ReadyCondition apis.Condition `json:"ready"` +} + +type ParallelSubscriptionStatus struct { + // Subscription is the reference to the underlying Subscription. + Subscription corev1.ObjectReference `json:"subscription"` + + // ReadyCondition indicates whether the Subscription is ready or not. + ReadyCondition apis.Condition `json:"ready"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ParallelList is a collection of Parallels. +type ParallelList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Parallel `json:"items"` +} + +// GetGroupVersionKind returns GroupVersionKind for Parallel +func (p *Parallel) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Parallel") +} + +// GetUntypedSpec returns the spec of the Parallel. +func (p *Parallel) GetUntypedSpec() interface{} { + return p.Spec +} diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_validation.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_validation.go new file mode 100644 index 0000000000..cbd758fb0e --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/parallel_validation.go @@ -0,0 +1,68 @@ +/* +Copyright 2019 The Knative 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 ( + "context" + + "knative.dev/pkg/apis" +) + +func (p *Parallel) Validate(ctx context.Context) *apis.FieldError { + return p.Spec.Validate(ctx).ViaField("spec") +} + +func (ps *ParallelSpec) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + if len(ps.Branches) == 0 { + errs = errs.Also(apis.ErrMissingField("branches")) + } + + for i, s := range ps.Branches { + if err := s.Filter.Validate(ctx); err != nil { + errs = errs.Also(apis.ErrInvalidArrayValue(s, "branches.filter", i)) + } + + if e := s.Subscriber.Validate(ctx); e != nil { + errs = errs.Also(apis.ErrInvalidArrayValue(s, "branches.subscriber", i)) + } + + if e := s.Reply.Validate(ctx); e != nil { + errs = errs.Also(apis.ErrInvalidArrayValue(s, "branches.reply", i)) + } + } + + if ps.ChannelTemplate == nil { + errs = errs.Also(apis.ErrMissingField("channelTemplate")) + return errs + } + + if len(ps.ChannelTemplate.APIVersion) == 0 { + errs = errs.Also(apis.ErrMissingField("channelTemplate.apiVersion")) + } + + if len(ps.ChannelTemplate.Kind) == 0 { + errs = errs.Also(apis.ErrMissingField("channelTemplate.kind")) + } + + if err := ps.Reply.Validate(ctx); err != nil { + errs = errs.Also(err.ViaField("reply")) + } + + return errs +} diff --git a/vendor/k8s.io/api/admission/v1beta1/register.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/register.go similarity index 65% rename from vendor/k8s.io/api/admission/v1beta1/register.go rename to vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/register.go index 78d21a0c8a..b0d49a5876 100644 --- a/vendor/k8s.io/api/admission/v1beta1/register.go +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/register.go @@ -1,5 +1,5 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2019 The Knative Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,19 +14,23 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( + "knative.dev/eventing/pkg/apis/flows" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" ) -// GroupName is the group name for this API. -const GroupName = "admission.k8s.io" - // SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} +var SchemeGroupVersion = schema.GroupVersion{Group: flows.GroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} // Resource takes an unqualified resource and returns a Group qualified GroupResource func Resource(resource string) schema.GroupResource { @@ -34,17 +38,17 @@ func Resource(resource string) schema.GroupResource { } var ( - // TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api. - // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes. - SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) - localSchemeBuilder = &SchemeBuilder - AddToScheme = localSchemeBuilder.AddToScheme + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme ) -// Adds the list of known types to the given scheme. +// Adds the list of known types to Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, - &AdmissionReview{}, + &Sequence{}, + &SequenceList{}, + &Parallel{}, + &ParallelList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_defaults.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_defaults.go new file mode 100644 index 0000000000..017268237e --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_defaults.go @@ -0,0 +1,37 @@ +/* +Copyright 2019 The Knative 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 ( + "context" + + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" +) + +func (s *Sequence) SetDefaults(ctx context.Context) { + if s != nil && s.Spec.ChannelTemplate == nil { + // The singleton may not have been set, if so ignore it and validation will reject the + // Channel. + if cd := eventingduckv1alpha1.ChannelDefaulterSingleton; cd != nil { + channelTemplate := cd.GetDefault(s.Namespace) + s.Spec.ChannelTemplate = channelTemplate + } + } + s.Spec.SetDefaults(ctx) +} + +func (ss *SequenceSpec) SetDefaults(ctx context.Context) {} diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_lifecycle.go new file mode 100644 index 0000000000..015a7ecaa8 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_lifecycle.go @@ -0,0 +1,177 @@ +/* + * Copyright 2019 The Knative 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 ( + "context" + + corev1 "k8s.io/api/core/v1" + duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" + "knative.dev/pkg/apis" + pkgduckv1 "knative.dev/pkg/apis/duck/v1" + pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" +) + +var pCondSet = apis.NewLivingConditionSet(SequenceConditionReady, SequenceConditionChannelsReady, SequenceConditionSubscriptionsReady, SequenceConditionAddressable) + +const ( + // SequenceConditionReady has status True when all subconditions below have been set to True. + SequenceConditionReady = apis.ConditionReady + + // SequenceChannelsReady has status True when all the channels created as part of + // this sequence are ready. + SequenceConditionChannelsReady apis.ConditionType = "ChannelsReady" + + // SequenceSubscriptionsReady has status True when all the subscriptions created as part of + // this sequence are ready. + SequenceConditionSubscriptionsReady apis.ConditionType = "SubscriptionsReady" + + // SequenceConditionAddressable has status true when this Sequence meets + // the Addressable contract and has a non-empty hostname. + SequenceConditionAddressable apis.ConditionType = "Addressable" +) + +// GetCondition returns the condition currently associated with the given type, or nil. +func (ss *SequenceStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return pCondSet.Manage(ss).GetCondition(t) +} + +// IsReady returns true if the resource is ready overall. +func (ss *SequenceStatus) IsReady() bool { + return pCondSet.Manage(ss).IsHappy() +} + +// InitializeConditions sets relevant unset conditions to Unknown state. +func (ss *SequenceStatus) InitializeConditions() { + pCondSet.Manage(ss).InitializeConditions() +} + +// PropagateSubscriptionStatuses sets the SubscriptionStatuses and SequenceConditionSubscriptionsReady based on +// the status of the incoming subscriptions. +func (ss *SequenceStatus) PropagateSubscriptionStatuses(subscriptions []*messagingv1alpha1.Subscription) { + ss.SubscriptionStatuses = make([]SequenceSubscriptionStatus, len(subscriptions)) + allReady := true + // If there are no subscriptions, treat that as a False case. Could go either way, but this seems right. + if len(subscriptions) == 0 { + allReady = false + + } + for i, s := range subscriptions { + ss.SubscriptionStatuses[i] = SequenceSubscriptionStatus{ + Subscription: corev1.ObjectReference{ + APIVersion: s.APIVersion, + Kind: s.Kind, + Name: s.Name, + Namespace: s.Namespace, + }, + } + readyCondition := s.Status.GetCondition(messagingv1alpha1.SubscriptionConditionReady) + if readyCondition != nil { + ss.SubscriptionStatuses[i].ReadyCondition = *readyCondition + if readyCondition.Status != corev1.ConditionTrue { + allReady = false + } + } else { + allReady = false + } + + } + if allReady { + pCondSet.Manage(ss).MarkTrue(SequenceConditionSubscriptionsReady) + } else { + ss.MarkSubscriptionsNotReady("SubscriptionsNotReady", "Subscriptions are not ready yet, or there are none") + } +} + +// PropagateChannelStatuses sets the ChannelStatuses and SequenceConditionChannelsReady based on the +// status of the incoming channels. +func (ss *SequenceStatus) PropagateChannelStatuses(channels []*duckv1alpha1.Channelable) { + ss.ChannelStatuses = make([]SequenceChannelStatus, len(channels)) + allReady := true + // If there are no channels, treat that as a False case. Could go either way, but this seems right. + if len(channels) == 0 { + allReady = false + + } + for i, c := range channels { + ss.ChannelStatuses[i] = SequenceChannelStatus{ + Channel: corev1.ObjectReference{ + APIVersion: c.APIVersion, + Kind: c.Kind, + Name: c.Name, + Namespace: c.Namespace, + }, + } + // TODO: Once the addressable has a real status to dig through, use that here instead of + // addressable, because it might be addressable but not ready. + address := c.Status.AddressStatus.Address + if address != nil { + ss.ChannelStatuses[i].ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionTrue} + } else { + ss.ChannelStatuses[i].ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionFalse, Reason: "NotAddressable", Message: "Channel is not addressable"} + allReady = false + } + + // Mark the Sequence address as the Address of the first channel. + if i == 0 { + ss.setAddress(address) + } + } + if allReady { + pCondSet.Manage(ss).MarkTrue(SequenceConditionChannelsReady) + } else { + ss.MarkChannelsNotReady("ChannelsNotReady", "Channels are not ready yet, or there are none") + } +} + +func (ss *SequenceStatus) MarkChannelsNotReady(reason, messageFormat string, messageA ...interface{}) { + pCondSet.Manage(ss).MarkFalse(SequenceConditionChannelsReady, reason, messageFormat, messageA...) +} + +func (ss *SequenceStatus) MarkSubscriptionsNotReady(reason, messageFormat string, messageA ...interface{}) { + pCondSet.Manage(ss).MarkFalse(SequenceConditionSubscriptionsReady, reason, messageFormat, messageA...) +} + +func (ss *SequenceStatus) MarkAddressableNotReady(reason, messageFormat string, messageA ...interface{}) { + pCondSet.Manage(ss).MarkFalse(SequenceConditionAddressable, reason, messageFormat, messageA...) +} + +func (ss *SequenceStatus) setAddress(address *pkgduckv1alpha1.Addressable) { + if address == nil { + pCondSet.Manage(ss).MarkFalse(SequenceConditionAddressable, "emptyAddress", "addressable is nil") + ss.Address = nil + return + } + + if address.URL != nil || address.Hostname != "" { + // But, first, convert it to V1, since Channel Status + // is using v1alpha1 Address. Note that ConvertUp does + // not do anything with the passed in Context, so + // just make one up here. + v1Address := pkgduckv1.Addressable{} + if err := address.ConvertUp(context.TODO(), &v1Address); err != nil { + pCondSet.Manage(ss).MarkFalse(SequenceConditionAddressable, "emptyAddress", "unable to convert channel address up to v1") + return + } + pCondSet.Manage(ss).MarkTrue(SequenceConditionAddressable) + ss.Address = &v1Address + } else { + ss.Address = nil + pCondSet.Manage(ss).MarkFalse(SequenceConditionAddressable, "emptyAddress", "channel addressable is nil and/or no hostname") + } +} diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_types.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_types.go new file mode 100644 index 0000000000..8489cbfc82 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_types.go @@ -0,0 +1,135 @@ +/* + * Copyright 2019 The Knative 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 ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// Sequence defines a sequence of Subscribers that will be wired in +// series through Channels and Subscriptions. +type Sequence struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of the Sequence. + Spec SequenceSpec `json:"spec,omitempty"` + + // Status represents the current state of the Sequence. This data may be out of + // date. + // +optional + Status SequenceStatus `json:"status,omitempty"` +} + +var ( + // Check that Sequence can be validated and defaulted. + _ apis.Validatable = (*Sequence)(nil) + _ apis.Defaultable = (*Sequence)(nil) + + // Check that Sequence can return its spec untyped. + _ apis.HasSpec = (*Sequence)(nil) + + // TODO: make appropriate fields immutable. + //_ apis.Immutable = (*Sequence)(nil) + + _ runtime.Object = (*Sequence)(nil) + + // Check that we can create OwnerReferences to a Sequence. + _ kmeta.OwnerRefable = (*Sequence)(nil) +) + +type SequenceSpec struct { + // Steps is the list of Destinations (processors / functions) that will be called in the order + // provided. + Steps []duckv1.Destination `json:"steps"` + + // ChannelTemplate specifies which Channel CRD to use. If left unspecified, it is set to the default Channel CRD + // for the namespace (or cluster, in case there are no defaults for the namespace). + // +optional + ChannelTemplate *eventingduckv1alpha1.ChannelTemplateSpec `json:"channelTemplate,omitempty"` + + // Reply is a Reference to where the result of the last Subscriber gets sent to. + // +optional + Reply *duckv1.Destination `json:"reply,omitempty"` +} + +type SequenceChannelStatus struct { + // Channel is the reference to the underlying channel. + Channel corev1.ObjectReference `json:"channel"` + + // ReadyCondition indicates whether the Channel is ready or not. + ReadyCondition apis.Condition `json:"ready"` +} + +type SequenceSubscriptionStatus struct { + // Subscription is the reference to the underlying Subscription. + Subscription corev1.ObjectReference `json:"subscription"` + + // ReadyCondition indicates whether the Subscription is ready or not. + ReadyCondition apis.Condition `json:"ready"` +} + +// SequenceStatus represents the current state of a Sequence. +type SequenceStatus struct { + // inherits duck/v1 Status, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. + // * Conditions - the latest available observations of a resource's current state. + duckv1.Status `json:",inline"` + + // SubscriptionStatuses is an array of corresponding Subscription statuses. + // Matches the Spec.Steps array in the order. + SubscriptionStatuses []SequenceSubscriptionStatus `json:"subscriptionStatuses"` + + // ChannelStatuses is an array of corresponding Channel statuses. + // Matches the Spec.Steps array in the order. + ChannelStatuses []SequenceChannelStatus `json:"channelStatuses"` + + // AddressStatus is the starting point to this Sequence. Sending to this + // will target the first subscriber. + // It generally has the form {channel}.{namespace}.svc.{cluster domain name} + duckv1.AddressStatus `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SequenceList is a collection of Sequences. +type SequenceList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Sequence `json:"items"` +} + +// GetGroupVersionKind returns GroupVersionKind for InMemoryChannels +func (p *Sequence) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Sequence") +} + +// GetUntypedSpec returns the spec of the Sequence. +func (s *Sequence) GetUntypedSpec() interface{} { + return s.Spec +} diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_validation.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_validation.go new file mode 100644 index 0000000000..9f7c8c4b47 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/sequence_validation.go @@ -0,0 +1,60 @@ +/* +Copyright 2019 The Knative 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 ( + "context" + + "knative.dev/pkg/apis" +) + +func (p *Sequence) Validate(ctx context.Context) *apis.FieldError { + return p.Spec.Validate(ctx).ViaField("spec") +} + +func (ps *SequenceSpec) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + if len(ps.Steps) == 0 { + errs = errs.Also(apis.ErrMissingField("steps")) + } + + for i, s := range ps.Steps { + if e := s.Validate(ctx); e != nil { + errs = errs.Also(apis.ErrInvalidArrayValue(s, "steps", i)) + } + } + + if ps.ChannelTemplate == nil { + errs = errs.Also(apis.ErrMissingField("channelTemplate")) + return errs + } + + if len(ps.ChannelTemplate.APIVersion) == 0 { + errs = errs.Also(apis.ErrMissingField("channelTemplate.apiVersion")) + } + + if len(ps.ChannelTemplate.Kind) == 0 { + errs = errs.Also(apis.ErrMissingField("channelTemplate.kind")) + } + + if err := ps.Reply.Validate(ctx); err != nil { + errs = errs.Also(err.ViaField("reply")) + } + + return errs +} diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/test_helpers.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/test_helpers.go new file mode 100644 index 0000000000..9cc7f48074 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/test_helpers.go @@ -0,0 +1,37 @@ +/* +Copyright 2019 The Knative 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 ( + "github.com/google/go-cmp/cmp/cmpopts" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" +) + +var ( + defaultChannelTemplate = &eventingduckv1alpha1.ChannelTemplateSpec{ + TypeMeta: v1.TypeMeta{ + APIVersion: SchemeGroupVersion.String(), + Kind: "InMemoryChannel", + }, + } + + ignoreAllButTypeAndStatus = cmpopts.IgnoreFields( + apis.Condition{}, + "LastTransitionTime", "Message", "Reason", "Severity") +) diff --git a/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..5d13741abe --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/flows/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,391 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative 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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" + duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + v1 "knative.dev/pkg/apis/duck/v1" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Parallel) DeepCopyInto(out *Parallel) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Parallel. +func (in *Parallel) DeepCopy() *Parallel { + if in == nil { + return nil + } + out := new(Parallel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Parallel) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelBranch) DeepCopyInto(out *ParallelBranch) { + *out = *in + if in.Filter != nil { + in, out := &in.Filter, &out.Filter + *out = new(v1.Destination) + (*in).DeepCopyInto(*out) + } + in.Subscriber.DeepCopyInto(&out.Subscriber) + if in.Reply != nil { + in, out := &in.Reply, &out.Reply + *out = new(v1.Destination) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelBranch. +func (in *ParallelBranch) DeepCopy() *ParallelBranch { + if in == nil { + return nil + } + out := new(ParallelBranch) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelBranchStatus) DeepCopyInto(out *ParallelBranchStatus) { + *out = *in + in.FilterSubscriptionStatus.DeepCopyInto(&out.FilterSubscriptionStatus) + in.FilterChannelStatus.DeepCopyInto(&out.FilterChannelStatus) + in.SubscriptionStatus.DeepCopyInto(&out.SubscriptionStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelBranchStatus. +func (in *ParallelBranchStatus) DeepCopy() *ParallelBranchStatus { + if in == nil { + return nil + } + out := new(ParallelBranchStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelChannelStatus) DeepCopyInto(out *ParallelChannelStatus) { + *out = *in + out.Channel = in.Channel + in.ReadyCondition.DeepCopyInto(&out.ReadyCondition) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelChannelStatus. +func (in *ParallelChannelStatus) DeepCopy() *ParallelChannelStatus { + if in == nil { + return nil + } + out := new(ParallelChannelStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelList) DeepCopyInto(out *ParallelList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Parallel, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelList. +func (in *ParallelList) DeepCopy() *ParallelList { + if in == nil { + return nil + } + out := new(ParallelList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ParallelList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelSpec) DeepCopyInto(out *ParallelSpec) { + *out = *in + if in.Branches != nil { + in, out := &in.Branches, &out.Branches + *out = make([]ParallelBranch, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ChannelTemplate != nil { + in, out := &in.ChannelTemplate, &out.ChannelTemplate + *out = new(duckv1alpha1.ChannelTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.Reply != nil { + in, out := &in.Reply, &out.Reply + *out = new(v1.Destination) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelSpec. +func (in *ParallelSpec) DeepCopy() *ParallelSpec { + if in == nil { + return nil + } + out := new(ParallelSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelStatus) DeepCopyInto(out *ParallelStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + in.IngressChannelStatus.DeepCopyInto(&out.IngressChannelStatus) + if in.BranchStatuses != nil { + in, out := &in.BranchStatuses, &out.BranchStatuses + *out = make([]ParallelBranchStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.AddressStatus.DeepCopyInto(&out.AddressStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelStatus. +func (in *ParallelStatus) DeepCopy() *ParallelStatus { + if in == nil { + return nil + } + out := new(ParallelStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelSubscriptionStatus) DeepCopyInto(out *ParallelSubscriptionStatus) { + *out = *in + out.Subscription = in.Subscription + in.ReadyCondition.DeepCopyInto(&out.ReadyCondition) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelSubscriptionStatus. +func (in *ParallelSubscriptionStatus) DeepCopy() *ParallelSubscriptionStatus { + if in == nil { + return nil + } + out := new(ParallelSubscriptionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Sequence) DeepCopyInto(out *Sequence) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Sequence. +func (in *Sequence) DeepCopy() *Sequence { + if in == nil { + return nil + } + out := new(Sequence) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Sequence) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceChannelStatus) DeepCopyInto(out *SequenceChannelStatus) { + *out = *in + out.Channel = in.Channel + in.ReadyCondition.DeepCopyInto(&out.ReadyCondition) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceChannelStatus. +func (in *SequenceChannelStatus) DeepCopy() *SequenceChannelStatus { + if in == nil { + return nil + } + out := new(SequenceChannelStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceList) DeepCopyInto(out *SequenceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Sequence, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceList. +func (in *SequenceList) DeepCopy() *SequenceList { + if in == nil { + return nil + } + out := new(SequenceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SequenceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceSpec) DeepCopyInto(out *SequenceSpec) { + *out = *in + if in.Steps != nil { + in, out := &in.Steps, &out.Steps + *out = make([]v1.Destination, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ChannelTemplate != nil { + in, out := &in.ChannelTemplate, &out.ChannelTemplate + *out = new(duckv1alpha1.ChannelTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.Reply != nil { + in, out := &in.Reply, &out.Reply + *out = new(v1.Destination) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceSpec. +func (in *SequenceSpec) DeepCopy() *SequenceSpec { + if in == nil { + return nil + } + out := new(SequenceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceStatus) DeepCopyInto(out *SequenceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.SubscriptionStatuses != nil { + in, out := &in.SubscriptionStatuses, &out.SubscriptionStatuses + *out = make([]SequenceSubscriptionStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ChannelStatuses != nil { + in, out := &in.ChannelStatuses, &out.ChannelStatuses + *out = make([]SequenceChannelStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.AddressStatus.DeepCopyInto(&out.AddressStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceStatus. +func (in *SequenceStatus) DeepCopy() *SequenceStatus { + if in == nil { + return nil + } + out := new(SequenceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceSubscriptionStatus) DeepCopyInto(out *SequenceSubscriptionStatus) { + *out = *in + out.Subscription = in.Subscription + in.ReadyCondition.DeepCopyInto(&out.ReadyCondition) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceSubscriptionStatus. +func (in *SequenceSubscriptionStatus) DeepCopy() *SequenceSubscriptionStatus { + if in == nil { + return nil + } + out := new(SequenceSubscriptionStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_types.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_types.go index 601d9dbae6..095c16a0e8 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_types.go @@ -26,7 +26,6 @@ import ( duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" "knative.dev/pkg/kmeta" - "knative.dev/pkg/webhook" ) // +genclient @@ -55,8 +54,7 @@ var ( // Check that Channel can return its spec untyped. _ apis.HasSpec = (*Channel)(nil) - _ runtime.Object = (*Channel)(nil) - _ webhook.GenericCRD = (*Channel)(nil) + _ runtime.Object = (*Channel)(nil) // Check that we can create OwnerReferences to a Channel. _ kmeta.OwnerRefable = (*Channel)(nil) diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_validation.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_validation.go index 401a816c53..5bc7424440 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/channel_validation.go @@ -45,7 +45,7 @@ func (cs *ChannelSpec) Validate(ctx context.Context) *apis.FieldError { if cs.Subscribable != nil { for i, subscriber := range cs.Subscribable.Subscribers { - if subscriber.ReplyURI == "" && subscriber.SubscriberURI == "" { + if subscriber.ReplyURI == nil && subscriber.SubscriberURI == nil { fe := apis.ErrMissingField("replyURI", "subscriberURI") fe.Details = "expected at least one of, got none" errs = errs.Also(fe.ViaField(fmt.Sprintf("subscriber[%d]", i)).ViaField("subscribable")) @@ -67,16 +67,11 @@ func isValidChannelTemplate(ct *eventingduck.ChannelTemplateSpec) *apis.FieldErr return errs } -func (c *Channel) CheckImmutableFields(ctx context.Context, og apis.Immutable) *apis.FieldError { - if og == nil { +func (c *Channel) CheckImmutableFields(ctx context.Context, original *Channel) *apis.FieldError { + if original == nil { return nil } - original, ok := og.(*Channel) - if !ok { - return &apis.FieldError{Message: "The provided original was not a Channel"} - } - ignoreArguments := cmpopts.IgnoreFields(ChannelSpec{}, "Subscribable") if diff, err := kmp.ShortDiff(original.Spec, c.Spec, ignoreArguments); err != nil { return &apis.FieldError{ diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_types.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_types.go index 163b7b4bcb..0222f137f3 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_types.go @@ -25,7 +25,6 @@ import ( duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" "knative.dev/pkg/kmeta" - "knative.dev/pkg/webhook" ) // +genclient @@ -54,8 +53,7 @@ var ( // Check that InMemoryChannel can return its spec untyped. _ apis.HasSpec = (*InMemoryChannel)(nil) - _ runtime.Object = (*InMemoryChannel)(nil) - _ webhook.GenericCRD = (*InMemoryChannel)(nil) + _ runtime.Object = (*InMemoryChannel)(nil) // Check that we can create OwnerReferences to an InMemoryChannel. _ kmeta.OwnerRefable = (*InMemoryChannel)(nil) diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go index f330b2661f..36658a405c 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/in_memory_channel_validation.go @@ -32,7 +32,7 @@ func (imcs *InMemoryChannelSpec) Validate(ctx context.Context) *apis.FieldError if imcs.Subscribable != nil { for i, subscriber := range imcs.Subscribable.Subscribers { - if subscriber.ReplyURI == "" && subscriber.SubscriberURI == "" { + if subscriber.ReplyURI == nil && subscriber.SubscriberURI == nil { fe := apis.ErrMissingField("replyURI", "subscriberURI") fe.Details = "expected at least one of, got none" errs = errs.Also(fe.ViaField(fmt.Sprintf("subscriber[%d]", i)).ViaField("subscribable")) diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/parallel_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/parallel_lifecycle.go index 9445e3fd2d..f28aea0334 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/parallel_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/parallel_lifecycle.go @@ -206,7 +206,7 @@ func (ps *ParallelStatus) setAddress(address *pkgduckv1alpha1.Addressable) { // MarkDeprecated adds a warning condition that this object's spec is using deprecated fields // and will stop working in the future. Note that this does not affect the Ready condition. -func (ps *ParallelStatus) MarkDestinationDeprecatedRef(reason, msg string) { +func (ps *ParallelStatus) MarkDeprecated(reason, msg string) { dc := apis.Condition{ Type: StatusConditionTypeDeprecated, Reason: reason, diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/parallel_types.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/parallel_types.go index be655258bf..281ccb0047 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/parallel_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/parallel_types.go @@ -25,9 +25,8 @@ import ( "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" - "knative.dev/pkg/webhook" ) // +genclient @@ -56,11 +55,7 @@ var ( // Check that Parallel can return its spec untyped. _ apis.HasSpec = (*Parallel)(nil) - // TODO: make appropriate fields immutable. - //_ apis.Immutable = (*Parallel)(nil) - - _ runtime.Object = (*Parallel)(nil) - _ webhook.GenericCRD = (*Parallel)(nil) + _ runtime.Object = (*Parallel)(nil) // Check that we can create OwnerReferences to a Parallel. _ kmeta.OwnerRefable = (*Parallel)(nil) @@ -78,20 +73,20 @@ type ParallelSpec struct { // Reply is a Reference to where the result of a case Subscriber gets sent to // when the case does not have a Reply // +optional - Reply *v1alpha1.Destination `json:"reply,omitempty"` + Reply *duckv1beta1.Destination `json:"reply,omitempty"` } type ParallelBranch struct { // Filter is the expression guarding the branch - Filter *v1alpha1.Destination `json:"filter,omitempty"` + Filter *duckv1beta1.Destination `json:"filter,omitempty"` // Subscriber receiving the event when the filter passes - Subscriber v1alpha1.Destination `json:"subscriber"` + Subscriber duckv1beta1.Destination `json:"subscriber"` // Reply is a Reference to where the result of Subscriber of this case gets sent to. // If not specified, sent the result to the Parallel Reply // +optional - Reply *v1alpha1.Destination `json:"reply,omitempty"` + Reply *duckv1beta1.Destination `json:"reply,omitempty"` } // ParallelStatus represents the current state of a Parallel. diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/sequence_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/sequence_lifecycle.go index f888ec6c26..cad618fecd 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/sequence_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/sequence_lifecycle.go @@ -166,9 +166,10 @@ func (ss *SequenceStatus) setAddress(address *pkgduckv1alpha1.Addressable) { } } -// MarkDeprecated adds a warning condition that this object's spec is using deprecated fields -// and will stop working in the future. Note that this does not affect the Ready condition. -func (ss *SequenceStatus) MarkDestinationDeprecatedRef(reason, msg string) { +// MarkDeprecated adds a warning condition that this object's +// spec is using deprecated fields and will stop working in the future. Note that +// this does not affect the Ready condition. +func (ss *SequenceStatus) MarkDeprecated(reason, msg string) { dc := apis.Condition{ Type: StatusConditionTypeDeprecated, Reason: reason, diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/sequence_types.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/sequence_types.go index 6f59abe2ca..fd7ca989b1 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/sequence_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/sequence_types.go @@ -25,9 +25,8 @@ import ( "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" - "knative.dev/pkg/webhook" ) // +genclient @@ -56,11 +55,7 @@ var ( // Check that Sequence can return its spec untyped. _ apis.HasSpec = (*Sequence)(nil) - // TODO: make appropriate fields immutable. - //_ apis.Immutable = (*Sequence)(nil) - - _ runtime.Object = (*Sequence)(nil) - _ webhook.GenericCRD = (*Sequence)(nil) + _ runtime.Object = (*Sequence)(nil) // Check that we can create OwnerReferences to a Sequence. _ kmeta.OwnerRefable = (*Sequence)(nil) @@ -69,7 +64,7 @@ var ( type SequenceSpec struct { // Steps is the list of Destinations (processors / functions) that will be called in the order // provided. - Steps []v1alpha1.Destination `json:"steps"` + Steps []duckv1beta1.Destination `json:"steps"` // ChannelTemplate specifies which Channel CRD to use. If left unspecified, it is set to the default Channel CRD // for the namespace (or cluster, in case there are no defaults for the namespace). @@ -78,7 +73,7 @@ type SequenceSpec struct { // Reply is a Reference to where the result of the last Subscriber gets sent to. // +optional - Reply *v1alpha1.Destination `json:"reply,omitempty"` + Reply *duckv1beta1.Destination `json:"reply,omitempty"` } type SequenceChannelStatus struct { diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_types.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_types.go index a9fa7b0334..747ec77b4f 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_types.go @@ -23,9 +23,10 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" - "knative.dev/pkg/webhook" + + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" ) // +genclient @@ -45,13 +46,11 @@ var ( // Check that Subscription can be validated, can be defaulted, and has immutable fields. _ apis.Validatable = (*Subscription)(nil) _ apis.Defaultable = (*Subscription)(nil) - _ apis.Immutable = (*Subscription)(nil) // Check that Subscription can return its spec untyped. _ apis.HasSpec = (*Subscription)(nil) - _ runtime.Object = (*Subscription)(nil) - _ webhook.GenericCRD = (*Subscription)(nil) + _ runtime.Object = (*Subscription)(nil) // Check that we can create OwnerReferences to a Subscription. _ kmeta.OwnerRefable = (*Subscription)(nil) @@ -105,22 +104,32 @@ type SubscriptionSpec struct { // Events from the Channel will be delivered here and replies are // sent to a channel as specified by the Reply. // +optional - Subscriber *apisv1alpha1.Destination `json:"subscriber,omitempty"` + Subscriber *duckv1beta1.Destination `json:"subscriber,omitempty"` // Reply specifies (optionally) how to handle events returned from // the Subscriber target. // +optional Reply *ReplyStrategy `json:"reply,omitempty"` + + // Delivery configuration + // +optional + Delivery *eventingduckv1alpha1.DeliverySpec `json:"delivery,omitempty"` } // ReplyStrategy specifies the handling of the Subscriber's returned replies. // If no Subscriber is specified, the identity function is assumed. type ReplyStrategy struct { + // The resource pointed by this Destination must meet the Addressable contract + // with a reference to the Addressable duck type. If the resource does not meet this contract, + // it will be reflected in the Subscription's status. + // +optional + *duckv1beta1.Destination `json:",inline"` + // The resource pointed by this ObjectReference must meet the Addressable contract // with a reference to the Addressable duck type. If the resource does not meet this contract, // it will be reflected in the Subscription's status. // +optional - Channel *apisv1alpha1.Destination `json:"channel,omitempty"` + DeprecatedChannel *duckv1beta1.Destination `json:"channel,omitempty"` } // SubscriptionStatus (computed) for a subscription @@ -142,6 +151,9 @@ type SubscriptionStatusPhysicalSubscription struct { // ReplyURI is the fully resolved URI for the spec.reply. ReplyURI *apis.URL `json:"replyURI,omitempty"` + + // ReplyURI is the fully resolved URI for the spec.delivery.deadLetterSink. + DeadLetterSinkURI *apis.URL `json:"deadLetterSinkURI,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_validation.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_validation.go index a377cc281b..7411a9137f 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_validation.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/subscription_validation.go @@ -22,7 +22,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "k8s.io/apimachinery/pkg/api/equality" "knative.dev/pkg/apis" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmp" ) @@ -58,27 +58,32 @@ func (ss *SubscriptionSpec) Validate(ctx context.Context) *apis.FieldError { } if !missingReply { - if fe := ss.Reply.Channel.Validate(ctx); fe != nil { - errs = errs.Also(fe.ViaField("reply.channel")) + if !isDestinationNilOrEmpty(ss.Reply.DeprecatedChannel) && !isDestinationNilOrEmpty(ss.Reply.Destination) { + errs = errs.Also(apis.ErrGeneric("channel and [ref, uri] can't be both present", "reply.channel", "reply.ref", "reply.uri")) + } else if !isDestinationNilOrEmpty(ss.Reply.DeprecatedChannel) { + if fe := ss.Reply.DeprecatedChannel.Validate(ctx); fe != nil { + errs = errs.Also(fe.ViaField("reply.channel")) + } + } else { + if fe := ss.Reply.Destination.Validate(ctx); fe != nil { + errs = errs.Also(fe.ViaField("reply")) + } } } return errs } -func isDestinationNilOrEmpty(d *apisv1alpha1.Destination) bool { - return d == nil || equality.Semantic.DeepEqual(d, &apisv1alpha1.Destination{}) +func isDestinationNilOrEmpty(d *duckv1beta1.Destination) bool { + return d == nil || equality.Semantic.DeepEqual(d, &duckv1beta1.Destination{}) } func isReplyStrategyNilOrEmpty(r *ReplyStrategy) bool { - return r == nil || equality.Semantic.DeepEqual(r, &ReplyStrategy{}) || equality.Semantic.DeepEqual(r.Channel, &apisv1alpha1.Destination{}) + return r == nil || equality.Semantic.DeepEqual(r, &ReplyStrategy{}) || + (equality.Semantic.DeepEqual(r.DeprecatedChannel, &duckv1beta1.Destination{}) && (equality.Semantic.DeepEqual(r.Destination, &duckv1beta1.Destination{}))) } -func (s *Subscription) CheckImmutableFields(ctx context.Context, og apis.Immutable) *apis.FieldError { - original, ok := og.(*Subscription) - if !ok { - return &apis.FieldError{Message: "The provided original was not a Subscription"} - } +func (s *Subscription) CheckImmutableFields(ctx context.Context, original *Subscription) *apis.FieldError { if original == nil { return nil } diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/zz_generated.deepcopy.go index 06f5dd4fa5..9bf09042c1 100644 --- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1alpha1/zz_generated.deepcopy.go @@ -25,7 +25,7 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" apis "knative.dev/pkg/apis" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + v1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -273,13 +273,13 @@ func (in *ParallelBranch) DeepCopyInto(out *ParallelBranch) { *out = *in if in.Filter != nil { in, out := &in.Filter, &out.Filter - *out = new(apisv1alpha1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } in.Subscriber.DeepCopyInto(&out.Subscriber) if in.Reply != nil { in, out := &in.Reply, &out.Reply - *out = new(apisv1alpha1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } return @@ -382,7 +382,7 @@ func (in *ParallelSpec) DeepCopyInto(out *ParallelSpec) { } if in.Reply != nil { in, out := &in.Reply, &out.Reply - *out = new(apisv1alpha1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } return @@ -445,9 +445,14 @@ func (in *ParallelSubscriptionStatus) DeepCopy() *ParallelSubscriptionStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ReplyStrategy) DeepCopyInto(out *ReplyStrategy) { *out = *in - if in.Channel != nil { - in, out := &in.Channel, &out.Channel - *out = new(apisv1alpha1.Destination) + if in.Destination != nil { + in, out := &in.Destination, &out.Destination + *out = new(v1beta1.Destination) + (*in).DeepCopyInto(*out) + } + if in.DeprecatedChannel != nil { + in, out := &in.DeprecatedChannel, &out.DeprecatedChannel + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } return @@ -547,7 +552,7 @@ func (in *SequenceSpec) DeepCopyInto(out *SequenceSpec) { *out = *in if in.Steps != nil { in, out := &in.Steps, &out.Steps - *out = make([]apisv1alpha1.Destination, len(*in)) + *out = make([]v1beta1.Destination, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } @@ -559,7 +564,7 @@ func (in *SequenceSpec) DeepCopyInto(out *SequenceSpec) { } if in.Reply != nil { in, out := &in.Reply, &out.Reply - *out = new(apisv1alpha1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } return @@ -692,7 +697,7 @@ func (in *SubscriptionSpec) DeepCopyInto(out *SubscriptionSpec) { out.Channel = in.Channel if in.Subscriber != nil { in, out := &in.Subscriber, &out.Subscriber - *out = new(apisv1alpha1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } if in.Reply != nil { @@ -700,6 +705,11 @@ func (in *SubscriptionSpec) DeepCopyInto(out *SubscriptionSpec) { *out = new(ReplyStrategy) (*in).DeepCopyInto(*out) } + if in.Delivery != nil { + in, out := &in.Delivery, &out.Delivery + *out = new(duckv1alpha1.DeliverySpec) + (*in).DeepCopyInto(*out) + } return } @@ -744,6 +754,11 @@ func (in *SubscriptionStatusPhysicalSubscription) DeepCopyInto(out *Subscription *out = new(apis.URL) (*in).DeepCopyInto(*out) } + if in.DeadLetterSinkURI != nil { + in, out := &in.DeadLetterSinkURI, &out.DeadLetterSinkURI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } return } diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go index 0a782a8836..e0103ada2c 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go @@ -35,6 +35,9 @@ const ( // ApiServerConditionDeployed has status True when the ApiServerSource has had it's deployment created. ApiServerConditionDeployed apis.ConditionType = "Deployed" + // ApiServerConditionSufficientPermissions has status True when the ApiServerSource has sufficient permissions to access resources. + ApiServerConditionSufficientPermissions apis.ConditionType = "SufficientPermissions" + // ApiServerConditionEventTypeProvided has status True when the ApiServerSource has been configured with its event types. ApiServerConditionEventTypeProvided apis.ConditionType = "EventTypesProvided" ) @@ -42,6 +45,7 @@ const ( var apiserverCondSet = apis.NewLivingConditionSet( ApiServerConditionSinkProvided, ApiServerConditionDeployed, + ApiServerConditionSufficientPermissions, ) // GetCondition returns the condition currently associated with the given type, or nil. @@ -72,7 +76,7 @@ func (s *ApiServerSourceStatus) MarkSinkWarnRefDeprecated(uri string) { Type: ApiServerConditionSinkProvided, Status: corev1.ConditionTrue, Severity: apis.ConditionSeverityError, - Message: "Using deprecated object ref fields when specifying spec.sink. Update to spec.sink.ref. These will be removed in 0.11.", + Message: "Using deprecated object ref fields when specifying spec.sink. Update to spec.sink.ref. These will be removed in the future.", } apiserverCondSet.Manage(s).SetCondition(c) } else { @@ -107,6 +111,16 @@ func (s *ApiServerSourceStatus) MarkNoEventTypes(reason, messageFormat string, m apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionEventTypeProvided, reason, messageFormat, messageA...) } +// MarkSufficientPermissions sets the condition that the source has enough permissions to access the resources. +func (s *ApiServerSourceStatus) MarkSufficientPermissions() { + apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionSufficientPermissions) +} + +// MarkNoSufficientPermissions sets the condition that the source does not have enough permissions to access the resources +func (s *ApiServerSourceStatus) MarkNoSufficientPermissions(reason, messageFormat string, messageA ...interface{}) { + apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionSufficientPermissions, reason, messageFormat, messageA...) +} + // IsReady returns true if the resource is ready overall. func (s *ApiServerSourceStatus) IsReady() bool { return apiserverCondSet.Manage(s).IsHappy() diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go index adf4f3c3ca..07405c4d43 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/apiserver_types.go @@ -21,7 +21,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" ) @@ -87,7 +87,7 @@ type ApiServerSourceSpec struct { // Sink is a reference to an object that will resolve to a domain name to use as the sink. // +optional - Sink *apisv1alpha1.Destination `json:"sink,omitempty"` + Sink *duckv1beta1.Destination `json:"sink,omitempty"` // Mode is the mode the receive adapter controller runs under: Ref or Resource. // `Ref` sends only the reference to the resource. diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/containersource_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/containersource_lifecycle.go index 1428616066..dfe8670c9f 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/containersource_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/containersource_lifecycle.go @@ -70,7 +70,7 @@ func (s *ContainerSourceStatus) MarkSinkWarnRefDeprecated(uri string) { Type: ContainerConditionSinkProvided, Status: corev1.ConditionTrue, Severity: apis.ConditionSeverityError, - Message: "Using deprecated object ref fields when specifying spec.sink. Update to spec.sink.ref. These will be removed in 0.11.", + Message: "Using deprecated object ref fields when specifying spec.sink. Update to spec.sink.ref. These will be removed in the future.", } apiserverCondSet.Manage(s).SetCondition(c) } else { diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/containersource_types.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/containersource_types.go index 90f776b775..f044dd9a73 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/containersource_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/containersource_types.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" ) @@ -84,7 +84,7 @@ type ContainerSourceSpec struct { DeprecatedServiceAccountName string `json:"serviceAccountName,omitempty"` // Sink is a reference to an object that will resolve to a domain name to use as the sink. - Sink *apisv1alpha1.Destination `json:"sink,omitempty"` + Sink *duckv1beta1.Destination `json:"sink,omitempty"` } // GetGroupVersionKind returns the GroupVersionKind. diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/cron_job_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/cron_job_lifecycle.go index fc92cde65c..67434fa074 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/cron_job_lifecycle.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/cron_job_lifecycle.go @@ -95,7 +95,7 @@ func (s *CronJobSourceStatus) MarkSinkWarnRefDeprecated(uri string) { Type: CronJobConditionSinkProvided, Status: corev1.ConditionTrue, Severity: apis.ConditionSeverityError, - Message: "Using deprecated object ref fields when specifying spec.sink. Update to spec.sink.ref. These will be removed in 0.11.", + Message: "Using deprecated object ref fields when specifying spec.sink. Update to spec.sink.ref. These will be removed in the future.", } apiserverCondSet.Manage(s).SetCondition(c) } else { diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/cron_job_types.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/cron_job_types.go index 8d8a7564b2..16997d03bf 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/cron_job_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/cron_job_types.go @@ -25,7 +25,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" duckv1 "knative.dev/pkg/apis/duck/v1" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" ) @@ -90,7 +90,7 @@ type CronJobSourceSpec struct { Data string `json:"data,omitempty"` // Sink is a reference to an object that will resolve to a domain name to use as the sink. - Sink *apisv1alpha1.Destination `json:"sink,omitempty"` + Sink *duckv1beta1.Destination `json:"sink,omitempty"` // ServiceAccoutName is the name of the ServiceAccount that will be used to run the Receive // Adapter Deployment. diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/register.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/register.go index 1f4f6e0370..a92c7c3771 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/register.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/register.go @@ -51,6 +51,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ContainerSourceList{}, &ApiServerSource{}, &ApiServerSourceList{}, + &SinkBinding{}, + &SinkBindingList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_context.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_context.go new file mode 100644 index 0000000000..420807fcd5 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_context.go @@ -0,0 +1,43 @@ +/* +Copyright 2019 The Knative 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 ( + "context" + + "knative.dev/pkg/apis" +) + +// sinkURIKey is used as the key for associating information +// with a context.Context. +type sinkURIKey struct{} + +// WithSinkURI notes on the context for binding that the resolved SinkURI +// is the provided apis.URL. +func WithSinkURI(ctx context.Context, uri *apis.URL) context.Context { + return context.WithValue(ctx, sinkURIKey{}, uri) +} + +// GetSinkURI accesses the apis.URL for the Sink URI that has been associated +// with this context. +func GetSinkURI(ctx context.Context) *apis.URL { + value := ctx.Value(sinkURIKey{}) + if value == nil { + return nil + } + return value.(*apis.URL) +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_defaults.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_defaults.go new file mode 100644 index 0000000000..f5a51165c8 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_defaults.go @@ -0,0 +1,34 @@ +/* +Copyright 2019 The Knative 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 ( + "context" +) + +// SetDefaults implements apis.Defaultable +func (fb *SinkBinding) SetDefaults(ctx context.Context) { + if fb.Spec.Subject.Namespace == "" { + // Default the subject's namespace to our namespace. + fb.Spec.Subject.Namespace = fb.Namespace + } + + if fb.Spec.Sink.Ref != nil && fb.Spec.Sink.Ref.Namespace == "" { + // Default the sink's namespace to our namespace. + fb.Spec.Sink.Ref.Namespace = fb.Namespace + } +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_lifecycle.go new file mode 100644 index 0000000000..a4b56c8390 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_lifecycle.go @@ -0,0 +1,120 @@ +/* +Copyright 2019 The Knative 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 ( + "context" + "fmt" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/eventing/pkg/logging" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/tracker" +) + +var sbCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (s *SinkBinding) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("SinkBinding") +} + +// GetUntypedSpec implements apis.HasSpec +func (c *SinkBinding) GetUntypedSpec() interface{} { + return c.Spec +} + +// GetSubject implements psbinding.Bindable +func (fb *SinkBinding) GetSubject() tracker.Reference { + return fb.Spec.Subject +} + +// GetBindingStatus implements psbinding.Bindable +func (fb *SinkBinding) GetBindingStatus() duck.BindableStatus { + return &fb.Status +} + +// SetObservedGeneration implements psbinding.BindableStatus +func (fbs *SinkBindingStatus) SetObservedGeneration(gen int64) { + fbs.ObservedGeneration = gen +} + +// InitializeConditions populates the SinkBindingStatus's conditions field +// with all of its conditions configured to Unknown. +func (fbs *SinkBindingStatus) InitializeConditions() { + sbCondSet.Manage(fbs).InitializeConditions() +} + +// MarkBindingUnavailable marks the SinkBinding's Ready condition to False with +// the provided reason and message. +func (fbs *SinkBindingStatus) MarkBindingUnavailable(reason, message string) { + sbCondSet.Manage(fbs).MarkFalse(SinkBindingConditionReady, reason, message) +} + +// MarkBindingAvailable marks the SinkBinding's Ready condition to True. +func (fbs *SinkBindingStatus) MarkBindingAvailable() { + sbCondSet.Manage(fbs).MarkTrue(SinkBindingConditionReady) +} + +// Do implements psbinding.Bindable +func (fb *SinkBinding) Do(ctx context.Context, ps *duckv1.WithPod) { + // First undo so that we can just unconditionally append below. + fb.Undo(ctx, ps) + + uri := GetSinkURI(ctx) + if uri == nil { + logging.FromContext(ctx).Error(fmt.Sprintf("No sink URI associated with context for %+v", fb)) + return + } + + spec := ps.Spec.Template.Spec + for i := range spec.InitContainers { + spec.InitContainers[i].Env = append(spec.InitContainers[i].Env, corev1.EnvVar{ + Name: "K_SINK", + Value: uri.String(), + }) + } + for i := range spec.Containers { + spec.Containers[i].Env = append(spec.Containers[i].Env, corev1.EnvVar{ + Name: "K_SINK", + Value: uri.String(), + }) + } +} + +func (fb *SinkBinding) Undo(ctx context.Context, ps *duckv1.WithPod) { + spec := ps.Spec.Template.Spec + for i, c := range spec.InitContainers { + for j, ev := range c.Env { + if ev.Name == "K_SINK" { + spec.InitContainers[i].Env = append(spec.InitContainers[i].Env[:j], spec.InitContainers[i].Env[j+1:]...) + break + } + } + } + for i, c := range spec.Containers { + for j, ev := range c.Env { + if ev.Name == "K_SINK" { + spec.Containers[i].Env = append(spec.Containers[i].Env[:j], spec.Containers[i].Env[j+1:]...) + break + } + } + } +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_types.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_types.go new file mode 100644 index 0000000000..600aed7f61 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_types.go @@ -0,0 +1,79 @@ +/* +Copyright 2019 The Knative 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 ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +k8s:defaulter-gen=true + +// SinkBinding describes a Binding that is also a Source. +// The `sink` (from the Source duck) is resolved to a URL and +// then projected into the `subject` by augmenting the runtime +// contract of the referenced containers to have a `K_SINK` +// environment variable holding the endpoint to which to send +// cloud events. +type SinkBinding struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec SinkBindingSpec `json:"spec"` + Status SinkBindingStatus `json:"status"` +} + +// Check the interfaces that SinkBinding should be implementing. +var ( + _ runtime.Object = (*SinkBinding)(nil) + _ kmeta.OwnerRefable = (*SinkBinding)(nil) + _ apis.Validatable = (*SinkBinding)(nil) + _ apis.Defaultable = (*SinkBinding)(nil) + _ apis.HasSpec = (*SinkBinding)(nil) +) + +// SinkBindingSpec holds the desired state of the SinkBinding (from the client). +type SinkBindingSpec struct { + duckv1.SourceSpec `json:",inline"` + duckv1alpha1.BindingSpec `json:",inline"` +} + +const ( + // SinkBindingConditionReady is configured to indicate whether the Binding + // has been configured for resources subject to its runtime contract. + SinkBindingConditionReady = apis.ConditionReady +) + +// SinkBindingStatus communicates the observed state of the SinkBinding (from the controller). +type SinkBindingStatus struct { + duckv1.SourceStatus `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SinkBindingList contains a list of SinkBinding +type SinkBindingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []SinkBinding `json:"items"` +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_validation.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_validation.go new file mode 100644 index 0000000000..7753194af6 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/sinkbinding_validation.go @@ -0,0 +1,41 @@ +/* +Copyright 2019 The Knative 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 ( + "context" + + "knative.dev/pkg/apis" +) + +// Validate implements apis.Validatable +func (fb *SinkBinding) Validate(ctx context.Context) *apis.FieldError { + err := fb.Spec.Validate(ctx).ViaField("spec") + if fb.Spec.Subject.Namespace != "" && fb.Namespace != fb.Spec.Subject.Namespace { + err = err.Also(apis.ErrInvalidValue(fb.Spec.Subject.Namespace, "spec.subject.namespace")) + } + if fb.Spec.Sink.Ref != nil && fb.Spec.Sink.Ref.Namespace != "" && fb.Namespace != fb.Spec.Sink.Ref.Namespace { + err = err.Also(apis.ErrInvalidValue(fb.Spec.Sink.Ref.Namespace, "spec.sink.ref.namespace")) + } + return err +} + +// Validate implements apis.Validatable +func (fbs *SinkBindingSpec) Validate(ctx context.Context) *apis.FieldError { + return fbs.Subject.Validate(ctx).ViaField("subject").Also( + fbs.Sink.Validate(ctx).ViaField("sink")) +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go index e71a4ccb3a..1dfdb28b6c 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go @@ -23,7 +23,7 @@ package v1alpha1 import ( v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" + v1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -117,7 +117,7 @@ func (in *ApiServerSourceSpec) DeepCopyInto(out *ApiServerSourceSpec) { } if in.Sink != nil { in, out := &in.Sink, &out.Sink - *out = new(apisv1alpha1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } return @@ -233,7 +233,7 @@ func (in *ContainerSourceSpec) DeepCopyInto(out *ContainerSourceSpec) { } if in.Sink != nil { in, out := &in.Sink, &out.Sink - *out = new(apisv1alpha1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } return @@ -382,7 +382,7 @@ func (in *CronJobSourceSpec) DeepCopyInto(out *CronJobSourceSpec) { *out = *in if in.Sink != nil { in, out := &in.Sink, &out.Sink - *out = new(apisv1alpha1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } out.Resources = in.Resources @@ -415,3 +415,99 @@ func (in *CronJobSourceStatus) DeepCopy() *CronJobSourceStatus { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SinkBinding) DeepCopyInto(out *SinkBinding) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBinding. +func (in *SinkBinding) DeepCopy() *SinkBinding { + if in == nil { + return nil + } + out := new(SinkBinding) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SinkBinding) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SinkBindingList) DeepCopyInto(out *SinkBindingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]SinkBinding, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingList. +func (in *SinkBindingList) DeepCopy() *SinkBindingList { + if in == nil { + return nil + } + out := new(SinkBindingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SinkBindingList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SinkBindingSpec) DeepCopyInto(out *SinkBindingSpec) { + *out = *in + in.SourceSpec.DeepCopyInto(&out.SourceSpec) + in.BindingSpec.DeepCopyInto(&out.BindingSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingSpec. +func (in *SinkBindingSpec) DeepCopy() *SinkBindingSpec { + if in == nil { + return nil + } + out := new(SinkBindingSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SinkBindingStatus) DeepCopyInto(out *SinkBindingStatus) { + *out = *in + in.SourceStatus.DeepCopyInto(&out.SourceStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingStatus. +func (in *SinkBindingStatus) DeepCopy() *SinkBindingStatus { + if in == nil { + return nil + } + out := new(SinkBindingStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/scheme/register.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/scheme/register.go index badcd878f1..9c2239c0dd 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/scheme/register.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/scheme/register.go @@ -25,6 +25,7 @@ import ( serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" ) @@ -34,6 +35,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ eventingv1alpha1.AddToScheme, + flowsv1alpha1.AddToScheme, messagingv1alpha1.AddToScheme, sourcesv1alpha1.AddToScheme, } diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go new file mode 100644 index 0000000000..aeb1ad510f --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go @@ -0,0 +1,140 @@ +/* +Copyright 2019 The Knative 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" +) + +// FakeSinkBindings implements SinkBindingInterface +type FakeSinkBindings struct { + Fake *FakeSourcesV1alpha1 + ns string +} + +var sinkbindingsResource = schema.GroupVersionResource{Group: "sources.eventing.knative.dev", Version: "v1alpha1", Resource: "sinkbindings"} + +var sinkbindingsKind = schema.GroupVersionKind{Group: "sources.eventing.knative.dev", Version: "v1alpha1", Kind: "SinkBinding"} + +// Get takes name of the sinkBinding, and returns the corresponding sinkBinding object, and an error if there is any. +func (c *FakeSinkBindings) Get(name string, options v1.GetOptions) (result *v1alpha1.SinkBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(sinkbindingsResource, c.ns, name), &v1alpha1.SinkBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SinkBinding), err +} + +// List takes label and field selectors, and returns the list of SinkBindings that match those selectors. +func (c *FakeSinkBindings) List(opts v1.ListOptions) (result *v1alpha1.SinkBindingList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(sinkbindingsResource, sinkbindingsKind, c.ns, opts), &v1alpha1.SinkBindingList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.SinkBindingList{ListMeta: obj.(*v1alpha1.SinkBindingList).ListMeta} + for _, item := range obj.(*v1alpha1.SinkBindingList).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 sinkBindings. +func (c *FakeSinkBindings) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(sinkbindingsResource, c.ns, opts)) + +} + +// Create takes the representation of a sinkBinding and creates it. Returns the server's representation of the sinkBinding, and an error, if there is any. +func (c *FakeSinkBindings) Create(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(sinkbindingsResource, c.ns, sinkBinding), &v1alpha1.SinkBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SinkBinding), err +} + +// Update takes the representation of a sinkBinding and updates it. Returns the server's representation of the sinkBinding, and an error, if there is any. +func (c *FakeSinkBindings) Update(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(sinkbindingsResource, c.ns, sinkBinding), &v1alpha1.SinkBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SinkBinding), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeSinkBindings) UpdateStatus(sinkBinding *v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(sinkbindingsResource, "status", c.ns, sinkBinding), &v1alpha1.SinkBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SinkBinding), err +} + +// Delete takes name of the sinkBinding and deletes it. Returns an error if one occurs. +func (c *FakeSinkBindings) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(sinkbindingsResource, c.ns, name), &v1alpha1.SinkBinding{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSinkBindings) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(sinkbindingsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.SinkBindingList{}) + return err +} + +// Patch applies the patch and returns the patched sinkBinding. +func (c *FakeSinkBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.SinkBinding, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(sinkbindingsResource, c.ns, name, pt, data, subresources...), &v1alpha1.SinkBinding{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.SinkBinding), err +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go index 9a5bcecf5f..a69423c19a 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go @@ -40,6 +40,10 @@ func (c *FakeSourcesV1alpha1) CronJobSources(namespace string) v1alpha1.CronJobS return &FakeCronJobSources{c, namespace} } +func (c *FakeSourcesV1alpha1) SinkBindings(namespace string) v1alpha1.SinkBindingInterface { + return &FakeSinkBindings{c, namespace} +} + // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeSourcesV1alpha1) RESTClient() rest.Interface { diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go index 90d7d66818..e9f6629345 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go @@ -23,3 +23,5 @@ type ApiServerSourceExpansion interface{} type ContainerSourceExpansion interface{} type CronJobSourceExpansion interface{} + +type SinkBindingExpansion interface{} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go new file mode 100644 index 0000000000..ebffe551cd --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go @@ -0,0 +1,191 @@ +/* +Copyright 2019 The Knative 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. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" + scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +// SinkBindingsGetter has a method to return a SinkBindingInterface. +// A group's client should implement this interface. +type SinkBindingsGetter interface { + SinkBindings(namespace string) SinkBindingInterface +} + +// SinkBindingInterface has methods to work with SinkBinding resources. +type SinkBindingInterface interface { + Create(*v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) + Update(*v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) + UpdateStatus(*v1alpha1.SinkBinding) (*v1alpha1.SinkBinding, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.SinkBinding, error) + List(opts v1.ListOptions) (*v1alpha1.SinkBindingList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.SinkBinding, err error) + SinkBindingExpansion +} + +// sinkBindings implements SinkBindingInterface +type sinkBindings struct { + client rest.Interface + ns string +} + +// newSinkBindings returns a SinkBindings +func newSinkBindings(c *SourcesV1alpha1Client, namespace string) *sinkBindings { + return &sinkBindings{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the sinkBinding, and returns the corresponding sinkBinding object, and an error if there is any. +func (c *sinkBindings) Get(name string, options v1.GetOptions) (result *v1alpha1.SinkBinding, err error) { + result = &v1alpha1.SinkBinding{} + err = c.client.Get(). + Namespace(c.ns). + Resource("sinkbindings"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of SinkBindings that match those selectors. +func (c *sinkBindings) List(opts v1.ListOptions) (result *v1alpha1.SinkBindingList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.SinkBindingList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("sinkbindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested sinkBindings. +func (c *sinkBindings) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("sinkbindings"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a sinkBinding and creates it. Returns the server's representation of the sinkBinding, and an error, if there is any. +func (c *sinkBindings) Create(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { + result = &v1alpha1.SinkBinding{} + err = c.client.Post(). + Namespace(c.ns). + Resource("sinkbindings"). + Body(sinkBinding). + Do(). + Into(result) + return +} + +// Update takes the representation of a sinkBinding and updates it. Returns the server's representation of the sinkBinding, and an error, if there is any. +func (c *sinkBindings) Update(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { + result = &v1alpha1.SinkBinding{} + err = c.client.Put(). + Namespace(c.ns). + Resource("sinkbindings"). + Name(sinkBinding.Name). + Body(sinkBinding). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *sinkBindings) UpdateStatus(sinkBinding *v1alpha1.SinkBinding) (result *v1alpha1.SinkBinding, err error) { + result = &v1alpha1.SinkBinding{} + err = c.client.Put(). + Namespace(c.ns). + Resource("sinkbindings"). + Name(sinkBinding.Name). + SubResource("status"). + Body(sinkBinding). + Do(). + Into(result) + return +} + +// Delete takes name of the sinkBinding and deletes it. Returns an error if one occurs. +func (c *sinkBindings) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("sinkbindings"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *sinkBindings) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("sinkbindings"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched sinkBinding. +func (c *sinkBindings) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.SinkBinding, err error) { + result = &v1alpha1.SinkBinding{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("sinkbindings"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go index ef2db2a47a..3c23692031 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go @@ -29,6 +29,7 @@ type SourcesV1alpha1Interface interface { ApiServerSourcesGetter ContainerSourcesGetter CronJobSourcesGetter + SinkBindingsGetter } // SourcesV1alpha1Client is used to interact with features provided by the sources.eventing.knative.dev group. @@ -48,6 +49,10 @@ func (c *SourcesV1alpha1Client) CronJobSources(namespace string) CronJobSourceIn return newCronJobSources(c, namespace) } +func (c *SourcesV1alpha1Client) SinkBindings(namespace string) SinkBindingInterface { + return newSinkBindings(c, namespace) +} + // NewForConfig creates a new SourcesV1alpha1Client for the given config. func NewForConfig(c *rest.Config) (*SourcesV1alpha1Client, error) { config := *c diff --git a/vendor/knative.dev/eventing/pkg/logging/logging.go b/vendor/knative.dev/eventing/pkg/logging/logging.go new file mode 100644 index 0000000000..963bfdde68 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/logging/logging.go @@ -0,0 +1,38 @@ +/* +Copyright 2019 The Knative 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 logging is a copy of knative/pkg's logging package, except it uses desugared loggers. +package logging + +import ( + "context" + + "go.uber.org/zap" + "knative.dev/pkg/logging" +) + +func WithLogger(ctx context.Context, logger *zap.Logger) context.Context { + return logging.WithLogger(ctx, logger.Sugar()) +} + +func FromContext(ctx context.Context) *zap.Logger { + return logging.FromContext(ctx).Desugar() +} + +func With(ctx context.Context, fields ...zap.Field) context.Context { + logger := FromContext(ctx) + return WithLogger(ctx, logger.With(fields...)) +} diff --git a/vendor/knative.dev/pkg/apis/condition_types.go b/vendor/knative.dev/pkg/apis/condition_types.go index c90438648b..a3d3f2b2f6 100644 --- a/vendor/knative.dev/pkg/apis/condition_types.go +++ b/vendor/knative.dev/pkg/apis/condition_types.go @@ -55,7 +55,6 @@ const ( // Conditions defines a readiness condition for a Knative resource. // See: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties // +k8s:deepcopy-gen=true -// +k8s:openapi-gen=true type Condition struct { // Type of condition. // +required diff --git a/vendor/knative.dev/pkg/apis/duck/README.md b/vendor/knative.dev/pkg/apis/duck/README.md index a56e4c2d12..ab9a590308 100644 --- a/vendor/knative.dev/pkg/apis/duck/README.md +++ b/vendor/knative.dev/pkg/apis/duck/README.md @@ -12,6 +12,7 @@ are as follows: | Label | Duck-Type | | ----------------------------------- | ----------------------------------------------------------------------------- | | `duck.knative.dev/addressable=true` | [Addressable](https://godoc.org/knative.dev/pkg/apis/duck/v1#AddressableType) | +| `duck.knative.dev/binding=true` | [Binding](https://godoc.org/knative.dev/pkg/apis/duck/v1alpha1#Binding) | | `duck.knative.dev/source=true` | [Source](https://godoc.org/knative.dev/pkg/apis/duck/v1#Source) | ## Addressable Shape @@ -26,6 +27,38 @@ status: url: http://host/path?query ``` +## Binding Shape + +Binding is expected to be in the following shape: + +(with direct subject) + +```yaml +apiVersion: group/version +kind: Kind +spec: + subject: + apiVersion: group/version + kind: SomeKind + namespace: the-namespace + name: a-name +``` + +(with indirect subject) + +```yaml +apiVersion: group/version +kind: Kind +spec: + subject: + apiVersion: group/version + kind: SomeKind + namespace: the-namespace + selector: + matchLabels: + key: value +``` + ## Source Shape Source is expected to be in the following shape: diff --git a/vendor/knative.dev/pkg/apis/duck/const.go b/vendor/knative.dev/pkg/apis/duck/const.go new file mode 100644 index 0000000000..4fe4a7aac1 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/const.go @@ -0,0 +1,25 @@ +/* +Copyright 2019 The Knative 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 duck + +const ( + // BindingExcludeLabel is a label that is placed on namespaces and + // resources to exclude them from consideration when binding things. + // It is critical that bindings dealing with Deployments label their + // controller Deployment (or enclosing namespace). + BindingExcludeLabel = "bindings.knative.dev/exclude" +) diff --git a/vendor/knative.dev/pkg/apis/duck/interface.go b/vendor/knative.dev/pkg/apis/duck/interface.go index f99a636339..99cf4ac29c 100644 --- a/vendor/knative.dev/pkg/apis/duck/interface.go +++ b/vendor/knative.dev/pkg/apis/duck/interface.go @@ -19,6 +19,8 @@ package duck import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/tools/cache" + "knative.dev/pkg/kmeta" + "knative.dev/pkg/tracker" ) // InformerFactory is used to create Informer/Lister pairs for a schema.GroupVersionResource @@ -26,3 +28,42 @@ type InformerFactory interface { // Get returns a synced Informer/Lister pair for the provided schema.GroupVersionResource. Get(schema.GroupVersionResource) (cache.SharedIndexInformer, cache.GenericLister, error) } + +// OneOfOurs is the union of our Accessor interface and the OwnerRefable interface +// that is implemented by our resources that implement the kmeta.Accessor. +type OneOfOurs interface { + kmeta.Accessor + kmeta.OwnerRefable +} + +// BindableStatus is the interface that the .status of Bindable resources must +// implement to work smoothly with our BaseReconciler. +type BindableStatus interface { + // InitializeConditions seeds the resource's status.conditions field + // with all of the conditions that this Binding surfaces. + InitializeConditions() + + // MarkBindingAvailable notes that this Binding has been properly + // configured. + MarkBindingAvailable() + + // MarkBindingUnavailable notes the provided reason for why the Binding + // has failed. + MarkBindingUnavailable(reason string, message string) + + // SetObservedGeneration updates the .status.observedGeneration to the + // provided generation value. + SetObservedGeneration(int64) +} + +// Bindable may be implemented by Binding resources to use shared libraries. +type Bindable interface { + OneOfOurs + + // GetSubject returns the standard Binding duck's "Subject" field. + GetSubject() tracker.Reference + + // GetBindingStatus returns the status of the Binding, which must + // implement BindableStatus. + GetBindingStatus() BindableStatus +} diff --git a/vendor/knative.dev/pkg/apis/duck/typed.go b/vendor/knative.dev/pkg/apis/duck/typed.go index 8931866366..5e1644a939 100644 --- a/vendor/knative.dev/pkg/apis/duck/typed.go +++ b/vendor/knative.dev/pkg/apis/duck/typed.go @@ -46,6 +46,12 @@ var _ InformerFactory = (*TypedInformerFactory)(nil) // Get implements InformerFactory. func (dif *TypedInformerFactory) Get(gvr schema.GroupVersionResource) (cache.SharedIndexInformer, cache.GenericLister, error) { + // Avoid error cases, like the GVR does not exist. + // It is not a full check. Some RBACs might sneak by, but the window is very small. + if _, err := dif.Client.Resource(gvr).List(metav1.ListOptions{}); err != nil { + return nil, nil, err + } + listObj := dif.Type.GetListType() lw := &cache.ListWatch{ ListFunc: asStructuredLister(dif.Client.Resource(gvr).List, listObj), diff --git a/vendor/knative.dev/pkg/apis/duck/unstructured.go b/vendor/knative.dev/pkg/apis/duck/unstructured.go index 98b3cef946..3a80390ddb 100644 --- a/vendor/knative.dev/pkg/apis/duck/unstructured.go +++ b/vendor/knative.dev/pkg/apis/duck/unstructured.go @@ -18,16 +18,41 @@ package duck import ( "encoding/json" + + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) -// Marshallable is implementated by the Unstructured K8s types. -type Marshalable interface { - MarshalJSON() ([]byte, error) +// ToUnstructured takes an instance of a OneOfOurs compatible type and +// converts it to unstructured.Unstructured. We take OneOfOurs in place +// or runtime.Object because sometimes we get resources that do not have their +// TypeMeta populated but that is required for unstructured.Unstructured to +// deserialize things, so we leverage our content-agnostic GroupVersionKind() +// method to populate this as-needed (in a copy, so that we don't modify the +// informer's copy, if that is what we are passed). +func ToUnstructured(desired OneOfOurs) (*unstructured.Unstructured, error) { + // If the TypeMeta is not populated, then unmarshalling will fail, so ensure + // the TypeMeta is populated. See also EnsureTypeMeta. + if gvk := desired.GroupVersionKind(); gvk.Version == "" || gvk.Kind == "" { + gvk = desired.GetGroupVersionKind() + desired = desired.DeepCopyObject().(OneOfOurs) + desired.SetGroupVersionKind(gvk) + } + + // Convert desired to unstructured.Unstructured + b, err := json.Marshal(desired) + if err != nil { + return nil, err + } + ud := &unstructured.Unstructured{} + if err := json.Unmarshal(b, ud); err != nil { + return nil, err + } + return ud, nil } // FromUnstructured takes unstructured object from (say from client-go/dynamic) and // converts it into our duck types. -func FromUnstructured(obj Marshalable, target interface{}) error { +func FromUnstructured(obj json.Marshaler, target interface{}) error { // Use the unstructured marshaller to ensure it's proper JSON raw, err := obj.MarshalJSON() if err != nil { diff --git a/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go index 7d804ea885..e5955aeb69 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/addressable_types.go @@ -27,9 +27,11 @@ import ( "knative.dev/pkg/apis/duck" ) +// +genduck + // Addressable provides a generic mechanism for a custom resource // definition to indicate a destination for message delivery. - +// // Addressable is the schema for the destination information. This is // typically stored in the object's `status`, as this information may // be generated by the controller. @@ -44,7 +46,6 @@ var ( _ apis.Convertible = (*Addressable)(nil) ) -// +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // AddressableType is a skeleton type wrapping Addressable in the manner we expect diff --git a/vendor/knative.dev/pkg/apis/duck/v1/destination.go b/vendor/knative.dev/pkg/apis/duck/v1/destination.go new file mode 100644 index 0000000000..136e757aea --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1/destination.go @@ -0,0 +1,93 @@ +/* +Copyright 2019 The Knative 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 v1 + +import ( + "context" + + corev1 "k8s.io/api/core/v1" + "knative.dev/pkg/apis" +) + +// Destination represents a target of an invocation over HTTP. +type Destination struct { + // Ref points to an Addressable. + // +optional + Ref *corev1.ObjectReference `json:"ref,omitempty"` + + // URI can be an absolute URL(non-empty scheme and non-empty host) pointing to the target or a relative URI. Relative URIs will be resolved using the base URI retrieved from Ref. + // +optional + URI *apis.URL `json:"uri,omitempty"` +} + +func (dest *Destination) Validate(ctx context.Context) *apis.FieldError { + if dest == nil { + return nil + } + return ValidateDestination(*dest).ViaField(apis.CurrentField) +} + +// ValidateDestination validates Destination. +func ValidateDestination(dest Destination) *apis.FieldError { + var ref *corev1.ObjectReference + if dest.Ref != nil { + ref = dest.Ref + } + if ref == nil && dest.URI == nil { + return apis.ErrGeneric("expected at least one, got none", "ref", "uri") + } + + if ref != nil && dest.URI != nil && dest.URI.URL().IsAbs() { + return apis.ErrGeneric("Absolute URI is not allowed when Ref or [apiVersion, kind, name] is present", "[apiVersion, kind, name]", "ref", "uri") + } + // IsAbs() check whether the URL has a non-empty scheme. Besides the non-empty scheme, we also require dest.URI has a non-empty host + if ref == nil && dest.URI != nil && (!dest.URI.URL().IsAbs() || dest.URI.Host == "") { + return apis.ErrInvalidValue("Relative URI is not allowed when Ref and [apiVersion, kind, name] is absent", "uri") + } + if ref != nil && dest.URI == nil { + if dest.Ref != nil { + return validateDestinationRef(*ref).ViaField("ref") + } + } + return nil +} + +// GetRef gets the ObjectReference from this Destination, if one is present. If no ref is present, +// then nil is returned. +func (dest *Destination) GetRef() *corev1.ObjectReference { + if dest == nil { + return nil + } + return dest.Ref +} + +func validateDestinationRef(ref corev1.ObjectReference) *apis.FieldError { + // Check the object. + var errs *apis.FieldError + // Required Fields + if ref.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } + if ref.APIVersion == "" { + errs = errs.Also(apis.ErrMissingField("apiVersion")) + } + if ref.Kind == "" { + errs = errs.Also(apis.ErrMissingField("kind")) + } + + return errs +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1/podspec_types.go b/vendor/knative.dev/pkg/apis/duck/v1/podspec_types.go new file mode 100644 index 0000000000..0dd9ec3386 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1/podspec_types.go @@ -0,0 +1,93 @@ +/* +Copyright 2018 The Knative 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 v1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" +) + +// +genduck + +// PodSpecable is implemented by types containing a PodTemplateSpec +// in the manner of ReplicaSet, Deployment, DaemonSet, StatefulSet. +type PodSpecable corev1.PodTemplateSpec + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// WithPod is the shell that demonstrates how PodSpecable types wrap +// a PodSpec. +type WithPod struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec WithPodSpec `json:"spec,omitempty"` +} + +// WithPodSpec is the shell around the PodSpecable within WithPod. +type WithPodSpec struct { + Template PodSpecable `json:"template,omitempty"` +} + +// Assert that we implement the interfaces necessary to +// use duck.VerifyType. +var ( + _ duck.Populatable = (*WithPod)(nil) + _ duck.Implementable = (*PodSpecable)(nil) + _ apis.Listable = (*WithPod)(nil) +) + +// GetFullType implements duck.Implementable +func (*PodSpecable) GetFullType() duck.Populatable { + return &WithPod{} +} + +// Populate implements duck.Populatable +func (t *WithPod) Populate() { + t.Spec.Template = PodSpecable{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "foo": "bar", + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "container-name", + Image: "container-image:latest", + }}, + }, + } +} + +// GetListType implements apis.Listable +func (*WithPod) GetListType() runtime.Object { + return &WithPodList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// WithPodList is a list of WithPod resources +type WithPodList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []WithPod `json:"items"` +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1/register.go b/vendor/knative.dev/pkg/apis/duck/v1/register.go index 43f5e89ad2..e3af46d6f8 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/register.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/register.go @@ -49,6 +49,10 @@ func addKnownTypes(scheme *runtime.Scheme) error { (&KResource{}).GetListType(), &AddressableType{}, (&AddressableType{}).GetListType(), + &Source{}, + (&Source{}).GetListType(), + &WithPod{}, + (&WithPod{}).GetListType(), ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/vendor/knative.dev/pkg/apis/duck/v1/source_types.go b/vendor/knative.dev/pkg/apis/duck/v1/source_types.go index da217c59c7..321156d731 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/source_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/source_types.go @@ -25,13 +25,12 @@ import ( "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" ) // Source is an Implementable "duck type". var _ duck.Implementable = (*Source)(nil) -// +genclient +// +genduck // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Source is the minimum resource shape to adhere to the Source Specification. @@ -51,7 +50,7 @@ type Source struct { type SourceSpec struct { // Sink is a reference to an object that will resolve to a domain name or a // URI directly to use as the sink. - Sink apisv1alpha1.Destination `json:"sink,omitempty"` + Sink Destination `json:"sink,omitempty"` // CloudEventOverrides defines overrides to control the output format and // modifications of the event sent to the sink. @@ -117,7 +116,7 @@ func (*Source) GetFullType() duck.Populatable { // Populate implements duck.Populatable func (s *Source) Populate() { - s.Spec.Sink = apisv1alpha1.Destination{ + s.Spec.Sink = Destination{ URI: &apis.URL{ Scheme: "https", Host: "tableflip.dev", diff --git a/vendor/knative.dev/pkg/apis/duck/v1/status_types.go b/vendor/knative.dev/pkg/apis/duck/v1/status_types.go index 68a6b47693..c2cb989a19 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/status_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/status_types.go @@ -28,15 +28,15 @@ import ( "knative.dev/pkg/apis/duck" ) +// +genduck + // Conditions is a simple wrapper around apis.Conditions to implement duck.Implementable. type Conditions apis.Conditions // Conditions is an Implementable "duck type". var _ duck.Implementable = (*Conditions)(nil) -// +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:openapi-gen=true // KResource is a skeleton type wrapping Conditions in the manner we expect // resource writers defining compatible resources to embed it. We will diff --git a/vendor/knative.dev/pkg/apis/duck/v1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/duck/v1/zz_generated.deepcopy.go index 6be6207a3a..8ef1baca25 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v1 import ( + corev1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" apis "knative.dev/pkg/apis" ) @@ -172,6 +173,32 @@ func (in Conditions) DeepCopy() Conditions { return *out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Destination) DeepCopyInto(out *Destination) { + *out = *in + if in.Ref != nil { + in, out := &in.Ref, &out.Ref + *out = new(corev1.ObjectReference) + **out = **in + } + if in.URI != nil { + in, out := &in.URI, &out.URI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Destination. +func (in *Destination) DeepCopy() *Destination { + if in == nil { + return nil + } + out := new(Destination) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KResource) DeepCopyInto(out *KResource) { *out = *in @@ -232,6 +259,24 @@ func (in *KResourceList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodSpecable) DeepCopyInto(out *PodSpecable) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodSpecable. +func (in *PodSpecable) DeepCopy() *PodSpecable { + if in == nil { + return nil + } + out := new(PodSpecable) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Source) DeepCopyInto(out *Source) { *out = *in @@ -359,3 +404,80 @@ func (in *Status) DeepCopy() *Status { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WithPod) DeepCopyInto(out *WithPod) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WithPod. +func (in *WithPod) DeepCopy() *WithPod { + if in == nil { + return nil + } + out := new(WithPod) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WithPod) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WithPodList) DeepCopyInto(out *WithPodList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]WithPod, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WithPodList. +func (in *WithPodList) DeepCopy() *WithPodList { + if in == nil { + return nil + } + out := new(WithPodList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *WithPodList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WithPodSpec) DeepCopyInto(out *WithPodSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WithPodSpec. +func (in *WithPodSpec) DeepCopy() *WithPodSpec { + if in == nil { + return nil + } + out := new(WithPodSpec) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go index e0b3300111..05a8d91ae7 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/addressable_types.go @@ -29,9 +29,11 @@ import ( "knative.dev/pkg/apis/duck/v1beta1" ) +// +genduck + // Addressable provides a generic mechanism for a custom resource // definition to indicate a destination for message delivery. - +// // Addressable is the schema for the destination information. This is // typically stored in the object's `status`, as this information may // be generated by the controller. @@ -48,7 +50,6 @@ var ( _ apis.Convertible = (*Addressable)(nil) ) -// +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // AddressableType is a skeleton type wrapping Addressable in the manner we expect diff --git a/vendor/knative.dev/pkg/apis/duck/v1alpha1/binding_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/binding_types.go new file mode 100644 index 0000000000..168439686c --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/binding_types.go @@ -0,0 +1,92 @@ +/* +Copyright 2019 The Knative 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 ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" + "knative.dev/pkg/tracker" +) + +// +genduck +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Binding is a duck type that specifies the partial schema to which all +// Binding implementations should adhere. +type Binding struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec BindingSpec `json:"spec"` +} + +// Verify that Binding implements the appropriate interfaces. +var ( + _ duck.Implementable = (*Binding)(nil) + _ duck.Populatable = (*Binding)(nil) + _ apis.Listable = (*Binding)(nil) +) + +// BindingSpec specifies the spec portion of the Binding partial-schema. +type BindingSpec struct { + // Subject references the resource(s) whose "runtime contract" should be + // augmented by Binding implementations. + Subject tracker.Reference `json:"subject"` +} + +// GetFullType implements duck.Implementable +func (*Binding) GetFullType() duck.Populatable { + return &Binding{} +} + +// Populate implements duck.Populatable +func (t *Binding) Populate() { + t.Spec = BindingSpec{ + Subject: tracker.Reference{ + APIVersion: "apps/v1", + Kind: "Deployment", + Namespace: "default", + // Name and Selector are mutually exclusive, + // but we fill them both in for this test. + Name: "bazinga", + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "foo": "bar", + "baz": "blah", + }, + }, + }, + } +} + +// GetListType implements apis.Listable +func (*Binding) GetListType() runtime.Object { + return &BindingList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// BindingList is a list of Binding resources +type BindingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Binding `json:"items"` +} diff --git a/vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go index 043ad5e8a6..5093898c93 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/conditions_types.go @@ -27,6 +27,8 @@ import ( "knative.dev/pkg/apis/duck" ) +// +genduck + // Conditions is the schema for the conditions portion of the payload type Conditions []Condition @@ -118,7 +120,6 @@ func (c *Condition) IsUnknown() bool { // Conditions is an Implementable "duck type". var _ duck.Implementable = (*Conditions)(nil) -// +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // KResource is a skeleton type wrapping Conditions in the manner we expect diff --git a/vendor/knative.dev/pkg/apis/duck/v1alpha1/legacy_targetable_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/legacy_targetable_types.go index 27e7c3daaa..c8a32a7350 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1alpha1/legacy_targetable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/legacy_targetable_types.go @@ -24,6 +24,8 @@ import ( "knative.dev/pkg/apis/duck" ) +// +genduck + // LegacyTargetable left around until we migrate to Addressable in the // dependent resources. Addressable has more structure in the way it // defines the fields. LegacyTargetable only assumed a single string @@ -32,7 +34,7 @@ import ( // This is to support existing resources until they migrate. // // Do not use this for anything new, use Addressable - +// // LegacyTargetable is the old schema for the addressable portion // of the payload // @@ -44,7 +46,6 @@ type LegacyTargetable struct { // LegacyTargetable is an Implementable "duck type". var _ duck.Implementable = (*LegacyTargetable)(nil) -// +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // LegacyTarget is a skeleton type wrapping LegacyTargetable in the manner we diff --git a/vendor/knative.dev/pkg/apis/duck/v1alpha1/retired_targetable_types.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/retired_targetable_types.go index 9306336d27..d8afb324a4 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1alpha1/retired_targetable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/retired_targetable_types.go @@ -24,6 +24,8 @@ import ( "knative.dev/pkg/apis/duck" ) +// +genduck + // Targetable is an earlier version of the Callable interface. // Callable is a higher-level interface which implements Addressable // but further promises that the destination may synchronously return @@ -31,7 +33,7 @@ import ( // // Targetable implementations should instead implement Addressable and // include an `eventing.knative.dev/returns=any` annotation. - +// // Targetable is retired; implement Addressable for now. type Targetable struct { DomainInternal string `json:"domainInternal,omitempty"` @@ -40,7 +42,6 @@ type Targetable struct { // Targetable is an Implementable "duck type". var _ duck.Implementable = (*Targetable)(nil) -// +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Target is a skeleton type wrapping Targetable in the manner we expect diff --git a/vendor/knative.dev/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go index bdae1b58cf..b72de9d262 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go @@ -122,6 +122,83 @@ func (in *AddressableTypeList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Binding) DeepCopyInto(out *Binding) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Binding. +func (in *Binding) DeepCopy() *Binding { + if in == nil { + return nil + } + out := new(Binding) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Binding) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BindingList) DeepCopyInto(out *BindingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Binding, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingList. +func (in *BindingList) DeepCopy() *BindingList { + if in == nil { + return nil + } + out := new(BindingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BindingList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BindingSpec) DeepCopyInto(out *BindingSpec) { + *out = *in + in.Subject.DeepCopyInto(&out.Subject) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BindingSpec. +func (in *BindingSpec) DeepCopy() *BindingSpec { + if in == nil { + return nil + } + out := new(BindingSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Condition) DeepCopyInto(out *Condition) { *out = *in diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go index 2aa9de0d2e..6093bd0338 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/addressable_types.go @@ -28,9 +28,11 @@ import ( v1 "knative.dev/pkg/apis/duck/v1" ) +// +genduck + // Addressable provides a generic mechanism for a custom resource // definition to indicate a destination for message delivery. - +// // Addressable is the schema for the destination information. This is // typically stored in the object's `status`, as this information may // be generated by the controller. @@ -45,7 +47,6 @@ var ( _ apis.Convertible = (*Addressable)(nil) ) -// +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // AddressableType is a skeleton type wrapping Addressable in the manner we expect diff --git a/vendor/knative.dev/pkg/apis/v1alpha1/destination.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go similarity index 99% rename from vendor/knative.dev/pkg/apis/v1alpha1/destination.go rename to vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go index 85c4eebfbe..9c247b0305 100644 --- a/vendor/knative.dev/pkg/apis/v1alpha1/destination.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/destination.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1beta1 import ( "context" diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go index 9358e35318..5853a1ae41 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/source_types.go @@ -25,13 +25,12 @@ import ( "knative.dev/pkg/apis" "knative.dev/pkg/apis/duck" - apisv1alpha1 "knative.dev/pkg/apis/v1alpha1" ) // Source is an Implementable "duck type". var _ duck.Implementable = (*Source)(nil) -// +genclient +// +genduck // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Source is the minimum resource shape to adhere to the Source Specification. @@ -51,7 +50,7 @@ type Source struct { type SourceSpec struct { // Sink is a reference to an object that will resolve to a domain name or a // URI directly to use as the sink. - Sink apisv1alpha1.Destination `json:"sink,omitempty"` + Sink Destination `json:"sink,omitempty"` // CloudEventOverrides defines overrides to control the output format and // modifications of the event sent to the sink. @@ -117,7 +116,7 @@ func (*Source) GetFullType() duck.Populatable { // Populate implements duck.Populatable func (s *Source) Populate() { - s.Spec.Sink = apisv1alpha1.Destination{ + s.Spec.Sink = Destination{ URI: &apis.URL{ Scheme: "https", Host: "tableflip.dev", diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go index ef6804deae..b2095fb584 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/status_types.go @@ -28,15 +28,15 @@ import ( "knative.dev/pkg/apis/duck" ) +// +genduck + // Conditions is a simple wrapper around apis.Conditions to implement duck.Implementable. type Conditions apis.Conditions // Conditions is an Implementable "duck type". var _ duck.Implementable = (*Conditions)(nil) -// +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:openapi-gen=true // KResource is a skeleton type wrapping Conditions in the manner we expect // resource writers defining compatible resources to embed it. We will diff --git a/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go index 79e359d884..eb64a47674 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/pkg/apis/duck/v1beta1/zz_generated.deepcopy.go @@ -21,6 +21,7 @@ limitations under the License. package v1beta1 import ( + v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" apis "knative.dev/pkg/apis" ) @@ -172,6 +173,32 @@ func (in Conditions) DeepCopy() Conditions { return *out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Destination) DeepCopyInto(out *Destination) { + *out = *in + if in.Ref != nil { + in, out := &in.Ref, &out.Ref + *out = new(v1.ObjectReference) + **out = **in + } + if in.URI != nil { + in, out := &in.URI, &out.URI + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Destination. +func (in *Destination) DeepCopy() *Destination { + if in == nil { + return nil + } + out := new(Destination) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KResource) DeepCopyInto(out *KResource) { *out = *in diff --git a/vendor/knative.dev/pkg/apis/duck/verify.go b/vendor/knative.dev/pkg/apis/duck/verify.go index 236a392c7e..3f42330fff 100644 --- a/vendor/knative.dev/pkg/apis/duck/verify.go +++ b/vendor/knative.dev/pkg/apis/duck/verify.go @@ -20,6 +20,7 @@ import ( "encoding/json" "fmt" + "knative.dev/pkg/apis" "knative.dev/pkg/kmp" ) @@ -36,6 +37,8 @@ type Implementable interface { // duck type. It will generally have TypeMeta, ObjectMeta, and a Status field // wrapping a Fooable field. type Populatable interface { + apis.Listable + // Populate fills in all possible fields, so that we can verify that // they roundtrip properly through JSON. Populate() diff --git a/vendor/knative.dev/pkg/apis/interfaces.go b/vendor/knative.dev/pkg/apis/interfaces.go index 6b6c772d74..fef69d8b31 100644 --- a/vendor/knative.dev/pkg/apis/interfaces.go +++ b/vendor/knative.dev/pkg/apis/interfaces.go @@ -44,15 +44,6 @@ type Convertible interface { ConvertDown(ctx context.Context, from Convertible) error } -// Immutable indicates that a particular type has fields that should -// not change after creation. -// DEPRECATED: Use WithinUpdate / GetBaseline from within Validatable instead. -type Immutable interface { - // CheckImmutableFields checks that the current instance's immutable - // fields haven't changed from the provided original. - CheckImmutableFields(ctx context.Context, original Immutable) *FieldError -} - // Listable indicates that a particular type can be returned via the returned // list type by the API server. type Listable interface { diff --git a/vendor/knative.dev/pkg/apis/url.go b/vendor/knative.dev/pkg/apis/url.go index b059907568..55c9260d54 100644 --- a/vendor/knative.dev/pkg/apis/url.go +++ b/vendor/knative.dev/pkg/apis/url.go @@ -109,3 +109,20 @@ func (u *URL) URL() *url.URL { url := url.URL(*u) return &url } + +// ResolveReference calls the underlying ResolveReference method +// and returns an apis.URL +func (u *URL) ResolveReference(ref *URL) *URL { + if ref == nil { + return u + } + // Turn both u / ref to url.URL + uRef := url.URL(*ref) + uu := url.URL(*u) + + newU := uu.ResolveReference(&uRef) + + // Turn new back to apis.URL + ret := URL(*newU) + return &ret +} diff --git a/vendor/knative.dev/pkg/apis/volatile_time.go b/vendor/knative.dev/pkg/apis/volatile_time.go index 48d790d92e..3d2daa2772 100644 --- a/vendor/knative.dev/pkg/apis/volatile_time.go +++ b/vendor/knative.dev/pkg/apis/volatile_time.go @@ -22,7 +22,6 @@ import ( ) // VolatileTime wraps metav1.Time -// +k8s:openapi-gen=true type VolatileTime struct { Inner metav1.Time } diff --git a/vendor/knative.dev/pkg/controller/controller.go b/vendor/knative.dev/pkg/controller/controller.go index 38fafda80f..d385908c76 100644 --- a/vendor/knative.dev/pkg/controller/controller.go +++ b/vendor/knative.dev/pkg/controller/controller.go @@ -98,6 +98,17 @@ func Filter(gvk schema.GroupVersionKind) func(obj interface{}) bool { } } +// FilterWithName makes it simple to create FilterFunc's for use with +// cache.FilteringResourceEventHandler that filter based on a name. +func FilterWithName(name string) func(obj interface{}) bool { + return func(obj interface{}) bool { + if object, ok := obj.(metav1.Object); ok { + return name == object.GetName() + } + return false + } +} + // FilterWithNameAndNamespace makes it simple to create FilterFunc's for use with // cache.FilteringResourceEventHandler that filter based on a namespace and a name. func FilterWithNameAndNamespace(namespace, name string) func(obj interface{}) bool { @@ -175,6 +186,14 @@ func (c *Impl) Enqueue(obj interface{}) { c.EnqueueKey(types.NamespacedName{Namespace: object.GetNamespace(), Name: object.GetName()}) } +// EnqueueSentinel returns a Enqueue method which will always enqueue a +// predefined key instead of the object key. +func (c *Impl) EnqueueSentinel(k types.NamespacedName) func(interface{}) { + return func(interface{}) { + c.EnqueueKey(k) + } +} + // EnqueueControllerOf takes a resource, identifies its controller resource, // converts it into a namespace/name string, and passes that to EnqueueKey. func (c *Impl) EnqueueControllerOf(obj interface{}) { diff --git a/vendor/knative.dev/pkg/controller/stats_reporter.go b/vendor/knative.dev/pkg/controller/stats_reporter.go index b829c9f2ef..de0a938d44 100644 --- a/vendor/knative.dev/pkg/controller/stats_reporter.go +++ b/vendor/knative.dev/pkg/controller/stats_reporter.go @@ -174,15 +174,9 @@ func init() { Aggregation: reconcileDistribution, TagKeys: []tag.Key{reconcilerTagKey, keyTagKey, successTagKey}, }} - for _, view := range wp.DefaultViews() { - views = append(views, view) - } - for _, view := range rp.DefaultViews() { - views = append(views, view) - } - for _, view := range cp.DefaultViews() { - views = append(views, view) - } + views = append(views, wp.DefaultViews()...) + views = append(views, rp.DefaultViews()...) + views = append(views, cp.DefaultViews()...) // Create views to see our measurements. This can return an error if // a previously-registered view has the same name with a different value. diff --git a/vendor/knative.dev/pkg/logging/config.go b/vendor/knative.dev/pkg/logging/config.go index 2317c92711..6f59bdec24 100644 --- a/vendor/knative.dev/pkg/logging/config.go +++ b/vendor/knative.dev/pkg/logging/config.go @@ -38,7 +38,7 @@ const ( fallbackLoggerName = "fallback-logger" ) -var emptyLoggerConfigError = errors.New("empty logger configuration") +var errEmptyLoggerConfig = errors.New("empty logger configuration") // NewLogger creates a logger with the supplied configuration. // In addition to the logger, it returns AtomicLevel that can @@ -105,14 +105,14 @@ func newLoggerFromConfig(configJSON string, levelOverride string, opts []zap.Opt return nil, zap.AtomicLevel{}, err } - logger.Info("Successfully created the logger.", zap.String(logkey.JSONConfig, configJSON)) + logger.Info("Successfully created the logger.") logger.Sugar().Infof("Logging level set to %v", loggingCfg.Level) return logger, loggingCfg.Level, nil } func zapConfigFromJSON(configJSON string) (*zap.Config, error) { if configJSON == "" { - return nil, emptyLoggerConfigError + return nil, errEmptyLoggerConfig } loggingCfg := &zap.Config{} @@ -206,7 +206,7 @@ func UpdateLevelFromConfigMap(logger *zap.SugaredLogger, atomicLevel zap.AtomicL // reset to global level loggingCfg, err := zapConfigFromJSON(config.LoggingConfig) switch { - case err == emptyLoggerConfigError: + case err == errEmptyLoggerConfig: level = zap.NewAtomicLevel().Level() case err != nil: logger.With(zap.Error(err)).Errorf("Failed to parse logger configuration. "+ diff --git a/vendor/knative.dev/pkg/metrics/config.go b/vendor/knative.dev/pkg/metrics/config.go index af7e3e7299..05aeb2335c 100644 --- a/vendor/knative.dev/pkg/metrics/config.go +++ b/vendor/knative.dev/pkg/metrics/config.go @@ -17,6 +17,7 @@ limitations under the License. package metrics import ( + "context" "encoding/json" "errors" "fmt" @@ -26,12 +27,13 @@ import ( "strings" "time" + "go.opencensus.io/stats" "go.uber.org/zap" + "knative.dev/pkg/metrics/metricskey" ) const ( - DomainEnv = "METRICS_DOMAIN" - ConfigMapNameEnv = "CONFIG_OBSERVABILITY_NAME" + DomainEnv = "METRICS_DOMAIN" ) // metricsBackend specifies the backend to use for metrics @@ -46,11 +48,10 @@ const ( ReportingPeriodKey = "metrics.reporting-period-seconds" StackdriverCustomMetricSubDomainKey = "metrics.stackdriver-custom-metrics-subdomain" // Stackdriver client configuration keys - stackdriverProjectIDKey = "metrics.stackdriver-project-id" - stackdriverGCPLocationKey = "metrics.stackdriver-gcp-location" - stackdriverClusterNameKey = "metrics.stackdriver-cluster-name" - stackdriverGCPSecretNameKey = "metrics.stackdriver-gcp-secret-name" - stackdriverGCPSecretNamespaceKey = "metrics.stackdriver-gcp-secret-namespace" + StackdriverProjectIDKey = "metrics.stackdriver-project-id" + StackdriverGCPLocationKey = "metrics.stackdriver-gcp-location" + StackdriverClusterNameKey = "metrics.stackdriver-cluster-name" + StackdriverUseSecretKey = "metrics.stackdriver-use-secret" // Stackdriver is used for Stackdriver backend Stackdriver metricsBackend = "stackdriver" @@ -75,22 +76,16 @@ type metricsConfig struct { // If duration is less than or equal to zero, it enables the default behavior. reportingPeriod time.Duration + // recorder provides a hook for performing custom transformations before + // writing the metrics to the stats.RecordWithOptions interface. + recorder func(context.Context, stats.Measurement, ...stats.Options) error + // ---- Prometheus specific below ---- // prometheusPort is the port where metrics are exposed in Prometheus // format. It defaults to 9090. prometheusPort int // ---- Stackdriver specific below ---- - // allowStackdriverCustomMetrics indicates whether it is allowed to send metrics to - // Stackdriver using "global" resource type and custom metric type if the - // metrics are not supported by the registered monitored resource types. Setting this - // flag to "true" could cause extra Stackdriver charge. - // If backendDestination is not Stackdriver, this is ignored. - allowStackdriverCustomMetrics bool - // stackdriverCustomMetricsSubDomain is the subdomain to use when sending custom metrics to StackDriver. - // If not specified, the default is `knative.dev`. - // If backendDestination is not Stackdriver, this is ignored. - stackdriverCustomMetricsSubDomain string // True if backendDestination equals to "stackdriver". Store this in a variable // to reduce string comparison operations. isStackdriverBackend bool @@ -103,11 +98,11 @@ type metricsConfig struct { // Store this in a variable to reduce string join operations. stackdriverCustomMetricTypePrefix string // stackdriverClientConfig is the metadata to configure the metrics exporter's Stackdriver client. - stackdriverClientConfig stackdriverClientConfig + stackdriverClientConfig StackdriverClientConfig } -// stackdriverClientConfig encapsulates the metadata required to configure a Stackdriver client. -type stackdriverClientConfig struct { +// StackdriverClientConfig encapsulates the metadata required to configure a Stackdriver client. +type StackdriverClientConfig struct { // ProjectID is the stackdriver project ID to which data is uploaded. // This is not necessarily the GCP project ID where the Kubernetes cluster is hosted. // Required when the Kubernetes cluster is not hosted on GCE. @@ -119,27 +114,33 @@ type stackdriverClientConfig struct { // ClusterName is the cluster name with which the data will be associated in Stackdriver. // Required when the Kubernetes cluster is not hosted on GCE. ClusterName string - // GCPSecretName is the optional GCP service account key which will be used to - // authenticate with Stackdriver. If not provided, Google Application Default Credentials + // UseSecret is whether the credentials stored in a Kubernetes Secret should be used to + // authenticate with Stackdriver. The Secret name and namespace can be specified by calling + // metrics.SetStackdriverSecretLocation. + // If UseSecret is false, Google Application Default Credentials // will be used (https://cloud.google.com/docs/authentication/production). - GCPSecretName string - // GCPSecretNamespace is the Kubernetes namespace where GCPSecretName is located. - // The Kubernetes ServiceAccount used by the pod that is exporting data to - // Stackdriver should have access to Secrets in this namespace. - GCPSecretNamespace string + UseSecret bool } -// newStackdriverClientConfigFromMap creates a stackdriverClientConfig from the given map -func newStackdriverClientConfigFromMap(config map[string]string) *stackdriverClientConfig { - return &stackdriverClientConfig{ - ProjectID: config[stackdriverProjectIDKey], - GCPLocation: config[stackdriverGCPLocationKey], - ClusterName: config[stackdriverClusterNameKey], - GCPSecretName: config[stackdriverGCPSecretNameKey], - GCPSecretNamespace: config[stackdriverGCPSecretNamespaceKey], +// NewStackdriverClientConfigFromMap creates a stackdriverClientConfig from the given map +func NewStackdriverClientConfigFromMap(config map[string]string) *StackdriverClientConfig { + return &StackdriverClientConfig{ + ProjectID: config[StackdriverProjectIDKey], + GCPLocation: config[StackdriverGCPLocationKey], + ClusterName: config[StackdriverClusterNameKey], + UseSecret: strings.EqualFold(config[StackdriverUseSecretKey], "true"), } } +// Record applies the `ros` Options to `ms` and then records the resulting +// measurements in the metricsConfig's designated backend. +func (mc *metricsConfig) Record(ctx context.Context, ms stats.Measurement, ros ...stats.Options) error { + if mc == nil || mc.recorder == nil { + return stats.RecordWithOptions(ctx, append(ros, stats.WithMeasurements(ms))...) + } + return mc.recorder(ctx, ms, ros...) +} + func createMetricsConfig(ops ExporterOptions, logger *zap.SugaredLogger) (*metricsConfig, error) { var mc metricsConfig @@ -190,22 +191,37 @@ func createMetricsConfig(ops ExporterOptions, logger *zap.SugaredLogger) (*metri // use the application default credentials. If that is not available, Opencensus would fail to create the // metrics exporter. if mc.backendDestination == Stackdriver { - scc := newStackdriverClientConfigFromMap(m) + scc := NewStackdriverClientConfigFromMap(m) mc.stackdriverClientConfig = *scc mc.isStackdriverBackend = true + var allowCustomMetrics bool + var err error mc.stackdriverMetricTypePrefix = path.Join(mc.domain, mc.component) - mc.stackdriverCustomMetricsSubDomain = defaultCustomMetricSubDomain - if sdcmd, ok := m[StackdriverCustomMetricSubDomainKey]; ok && sdcmd != "" { - mc.stackdriverCustomMetricsSubDomain = sdcmd + customMetricsSubDomain := m[StackdriverCustomMetricSubDomainKey] + if customMetricsSubDomain == "" { + customMetricsSubDomain = defaultCustomMetricSubDomain } - mc.stackdriverCustomMetricTypePrefix = path.Join(customMetricTypePrefix, mc.stackdriverCustomMetricsSubDomain, mc.component) - if ascmStr, ok := m[AllowStackdriverCustomMetricsKey]; ok && ascmStr != "" { - ascmBool, err := strconv.ParseBool(ascmStr) + mc.stackdriverCustomMetricTypePrefix = path.Join(customMetricTypePrefix, customMetricsSubDomain, mc.component) + if ascmStr := m[AllowStackdriverCustomMetricsKey]; ascmStr != "" { + allowCustomMetrics, err = strconv.ParseBool(ascmStr) if err != nil { return nil, fmt.Errorf("invalid %s value %q", AllowStackdriverCustomMetricsKey, ascmStr) } - mc.allowStackdriverCustomMetrics = ascmBool + } + + if !allowCustomMetrics { + servingOrEventing := metricskey.KnativeRevisionMetrics.Union( + metricskey.KnativeTriggerMetrics) + mc.recorder = func(ctx context.Context, ms stats.Measurement, ros ...stats.Options) error { + metricType := path.Join(mc.stackdriverMetricTypePrefix, ms.Measure().Name()) + + if servingOrEventing.Has(metricType) { + return stats.RecordWithOptions(ctx, append(ros, stats.WithMeasurements(ms))...) + } + // Otherwise, skip (because it won't be accepted) + return nil + } } } @@ -231,15 +247,6 @@ func createMetricsConfig(ops ExporterOptions, logger *zap.SugaredLogger) (*metri return &mc, nil } -// ConfigMapName gets the name of the metrics ConfigMap -func ConfigMapName() string { - cm := os.Getenv(ConfigMapNameEnv) - if cm == "" { - return "config-observability" - } - return cm -} - // Domain holds the metrics domain to use for surfacing metrics. func Domain() string { if domain := os.Getenv(DomainEnv); domain != "" { diff --git a/vendor/knative.dev/pkg/metrics/config_observability.go b/vendor/knative.dev/pkg/metrics/config_observability.go new file mode 100644 index 0000000000..496443e91f --- /dev/null +++ b/vendor/knative.dev/pkg/metrics/config_observability.go @@ -0,0 +1,103 @@ +/* +Copyright 2019 The Knative 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 metrics + +import ( + "os" + "strings" + texttemplate "text/template" + + corev1 "k8s.io/api/core/v1" +) + +const ( + // The following is used to set the default log url template + DefaultLogURLTemplate = "http://localhost:8001/api/v1/namespaces/knative-monitoring/services/kibana-logging/proxy/app/kibana#/discover?_a=(query:(match:(kubernetes.labels.knative-dev%2FrevisionUID:(query:'${REVISION_UID}',type:phrase))))" + // The env var name for config-observability + ConfigMapNameEnv = "CONFIG_OBSERVABILITY_NAME" +) + +// ObservabilityConfig contains the configuration defined in the observability ConfigMap. +// +k8s:deepcopy-gen=true +type ObservabilityConfig struct { + // EnableVarLogCollection specifies whether the logs under /var/log/ should be available + // for collection on the host node by the fluentd daemon set. + EnableVarLogCollection bool + + // LoggingURLTemplate is a string containing the logging url template where + // the variable REVISION_UID will be replaced with the created revision's UID. + LoggingURLTemplate string + + // RequestLogTemplate is the go template to use to shape the request logs. + RequestLogTemplate string + + // EnableProbeRequestLog enables queue-proxy to write health check probe request logs. + EnableProbeRequestLog bool + + // RequestMetricsBackend specifies the request metrics destination, e.g. Prometheus, + // Stackdriver. + RequestMetricsBackend string + + // EnableProfiling indicates whether it is allowed to retrieve runtime profiling data from + // the pods via an HTTP server in the format expected by the pprof visualization tool. + EnableProfiling bool +} + +// NewObservabilityConfigFromConfigMap creates a ObservabilityConfig from the supplied ConfigMap +func NewObservabilityConfigFromConfigMap(configMap *corev1.ConfigMap) (*ObservabilityConfig, error) { + oc := &ObservabilityConfig{} + if evlc, ok := configMap.Data["logging.enable-var-log-collection"]; ok { + oc.EnableVarLogCollection = strings.EqualFold(evlc, "true") + } + + if rut, ok := configMap.Data["logging.revision-url-template"]; ok { + oc.LoggingURLTemplate = rut + } else { + oc.LoggingURLTemplate = DefaultLogURLTemplate + } + + if rlt, ok := configMap.Data["logging.request-log-template"]; ok { + // Verify that we get valid templates. + if _, err := texttemplate.New("requestLog").Parse(rlt); err != nil { + return nil, err + } + oc.RequestLogTemplate = rlt + } + + if eprl, ok := configMap.Data["logging.enable-probe-request-log"]; ok { + oc.EnableProbeRequestLog = strings.EqualFold(eprl, "true") + } + + if mb, ok := configMap.Data["metrics.request-metrics-backend-destination"]; ok { + oc.RequestMetricsBackend = mb + } + + if prof, ok := configMap.Data["profiling.enable"]; ok { + oc.EnableProfiling = strings.EqualFold(prof, "true") + } + + return oc, nil +} + +// ConfigMapName gets the name of the metrics ConfigMap +func ConfigMapName() string { + cm := os.Getenv(ConfigMapNameEnv) + if cm == "" { + return "config-observability" + } + return cm +} diff --git a/vendor/knative.dev/pkg/metrics/exporter.go b/vendor/knative.dev/pkg/metrics/exporter.go index ddbb6b7d14..1a697c15c3 100644 --- a/vendor/knative.dev/pkg/metrics/exporter.go +++ b/vendor/knative.dev/pkg/metrics/exporter.go @@ -33,6 +33,11 @@ type flushable interface { Flush() } +type stoppable interface { + // StopMetricsExporter stops the exporter + StopMetricsExporter() +} + // ExporterOptions contains options for configuring the exporter. type ExporterOptions struct { // Domain is the metrics domain. e.g. "knative.dev". Must be present. @@ -126,11 +131,12 @@ func newMetricsExporter(config *metricsConfig, logger *zap.SugaredLogger) (view. // If there is a Prometheus Exporter server running, stop it. resetCurPromSrv() - if ce != nil { - // UnregisterExporter is idempotent and it can be called multiple times for the same exporter - // without side effects. - view.UnregisterExporter(ce) + // TODO(https://github.com/knative/pkg/issues/866): Move Stackdriver and Promethus + // operations before stopping to an interface. + if se, ok := ce.(stoppable); ok { + se.StopMetricsExporter() } + var err error var e view.Exporter switch config.backendDestination { @@ -156,7 +162,6 @@ func getCurMetricsExporter() view.Exporter { func setCurMetricsExporter(e view.Exporter) { metricsMux.Lock() defer metricsMux.Unlock() - view.RegisterExporter(e) curMetricsExporter = e } diff --git a/vendor/knative.dev/pkg/metrics/monitored_resources_eventing.go b/vendor/knative.dev/pkg/metrics/monitored_resources_eventing.go index 87c2b55a96..32742e7732 100644 --- a/vendor/knative.dev/pkg/metrics/monitored_resources_eventing.go +++ b/vendor/knative.dev/pkg/metrics/monitored_resources_eventing.go @@ -20,8 +20,7 @@ package metrics import ( "contrib.go.opencensus.io/exporter/stackdriver/monitoredresource" - "go.opencensus.io/stats/view" - "go.opencensus.io/tag" + "go.opencensus.io/metric/metricdata" "knative.dev/pkg/metrics/metricskey" ) @@ -89,75 +88,72 @@ func (ki *KnativeSource) MonitoredResource() (resType string, labels map[string] } func GetKnativeBrokerMonitoredResource( - v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface) { - tagsMap := getTagsMap(tags) + des *metricdata.Descriptor, tags map[string]string, gm *gcpMetadata) (map[string]string, monitoredresource.Interface) { kb := &KnativeBroker{ // The first three resource labels are from metadata. Project: gm.project, Location: gm.location, ClusterName: gm.cluster, // The rest resource labels are from metrics labels. - NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tagsMap), - BrokerName: valueOrUnknown(metricskey.LabelBrokerName, tagsMap), + NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tags), + BrokerName: valueOrUnknown(metricskey.LabelBrokerName, tags), } - var newTags []tag.Tag - for _, t := range tags { + metricLabels := map[string]string{} + for k, v := range tags { // Keep the metrics labels that are not resource labels - if !metricskey.KnativeBrokerLabels.Has(t.Key.Name()) { - newTags = append(newTags, t) + if !metricskey.KnativeBrokerLabels.Has(k) { + metricLabels[k] = v } } - return newTags, kb + return metricLabels, kb } func GetKnativeTriggerMonitoredResource( - v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface) { - tagsMap := getTagsMap(tags) + des *metricdata.Descriptor, tags map[string]string, gm *gcpMetadata) (map[string]string, monitoredresource.Interface) { kt := &KnativeTrigger{ // The first three resource labels are from metadata. Project: gm.project, Location: gm.location, ClusterName: gm.cluster, // The rest resource labels are from metrics labels. - NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tagsMap), - BrokerName: valueOrUnknown(metricskey.LabelBrokerName, tagsMap), - TriggerName: valueOrUnknown(metricskey.LabelTriggerName, tagsMap), + NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tags), + BrokerName: valueOrUnknown(metricskey.LabelBrokerName, tags), + TriggerName: valueOrUnknown(metricskey.LabelTriggerName, tags), } - var newTags []tag.Tag - for _, t := range tags { + metricLabels := map[string]string{} + for k, v := range tags { // Keep the metrics labels that are not resource labels - if !metricskey.KnativeTriggerLabels.Has(t.Key.Name()) { - newTags = append(newTags, t) + if !metricskey.KnativeTriggerLabels.Has(k) { + metricLabels[k] = v } } - return newTags, kt + return metricLabels, kt } func GetKnativeSourceMonitoredResource( - v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface) { - tagsMap := getTagsMap(tags) - ki := &KnativeSource{ + des *metricdata.Descriptor, tags map[string]string, gm *gcpMetadata) (map[string]string, monitoredresource.Interface) { + ks := &KnativeSource{ // The first three resource labels are from metadata. Project: gm.project, Location: gm.location, ClusterName: gm.cluster, // The rest resource labels are from metrics labels. - NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tagsMap), - SourceName: valueOrUnknown(metricskey.LabelName, tagsMap), - SourceResourceGroup: valueOrUnknown(metricskey.LabelResourceGroup, tagsMap), + NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tags), + SourceName: valueOrUnknown(metricskey.LabelName, tags), + SourceResourceGroup: valueOrUnknown(metricskey.LabelResourceGroup, tags), } - var newTags []tag.Tag - for _, t := range tags { + metricLabels := map[string]string{} + for k, v := range tags { // Keep the metrics labels that are not resource labels - if !metricskey.KnativeSourceLabels.Has(t.Key.Name()) { - newTags = append(newTags, t) + if !metricskey.KnativeSourceLabels.Has(k) { + metricLabels[k] = v } } - return newTags, ki + return metricLabels, ks } diff --git a/vendor/knative.dev/pkg/metrics/monitored_resources_serving.go b/vendor/knative.dev/pkg/metrics/monitored_resources_serving.go index b2a1d33f5c..eae42408b6 100644 --- a/vendor/knative.dev/pkg/metrics/monitored_resources_serving.go +++ b/vendor/knative.dev/pkg/metrics/monitored_resources_serving.go @@ -18,8 +18,7 @@ package metrics import ( "contrib.go.opencensus.io/exporter/stackdriver/monitoredresource" - "go.opencensus.io/stats/view" - "go.opencensus.io/tag" + "go.opencensus.io/metric/metricdata" "knative.dev/pkg/metrics/metricskey" ) @@ -49,27 +48,26 @@ func (kr *KnativeRevision) MonitoredResource() (resType string, labels map[strin } func GetKnativeRevisionMonitoredResource( - v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface) { - tagsMap := getTagsMap(tags) + des *metricdata.Descriptor, tags map[string]string, gm *gcpMetadata) (map[string]string, monitoredresource.Interface) { kr := &KnativeRevision{ // The first three resource labels are from metadata. Project: gm.project, Location: gm.location, ClusterName: gm.cluster, // The rest resource labels are from metrics labels. - NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tagsMap), - ServiceName: valueOrUnknown(metricskey.LabelServiceName, tagsMap), - ConfigurationName: valueOrUnknown(metricskey.LabelConfigurationName, tagsMap), - RevisionName: valueOrUnknown(metricskey.LabelRevisionName, tagsMap), + NamespaceName: valueOrUnknown(metricskey.LabelNamespaceName, tags), + ServiceName: valueOrUnknown(metricskey.LabelServiceName, tags), + ConfigurationName: valueOrUnknown(metricskey.LabelConfigurationName, tags), + RevisionName: valueOrUnknown(metricskey.LabelRevisionName, tags), } - var newTags []tag.Tag - for _, t := range tags { + metricLabels := map[string]string{} + for k, v := range tags { // Keep the metrics labels that are not resource labels - if !metricskey.KnativeRevisionLabels.Has(t.Key.Name()) { - newTags = append(newTags, t) + if !metricskey.KnativeRevisionLabels.Has(k) { + metricLabels[k] = v } } - return newTags, kr + return metricLabels, kr } diff --git a/vendor/knative.dev/pkg/metrics/record.go b/vendor/knative.dev/pkg/metrics/record.go index a8756837a8..397f9be77c 100644 --- a/vendor/knative.dev/pkg/metrics/record.go +++ b/vendor/knative.dev/pkg/metrics/record.go @@ -18,52 +18,18 @@ package metrics import ( "context" - "path" "go.opencensus.io/stats" - "knative.dev/pkg/metrics/metricskey" ) // TODO should be properly refactored and pieces should move to eventing and serving, as appropriate. // See https://github.com/knative/pkg/issues/608 -// Record decides whether to record one measurement via OpenCensus based on the -// following conditions: -// 1) No package level metrics config. In this case it just proxies to OpenCensus -// based on the assumption that users expect the metrics to be recorded when -// they call this function. Users must ensure metrics config are set before -// using this function to get expected behavior. -// 2) The backend is not Stackdriver. -// 3) The backend is Stackdriver and it is allowed to use custom metrics. -// 4) The backend is Stackdriver and the metric is one of the built-in metrics: "knative_revision", "knative_broker", -// "knative_trigger", "knative_source". +// Record stores the given Measurement from `ms` in the current metrics backend. func Record(ctx context.Context, ms stats.Measurement, ros ...stats.Options) { mc := getCurMetricsConfig() - ros = append(ros, stats.WithMeasurements(ms)) - - // Condition 1) - if mc == nil { - stats.RecordWithOptions(ctx, ros...) - return - } - - // Condition 2) and 3) - if !mc.isStackdriverBackend || mc.allowStackdriverCustomMetrics { - stats.RecordWithOptions(ctx, ros...) - return - } - - // Condition 4) - metricType := path.Join(mc.stackdriverMetricTypePrefix, ms.Measure().Name()) - isServingBuiltIn := metricskey.KnativeRevisionMetrics.Has(metricType) - isEventingBuiltIn := metricskey.KnativeTriggerMetrics.Has(metricType) || - metricskey.KnativeBrokerMetrics.Has(metricType) || - metricskey.KnativeSourceMetrics.Has(metricType) - - if isServingBuiltIn || isEventingBuiltIn { - stats.RecordWithOptions(ctx, ros...) - } + mc.Record(ctx, ms, ros...) } // Buckets125 generates an array of buckets with approximate powers-of-two diff --git a/vendor/knative.dev/pkg/metrics/stackdriver_exporter.go b/vendor/knative.dev/pkg/metrics/stackdriver_exporter.go index bb396ac0c6..90122f6fd4 100644 --- a/vendor/knative.dev/pkg/metrics/stackdriver_exporter.go +++ b/vendor/knative.dev/pkg/metrics/stackdriver_exporter.go @@ -23,8 +23,8 @@ import ( "contrib.go.opencensus.io/exporter/stackdriver" "contrib.go.opencensus.io/exporter/stackdriver/monitoredresource" + "go.opencensus.io/metric/metricdata" "go.opencensus.io/stats/view" - "go.opencensus.io/tag" "go.uber.org/zap" "google.golang.org/api/option" "knative.dev/pkg/metrics/metricskey" @@ -40,47 +40,94 @@ const ( // defaultCustomMetricSubDomain is the default subdomain to use for unsupported metrics by monitored resource types. // See: https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors#MetricDescriptor defaultCustomMetricSubDomain = "knative.dev" - // secretNamespaceDefault is the namespace to search for a k8s Secret to pass to Stackdriver client to authenticate with Stackdriver. - secretNamespaceDefault = "default" + // StackdriverSecretNamespaceDefault is the default namespace to search for a k8s Secret to pass to Stackdriver client to authenticate with Stackdriver. + StackdriverSecretNamespaceDefault = "default" + // StackdriverSecretNameDefault is the default name of the k8s Secret to pass to Stackdriver client to authenticate with Stackdriver. + StackdriverSecretNameDefault = "stackdriver-service-account-key" // secretDataFieldKey is the name of the k8s Secret field that contains the Secret's key. secretDataFieldKey = "key.json" ) var ( + // gcpMetadataFunc is the function used to fetch GCP metadata. + // In product usage, this is always set to function retrieveGCPMetadata. + // In unit tests this is set to a fake one to avoid calling GCP metadata + // service. + gcpMetadataFunc func() *gcpMetadata + + // newStackdriverExporterFunc is the function used to create new stackdriver + // exporter. + // In product usage, this is always set to function newOpencensusSDExporter. + // In unit tests this is set to a fake one to avoid calling actual Google API + // service. + newStackdriverExporterFunc func(stackdriver.Options) (view.Exporter, error) + // kubeclient is the in-cluster Kubernetes kubeclient, which is lazy-initialized on first use. kubeclient *kubernetes.Clientset // initClientOnce is the lazy initializer for kubeclient. initClientOnce sync.Once // kubeclientInitErr capture an error during initClientOnce kubeclientInitErr error + + // stackdriverMtx protects setting secretNamespace and secretName and useStackdriverSecretEnabled + stackdriverMtx sync.RWMutex + // secretName is the name of the k8s Secret to pass to Stackdriver client to authenticate with Stackdriver. + secretName = StackdriverSecretNameDefault + // secretNamespace is the namespace to search for a k8s Secret to pass to Stackdriver client to authenticate with Stackdriver. + secretNamespace = StackdriverSecretNamespaceDefault + // useStackdriverSecretEnabled specifies whether or not the exporter can be configured with a Secret. + // Consuming packages must do explicitly enable this by calling SetStackdriverSecretLocation. + useStackdriverSecretEnabled = false ) +// SetStackdriverSecretLocation sets the name and namespace of the Secret that can be used to authenticate with Stackdriver. +// The Secret is only used if both: +// 1. This function has been explicitly called to set the name and namespace +// 2. Users set metricsConfig.stackdriverClientConfig.UseSecret to "true" +func SetStackdriverSecretLocation(name string, namespace string) { + stackdriverMtx.Lock() + defer stackdriverMtx.Unlock() + secretName = name + secretNamespace = namespace + useStackdriverSecretEnabled = true +} + func init() { + // Set gcpMetadataFunc to call GCP metadata service. + gcpMetadataFunc = retrieveGCPMetadata + newStackdriverExporterFunc = newOpencensusSDExporter + kubeclientInitErr = nil } func newOpencensusSDExporter(o stackdriver.Options) (view.Exporter, error) { - return stackdriver.NewExporter(o) + e, err := stackdriver.NewExporter(o) + if err == nil { + // Start the exporter. + // TODO(https://github.com/knative/pkg/issues/866): Move this to an interface. + e.StartMetricsExporter() + } + return e, nil } -// TODO should be properly refactored to be able to inject the getMonitoredResourceFunc function. +// TODO should be properly refactored to be able to inject the getResourceByDescriptorFunc function. // See https://github.com/knative/pkg/issues/608 func newStackdriverExporter(config *metricsConfig, logger *zap.SugaredLogger) (view.Exporter, error) { gm := getMergedGCPMetadata(config) - mtf := getMetricTypeFunc(config.stackdriverMetricTypePrefix, config.stackdriverCustomMetricTypePrefix) + mpf := getMetricPrefixFunc(config.stackdriverMetricTypePrefix, config.stackdriverCustomMetricTypePrefix) co, err := getStackdriverExporterClientOptions(&config.stackdriverClientConfig) if err != nil { logger.Warnw("Issue configuring Stackdriver exporter client options, no additional client options will be used: ", zap.Error(err)) } // Automatically fall back on Google application default credentials - e, err := newOpencensusSDExporter(stackdriver.Options{ + e, err := newStackdriverExporterFunc(stackdriver.Options{ ProjectID: gm.project, Location: gm.location, MonitoringClientOptions: co, TraceClientOptions: co, - GetMetricDisplayName: mtf, // Use metric type for display name for custom metrics. No impact on built-in metrics. - GetMetricType: mtf, - GetMonitoredResource: getMonitoredResourceFunc(config.stackdriverMetricTypePrefix, gm), + GetMetricPrefix: mpf, + ResourceByDescriptor: getResourceByDescriptorFunc(config.stackdriverMetricTypePrefix, gm), + ReportingInterval: config.reportingPeriod, DefaultMonitoringLabels: &stackdriver.Labels{}, }) if err != nil { @@ -93,15 +140,19 @@ func newStackdriverExporter(config *metricsConfig, logger *zap.SugaredLogger) (v // getStackdriverExporterClientOptions creates client options for the opencensus Stackdriver exporter from the given stackdriverClientConfig. // On error, an empty array of client options is returned. -func getStackdriverExporterClientOptions(sdconfig *stackdriverClientConfig) ([]option.ClientOption, error) { +func getStackdriverExporterClientOptions(sdconfig *StackdriverClientConfig) ([]option.ClientOption, error) { var co []option.ClientOption - if sdconfig.GCPSecretName != "" { + if sdconfig.UseSecret && useStackdriverSecretEnabled { secret, err := getStackdriverSecret(sdconfig) if err != nil { return co, err } - co = append(co, convertSecretToExporterOption(secret)) + if opt, err := convertSecretToExporterOption(secret); err == nil { + co = append(co, opt) + } else { + return co, err + } } return co, nil @@ -111,7 +162,7 @@ func getStackdriverExporterClientOptions(sdconfig *stackdriverClientConfig) ([]o // to Stackdriver. Values can come from the GCE metadata server or the config. // Values explicitly set in the config take the highest precedent. func getMergedGCPMetadata(config *metricsConfig) *gcpMetadata { - gm := retrieveGCPMetadata() + gm := gcpMetadataFunc() if config.stackdriverClientConfig.ProjectID != "" { gm.project = config.stackdriverClientConfig.ProjectID } @@ -127,65 +178,67 @@ func getMergedGCPMetadata(config *metricsConfig) *gcpMetadata { return gm } -func getMonitoredResourceFunc(metricTypePrefix string, gm *gcpMetadata) func(v *view.View, tags []tag.Tag) ([]tag.Tag, monitoredresource.Interface) { - return func(view *view.View, tags []tag.Tag) ([]tag.Tag, monitoredresource.Interface) { - metricType := path.Join(metricTypePrefix, view.Measure.Name()) +func getResourceByDescriptorFunc(metricTypePrefix string, gm *gcpMetadata) func(*metricdata.Descriptor, map[string]string) (map[string]string, monitoredresource.Interface) { + return func(des *metricdata.Descriptor, tags map[string]string) (map[string]string, monitoredresource.Interface) { + metricType := path.Join(metricTypePrefix, des.Name) if metricskey.KnativeRevisionMetrics.Has(metricType) { - return GetKnativeRevisionMonitoredResource(view, tags, gm) + return GetKnativeRevisionMonitoredResource(des, tags, gm) } else if metricskey.KnativeBrokerMetrics.Has(metricType) { - return GetKnativeBrokerMonitoredResource(view, tags, gm) + return GetKnativeBrokerMonitoredResource(des, tags, gm) } else if metricskey.KnativeTriggerMetrics.Has(metricType) { - return GetKnativeTriggerMonitoredResource(view, tags, gm) + return GetKnativeTriggerMonitoredResource(des, tags, gm) } else if metricskey.KnativeSourceMetrics.Has(metricType) { - return GetKnativeSourceMonitoredResource(view, tags, gm) + return GetKnativeSourceMonitoredResource(des, tags, gm) } // Unsupported metric by knative_revision, knative_broker, knative_trigger, and knative_source, use "global" resource type. - return getGlobalMonitoredResource(view, tags) + return getGlobalMonitoredResource(des, tags) } } -func getGlobalMonitoredResource(v *view.View, tags []tag.Tag) ([]tag.Tag, monitoredresource.Interface) { +func getGlobalMonitoredResource(des *metricdata.Descriptor, tags map[string]string) (map[string]string, monitoredresource.Interface) { return tags, &Global{} } -func getMetricTypeFunc(metricTypePrefix, customMetricTypePrefix string) func(view *view.View) string { - return func(view *view.View) string { - metricType := path.Join(metricTypePrefix, view.Measure.Name()) +func getMetricPrefixFunc(metricTypePrefix, customMetricTypePrefix string) func(name string) string { + return func(name string) string { + metricType := path.Join(metricTypePrefix, name) inServing := metricskey.KnativeRevisionMetrics.Has(metricType) inEventing := metricskey.KnativeBrokerMetrics.Has(metricType) || metricskey.KnativeTriggerMetrics.Has(metricType) || metricskey.KnativeSourceMetrics.Has(metricType) if inServing || inEventing { - return metricType + return metricTypePrefix } // Unsupported metric by knative_revision, use custom domain. - return path.Join(customMetricTypePrefix, view.Measure.Name()) + return customMetricTypePrefix } } // getStackdriverSecret returns the Kubernetes Secret specified in the given config. -func getStackdriverSecret(sdconfig *stackdriverClientConfig) (*corev1.Secret, error) { +// TODO(anniefu): Update exporter if Secret changes (https://github.com/knative/pkg/issues/842) +func getStackdriverSecret(sdconfig *StackdriverClientConfig) (*corev1.Secret, error) { if err := ensureKubeclient(); err != nil { return nil, err } - ns := sdconfig.GCPSecretNamespace - if ns == "" { - ns = secretNamespaceDefault - } + stackdriverMtx.RLock() + defer stackdriverMtx.RUnlock() - sec, secErr := kubeclient.CoreV1().Secrets(ns).Get(sdconfig.GCPSecretName, metav1.GetOptions{}) + sec, secErr := kubeclient.CoreV1().Secrets(secretNamespace).Get(secretName, metav1.GetOptions{}) if secErr != nil { - return nil, fmt.Errorf("Error getting Secret [%v] in namespace [%v]: %v", sdconfig.GCPSecretName, sdconfig.GCPSecretNamespace, secErr) + return nil, fmt.Errorf("Error getting Secret [%v] in namespace [%v]: %v", secretName, secretNamespace, secErr) } return sec, nil } // convertSecretToExporterOption converts a Kubernetes Secret to an OpenCensus Stackdriver Exporter Option. -func convertSecretToExporterOption(secret *corev1.Secret) option.ClientOption { - return option.WithCredentialsJSON(secret.Data[secretDataFieldKey]) +func convertSecretToExporterOption(secret *corev1.Secret) (option.ClientOption, error) { + if data, ok := secret.Data[secretDataFieldKey]; ok { + return option.WithCredentialsJSON(data), nil + } + return nil, fmt.Errorf("Expected Secret to store key in data field named [%v]", secretDataFieldKey) } // ensureKubeclient is the lazy initializer for kubeclient. diff --git a/vendor/knative.dev/pkg/metrics/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/metrics/zz_generated.deepcopy.go new file mode 100644 index 0000000000..64996c609b --- /dev/null +++ b/vendor/knative.dev/pkg/metrics/zz_generated.deepcopy.go @@ -0,0 +1,37 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative 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. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package metrics + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ObservabilityConfig) DeepCopyInto(out *ObservabilityConfig) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObservabilityConfig. +func (in *ObservabilityConfig) DeepCopy() *ObservabilityConfig { + if in == nil { + return nil + } + out := new(ObservabilityConfig) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/pkg/profiling/server.go b/vendor/knative.dev/pkg/profiling/server.go index 22089ed5eb..fb27a51809 100644 --- a/vendor/knative.dev/pkg/profiling/server.go +++ b/vendor/knative.dev/pkg/profiling/server.go @@ -76,8 +76,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } -func readProfilingFlag(configMap *corev1.ConfigMap) (bool, error) { - profiling, ok := configMap.Data[profilingKey] +func ReadProfilingFlag(config map[string]string) (bool, error) { + profiling, ok := config[profilingKey] if !ok { return false, nil } @@ -91,7 +91,7 @@ func readProfilingFlag(configMap *corev1.ConfigMap) (bool, error) { // UpdateFromConfigMap modifies the Enabled flag in the Handler // according to the value in the given ConfigMap func (h *Handler) UpdateFromConfigMap(configMap *corev1.ConfigMap) { - enabled, err := readProfilingFlag(configMap) + enabled, err := ReadProfilingFlag(configMap.Data) if err != nil { h.log.Errorw("Failed to update the profiling flag", zap.Error(err)) return diff --git a/vendor/knative.dev/pkg/tracker/doc.go b/vendor/knative.dev/pkg/tracker/doc.go new file mode 100644 index 0000000000..5e0dfba60b --- /dev/null +++ b/vendor/knative.dev/pkg/tracker/doc.go @@ -0,0 +1,23 @@ +/* +Copyright 2018 The Knative 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. +*/ + +// +k8s:deepcopy-gen=package + +// Package tracker defines a utility to enable Reconcilers to trigger +// reconciliations when objects that are cross-referenced change, so +// that the level-based reconciliation can react to the change. The +// prototypical cross-reference in Kubernetes is corev1.ObjectReference. +package tracker diff --git a/vendor/knative.dev/pkg/tracker/enqueue.go b/vendor/knative.dev/pkg/tracker/enqueue.go new file mode 100644 index 0000000000..4a40a129ea --- /dev/null +++ b/vendor/knative.dev/pkg/tracker/enqueue.go @@ -0,0 +1,263 @@ +/* +Copyright 2018 The Knative 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 tracker + +import ( + "fmt" + "sort" + "strings" + "sync" + "time" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/validation" + + "knative.dev/pkg/kmeta" +) + +// New returns an implementation of Interface that lets a Reconciler +// register a particular resource as watching an ObjectReference for +// a particular lease duration. This watch must be refreshed +// periodically (e.g. by a controller resync) or it will expire. +// +// When OnChanged is called by the informer for a particular +// GroupVersionKind, the provided callback is called with the "key" +// of each object actively watching the changed object. +func New(callback func(types.NamespacedName), lease time.Duration) Interface { + return &impl{ + leaseDuration: lease, + cb: callback, + } +} + +type impl struct { + m sync.Mutex + // exact maps from an object reference to the set of + // keys for objects watching it. + exact map[Reference]set + // inexact maps from a partial object reference (no name/selector) to + // a map from watcher keys to the compiled selector and expiry. + inexact map[Reference]matchers + + // The amount of time that an object may watch another + // before having to renew the lease. + leaseDuration time.Duration + + cb func(types.NamespacedName) +} + +// Check that impl implements Interface. +var _ Interface = (*impl)(nil) + +// set is a map from keys to expirations +type set map[types.NamespacedName]time.Time + +// matchers maps the tracker's key to the matcher. +type matchers map[types.NamespacedName]matcher + +// matcher holds the selector and expiry for matching tracked objects. +type matcher struct { + // The selector to complete the match. + selector labels.Selector + + // When this lease expires. + expiry time.Time +} + +// Track implements Interface. +func (i *impl) Track(ref corev1.ObjectReference, obj interface{}) error { + return i.TrackReference(Reference{ + APIVersion: ref.APIVersion, + Kind: ref.Kind, + Namespace: ref.Namespace, + Name: ref.Name, + }, obj) +} + +func (i *impl) TrackReference(ref Reference, obj interface{}) error { + invalidFields := map[string][]string{ + "APIVersion": validation.IsQualifiedName(ref.APIVersion), + "Kind": validation.IsCIdentifier(ref.Kind), + "Namespace": validation.IsDNS1123Label(ref.Namespace), + } + var selector labels.Selector + fieldErrors := []string{} + switch { + case ref.Selector != nil && ref.Name != "": + fieldErrors = append(fieldErrors, "cannot provide both Name and Selector") + case ref.Name != "": + invalidFields["Name"] = validation.IsDNS1123Subdomain(ref.Name) + case ref.Selector != nil: + ls, err := metav1.LabelSelectorAsSelector(ref.Selector) + if err != nil { + invalidFields["Selector"] = []string{err.Error()} + } + selector = ls + default: + fieldErrors = append(fieldErrors, "must provide either Name or Selector") + } + for k, v := range invalidFields { + for _, msg := range v { + fieldErrors = append(fieldErrors, fmt.Sprintf("%s: %s", k, msg)) + } + } + if len(fieldErrors) > 0 { + sort.Strings(fieldErrors) + return fmt.Errorf("invalid Reference:\n%s", strings.Join(fieldErrors, "\n")) + } + + // Determine the key of the object tracking this reference. + object, err := kmeta.DeletionHandlingAccessor(obj) + if err != nil { + return err + } + key := types.NamespacedName{Namespace: object.GetNamespace(), Name: object.GetName()} + + i.m.Lock() + defer i.m.Unlock() + if i.exact == nil { + i.exact = make(map[Reference]set) + } + if i.inexact == nil { + i.inexact = make(map[Reference]matchers) + } + + // If the reference uses Name then it is an exact match. + if selector == nil { + l, ok := i.exact[ref] + if !ok { + l = set{} + } + + if expiry, ok := l[key]; !ok || isExpired(expiry) { + // When covering an uncovered key, immediately call the + // registered callback to ensure that the following pattern + // doesn't create problems: + // foo, err := lister.Get(key) + // // Later... + // err := tracker.Track(fooRef, parent) + // In this example, "Later" represents a window where "foo" may + // have changed or been created while the Track is not active. + // The simplest way of eliminating such a window is to call the + // callback to "catch up" immediately following new + // registrations. + i.cb(key) + } + // Overwrite the key with a new expiration. + l[key] = time.Now().Add(i.leaseDuration) + + i.exact[ref] = l + return nil + } + + // Otherwise, it is an inexact match by selector. + partialRef := Reference{ + APIVersion: ref.APIVersion, + Kind: ref.Kind, + Namespace: ref.Namespace, + // Exclude the selector. + } + l, ok := i.inexact[partialRef] + if !ok { + l = matchers{} + } + + if m, ok := l[key]; !ok || isExpired(m.expiry) { + // When covering an uncovered key, immediately call the + // registered callback to ensure that the following pattern + // doesn't create problems: + // foo, err := lister.Get(key) + // // Later... + // err := tracker.Track(fooRef, parent) + // In this example, "Later" represents a window where "foo" may + // have changed or been created while the Track is not active. + // The simplest way of eliminating such a window is to call the + // callback to "catch up" immediately following new + // registrations. + i.cb(key) + } + // Overwrite the key with a new expiration. + l[key] = matcher{ + selector: selector, + expiry: time.Now().Add(i.leaseDuration), + } + + i.inexact[partialRef] = l + return nil +} + +func isExpired(expiry time.Time) bool { + return time.Now().After(expiry) +} + +// OnChanged implements Interface. +func (i *impl) OnChanged(obj interface{}) { + item, err := kmeta.DeletionHandlingAccessor(obj) + if err != nil { + return + } + + or := kmeta.ObjectReference(item) + ref := Reference{ + APIVersion: or.APIVersion, + Kind: or.Kind, + Namespace: or.Namespace, + Name: or.Name, + } + + i.m.Lock() + defer i.m.Unlock() + + // Handle exact matches. + s, ok := i.exact[ref] + if ok { + for key, expiry := range s { + // If the expiration has lapsed, then delete the key. + if isExpired(expiry) { + delete(s, key) + continue + } + i.cb(key) + } + if len(s) == 0 { + delete(i.exact, ref) + } + } + + // Handle inexact matches. + ref.Name = "" + ms, ok := i.inexact[ref] + if ok { + ls := labels.Set(item.GetLabels()) + for key, m := range ms { + // If the expiration has lapsed, then delete the key. + if isExpired(m.expiry) { + delete(ms, key) + continue + } + if m.selector.Matches(ls) { + i.cb(key) + } + } + if len(s) == 0 { + delete(i.exact, ref) + } + } +} diff --git a/vendor/knative.dev/pkg/tracker/interface.go b/vendor/knative.dev/pkg/tracker/interface.go new file mode 100644 index 0000000000..2e5278c3c7 --- /dev/null +++ b/vendor/knative.dev/pkg/tracker/interface.go @@ -0,0 +1,170 @@ +/* +Copyright 2018 The Knative 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 tracker + +import ( + "context" + "strings" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/validation" + + "knative.dev/pkg/apis" +) + +// Reference is modeled after corev1.ObjectReference, but omits fields +// unsupported by the tracker, and permits us to extend things in +// divergent ways. +type Reference struct { + // API version of the referent. + // +optional + APIVersion string `json:"apiVersion,omitempty"` + + // Kind of the referent. + // +optional + Kind string `json:"kind,omitempty"` + + // Namespace of the referent. + // +optional + Namespace string `json:"namespace,omitempty"` + + // Name of the referent. + // Mutually exclusive with Selector. + // +optional + Name string `json:"name,omitempty"` + + // Selector of the referents. + // Mutually exclusive with Name. + // +optional + Selector *metav1.LabelSelector `json:"selector,omitempty"` +} + +// Interface defines the interface through which an object can register +// that it is tracking another object by reference. +type Interface interface { + // Track tells us that "obj" is tracking changes to the + // referenced object. + // DEPRECATED: use TrackReference + Track(ref corev1.ObjectReference, obj interface{}) error + + // Track tells us that "obj" is tracking changes to the + // referenced object. + TrackReference(ref Reference, obj interface{}) error + + // OnChanged is a callback to register with the InformerFactory + // so that we are notified for appropriate object changes. + OnChanged(obj interface{}) +} + +// GroupVersionKind returns the GroupVersion of the object referenced. +func (ref *Reference) GroupVersionKind() schema.GroupVersionKind { + gv, _ := schema.ParseGroupVersion(ref.APIVersion) + return schema.GroupVersionKind{ + Group: gv.Group, + Version: gv.Version, + Kind: ref.Kind, + } +} + +// ObjectReference returns the tracker Reference as an ObjectReference. +func (ref *Reference) ObjectReference() corev1.ObjectReference { + return corev1.ObjectReference{ + APIVersion: ref.APIVersion, + Kind: ref.Kind, + Namespace: ref.Namespace, + Name: ref.Name, + } +} + +// ValidateObjectReference validates that the Reference uses a subset suitable for +// translation to a corev1.ObjectReference. This helper is intended to simplify +// validating a particular (narrow) use of tracker.Reference. +func (ref *Reference) ValidateObjectReference(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + // Required fields + if ref.APIVersion == "" { + errs = errs.Also(apis.ErrMissingField("apiVersion")) + } else if verrs := validation.IsQualifiedName(ref.APIVersion); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "apiVersion")) + } + if ref.Kind == "" { + errs = errs.Also(apis.ErrMissingField("kind")) + } else if verrs := validation.IsCIdentifier(ref.Kind); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "kind")) + } + if ref.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } else if verrs := validation.IsDNS1123Label(ref.Name); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "name")) + } + if ref.Namespace == "" { + errs = errs.Also(apis.ErrMissingField("namespace")) + } else if verrs := validation.IsDNS1123Label(ref.Namespace); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "namespace")) + } + + // Disallowed fields in ObjectReference-compatible context. + if ref.Selector != nil { + errs = errs.Also(apis.ErrDisallowedFields("selector")) + } + + return errs +} + +func (ref *Reference) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + // Required fields + if ref.APIVersion == "" { + errs = errs.Also(apis.ErrMissingField("apiVersion")) + } else if verrs := validation.IsQualifiedName(ref.APIVersion); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "apiVersion")) + } + if ref.Kind == "" { + errs = errs.Also(apis.ErrMissingField("kind")) + } else if verrs := validation.IsCIdentifier(ref.Kind); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "kind")) + } + if ref.Namespace == "" { + errs = errs.Also(apis.ErrMissingField("namespace")) + } else if verrs := validation.IsDNS1123Label(ref.Namespace); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "namespace")) + } + + switch { + case ref.Selector != nil && ref.Name != "": + errs = errs.Also(apis.ErrMultipleOneOf("selector", "name")) + case ref.Selector != nil: + _, err := metav1.LabelSelectorAsSelector(ref.Selector) + if err != nil { + errs = errs.Also(apis.ErrInvalidValue(err.Error(), "selector")) + } + + case ref.Name != "": + if verrs := validation.IsDNS1123Label(ref.Name); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "name")) + } + default: + errs = errs.Also(apis.ErrMissingOneOf("selector", "name")) + } + + return errs + +} diff --git a/vendor/knative.dev/pkg/apis/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/pkg/tracker/zz_generated.deepcopy.go similarity index 69% rename from vendor/knative.dev/pkg/apis/v1alpha1/zz_generated.deepcopy.go rename to vendor/knative.dev/pkg/tracker/zz_generated.deepcopy.go index 5640bf0a81..fba51f5d6f 100644 --- a/vendor/knative.dev/pkg/apis/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/knative.dev/pkg/tracker/zz_generated.deepcopy.go @@ -18,35 +18,29 @@ limitations under the License. // Code generated by deepcopy-gen. DO NOT EDIT. -package v1alpha1 +package tracker import ( - v1 "k8s.io/api/core/v1" - apis "knative.dev/pkg/apis" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Destination) DeepCopyInto(out *Destination) { +func (in *Reference) DeepCopyInto(out *Reference) { *out = *in - if in.Ref != nil { - in, out := &in.Ref, &out.Ref - *out = new(v1.ObjectReference) - **out = **in - } - if in.URI != nil { - in, out := &in.URI, &out.URI - *out = new(apis.URL) + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) (*in).DeepCopyInto(*out) } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Destination. -func (in *Destination) DeepCopy() *Destination { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Reference. +func (in *Reference) DeepCopy() *Reference { if in == nil { return nil } - out := new(Destination) + out := new(Reference) in.DeepCopyInto(out) return out } diff --git a/vendor/knative.dev/pkg/webhook/OWNERS b/vendor/knative.dev/pkg/webhook/OWNERS deleted file mode 100644 index b87878d94a..0000000000 --- a/vendor/knative.dev/pkg/webhook/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- webhook-approvers diff --git a/vendor/knative.dev/pkg/webhook/certs.go b/vendor/knative.dev/pkg/webhook/certs.go deleted file mode 100644 index 1a0348394d..0000000000 --- a/vendor/knative.dev/pkg/webhook/certs.go +++ /dev/null @@ -1,165 +0,0 @@ -/* -Copyright 2018 The Knative 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 webhook - -import ( - "context" - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "crypto/x509/pkix" - "encoding/pem" - "errors" - "math/big" - "time" - - "go.uber.org/zap" - - "knative.dev/pkg/logging" -) - -const ( - organization = "knative.dev" -) - -// Create the common parts of the cert. These don't change between -// the root/CA cert and the server cert. -func createCertTemplate(name, namespace string) (*x509.Certificate, error) { - serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) - serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) - if err != nil { - return nil, errors.New("failed to generate serial number: " + err.Error()) - } - - serviceName := name + "." + namespace - serviceNames := []string{ - name, - serviceName, - serviceName + ".svc", - serviceName + ".svc.cluster.local", - } - - tmpl := x509.Certificate{ - SerialNumber: serialNumber, - Subject: pkix.Name{Organization: []string{organization}}, - SignatureAlgorithm: x509.SHA256WithRSA, - NotBefore: time.Now(), - NotAfter: time.Now().AddDate(1, 0, 0), // valid for 1 years - BasicConstraintsValid: true, - DNSNames: serviceNames, - } - return &tmpl, nil -} - -// Create cert template suitable for CA and hence signing -func createCACertTemplate(name, namespace string) (*x509.Certificate, error) { - rootCert, err := createCertTemplate(name, namespace) - if err != nil { - return nil, err - } - // Make it into a CA cert and change it so we can use it to sign certs - rootCert.IsCA = true - rootCert.KeyUsage = x509.KeyUsageCertSign | x509.KeyUsageDigitalSignature - rootCert.ExtKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth} - return rootCert, nil -} - -// Create cert template that we can use on the server for TLS -func createServerCertTemplate(name, namespace string) (*x509.Certificate, error) { - serverCert, err := createCertTemplate(name, namespace) - if err != nil { - return nil, err - } - serverCert.KeyUsage = x509.KeyUsageDigitalSignature - serverCert.ExtKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth} - return serverCert, err -} - -// Actually sign the cert and return things in a form that we can use later on -func createCert(template, parent *x509.Certificate, pub interface{}, parentPriv interface{}) ( - cert *x509.Certificate, certPEM []byte, err error) { - - certDER, err := x509.CreateCertificate(rand.Reader, template, parent, pub, parentPriv) - if err != nil { - return - } - cert, err = x509.ParseCertificate(certDER) - if err != nil { - return - } - b := pem.Block{Type: "CERTIFICATE", Bytes: certDER} - certPEM = pem.EncodeToMemory(&b) - return -} - -func createCA(ctx context.Context, name, namespace string) (*rsa.PrivateKey, *x509.Certificate, []byte, error) { - logger := logging.FromContext(ctx) - rootKey, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - logger.Errorw("error generating random key", zap.Error(err)) - return nil, nil, nil, err - } - - rootCertTmpl, err := createCACertTemplate(name, namespace) - if err != nil { - logger.Errorw("error generating CA cert", zap.Error(err)) - return nil, nil, nil, err - } - - rootCert, rootCertPEM, err := createCert(rootCertTmpl, rootCertTmpl, &rootKey.PublicKey, rootKey) - if err != nil { - logger.Errorw("error signing the CA cert", zap.Error(err)) - return nil, nil, nil, err - } - return rootKey, rootCert, rootCertPEM, nil -} - -// CreateCerts creates and returns a CA certificate and certificate and -// key for the server. serverKey and serverCert are used by the server -// to establish trust for clients, CA certificate is used by the -// client to verify the server authentication chain. -func CreateCerts(ctx context.Context, name, namespace string) (serverKey, serverCert, caCert []byte, err error) { - logger := logging.FromContext(ctx) - // First create a CA certificate and private key - caKey, caCertificate, caCertificatePEM, err := createCA(ctx, name, namespace) - if err != nil { - return nil, nil, nil, err - } - - // Then create the private key for the serving cert - servKey, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - logger.Errorw("error generating random key", zap.Error(err)) - return nil, nil, nil, err - } - servCertTemplate, err := createServerCertTemplate(name, namespace) - if err != nil { - logger.Errorw("failed to create the server certificate template", zap.Error(err)) - return nil, nil, nil, err - } - - // create a certificate which wraps the server's public key, sign it with the CA private key - _, servCertPEM, err := createCert(servCertTemplate, caCertificate, &servKey.PublicKey, caKey) - if err != nil { - logger.Errorw("error signing server certificate template", zap.Error(err)) - return nil, nil, nil, err - } - servKeyPEM := pem.EncodeToMemory(&pem.Block{ - Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(servKey), - }) - return servKeyPEM, servCertPEM, caCertificatePEM, nil -} diff --git a/vendor/knative.dev/pkg/webhook/config_validation_controller.go b/vendor/knative.dev/pkg/webhook/config_validation_controller.go deleted file mode 100644 index 1f00f985b0..0000000000 --- a/vendor/knative.dev/pkg/webhook/config_validation_controller.go +++ /dev/null @@ -1,184 +0,0 @@ -/* -Copyright 2019 The Knative 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 webhook - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "reflect" - - admissionv1beta1 "k8s.io/api/admission/v1beta1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/kubernetes" - - "knative.dev/pkg/configmap" - "knative.dev/pkg/kmp" - "knative.dev/pkg/logging" - "knative.dev/pkg/ptr" -) - -// ConfigValidationController implements the AdmissionController for ConfigMaps -type ConfigValidationController struct { - constructors map[string]reflect.Value - options ControllerOptions -} - -// NewConfigValidationController constructs a ConfigValidationController -func NewConfigValidationController( - constructors configmap.Constructors, - opts ControllerOptions) AdmissionController { - cfgValidations := &ConfigValidationController{ - constructors: make(map[string]reflect.Value), - options: opts, - } - - for configName, constructor := range constructors { - cfgValidations.registerConfig(configName, constructor) - } - - return cfgValidations -} - -func (ac *ConfigValidationController) Admit(ctx context.Context, request *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse { - logger := logging.FromContext(ctx) - switch request.Operation { - case admissionv1beta1.Create, admissionv1beta1.Update: - default: - logger.Infof("Unhandled webhook operation, letting it through %v", request.Operation) - return &admissionv1beta1.AdmissionResponse{Allowed: true} - } - - if err := ac.validate(ctx, request); err != nil { - return makeErrorStatus("validation failed: %v", err) - } - - return &admissionv1beta1.AdmissionResponse{ - Allowed: true, - } -} - -func (ac *ConfigValidationController) Register(ctx context.Context, kubeClient kubernetes.Interface, caCert []byte) error { - client := kubeClient.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations() - logger := logging.FromContext(ctx) - - ruleScope := admissionregistrationv1beta1.NamespacedScope - rules := []admissionregistrationv1beta1.RuleWithOperations{{ - Operations: []admissionregistrationv1beta1.OperationType{ - admissionregistrationv1beta1.Create, - admissionregistrationv1beta1.Update, - }, - Rule: admissionregistrationv1beta1.Rule{ - APIGroups: []string{""}, - APIVersions: []string{"v1"}, - Resources: []string{"configmaps/*"}, - Scope: &ruleScope, - }, - }} - - configuredWebhook, err := client.Get(ac.options.ConfigValidationWebhookName, metav1.GetOptions{}) - if err != nil { - return fmt.Errorf("error retrieving webhook: %v", err) - } - - webhook := configuredWebhook.DeepCopy() - - // Clear out any previous (bad) OwnerReferences. - // See: https://github.com/knative/serving/issues/5845 - webhook.OwnerReferences = nil - - for i, wh := range webhook.Webhooks { - if wh.Name != webhook.Name { - continue - } - webhook.Webhooks[i].Rules = rules - webhook.Webhooks[i].ClientConfig.CABundle = caCert - if webhook.Webhooks[i].ClientConfig.Service == nil { - return fmt.Errorf("missing service reference for webhook: %s", wh.Name) - } - webhook.Webhooks[i].ClientConfig.Service.Path = ptr.String(ac.options.ConfigValidationControllerPath) - } - - if ok, err := kmp.SafeEqual(configuredWebhook, webhook); err != nil { - return fmt.Errorf("error diffing webhooks: %v", err) - } else if !ok { - logger.Info("Updating webhook") - if _, err := client.Update(webhook); err != nil { - return fmt.Errorf("failed to update webhook: %v", err) - } - } else { - logger.Info("Webhook is valid") - } - - return nil -} - -func (ac *ConfigValidationController) validate(ctx context.Context, req *admissionv1beta1.AdmissionRequest) error { - logger := logging.FromContext(ctx) - kind := req.Kind - newBytes := req.Object.Raw - - // Why, oh why are these different types... - gvk := schema.GroupVersionKind{ - Group: kind.Group, - Version: kind.Version, - Kind: kind.Kind, - } - - resourceGVK := corev1.SchemeGroupVersion.WithKind("ConfigMap") - if gvk != resourceGVK { - logger.Errorf("Unhandled kind: %v", gvk) - return fmt.Errorf("unhandled kind: %v", gvk) - } - - var newObj corev1.ConfigMap - if len(newBytes) != 0 { - newDecoder := json.NewDecoder(bytes.NewBuffer(newBytes)) - if err := newDecoder.Decode(&newObj); err != nil { - return fmt.Errorf("cannot decode incoming new object: %v", err) - } - } - - var err error - if constructor, ok := ac.constructors[newObj.Name]; ok { - - inputs := []reflect.Value{ - reflect.ValueOf(&newObj), - } - - outputs := constructor.Call(inputs) - errVal := outputs[1] - - if !errVal.IsNil() { - err = errVal.Interface().(error) - } - } - - return err -} - -func (ac *ConfigValidationController) registerConfig(name string, constructor interface{}) { - if err := configmap.ValidateConstructor(constructor); err != nil { - panic(err) - } - - ac.constructors[name] = reflect.ValueOf(constructor) -} diff --git a/vendor/knative.dev/pkg/webhook/resource_admission_controller.go b/vendor/knative.dev/pkg/webhook/resource_admission_controller.go deleted file mode 100644 index 8dacc142ed..0000000000 --- a/vendor/knative.dev/pkg/webhook/resource_admission_controller.go +++ /dev/null @@ -1,357 +0,0 @@ -/* -Copyright 2019 The Knative 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 webhook - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "sort" - "strings" - - "github.com/markbates/inflect" - "github.com/mattbaird/jsonpatch" - "go.uber.org/zap" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/kubernetes" - - "knative.dev/pkg/apis" - "knative.dev/pkg/apis/duck" - "knative.dev/pkg/kmp" - "knative.dev/pkg/logging" - "knative.dev/pkg/ptr" -) - -// ResourceCallback defines a signature for resource specific (Route, Configuration, etc.) -// handlers that can validate and mutate an object. If non-nil error is returned, object mutation -// is denied. Mutations should be appended to the patches operations. -type ResourceCallback func(patches *[]jsonpatch.JsonPatchOperation, old GenericCRD, new GenericCRD) error - -// ResourceDefaulter defines a signature for resource specific (Route, Configuration, etc.) -// handlers that can set defaults on an object. If non-nil error is returned, object mutation -// is denied. Mutations should be appended to the patches operations. -type ResourceDefaulter func(patches *[]jsonpatch.JsonPatchOperation, crd GenericCRD) error - -// GenericCRD is the interface definition that allows us to perform the generic -// CRD actions like deciding whether to increment generation and so forth. -type GenericCRD interface { - apis.Defaultable - apis.Validatable - runtime.Object -} - -// ResourceAdmissionController implements the AdmissionController for resources -type ResourceAdmissionController struct { - handlers map[schema.GroupVersionKind]GenericCRD - options ControllerOptions - - disallowUnknownFields bool -} - -// NewResourceAdmissionController constructs a ResourceAdmissionController -func NewResourceAdmissionController( - handlers map[schema.GroupVersionKind]GenericCRD, - opts ControllerOptions, - disallowUnknownFields bool) AdmissionController { - return &ResourceAdmissionController{ - handlers: handlers, - options: opts, - disallowUnknownFields: disallowUnknownFields, - } -} - -func (ac *ResourceAdmissionController) Admit(ctx context.Context, request *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse { - logger := logging.FromContext(ctx) - switch request.Operation { - case admissionv1beta1.Create, admissionv1beta1.Update: - default: - logger.Infof("Unhandled webhook operation, letting it through %v", request.Operation) - return &admissionv1beta1.AdmissionResponse{Allowed: true} - } - - patchBytes, err := ac.mutate(ctx, request) - if err != nil { - return makeErrorStatus("mutation failed: %v", err) - } - logger.Infof("Kind: %q PatchBytes: %v", request.Kind, string(patchBytes)) - - return &admissionv1beta1.AdmissionResponse{ - Patch: patchBytes, - Allowed: true, - PatchType: func() *admissionv1beta1.PatchType { - pt := admissionv1beta1.PatchTypeJSONPatch - return &pt - }(), - } -} - -func (ac *ResourceAdmissionController) Register(ctx context.Context, kubeClient kubernetes.Interface, caCert []byte) error { - client := kubeClient.AdmissionregistrationV1beta1().MutatingWebhookConfigurations() - logger := logging.FromContext(ctx) - - var rules []admissionregistrationv1beta1.RuleWithOperations - for gvk := range ac.handlers { - plural := strings.ToLower(inflect.Pluralize(gvk.Kind)) - - rules = append(rules, admissionregistrationv1beta1.RuleWithOperations{ - Operations: []admissionregistrationv1beta1.OperationType{ - admissionregistrationv1beta1.Create, - admissionregistrationv1beta1.Update, - }, - Rule: admissionregistrationv1beta1.Rule{ - APIGroups: []string{gvk.Group}, - APIVersions: []string{gvk.Version}, - Resources: []string{plural + "/*"}, - }, - }) - } - - // Sort the rules by Group, Version, Kind so that things are deterministically ordered. - sort.Slice(rules, func(i, j int) bool { - lhs, rhs := rules[i], rules[j] - if lhs.APIGroups[0] != rhs.APIGroups[0] { - return lhs.APIGroups[0] < rhs.APIGroups[0] - } - if lhs.APIVersions[0] != rhs.APIVersions[0] { - return lhs.APIVersions[0] < rhs.APIVersions[0] - } - return lhs.Resources[0] < rhs.Resources[0] - }) - - configuredWebhook, err := client.Get(ac.options.ResourceMutatingWebhookName, metav1.GetOptions{}) - if err != nil { - return fmt.Errorf("error retrieving webhook: %v", err) - } - - webhook := configuredWebhook.DeepCopy() - - // Clear out any previous (bad) OwnerReferences. - // See: https://github.com/knative/serving/issues/5845 - webhook.OwnerReferences = nil - - for i, wh := range webhook.Webhooks { - if wh.Name != webhook.Name { - continue - } - webhook.Webhooks[i].Rules = rules - webhook.Webhooks[i].ClientConfig.CABundle = caCert - if webhook.Webhooks[i].ClientConfig.Service == nil { - return fmt.Errorf("missing service reference for webhook: %s", wh.Name) - } - webhook.Webhooks[i].ClientConfig.Service.Path = ptr.String( - ac.options.ResourceAdmissionControllerPath) - } - - if ok, err := kmp.SafeEqual(configuredWebhook, webhook); err != nil { - return fmt.Errorf("error diffing webhooks: %v", err) - } else if !ok { - logger.Info("Updating webhook") - if _, err := client.Update(webhook); err != nil { - return fmt.Errorf("failed to update webhook: %v", err) - } - } else { - logger.Info("Webhook is valid") - } - return nil -} - -func (ac *ResourceAdmissionController) mutate(ctx context.Context, req *admissionv1beta1.AdmissionRequest) ([]byte, error) { - kind := req.Kind - newBytes := req.Object.Raw - oldBytes := req.OldObject.Raw - // Why, oh why are these different types... - gvk := schema.GroupVersionKind{ - Group: kind.Group, - Version: kind.Version, - Kind: kind.Kind, - } - - logger := logging.FromContext(ctx) - handler, ok := ac.handlers[gvk] - if !ok { - logger.Errorf("Unhandled kind: %v", gvk) - return nil, fmt.Errorf("unhandled kind: %v", gvk) - } - - // nil values denote absence of `old` (create) or `new` (delete) objects. - var oldObj, newObj GenericCRD - - if len(newBytes) != 0 { - newObj = handler.DeepCopyObject().(GenericCRD) - newDecoder := json.NewDecoder(bytes.NewBuffer(newBytes)) - if ac.disallowUnknownFields { - newDecoder.DisallowUnknownFields() - } - if err := newDecoder.Decode(&newObj); err != nil { - return nil, fmt.Errorf("cannot decode incoming new object: %v", err) - } - } - if len(oldBytes) != 0 { - oldObj = handler.DeepCopyObject().(GenericCRD) - oldDecoder := json.NewDecoder(bytes.NewBuffer(oldBytes)) - if ac.disallowUnknownFields { - oldDecoder.DisallowUnknownFields() - } - if err := oldDecoder.Decode(&oldObj); err != nil { - return nil, fmt.Errorf("cannot decode incoming old object: %v", err) - } - } - var patches duck.JSONPatch - - var err error - // Skip this step if the type we're dealing with is a duck type, since it is inherently - // incomplete and this will patch away all of the unspecified fields. - if _, ok := newObj.(duck.Populatable); !ok { - // Add these before defaulting fields, otherwise defaulting may cause an illegal patch - // because it expects the round tripped through Golang fields to be present already. - rtp, err := roundTripPatch(newBytes, newObj) - if err != nil { - return nil, fmt.Errorf("cannot create patch for round tripped newBytes: %v", err) - } - patches = append(patches, rtp...) - } - - // Set up the context for defaulting and validation - if oldObj != nil { - // Copy the old object and set defaults so that we don't reject our own - // defaulting done earlier in the webhook. - oldObj = oldObj.DeepCopyObject().(GenericCRD) - oldObj.SetDefaults(ctx) - - s, ok := oldObj.(apis.HasSpec) - if ok { - SetUserInfoAnnotations(s, ctx, req.Resource.Group) - } - - if req.SubResource == "" { - ctx = apis.WithinUpdate(ctx, oldObj) - } else { - ctx = apis.WithinSubResourceUpdate(ctx, oldObj, req.SubResource) - } - } else { - ctx = apis.WithinCreate(ctx) - } - ctx = apis.WithUserInfo(ctx, &req.UserInfo) - - // Default the new object. - if patches, err = setDefaults(ctx, patches, newObj); err != nil { - logger.Errorw("Failed the resource specific defaulter", zap.Error(err)) - // Return the error message as-is to give the defaulter callback - // discretion over (our portion of) the message that the user sees. - return nil, err - } - - if patches, err = ac.setUserInfoAnnotations(ctx, patches, newObj, req.Resource.Group); err != nil { - logger.Errorw("Failed the resource user info annotator", zap.Error(err)) - return nil, err - } - - // None of the validators will accept a nil value for newObj. - if newObj == nil { - return nil, errMissingNewObject - } - if err := validate(ctx, newObj); err != nil { - logger.Errorw("Failed the resource specific validation", zap.Error(err)) - // Return the error message as-is to give the validation callback - // discretion over (our portion of) the message that the user sees. - return nil, err - } - - return json.Marshal(patches) -} - -func (ac *ResourceAdmissionController) setUserInfoAnnotations(ctx context.Context, patches duck.JSONPatch, new GenericCRD, groupName string) (duck.JSONPatch, error) { - if new == nil { - return patches, nil - } - nh, ok := new.(apis.HasSpec) - if !ok { - return patches, nil - } - - b, a := new.DeepCopyObject().(apis.HasSpec), nh - - SetUserInfoAnnotations(nh, ctx, groupName) - - patch, err := duck.CreatePatch(b, a) - if err != nil { - return nil, err - } - return append(patches, patch...), nil -} - -// roundTripPatch generates the JSONPatch that corresponds to round tripping the given bytes through -// the Golang type (JSON -> Golang type -> JSON). Because it is not always true that -// bytes == json.Marshal(json.Unmarshal(bytes)). -// -// For example, if bytes did not contain a 'spec' field and the Golang type specifies its 'spec' -// field without omitempty, then by round tripping through the Golang type, we would have added -// `'spec': {}`. -func roundTripPatch(bytes []byte, unmarshalled interface{}) (duck.JSONPatch, error) { - if unmarshalled == nil { - return duck.JSONPatch{}, nil - } - marshaledBytes, err := json.Marshal(unmarshalled) - if err != nil { - return nil, fmt.Errorf("cannot marshal interface: %v", err) - } - return jsonpatch.CreatePatch(bytes, marshaledBytes) -} - -// validate performs validation on the provided "new" CRD. -// For legacy purposes, this also does apis.Immutable validation, -// which is deprecated and will be removed in a future release. -func validate(ctx context.Context, new apis.Validatable) error { - if apis.IsInUpdate(ctx) { - old := apis.GetBaseline(ctx) - if immutableNew, ok := new.(apis.Immutable); ok { - immutableOld, ok := old.(apis.Immutable) - if !ok { - return fmt.Errorf("unexpected type mismatch %T vs. %T", old, new) - } - if err := immutableNew.CheckImmutableFields(ctx, immutableOld); err != nil { - return err - } - } - } - - // Can't just `return new.Validate()` because it doesn't properly nil-check. - if err := new.Validate(ctx); err != nil { - return err - } - - return nil -} - -// setDefaults simply leverages apis.Defaultable to set defaults. -func setDefaults(ctx context.Context, patches duck.JSONPatch, crd GenericCRD) (duck.JSONPatch, error) { - before, after := crd.DeepCopyObject(), crd - after.SetDefaults(ctx) - - patch, err := duck.CreatePatch(before, after) - if err != nil { - return nil, err - } - - return append(patches, patch...), nil -} diff --git a/vendor/knative.dev/pkg/webhook/stats_reporter.go b/vendor/knative.dev/pkg/webhook/stats_reporter.go deleted file mode 100644 index d6c4df35c0..0000000000 --- a/vendor/knative.dev/pkg/webhook/stats_reporter.go +++ /dev/null @@ -1,143 +0,0 @@ -/* -Copyright 2019 The Knative 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 webhook - -import ( - "context" - "strconv" - "time" - - "go.opencensus.io/stats" - "go.opencensus.io/stats/view" - "go.opencensus.io/tag" - admissionv1beta1 "k8s.io/api/admission/v1beta1" - "knative.dev/pkg/metrics" -) - -const ( - requestCountName = "request_count" - requestLatenciesName = "request_latencies" -) - -var ( - requestCountM = stats.Int64( - requestCountName, - "The number of requests that are routed to webhook", - stats.UnitDimensionless) - responseTimeInMsecM = stats.Float64( - requestLatenciesName, - "The response time in milliseconds", - stats.UnitMilliseconds) - - // Create the tag keys that will be used to add tags to our measurements. - // Tag keys must conform to the restrictions described in - // go.opencensus.io/tag/validate.go. Currently those restrictions are: - // - length between 1 and 255 inclusive - // - characters are printable US-ASCII - requestOperationKey = tag.MustNewKey("request_operation") - kindGroupKey = tag.MustNewKey("kind_group") - kindVersionKey = tag.MustNewKey("kind_version") - kindKindKey = tag.MustNewKey("kind_kind") - resourceGroupKey = tag.MustNewKey("resource_group") - resourceVersionKey = tag.MustNewKey("resource_version") - resourceResourceKey = tag.MustNewKey("resource_resource") - resourceNameKey = tag.MustNewKey("resource_name") - resourceNamespaceKey = tag.MustNewKey("resource_namespace") - admissionAllowedKey = tag.MustNewKey("admission_allowed") -) - -func init() { - register() -} - -// StatsReporter reports webhook metrics -type StatsReporter interface { - ReportRequest(request *admissionv1beta1.AdmissionRequest, response *admissionv1beta1.AdmissionResponse, d time.Duration) error -} - -// reporter implements StatsReporter interface -type reporter struct { - ctx context.Context -} - -// NewStatsReporter creaters a reporter for webhook metrics -func NewStatsReporter() (StatsReporter, error) { - ctx, err := tag.New( - context.Background(), - ) - if err != nil { - return nil, err - } - - return &reporter{ctx: ctx}, nil -} - -// Captures req count metric, recording the count and the duration -func (r *reporter) ReportRequest(req *admissionv1beta1.AdmissionRequest, resp *admissionv1beta1.AdmissionResponse, d time.Duration) error { - ctx, err := tag.New( - r.ctx, - tag.Insert(requestOperationKey, string(req.Operation)), - tag.Insert(kindGroupKey, req.Kind.Group), - tag.Insert(kindVersionKey, req.Kind.Version), - tag.Insert(kindKindKey, req.Kind.Kind), - tag.Insert(resourceGroupKey, req.Resource.Group), - tag.Insert(resourceVersionKey, req.Resource.Version), - tag.Insert(resourceResourceKey, req.Resource.Resource), - tag.Insert(resourceNameKey, req.Name), - tag.Insert(resourceNamespaceKey, req.Namespace), - tag.Insert(admissionAllowedKey, strconv.FormatBool(resp.Allowed)), - ) - if err != nil { - return err - } - - metrics.Record(ctx, requestCountM.M(1)) - // Convert time.Duration in nanoseconds to milliseconds - metrics.Record(ctx, responseTimeInMsecM.M(float64(d/time.Millisecond))) - return nil -} - -func register() { - tagKeys := []tag.Key{ - requestOperationKey, - kindGroupKey, - kindVersionKey, - kindKindKey, - resourceGroupKey, - resourceVersionKey, - resourceResourceKey, - resourceNamespaceKey, - resourceNameKey, - admissionAllowedKey} - - if err := view.Register( - &view.View{ - Description: requestCountM.Description(), - Measure: requestCountM, - Aggregation: view.Count(), - TagKeys: tagKeys, - }, - &view.View{ - Description: responseTimeInMsecM.Description(), - Measure: responseTimeInMsecM, - Aggregation: view.Distribution(metrics.Buckets125(1, 100000)...), // [1 2 5 10 20 50 100 200 500 1000 2000 5000 10000 20000 50000 100000]ms - TagKeys: tagKeys, - }, - ); err != nil { - panic(err) - } -} diff --git a/vendor/knative.dev/pkg/webhook/user_info.go b/vendor/knative.dev/pkg/webhook/user_info.go deleted file mode 100644 index 405290e7a7..0000000000 --- a/vendor/knative.dev/pkg/webhook/user_info.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2019 The Knative 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 webhook - -import ( - "context" - - "k8s.io/apimachinery/pkg/api/equality" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/apis" -) - -// SetUserInfoAnnotations sets creator and updater annotations on a resource. -func SetUserInfoAnnotations(resource apis.HasSpec, ctx context.Context, groupName string) { - if ui := apis.GetUserInfo(ctx); ui != nil { - objectMetaAccessor, ok := resource.(metav1.ObjectMetaAccessor) - if !ok { - return - } - - annotations := objectMetaAccessor.GetObjectMeta().GetAnnotations() - if annotations == nil { - annotations = map[string]string{} - objectMetaAccessor.GetObjectMeta().SetAnnotations(annotations) - } - - if apis.IsInUpdate(ctx) { - old := apis.GetBaseline(ctx).(apis.HasSpec) - if equality.Semantic.DeepEqual(old.GetUntypedSpec(), resource.GetUntypedSpec()) { - return - } - annotations[groupName+apis.UpdaterAnnotationSuffix] = ui.Username - } else { - annotations[groupName+apis.CreatorAnnotationSuffix] = ui.Username - annotations[groupName+apis.UpdaterAnnotationSuffix] = ui.Username - } - } -} diff --git a/vendor/knative.dev/pkg/webhook/webhook.go b/vendor/knative.dev/pkg/webhook/webhook.go deleted file mode 100644 index 1aca8fc400..0000000000 --- a/vendor/knative.dev/pkg/webhook/webhook.go +++ /dev/null @@ -1,386 +0,0 @@ -/* -Copyright 2017 The Knative 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 webhook - -import ( - "context" - "crypto/tls" - "crypto/x509" - "encoding/json" - "errors" - "fmt" - "net/http" - "time" - - "go.uber.org/zap" - "golang.org/x/sync/errgroup" - "knative.dev/pkg/logging" - "knative.dev/pkg/logging/logkey" - - admissionv1beta1 "k8s.io/api/admission/v1beta1" - corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/kubernetes" -) - -const ( - secretServerKey = "server-key.pem" - secretServerCert = "server-cert.pem" - secretCACert = "ca-cert.pem" -) - -var ( - errMissingNewObject = errors.New("the new object may not be nil") -) - -// ControllerOptions contains the configuration for the webhook -type ControllerOptions struct { - // ResourceMutatingWebhookName is the name of the webhook we create to handle - // mutations before they get stored in the storage. - ResourceMutatingWebhookName string - - // ConfigValidationWebhookName is the name of the webhook we create to handle - // mutations before they get stored in the storage. - ConfigValidationWebhookName string - - // ServiceName is the service name of the webhook. - ServiceName string - - // SecretName is the name of k8s secret that contains the webhook - // server key/cert and corresponding CA cert that signed them. The - // server key/cert are used to serve the webhook and the CA cert - // is provided to k8s apiserver during admission controller - // registration. - SecretName string - - // Namespace is the namespace in which everything above lives. - Namespace string - - // Port where the webhook is served. Per k8s admission - // registration requirements this should be 443 unless there is - // only a single port for the service. - Port int - - // RegistrationDelay controls how long admission registration - // occurs after the webhook is started. This is used to avoid - // potential races where registration completes and k8s apiserver - // invokes the webhook before the HTTP server is started. - RegistrationDelay time.Duration - - // ClientAuthType declares the policy the webhook server will follow for - // TLS Client Authentication. - // The default value is tls.NoClientCert. - ClientAuth tls.ClientAuthType - - // StatsReporter reports metrics about the webhook. - // This will be automatically initialized by the constructor if left uninitialized. - StatsReporter StatsReporter - - // Service path for ResourceAdmissionController webhook - // Default is "/" for backward compatibility and is set by the constructor - ResourceAdmissionControllerPath string - - // Service path for ConfigValidationController webhook - // Default is "/config-validation" and is set by the constructor - ConfigValidationControllerPath string -} - -// AdmissionController provides the interface for different admission controllers -type AdmissionController interface { - Admit(context.Context, *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse - Register(context.Context, kubernetes.Interface, []byte) error -} - -// Webhook implements the external webhook for validation of -// resources and configuration. -type Webhook struct { - Client kubernetes.Interface - Options ControllerOptions - Logger *zap.SugaredLogger - admissionControllers map[string]AdmissionController - - WithContext func(context.Context) context.Context -} - -// New constructs a Webhook -func New( - client kubernetes.Interface, - opts ControllerOptions, - admissionControllers map[string]AdmissionController, - logger *zap.SugaredLogger, - ctx func(context.Context) context.Context, -) (*Webhook, error) { - - if opts.StatsReporter == nil { - reporter, err := NewStatsReporter() - if err != nil { - return nil, err - } - opts.StatsReporter = reporter - } - - return &Webhook{ - Client: client, - Options: opts, - admissionControllers: admissionControllers, - Logger: logger, - WithContext: ctx, - }, nil -} - -// Run implements the admission controller run loop. -func (ac *Webhook) Run(stop <-chan struct{}) error { - logger := ac.Logger - ctx := logging.WithLogger(context.TODO(), logger) - tlsConfig, caCert, err := configureCerts(ctx, ac.Client, &ac.Options) - if err != nil { - logger.Errorw("could not configure admission webhook certs", zap.Error(err)) - return err - } - - server := &http.Server{ - Handler: ac, - Addr: fmt.Sprintf(":%v", ac.Options.Port), - TLSConfig: tlsConfig, - } - - logger.Info("Found certificates for webhook...") - if ac.Options.RegistrationDelay != 0 { - logger.Infof("Delaying admission webhook registration for %v", ac.Options.RegistrationDelay) - } - - eg, ctx := errgroup.WithContext(ctx) - eg.Go(func() error { - select { - case <-time.After(ac.Options.RegistrationDelay): - // Wait an initial delay before registering - case <-stop: - return nil - } - // Register the webhook, and then periodically check that it is up to date. - for { - for _, c := range ac.admissionControllers { - if err := c.Register(ctx, ac.Client, caCert); err != nil { - logger.Errorw("failed to register webhook", zap.Error(err)) - return err - } - } - logger.Info("Successfully registered webhook") - select { - case <-time.After(10 * time.Minute): - case <-stop: - return nil - } - } - }) - eg.Go(func() error { - if err := server.ListenAndServeTLS("", ""); err != nil { - logger.Errorw("ListenAndServeTLS for admission webhook returned error", zap.Error(err)) - return err - } - return nil - }) - - select { - case <-stop: - return server.Close() - case <-ctx.Done(): - return fmt.Errorf("webhook server bootstrap failed %v", err) - } -} - -// ServeHTTP implements the external admission webhook for mutating -// serving resources. -func (ac *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request) { - var ttStart = time.Now() - logger := ac.Logger - logger.Infof("Webhook ServeHTTP request=%#v", r) - - // Verify the content type is accurate. - contentType := r.Header.Get("Content-Type") - if contentType != "application/json" { - http.Error(w, "invalid Content-Type, want `application/json`", http.StatusUnsupportedMediaType) - return - } - - var review admissionv1beta1.AdmissionReview - if err := json.NewDecoder(r.Body).Decode(&review); err != nil { - http.Error(w, fmt.Sprintf("could not decode body: %v", err), http.StatusBadRequest) - return - } - - logger = logger.With( - zap.String(logkey.Kind, fmt.Sprint(review.Request.Kind)), - zap.String(logkey.Namespace, review.Request.Namespace), - zap.String(logkey.Name, review.Request.Name), - zap.String(logkey.Operation, fmt.Sprint(review.Request.Operation)), - zap.String(logkey.Resource, fmt.Sprint(review.Request.Resource)), - zap.String(logkey.SubResource, fmt.Sprint(review.Request.SubResource)), - zap.String(logkey.UserInfo, fmt.Sprint(review.Request.UserInfo))) - ctx := logging.WithLogger(r.Context(), logger) - - if ac.WithContext != nil { - ctx = ac.WithContext(ctx) - } - - if _, ok := ac.admissionControllers[r.URL.Path]; !ok { - http.Error(w, fmt.Sprintf("no admission controller registered for: %s", r.URL.Path), http.StatusBadRequest) - return - } - - c := ac.admissionControllers[r.URL.Path] - reviewResponse := c.Admit(ctx, review.Request) - var response admissionv1beta1.AdmissionReview - if reviewResponse != nil { - response.Response = reviewResponse - response.Response.UID = review.Request.UID - } - - logger.Infof("AdmissionReview for %#v: %s/%s response=%#v", - review.Request.Kind, review.Request.Namespace, review.Request.Name, reviewResponse) - - if err := json.NewEncoder(w).Encode(response); err != nil { - http.Error(w, fmt.Sprintf("could encode response: %v", err), http.StatusInternalServerError) - return - } - - if ac.Options.StatsReporter != nil { - // Only report valid requests - ac.Options.StatsReporter.ReportRequest(review.Request, response.Response, time.Since(ttStart)) - } -} - -// GetAPIServerExtensionCACert gets the Kubernetes aggregate apiserver -// client CA cert used by validator. -// -// NOTE: this certificate is provided kubernetes. We do not control -// its name or location. -func getAPIServerExtensionCACert(cl kubernetes.Interface) ([]byte, error) { - const name = "extension-apiserver-authentication" - c, err := cl.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(name, metav1.GetOptions{}) - if err != nil { - return nil, err - } - const caFileName = "requestheader-client-ca-file" - pem, ok := c.Data[caFileName] - if !ok { - return nil, fmt.Errorf("cannot find %s in ConfigMap %s: ConfigMap.Data is %#v", caFileName, name, c.Data) - } - return []byte(pem), nil -} - -// MakeTLSConfig makes a TLS configuration suitable for use with the server -func makeTLSConfig(serverCert, serverKey, caCert []byte, clientAuthType tls.ClientAuthType) (*tls.Config, error) { - caCertPool := x509.NewCertPool() - caCertPool.AppendCertsFromPEM(caCert) - cert, err := tls.X509KeyPair(serverCert, serverKey) - if err != nil { - return nil, err - } - return &tls.Config{ - Certificates: []tls.Certificate{cert}, - ClientCAs: caCertPool, - ClientAuth: clientAuthType, - }, nil -} - -func getOrGenerateKeyCertsFromSecret(ctx context.Context, client kubernetes.Interface, - options *ControllerOptions) (serverKey, serverCert, caCert []byte, err error) { - logger := logging.FromContext(ctx) - secret, err := client.CoreV1().Secrets(options.Namespace).Get(options.SecretName, metav1.GetOptions{}) - if err != nil { - if !apierrors.IsNotFound(err) { - return nil, nil, nil, err - } - logger.Info("Did not find existing secret, creating one") - newSecret, err := generateSecret(ctx, options) - if err != nil { - return nil, nil, nil, err - } - secret, err = client.CoreV1().Secrets(newSecret.Namespace).Create(newSecret) - if err != nil { - if !apierrors.IsAlreadyExists(err) { - return nil, nil, nil, err - } - // OK, so something else might have created, try fetching it instead. - secret, err = client.CoreV1().Secrets(options.Namespace).Get(options.SecretName, metav1.GetOptions{}) - if err != nil { - return nil, nil, nil, err - } - } - } - - var ok bool - if serverKey, ok = secret.Data[secretServerKey]; !ok { - return nil, nil, nil, errors.New("server key missing") - } - if serverCert, ok = secret.Data[secretServerCert]; !ok { - return nil, nil, nil, errors.New("server cert missing") - } - if caCert, ok = secret.Data[secretCACert]; !ok { - return nil, nil, nil, errors.New("ca cert missing") - } - return serverKey, serverCert, caCert, nil -} - -func configureCerts(ctx context.Context, client kubernetes.Interface, options *ControllerOptions) (*tls.Config, []byte, error) { - var apiServerCACert []byte - if options.ClientAuth >= tls.VerifyClientCertIfGiven { - var err error - apiServerCACert, err = getAPIServerExtensionCACert(client) - if err != nil { - return nil, nil, err - } - } - - serverKey, serverCert, caCert, err := getOrGenerateKeyCertsFromSecret(ctx, client, options) - if err != nil { - return nil, nil, err - } - tlsConfig, err := makeTLSConfig(serverCert, serverKey, apiServerCACert, options.ClientAuth) - if err != nil { - return nil, nil, err - } - return tlsConfig, caCert, nil -} - -func makeErrorStatus(reason string, args ...interface{}) *admissionv1beta1.AdmissionResponse { - result := apierrors.NewBadRequest(fmt.Sprintf(reason, args...)).Status() - return &admissionv1beta1.AdmissionResponse{ - Result: &result, - Allowed: false, - } -} - -func generateSecret(ctx context.Context, options *ControllerOptions) (*corev1.Secret, error) { - serverKey, serverCert, caCert, err := CreateCerts(ctx, options.ServiceName, options.Namespace) - if err != nil { - return nil, err - } - return &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: options.SecretName, - Namespace: options.Namespace, - }, - Data: map[string][]byte{ - secretServerKey: serverKey, - secretServerCert: serverCert, - secretCACert: caCert, - }, - }, nil -} diff --git a/vendor/modules.txt b/vendor/modules.txt index dbb309c746..8fba0c0877 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# cloud.google.com/go v0.43.0 +# cloud.google.com/go v0.45.1 cloud.google.com/go/compute/metadata cloud.google.com/go/monitoring/apiv3 cloud.google.com/go/trace/apiv2 @@ -6,14 +6,14 @@ cloud.google.com/go/container/apiv1 cloud.google.com/go/internal/version # contrib.go.opencensus.io/exporter/prometheus v0.1.0 contrib.go.opencensus.io/exporter/prometheus -# contrib.go.opencensus.io/exporter/stackdriver v0.12.5 +# contrib.go.opencensus.io/exporter/stackdriver v0.12.9-0.20191108183826-59d068f8d8ff contrib.go.opencensus.io/exporter/stackdriver contrib.go.opencensus.io/exporter/stackdriver/monitoredresource # github.com/PuerkitoBio/purell v1.1.1 github.com/PuerkitoBio/purell # github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 github.com/PuerkitoBio/urlesc -# github.com/aws/aws-sdk-go v1.22.1 +# github.com/aws/aws-sdk-go v1.23.20 github.com/aws/aws-sdk-go/aws/ec2metadata github.com/aws/aws-sdk-go/aws/session github.com/aws/aws-sdk-go/aws @@ -45,6 +45,7 @@ github.com/aws/aws-sdk-go/private/protocol/rest github.com/aws/aws-sdk-go/private/protocol/query/queryutil github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil github.com/aws/aws-sdk-go/private/protocol +github.com/aws/aws-sdk-go/internal/sdkmath # github.com/beorn7/perks v1.0.0 github.com/beorn7/perks/quantile # github.com/census-instrumentation/opencensus-proto v0.2.1 @@ -72,20 +73,18 @@ github.com/go-openapi/jsonreference github.com/go-openapi/spec # github.com/go-openapi/swag v0.19.2 github.com/go-openapi/swag -# github.com/gobuffalo/envy v1.6.5 -github.com/gobuffalo/envy # github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d github.com/gogo/protobuf/proto github.com/gogo/protobuf/sortkeys -# github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef +# github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 github.com/golang/groupcache/lru # github.com/golang/protobuf v1.3.2 github.com/golang/protobuf/proto github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes +github.com/golang/protobuf/ptypes/duration github.com/golang/protobuf/ptypes/timestamp github.com/golang/protobuf/ptypes/wrappers -github.com/golang/protobuf/ptypes/duration github.com/golang/protobuf/ptypes/struct github.com/golang/protobuf/ptypes/empty github.com/golang/protobuf/protoc-gen-go/descriptor @@ -113,7 +112,7 @@ github.com/googleapis/gnostic/extensions # github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 github.com/gregjones/httpcache github.com/gregjones/httpcache/diskcache -# github.com/hashicorp/golang-lru v0.5.3 +# github.com/hashicorp/golang-lru v0.5.1 github.com/hashicorp/golang-lru github.com/hashicorp/golang-lru/simplelru # github.com/hashicorp/hcl v1.0.0 @@ -133,8 +132,6 @@ github.com/imdario/mergo github.com/inconshreveable/mousetrap # github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af github.com/jmespath/go-jmespath -# github.com/joho/godotenv v1.3.0 -github.com/joho/godotenv # github.com/json-iterator/go v1.1.7 github.com/json-iterator/go # github.com/magiconair/properties v1.8.0 @@ -144,8 +141,6 @@ github.com/magiconair/properties/assert github.com/mailru/easyjson/jlexer github.com/mailru/easyjson/jwriter github.com/mailru/easyjson/buffer -# github.com/markbates/inflect v1.0.4 -github.com/markbates/inflect # github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a github.com/mattbaird/jsonpatch # github.com/matttproud/golang_protobuf_extensions v1.0.1 @@ -197,7 +192,7 @@ github.com/spf13/jwalterweatherman github.com/spf13/pflag # github.com/spf13/viper v1.4.0 github.com/spf13/viper -# go.opencensus.io v0.22.0 +# go.opencensus.io v0.22.1 go.opencensus.io/stats go.opencensus.io/stats/view go.opencensus.io/tag @@ -230,7 +225,7 @@ go.uber.org/zap/internal/color go.uber.org/zap/internal/exit # golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 golang.org/x/crypto/ssh/terminal -# golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 +# golang.org/x/net v0.0.0-20190912160710-24e19bdeb0f2 golang.org/x/net/http2 golang.org/x/net/http/httpguts golang.org/x/net/http2/hpack @@ -246,8 +241,7 @@ golang.org/x/oauth2/google golang.org/x/oauth2/internal golang.org/x/oauth2/jws golang.org/x/oauth2/jwt -# golang.org/x/sync v0.0.0-20190423024810-112230192c58 -golang.org/x/sync/errgroup +# golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e golang.org/x/sync/semaphore # golang.org/x/sys v0.0.0-20191010194322-b09406accb47 golang.org/x/sys/unix @@ -266,7 +260,7 @@ golang.org/x/text/runes golang.org/x/text/width # golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 golang.org/x/time/rate -# google.golang.org/api v0.7.0 +# google.golang.org/api v0.14.0 google.golang.org/api/option google.golang.org/api/support/bundler google.golang.org/api/internal @@ -276,7 +270,7 @@ google.golang.org/api/transport/grpc google.golang.org/api/transport/http google.golang.org/api/googleapi/transport google.golang.org/api/transport/http/internal/propagation -# google.golang.org/appengine v1.6.1 +# google.golang.org/appengine v1.6.2 google.golang.org/appengine google.golang.org/appengine/urlfetch google.golang.org/appengine/internal @@ -289,7 +283,7 @@ google.golang.org/appengine/internal/log google.golang.org/appengine/internal/remote_api google.golang.org/appengine/socket google.golang.org/appengine/internal/socket -# google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64 +# google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51 google.golang.org/genproto/googleapis/api/distribution google.golang.org/genproto/googleapis/api/label google.golang.org/genproto/googleapis/api/metric @@ -393,7 +387,6 @@ k8s.io/api/settings/v1alpha1 k8s.io/api/storage/v1 k8s.io/api/storage/v1alpha1 k8s.io/api/storage/v1beta1 -k8s.io/api/admission/v1beta1 # k8s.io/apimachinery v0.0.0-20191004115701-31ade1b30762 k8s.io/apimachinery/pkg/apis/meta/v1 k8s.io/apimachinery/pkg/apis/meta/v1/unstructured @@ -622,33 +615,35 @@ k8s.io/kube-openapi/pkg/common k8s.io/utils/integer k8s.io/utils/buffer k8s.io/utils/trace -# knative.dev/eventing v0.10.0 +# knative.dev/eventing v0.11.0 knative.dev/eventing/pkg/apis/sources/v1alpha1 knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1 knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake knative.dev/eventing/pkg/apis/duck knative.dev/eventing/pkg/apis/sources +knative.dev/eventing/pkg/logging knative.dev/eventing/pkg/client/clientset/versioned/scheme knative.dev/eventing/pkg/apis/eventing/v1alpha1 +knative.dev/eventing/pkg/apis/flows/v1alpha1 knative.dev/eventing/pkg/apis/messaging/v1alpha1 knative.dev/eventing/pkg/apis/duck/v1alpha1 knative.dev/eventing/pkg/apis/eventing +knative.dev/eventing/pkg/apis/flows knative.dev/eventing/pkg/apis/messaging -# knative.dev/pkg v0.0.0-20191107185656-884d50f09454 +# knative.dev/pkg v0.0.0-20191203221237-94a34e416c44 knative.dev/pkg/apis knative.dev/pkg/apis/duck/v1 -knative.dev/pkg/apis/v1alpha1 +knative.dev/pkg/apis/duck/v1beta1 knative.dev/pkg/ptr +knative.dev/pkg/apis/duck +knative.dev/pkg/apis/duck/v1alpha1 knative.dev/pkg/kmeta +knative.dev/pkg/tracker knative.dev/pkg/kmp -knative.dev/pkg/apis/duck knative.dev/pkg/profiling -knative.dev/pkg/apis/duck/v1alpha1 -knative.dev/pkg/configmap knative.dev/pkg/logging +knative.dev/pkg/configmap knative.dev/pkg/network -knative.dev/pkg/apis/duck/v1beta1 -knative.dev/pkg/webhook knative.dev/pkg/changeset knative.dev/pkg/logging/logkey knative.dev/pkg/controller