From 6bb2020de264be1854ede429e90b0d8d61e85721 Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Fri, 17 Jan 2020 23:34:41 +0000 Subject: [PATCH 01/11] dep on serving and make service helper --- Gopkg.lock | 80 ++- Gopkg.toml | 6 +- config/200-controller-clusterrole.yaml | 133 +++- .../eventing/v1alpha1/broker_lifecycle.go | 8 + pkg/reconciler/broker/broker.go | 247 ++++--- pkg/reconciler/broker/broker_test.go | 403 ++++++++--- pkg/reconciler/broker/controller.go | 11 +- pkg/reconciler/broker/controller_test.go | 1 + pkg/reconciler/broker/resources/filter.go | 193 ++---- .../broker/resources/filter_test.go | 277 -------- pkg/reconciler/broker/resources/ingress.go | 183 ++--- pkg/reconciler/service_helper.go | 360 ++++++++++ pkg/reconciler/testing/broker.go | 6 + pkg/reconciler/testing/factory.go | 5 +- pkg/reconciler/testing/listers.go | 13 + pkg/reconciler/testing/serving_service.go | 125 ++++ pkg/reconciler/trigger/controller.go | 12 +- pkg/reconciler/trigger/controller_test.go | 2 + pkg/reconciler/trigger/trigger.go | 22 +- pkg/reconciler/trigger/trigger_test.go | 136 ++-- third_party/VENDOR-LICENSE | 415 ++++++++++++ .../google/go-containerregistry/LICENSE | 202 ++++++ .../go-containerregistry/pkg/name/check.go | 43 ++ .../go-containerregistry/pkg/name/digest.go | 90 +++ .../go-containerregistry/pkg/name/doc.go | 42 ++ .../go-containerregistry/pkg/name/errors.go | 37 + .../go-containerregistry/pkg/name/options.go | 49 ++ .../go-containerregistry/pkg/name/ref.go | 49 ++ .../go-containerregistry/pkg/name/registry.go | 142 ++++ .../pkg/name/repository.go | 101 +++ .../go-containerregistry/pkg/name/tag.go | 102 +++ vendor/github.com/mailru/easyjson/helpers.go | 78 +++ vendor/github.com/mailru/easyjson/raw.go | 45 ++ .../github.com/tsenart/vegeta/lib/attack.go | 24 + .../tsenart/vegeta/lib/attack_fuzz.go | 154 +++++ .../github.com/tsenart/vegeta/lib/metrics.go | 13 + vendor/github.com/tsenart/vegeta/lib/pacer.go | 60 ++ .../tsenart/vegeta/lib/reporters.go | 4 +- .../github.com/tsenart/vegeta/lib/results.go | 32 +- .../tsenart/vegeta/lib/results_easyjson.go | 150 ++--- .../tsenart/vegeta/lib/results_fuzz.go | 63 ++ .../github.com/tsenart/vegeta/lib/targets.go | 6 +- .../tsenart/vegeta/lib/targets_fuzz.go | 68 ++ .../tsenart/vegeta/lib/util_fuzz.go | 120 ++++ vendor/go.opencensus.io/trace/trace.go | 7 - vendor/k8s.io/code-generator/Godeps/OWNERS | 4 + vendor/k8s.io/code-generator/OWNERS | 13 + .../code-generator/cmd/client-gen/OWNERS | 10 + .../code-generator/cmd/go-to-protobuf/OWNERS | 6 + vendor/knative.dev/pkg/OWNERS | 4 + vendor/knative.dev/pkg/OWNERS_ALIASES | 67 ++ vendor/knative.dev/pkg/apis/OWNERS | 4 + vendor/knative.dev/pkg/apis/duck/OWNERS | 4 + vendor/knative.dev/pkg/configmap/OWNERS | 4 + vendor/knative.dev/pkg/controller/OWNERS | 4 + vendor/knative.dev/pkg/hack/OWNERS | 10 + vendor/knative.dev/pkg/injection/OWNERS | 5 + vendor/knative.dev/pkg/kmeta/OWNERS | 4 + vendor/knative.dev/pkg/logging/OWNERS | 4 + vendor/knative.dev/pkg/metrics/OWNERS | 4 + vendor/knative.dev/pkg/network/OWNERS | 5 + vendor/knative.dev/pkg/reconciler/OWNERS | 4 + vendor/knative.dev/pkg/resolver/OWNERS | 5 + vendor/knative.dev/pkg/source/OWNERS | 4 + vendor/knative.dev/pkg/test/OWNERS | 10 + vendor/knative.dev/pkg/testutils/OWNERS | 4 + vendor/knative.dev/pkg/webhook/OWNERS | 4 + vendor/knative.dev/pkg/websocket/OWNERS | 4 + vendor/knative.dev/serving/AUTHORS | 11 + vendor/knative.dev/serving/LICENSE | 202 ++++++ .../serving/cmd/activator/kodata/HEAD | 1 + .../serving/cmd/activator/kodata/LICENSE | 1 + .../cmd/activator/kodata/VENDOR-LICENSE | 1 + .../serving/cmd/activator/kodata/refs | 1 + .../serving/cmd/autoscaler-hpa/kodata/HEAD | 1 + .../serving/cmd/autoscaler-hpa/kodata/LICENSE | 1 + .../cmd/autoscaler-hpa/kodata/VENDOR-LICENSE | 1 + .../serving/cmd/autoscaler-hpa/kodata/refs | 1 + .../serving/cmd/autoscaler/kodata/HEAD | 1 + .../serving/cmd/autoscaler/kodata/LICENSE | 1 + .../cmd/autoscaler/kodata/VENDOR-LICENSE | 1 + .../serving/cmd/autoscaler/kodata/refs | 1 + .../serving/cmd/controller/kodata/HEAD | 1 + .../serving/cmd/controller/kodata/LICENSE | 1 + .../cmd/controller/kodata/VENDOR-LICENSE | 1 + .../serving/cmd/controller/kodata/refs | 1 + .../cmd/networking/certmanager/kodata/HEAD | 1 + .../cmd/networking/certmanager/kodata/LICENSE | 1 + .../certmanager/kodata/VENDOR-LICENSE | 1 + .../cmd/networking/certmanager/kodata/refs | 1 + .../serving/cmd/networking/istio/kodata/HEAD | 1 + .../cmd/networking/istio/kodata/LICENSE | 1 + .../networking/istio/kodata/VENDOR-LICENSE | 1 + .../serving/cmd/networking/istio/kodata/refs | 1 + .../serving/cmd/networking/nscert/kodata/HEAD | 1 + .../cmd/networking/nscert/kodata/LICENSE | 1 + .../networking/nscert/kodata/VENDOR-LICENSE | 1 + .../knative.dev/serving/cmd/queue/kodata/HEAD | 1 + .../serving/cmd/queue/kodata/LICENSE | 1 + .../serving/cmd/queue/kodata/VENDOR-LICENSE | 1 + .../knative.dev/serving/cmd/queue/kodata/refs | 1 + .../serving/cmd/webhook/kodata/HEAD | 1 + .../serving/cmd/webhook/kodata/LICENSE | 1 + .../serving/cmd/webhook/kodata/VENDOR-LICENSE | 1 + .../serving/cmd/webhook/kodata/refs | 1 + .../serving/config/100-namespace.yaml | 1 + ...200-addressable-resolvers-clusterrole.yaml | 1 + .../config/200-clusterrole-certmanager.yaml | 1 + .../serving/config/200-clusterrole-istio.yaml | 1 + .../config/200-clusterrole-metrics.yaml | 1 + .../config/200-clusterrole-namespaced.yaml | 1 + .../serving/config/200-clusterrole.yaml | 1 + .../200-podspecable-bindings-clusterrole.yaml | 1 + .../serving/config/200-serviceaccount.yaml | 1 + ...201-clusterrolebinding-metrics-server.yaml | 1 + .../201-clusterrolebinding-metrics.yaml | 1 + .../config/201-clusterrolebinding.yaml | 1 + .../201-rolebinding-metrics-server.yaml | 1 + .../serving/config/202-gateway.yaml | 1 + .../serving/config/203-local-gateway.yaml | 1 + .../serving/config/300-certificate.yaml | 1 + .../serving/config/300-configuration.yaml | 1 + .../serving/config/300-imagecache.yaml | 1 + .../serving/config/300-ingress.yaml | 1 + .../serving/config/300-metric.yaml | 1 + vendor/knative.dev/serving/config/300-pa.yaml | 1 + .../serving/config/300-revision.yaml | 1 + .../knative.dev/serving/config/300-route.yaml | 1 + .../serving/config/300-service.yaml | 1 + .../knative.dev/serving/config/300-sks.yaml | 1 + .../500-webhook-configmap-validation.yaml | 1 + .../config/500-webhook-defaulting.yaml | 1 + .../500-webhook-resource-validation.yaml | 1 + .../serving/config/500-webhook-secret.yaml | 1 + .../knative.dev/serving/config/999-cache.yaml | 1 + .../serving/config/activator-hpa.yaml | 1 + .../knative.dev/serving/config/activator.yaml | 1 + .../serving/config/autoscaler-hpa.yaml | 1 + .../serving/config/autoscaler.yaml | 1 + .../serving/config/config-autoscaler.yaml | 1 + .../serving/config/config-certmanager.yaml | 1 + .../serving/config/config-defaults.yaml | 1 + .../serving/config/config-deployment.yaml | 1 + .../serving/config/config-domain.yaml | 1 + .../knative.dev/serving/config/config-gc.yaml | 1 + .../serving/config/config-istio.yaml | 1 + .../serving/config/config-logging.yaml | 1 + .../serving/config/config-network.yaml | 1 + .../serving/config/config-observability.yaml | 1 + .../serving/config/config-tracing.yaml | 1 + .../serving/config/controller.yaml | 1 + .../config/custom-metrics-apiservice.yaml | 1 + .../config/networking-certmanager.yaml | 1 + .../serving/config/networking-istio.yaml | 1 + .../serving/config/networking-ns-cert.yaml | 1 + .../knative.dev/serving/config/webhook.yaml | 1 + .../apis/autoscaling/annotation_validation.go | 146 ++++ .../serving/pkg/apis/autoscaling/register.go | 160 +++++ .../pkg/apis/autoscaling/v1alpha1/doc.go | 19 + .../autoscaling/v1alpha1/metric_defaults.go | 31 + .../autoscaling/v1alpha1/metric_lifecycle.go | 73 ++ .../apis/autoscaling/v1alpha1/metric_types.go | 79 +++ .../autoscaling/v1alpha1/metric_validation.go | 39 ++ .../apis/autoscaling/v1alpha1/pa_defaults.go | 52 ++ .../apis/autoscaling/v1alpha1/pa_lifecycle.go | 237 +++++++ .../pkg/apis/autoscaling/v1alpha1/pa_types.go | 142 ++++ .../autoscaling/v1alpha1/pa_validation.go | 42 ++ .../autoscaling/v1alpha1/podscalable_types.go | 113 ++++ .../pkg/apis/autoscaling/v1alpha1/register.go | 55 ++ .../v1alpha1/zz_generated.deepcopy.go | 329 +++++++++ .../serving/pkg/apis/config/defaults.go | 172 +++++ .../serving/pkg/apis/config/doc.go | 21 + .../serving/pkg/apis/config/store.go | 92 +++ .../apis/config/testdata/config-defaults.yaml | 1 + .../pkg/apis/config/zz_generated.deepcopy.go | 57 ++ .../pkg/apis/networking/generic_types.go | 48 ++ .../serving/pkg/apis/networking/ports.go | 68 ++ .../serving/pkg/apis/networking/register.go | 111 +++ .../v1alpha1/certificate_defaults.go | 24 + .../v1alpha1/certificate_lifecycle.go | 80 +++ .../networking/v1alpha1/certificate_types.go | 117 ++++ .../v1alpha1/certificate_validation.go | 49 ++ .../pkg/apis/networking/v1alpha1/doc.go | 24 + .../networking/v1alpha1/ingress_defaults.go | 94 +++ .../networking/v1alpha1/ingress_lifecycle.go | 99 +++ .../apis/networking/v1alpha1/ingress_types.go | 343 ++++++++++ .../networking/v1alpha1/ingress_validation.go | 174 +++++ .../pkg/apis/networking/v1alpha1/register.go | 56 ++ .../v1alpha1/serverlessservice_defaults.go | 29 + .../v1alpha1/serverlessservice_lifecycle.go | 106 +++ .../v1alpha1/serverlessservice_types.go | 135 ++++ .../v1alpha1/serverlessservice_validation.go | 52 ++ .../v1alpha1/zz_generated.deepcopy.go | 586 ++++++++++++++++ .../serving/pkg/apis/serving/fieldmask.go | 569 ++++++++++++++++ .../serving/pkg/apis/serving/k8s_lifecycle.go | 78 +++ .../pkg/apis/serving/k8s_validation.go | 544 +++++++++++++++ .../pkg/apis/serving/metadata_validation.go | 171 +++++ .../serving/pkg/apis/serving/register.go | 72 ++ .../serving/v1/configuration_conversion.go | 34 + .../apis/serving/v1/configuration_defaults.go | 42 ++ .../serving/v1/configuration_lifecycle.go | 35 + .../apis/serving/v1/configuration_types.go | 102 +++ .../serving/v1/configuration_validation.go | 98 +++ .../serving/pkg/apis/serving/v1/contexts.go | 52 ++ .../serving/pkg/apis/serving/v1/doc.go | 21 + .../serving/pkg/apis/serving/v1/register.go | 61 ++ .../apis/serving/v1/revision_conversion.go | 34 + .../pkg/apis/serving/v1/revision_defaults.go | 102 +++ .../pkg/apis/serving/v1/revision_lifecycle.go | 55 ++ .../pkg/apis/serving/v1/revision_types.go | 125 ++++ .../apis/serving/v1/revision_validation.go | 129 ++++ .../pkg/apis/serving/v1/route_conversion.go | 34 + .../pkg/apis/serving/v1/route_defaults.go | 58 ++ .../pkg/apis/serving/v1/route_lifecycle.go | 35 + .../pkg/apis/serving/v1/route_types.go | 159 +++++ .../pkg/apis/serving/v1/route_validation.go | 226 +++++++ .../pkg/apis/serving/v1/service_conversion.go | 34 + .../pkg/apis/serving/v1/service_defaults.go | 42 ++ .../pkg/apis/serving/v1/service_lifecycle.go | 35 + .../pkg/apis/serving/v1/service_types.go | 113 ++++ .../pkg/apis/serving/v1/service_validation.go | 79 +++ .../apis/serving/v1/zz_generated.deepcopy.go | 526 +++++++++++++++ .../v1alpha1/configuration_conversion.go | 117 ++++ .../v1alpha1/configuration_defaults.go | 52 ++ .../v1alpha1/configuration_lifecycle.go | 119 ++++ .../serving/v1alpha1/configuration_types.go | 131 ++++ .../v1alpha1/configuration_validation.go | 84 +++ .../apis/serving/v1alpha1/conversion_error.go | 51 ++ .../serving/pkg/apis/serving/v1alpha1/doc.go | 23 + .../pkg/apis/serving/v1alpha1/register.go | 59 ++ .../serving/v1alpha1/revision_conversion.go | 120 ++++ .../serving/v1alpha1/revision_defaults.go | 68 ++ .../serving/v1alpha1/revision_lifecycle.go | 359 ++++++++++ .../apis/serving/v1alpha1/revision_types.go | 205 ++++++ .../serving/v1alpha1/revision_validation.go | 162 +++++ .../apis/serving/v1alpha1/route_conversion.go | 143 ++++ .../apis/serving/v1alpha1/route_defaults.go | 62 ++ .../apis/serving/v1alpha1/route_lifecycle.go | 175 +++++ .../pkg/apis/serving/v1alpha1/route_types.go | 163 +++++ .../apis/serving/v1alpha1/route_validation.go | 107 +++ .../serving/v1alpha1/service_conversion.go | 157 +++++ .../apis/serving/v1alpha1/service_defaults.go | 60 ++ .../serving/v1alpha1/service_lifecycle.go | 161 +++++ .../apis/serving/v1alpha1/service_types.go | 194 ++++++ .../serving/v1alpha1/service_validation.go | 183 +++++ .../serving/v1alpha1/zz_generated.deepcopy.go | 635 ++++++++++++++++++ .../v1beta1/configuration_conversion.go | 34 + .../serving/v1beta1/configuration_defaults.go | 37 + .../v1beta1/configuration_lifecycle.go | 24 + .../serving/v1beta1/configuration_types.go | 73 ++ .../v1beta1/configuration_validation.go | 83 +++ .../serving/pkg/apis/serving/v1beta1/doc.go | 23 + .../pkg/apis/serving/v1beta1/register.go | 59 ++ .../serving/v1beta1/revision_conversion.go | 34 + .../apis/serving/v1beta1/revision_defaults.go | 26 + .../serving/v1beta1/revision_lifecycle.go | 31 + .../apis/serving/v1beta1/revision_types.go | 73 ++ .../serving/v1beta1/revision_validation.go | 68 ++ .../apis/serving/v1beta1/route_conversion.go | 34 + .../apis/serving/v1beta1/route_defaults.go | 36 + .../apis/serving/v1beta1/route_lifecycle.go | 24 + .../pkg/apis/serving/v1beta1/route_types.go | 77 +++ .../apis/serving/v1beta1/route_validation.go | 60 ++ .../serving/v1beta1/service_conversion.go | 34 + .../apis/serving/v1beta1/service_defaults.go | 35 + .../apis/serving/v1beta1/service_lifecycle.go | 24 + .../pkg/apis/serving/v1beta1/service_types.go | 82 +++ .../serving/v1beta1/service_validation.go | 65 ++ .../serving/v1beta1/zz_generated.deepcopy.go | 269 ++++++++ .../testdata/config-autoscaler.yaml | 1 + .../client/clientset/versioned/clientset.go | 153 +++++ .../pkg/client/clientset/versioned/doc.go | 20 + .../versioned/fake/clientset_generated.go | 110 +++ .../client/clientset/versioned/fake/doc.go | 20 + .../clientset/versioned/fake/register.go | 64 ++ .../client/clientset/versioned/scheme/doc.go | 20 + .../clientset/versioned/scheme/register.go | 64 ++ .../v1alpha1/autoscaling_client.go | 94 +++ .../typed/autoscaling/v1alpha1/doc.go | 20 + .../typed/autoscaling/v1alpha1/fake/doc.go | 20 + .../v1alpha1/fake/fake_autoscaling_client.go | 44 ++ .../autoscaling/v1alpha1/fake/fake_metric.go | 140 ++++ .../v1alpha1/fake/fake_podautoscaler.go | 140 ++++ .../v1alpha1/generated_expansion.go | 23 + .../typed/autoscaling/v1alpha1/metric.go | 191 ++++++ .../autoscaling/v1alpha1/podautoscaler.go | 191 ++++++ .../typed/networking/v1alpha1/certificate.go | 191 ++++++ .../typed/networking/v1alpha1/doc.go | 20 + .../typed/networking/v1alpha1/fake/doc.go | 20 + .../v1alpha1/fake/fake_certificate.go | 140 ++++ .../networking/v1alpha1/fake/fake_ingress.go | 140 ++++ .../v1alpha1/fake/fake_networking_client.go | 48 ++ .../v1alpha1/fake/fake_serverlessservice.go | 140 ++++ .../v1alpha1/generated_expansion.go | 25 + .../typed/networking/v1alpha1/ingress.go | 191 ++++++ .../networking/v1alpha1/networking_client.go | 99 +++ .../networking/v1alpha1/serverlessservice.go | 191 ++++++ .../typed/serving/v1/configuration.go | 191 ++++++ .../versioned/typed/serving/v1/doc.go | 20 + .../versioned/typed/serving/v1/fake/doc.go | 20 + .../serving/v1/fake/fake_configuration.go | 140 ++++ .../typed/serving/v1/fake/fake_revision.go | 140 ++++ .../typed/serving/v1/fake/fake_route.go | 140 ++++ .../typed/serving/v1/fake/fake_service.go | 140 ++++ .../serving/v1/fake/fake_serving_client.go | 52 ++ .../typed/serving/v1/generated_expansion.go | 27 + .../versioned/typed/serving/v1/revision.go | 191 ++++++ .../versioned/typed/serving/v1/route.go | 191 ++++++ .../versioned/typed/serving/v1/service.go | 191 ++++++ .../typed/serving/v1/serving_client.go | 104 +++ .../typed/serving/v1alpha1/configuration.go | 191 ++++++ .../versioned/typed/serving/v1alpha1/doc.go | 20 + .../typed/serving/v1alpha1/fake/doc.go | 20 + .../v1alpha1/fake/fake_configuration.go | 140 ++++ .../serving/v1alpha1/fake/fake_revision.go | 140 ++++ .../typed/serving/v1alpha1/fake/fake_route.go | 140 ++++ .../serving/v1alpha1/fake/fake_service.go | 140 ++++ .../v1alpha1/fake/fake_serving_client.go | 52 ++ .../serving/v1alpha1/generated_expansion.go | 27 + .../typed/serving/v1alpha1/revision.go | 191 ++++++ .../versioned/typed/serving/v1alpha1/route.go | 191 ++++++ .../typed/serving/v1alpha1/service.go | 191 ++++++ .../typed/serving/v1alpha1/serving_client.go | 104 +++ .../typed/serving/v1beta1/configuration.go | 191 ++++++ .../versioned/typed/serving/v1beta1/doc.go | 20 + .../typed/serving/v1beta1/fake/doc.go | 20 + .../v1beta1/fake/fake_configuration.go | 140 ++++ .../serving/v1beta1/fake/fake_revision.go | 140 ++++ .../typed/serving/v1beta1/fake/fake_route.go | 140 ++++ .../serving/v1beta1/fake/fake_service.go | 140 ++++ .../v1beta1/fake/fake_serving_client.go | 52 ++ .../serving/v1beta1/generated_expansion.go | 27 + .../typed/serving/v1beta1/revision.go | 191 ++++++ .../versioned/typed/serving/v1beta1/route.go | 191 ++++++ .../typed/serving/v1beta1/service.go | 191 ++++++ .../typed/serving/v1beta1/serving_client.go | 104 +++ .../externalversions/autoscaling/interface.go | 46 ++ .../autoscaling/v1alpha1/interface.go | 52 ++ .../autoscaling/v1alpha1/metric.go | 89 +++ .../autoscaling/v1alpha1/podautoscaler.go | 89 +++ .../informers/externalversions/factory.go | 192 ++++++ .../informers/externalversions/generic.go | 106 +++ .../internalinterfaces/factory_interfaces.go | 40 ++ .../externalversions/networking/interface.go | 46 ++ .../networking/v1alpha1/certificate.go | 89 +++ .../networking/v1alpha1/ingress.go | 89 +++ .../networking/v1alpha1/interface.go | 59 ++ .../networking/v1alpha1/serverlessservice.go | 89 +++ .../externalversions/serving/interface.go | 62 ++ .../serving/v1/configuration.go | 89 +++ .../externalversions/serving/v1/interface.go | 66 ++ .../externalversions/serving/v1/revision.go | 89 +++ .../externalversions/serving/v1/route.go | 89 +++ .../externalversions/serving/v1/service.go | 89 +++ .../serving/v1alpha1/configuration.go | 89 +++ .../serving/v1alpha1/interface.go | 66 ++ .../serving/v1alpha1/revision.go | 89 +++ .../serving/v1alpha1/route.go | 89 +++ .../serving/v1alpha1/service.go | 89 +++ .../serving/v1beta1/configuration.go | 89 +++ .../serving/v1beta1/interface.go | 66 ++ .../serving/v1beta1/revision.go | 89 +++ .../externalversions/serving/v1beta1/route.go | 89 +++ .../serving/v1beta1/service.go | 89 +++ .../pkg/client/injection/client/client.go | 49 ++ .../pkg/client/injection/client/fake/fake.go | 54 ++ .../injection/informers/factory/factory.go | 56 ++ .../injection/informers/factory/fake/fake.go | 45 ++ .../informers/serving/v1/service/fake/fake.go | 40 ++ .../informers/serving/v1/service/service.go | 52 ++ .../v1alpha1/expansion_generated.go | 35 + .../listers/autoscaling/v1alpha1/metric.go | 94 +++ .../autoscaling/v1alpha1/podautoscaler.go | 94 +++ .../networking/v1alpha1/certificate.go | 94 +++ .../v1alpha1/expansion_generated.go | 43 ++ .../listers/networking/v1alpha1/ingress.go | 94 +++ .../networking/v1alpha1/serverlessservice.go | 94 +++ .../listers/serving/v1/configuration.go | 94 +++ .../listers/serving/v1/expansion_generated.go | 51 ++ .../pkg/client/listers/serving/v1/revision.go | 94 +++ .../pkg/client/listers/serving/v1/route.go | 94 +++ .../pkg/client/listers/serving/v1/service.go | 94 +++ .../listers/serving/v1alpha1/configuration.go | 94 +++ .../serving/v1alpha1/expansion_generated.go | 51 ++ .../listers/serving/v1alpha1/revision.go | 94 +++ .../client/listers/serving/v1alpha1/route.go | 94 +++ .../listers/serving/v1alpha1/service.go | 94 +++ .../listers/serving/v1beta1/configuration.go | 94 +++ .../serving/v1beta1/expansion_generated.go | 51 ++ .../listers/serving/v1beta1/revision.go | 94 +++ .../client/listers/serving/v1beta1/route.go | 94 +++ .../client/listers/serving/v1beta1/service.go | 94 +++ .../testdata/config-deployment.yaml | 1 + vendor/knative.dev/serving/pkg/gc/config.go | 95 +++ vendor/knative.dev/serving/pkg/gc/doc.go | 20 + .../serving/pkg/gc/testdata/config-gc.yaml | 1 + .../serving/pkg/gc/zz_generated.deepcopy.go | 37 + .../pkg/logging/testdata/config-logging.yaml | 1 + .../logging/testdata/test-config-logging.yaml | 1 + .../testdata/config-observability.yaml | 1 + .../serving/pkg/network/bufferpool.go | 55 ++ vendor/knative.dev/serving/pkg/network/doc.go | 20 + .../serving/pkg/network/network.go | 406 +++++++++++ .../serving/pkg/network/probe_handler.go | 52 ++ .../pkg/network/testdata/config-network.yaml | 1 + .../pkg/network/zz_generated.deepcopy.go | 76 +++ .../config/testdata/config-certmanager.yaml | 1 + .../gc/config/testdata/config-gc.yaml | 1 + .../ingress/config/testdata/config-istio.yaml | 1 + .../config/testdata/config-network.yaml | 1 + .../config/testdata/config-autoscaler.yaml | 1 + .../config/testdata/config-defaults.yaml | 1 + .../config/testdata/config-deployment.yaml | 1 + .../config/testdata/config-logging.yaml | 1 + .../config/testdata/config-network.yaml | 1 + .../config/testdata/config-observability.yaml | 1 + .../pkg/reconciler/route/config/doc.go | 20 + .../pkg/reconciler/route/config/domain.go | 122 ++++ .../pkg/reconciler/route/config/store.go | 91 +++ .../route/config/testdata/config-domain.yaml | 1 + .../route/config/testdata/config-gc.yaml | 1 + .../route/config/testdata/config-network.yaml | 1 + .../route/config/zz_generated.deepcopy.go | 75 +++ .../dataplane-probe/continuous/kodata/HEAD | 1 + .../continuous/kodata/dev.config | 1 + .../continuous/kodata/prod.config | 1 + .../dataplane-probe/continuous/kodata/refs | 1 + .../deployment-probe/continuous/kodata/HEAD | 1 + .../continuous/kodata/dev.config | 1 + .../continuous/kodata/prod.config | 1 + .../deployment-probe/continuous/kodata/refs | 1 + .../load-test/continuous/kodata/HEAD | 1 + .../load-test/continuous/kodata/dev.config | 1 + .../load-test/continuous/kodata/prod.config | 1 + .../load-test/continuous/kodata/refs | 1 + .../scale-from-zero/continuous/kodata/HEAD | 1 + .../continuous/kodata/dev.config | 1 + .../continuous/kodata/prod.config | 1 + .../scale-from-zero/continuous/kodata/refs | 1 + .../monitoring/logging/elasticsearch/LICENSE | 201 ++++++ .../metrics/prometheus/kubernetes/LICENSE | 201 ++++++ .../prometheus/prometheus-operator/LICENSE | 202 ++++++ .../prometheus/prometheus-operator/NOTICE | 5 + .../serving/third_party/istio-1.3-latest | 1 + .../serving/third_party/istio-1.4-latest | 1 + 445 files changed, 29861 insertions(+), 874 deletions(-) mode change 120000 => 100644 config/200-controller-clusterrole.yaml delete mode 100644 pkg/reconciler/broker/resources/filter_test.go create mode 100644 pkg/reconciler/service_helper.go create mode 100644 pkg/reconciler/testing/serving_service.go create mode 100644 vendor/github.com/google/go-containerregistry/LICENSE create mode 100644 vendor/github.com/google/go-containerregistry/pkg/name/check.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/name/digest.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/name/doc.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/name/errors.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/name/options.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/name/ref.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/name/registry.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/name/repository.go create mode 100644 vendor/github.com/google/go-containerregistry/pkg/name/tag.go create mode 100644 vendor/github.com/mailru/easyjson/helpers.go create mode 100644 vendor/github.com/mailru/easyjson/raw.go create mode 100644 vendor/github.com/tsenart/vegeta/lib/attack_fuzz.go create mode 100644 vendor/github.com/tsenart/vegeta/lib/results_fuzz.go create mode 100644 vendor/github.com/tsenart/vegeta/lib/targets_fuzz.go create mode 100644 vendor/github.com/tsenart/vegeta/lib/util_fuzz.go create mode 100644 vendor/k8s.io/code-generator/Godeps/OWNERS create mode 100644 vendor/k8s.io/code-generator/OWNERS create mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/OWNERS create mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS create mode 100644 vendor/knative.dev/pkg/OWNERS create mode 100644 vendor/knative.dev/pkg/OWNERS_ALIASES create mode 100644 vendor/knative.dev/pkg/apis/OWNERS create mode 100644 vendor/knative.dev/pkg/apis/duck/OWNERS create mode 100644 vendor/knative.dev/pkg/configmap/OWNERS create mode 100644 vendor/knative.dev/pkg/controller/OWNERS create mode 100644 vendor/knative.dev/pkg/hack/OWNERS create mode 100644 vendor/knative.dev/pkg/injection/OWNERS create mode 100644 vendor/knative.dev/pkg/kmeta/OWNERS create mode 100644 vendor/knative.dev/pkg/logging/OWNERS create mode 100644 vendor/knative.dev/pkg/metrics/OWNERS create mode 100644 vendor/knative.dev/pkg/network/OWNERS create mode 100644 vendor/knative.dev/pkg/reconciler/OWNERS create mode 100644 vendor/knative.dev/pkg/resolver/OWNERS create mode 100644 vendor/knative.dev/pkg/source/OWNERS create mode 100644 vendor/knative.dev/pkg/test/OWNERS create mode 100644 vendor/knative.dev/pkg/testutils/OWNERS create mode 100644 vendor/knative.dev/pkg/webhook/OWNERS create mode 100644 vendor/knative.dev/pkg/websocket/OWNERS create mode 100644 vendor/knative.dev/serving/AUTHORS create mode 100644 vendor/knative.dev/serving/LICENSE create mode 120000 vendor/knative.dev/serving/cmd/activator/kodata/HEAD create mode 120000 vendor/knative.dev/serving/cmd/activator/kodata/LICENSE create mode 120000 vendor/knative.dev/serving/cmd/activator/kodata/VENDOR-LICENSE create mode 120000 vendor/knative.dev/serving/cmd/activator/kodata/refs create mode 120000 vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/HEAD create mode 120000 vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/LICENSE create mode 120000 vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/VENDOR-LICENSE create mode 120000 vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/refs create mode 120000 vendor/knative.dev/serving/cmd/autoscaler/kodata/HEAD create mode 120000 vendor/knative.dev/serving/cmd/autoscaler/kodata/LICENSE create mode 120000 vendor/knative.dev/serving/cmd/autoscaler/kodata/VENDOR-LICENSE create mode 120000 vendor/knative.dev/serving/cmd/autoscaler/kodata/refs create mode 120000 vendor/knative.dev/serving/cmd/controller/kodata/HEAD create mode 120000 vendor/knative.dev/serving/cmd/controller/kodata/LICENSE create mode 120000 vendor/knative.dev/serving/cmd/controller/kodata/VENDOR-LICENSE create mode 120000 vendor/knative.dev/serving/cmd/controller/kodata/refs create mode 120000 vendor/knative.dev/serving/cmd/networking/certmanager/kodata/HEAD create mode 120000 vendor/knative.dev/serving/cmd/networking/certmanager/kodata/LICENSE create mode 120000 vendor/knative.dev/serving/cmd/networking/certmanager/kodata/VENDOR-LICENSE create mode 120000 vendor/knative.dev/serving/cmd/networking/certmanager/kodata/refs create mode 120000 vendor/knative.dev/serving/cmd/networking/istio/kodata/HEAD create mode 120000 vendor/knative.dev/serving/cmd/networking/istio/kodata/LICENSE create mode 120000 vendor/knative.dev/serving/cmd/networking/istio/kodata/VENDOR-LICENSE create mode 120000 vendor/knative.dev/serving/cmd/networking/istio/kodata/refs create mode 120000 vendor/knative.dev/serving/cmd/networking/nscert/kodata/HEAD create mode 120000 vendor/knative.dev/serving/cmd/networking/nscert/kodata/LICENSE create mode 120000 vendor/knative.dev/serving/cmd/networking/nscert/kodata/VENDOR-LICENSE create mode 120000 vendor/knative.dev/serving/cmd/queue/kodata/HEAD create mode 120000 vendor/knative.dev/serving/cmd/queue/kodata/LICENSE create mode 120000 vendor/knative.dev/serving/cmd/queue/kodata/VENDOR-LICENSE create mode 120000 vendor/knative.dev/serving/cmd/queue/kodata/refs create mode 120000 vendor/knative.dev/serving/cmd/webhook/kodata/HEAD create mode 120000 vendor/knative.dev/serving/cmd/webhook/kodata/LICENSE create mode 120000 vendor/knative.dev/serving/cmd/webhook/kodata/VENDOR-LICENSE create mode 120000 vendor/knative.dev/serving/cmd/webhook/kodata/refs create mode 120000 vendor/knative.dev/serving/config/100-namespace.yaml create mode 120000 vendor/knative.dev/serving/config/200-addressable-resolvers-clusterrole.yaml create mode 120000 vendor/knative.dev/serving/config/200-clusterrole-certmanager.yaml create mode 120000 vendor/knative.dev/serving/config/200-clusterrole-istio.yaml create mode 120000 vendor/knative.dev/serving/config/200-clusterrole-metrics.yaml create mode 120000 vendor/knative.dev/serving/config/200-clusterrole-namespaced.yaml create mode 120000 vendor/knative.dev/serving/config/200-clusterrole.yaml create mode 120000 vendor/knative.dev/serving/config/200-podspecable-bindings-clusterrole.yaml create mode 120000 vendor/knative.dev/serving/config/200-serviceaccount.yaml create mode 120000 vendor/knative.dev/serving/config/201-clusterrolebinding-metrics-server.yaml create mode 120000 vendor/knative.dev/serving/config/201-clusterrolebinding-metrics.yaml create mode 120000 vendor/knative.dev/serving/config/201-clusterrolebinding.yaml create mode 120000 vendor/knative.dev/serving/config/201-rolebinding-metrics-server.yaml create mode 120000 vendor/knative.dev/serving/config/202-gateway.yaml create mode 120000 vendor/knative.dev/serving/config/203-local-gateway.yaml create mode 120000 vendor/knative.dev/serving/config/300-certificate.yaml create mode 120000 vendor/knative.dev/serving/config/300-configuration.yaml create mode 120000 vendor/knative.dev/serving/config/300-imagecache.yaml create mode 120000 vendor/knative.dev/serving/config/300-ingress.yaml create mode 120000 vendor/knative.dev/serving/config/300-metric.yaml create mode 120000 vendor/knative.dev/serving/config/300-pa.yaml create mode 120000 vendor/knative.dev/serving/config/300-revision.yaml create mode 120000 vendor/knative.dev/serving/config/300-route.yaml create mode 120000 vendor/knative.dev/serving/config/300-service.yaml create mode 120000 vendor/knative.dev/serving/config/300-sks.yaml create mode 120000 vendor/knative.dev/serving/config/500-webhook-configmap-validation.yaml create mode 120000 vendor/knative.dev/serving/config/500-webhook-defaulting.yaml create mode 120000 vendor/knative.dev/serving/config/500-webhook-resource-validation.yaml create mode 120000 vendor/knative.dev/serving/config/500-webhook-secret.yaml create mode 120000 vendor/knative.dev/serving/config/999-cache.yaml create mode 120000 vendor/knative.dev/serving/config/activator-hpa.yaml create mode 120000 vendor/knative.dev/serving/config/activator.yaml create mode 120000 vendor/knative.dev/serving/config/autoscaler-hpa.yaml create mode 120000 vendor/knative.dev/serving/config/autoscaler.yaml create mode 120000 vendor/knative.dev/serving/config/config-autoscaler.yaml create mode 120000 vendor/knative.dev/serving/config/config-certmanager.yaml create mode 120000 vendor/knative.dev/serving/config/config-defaults.yaml create mode 120000 vendor/knative.dev/serving/config/config-deployment.yaml create mode 120000 vendor/knative.dev/serving/config/config-domain.yaml create mode 120000 vendor/knative.dev/serving/config/config-gc.yaml create mode 120000 vendor/knative.dev/serving/config/config-istio.yaml create mode 120000 vendor/knative.dev/serving/config/config-logging.yaml create mode 120000 vendor/knative.dev/serving/config/config-network.yaml create mode 120000 vendor/knative.dev/serving/config/config-observability.yaml create mode 120000 vendor/knative.dev/serving/config/config-tracing.yaml create mode 120000 vendor/knative.dev/serving/config/controller.yaml create mode 120000 vendor/knative.dev/serving/config/custom-metrics-apiservice.yaml create mode 120000 vendor/knative.dev/serving/config/networking-certmanager.yaml create mode 120000 vendor/knative.dev/serving/config/networking-istio.yaml create mode 120000 vendor/knative.dev/serving/config/networking-ns-cert.yaml create mode 120000 vendor/knative.dev/serving/config/webhook.yaml create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/register.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/doc.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/podscalable_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/register.go create mode 100644 vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/knative.dev/serving/pkg/apis/config/defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/config/doc.go create mode 100644 vendor/knative.dev/serving/pkg/apis/config/store.go create mode 120000 vendor/knative.dev/serving/pkg/apis/config/testdata/config-defaults.yaml create mode 100644 vendor/knative.dev/serving/pkg/apis/config/zz_generated.deepcopy.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/generic_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/ports.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/register.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/doc.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/register.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/fieldmask.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/k8s_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/register.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/contexts.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/doc.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/register.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/revision_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/revision_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/route_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/route_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/route_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/route_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/service_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/service_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/service_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/service_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1/zz_generated.deepcopy.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/conversion_error.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/doc.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/register.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/doc.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/register.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_conversion.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_defaults.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_lifecycle.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_types.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_validation.go create mode 100644 vendor/knative.dev/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go create mode 120000 vendor/knative.dev/serving/pkg/autoscaler/testdata/config-autoscaler.yaml create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/clientset.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/clientset_generated.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/register.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/scheme/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/scheme/register.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_metric.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_podautoscaler.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/metric.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/certificate.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_certificate.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_ingress.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_serverlessservice.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/ingress.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/serverlessservice.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_route.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_service.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_serving_client.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/generated_expansion.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/route.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/service.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/serving_client.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_route.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_service.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_serving_client.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/route.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/service.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/serving_client.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/doc.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_route.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_service.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_serving_client.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/generated_expansion.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/route.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/service.go create mode 100644 vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/serving_client.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/interface.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/metric.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/podautoscaler.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/factory.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/generic.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/interface.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/certificate.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/ingress.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/interface.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/serverlessservice.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/interface.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/interface.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/route.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/service.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/interface.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/route.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/service.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/interface.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/route.go create mode 100644 vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/service.go create mode 100644 vendor/knative.dev/serving/pkg/client/injection/client/client.go create mode 100644 vendor/knative.dev/serving/pkg/client/injection/client/fake/fake.go create mode 100644 vendor/knative.dev/serving/pkg/client/injection/informers/factory/factory.go create mode 100644 vendor/knative.dev/serving/pkg/client/injection/informers/factory/fake/fake.go create mode 100644 vendor/knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake/fake.go create mode 100644 vendor/knative.dev/serving/pkg/client/injection/informers/serving/v1/service/service.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/metric.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/podautoscaler.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/certificate.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/expansion_generated.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/ingress.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/serverlessservice.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1/configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1/expansion_generated.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1/revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1/route.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1/service.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/expansion_generated.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/route.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/service.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/configuration.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/expansion_generated.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/revision.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/route.go create mode 100644 vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/service.go create mode 120000 vendor/knative.dev/serving/pkg/deployment/testdata/config-deployment.yaml create mode 100644 vendor/knative.dev/serving/pkg/gc/config.go create mode 100644 vendor/knative.dev/serving/pkg/gc/doc.go create mode 120000 vendor/knative.dev/serving/pkg/gc/testdata/config-gc.yaml create mode 100644 vendor/knative.dev/serving/pkg/gc/zz_generated.deepcopy.go create mode 120000 vendor/knative.dev/serving/pkg/logging/testdata/config-logging.yaml create mode 120000 vendor/knative.dev/serving/pkg/logging/testdata/test-config-logging.yaml create mode 120000 vendor/knative.dev/serving/pkg/metrics/testdata/config-observability.yaml create mode 100644 vendor/knative.dev/serving/pkg/network/bufferpool.go create mode 100644 vendor/knative.dev/serving/pkg/network/doc.go create mode 100644 vendor/knative.dev/serving/pkg/network/network.go create mode 100644 vendor/knative.dev/serving/pkg/network/probe_handler.go create mode 120000 vendor/knative.dev/serving/pkg/network/testdata/config-network.yaml create mode 100644 vendor/knative.dev/serving/pkg/network/zz_generated.deepcopy.go create mode 120000 vendor/knative.dev/serving/pkg/reconciler/certificate/config/testdata/config-certmanager.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/gc/config/testdata/config-gc.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/ingress/config/testdata/config-istio.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/ingress/config/testdata/config-network.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-autoscaler.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-defaults.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-deployment.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-logging.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-network.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-observability.yaml create mode 100644 vendor/knative.dev/serving/pkg/reconciler/route/config/doc.go create mode 100644 vendor/knative.dev/serving/pkg/reconciler/route/config/domain.go create mode 100644 vendor/knative.dev/serving/pkg/reconciler/route/config/store.go create mode 120000 vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-domain.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-gc.yaml create mode 120000 vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-network.yaml create mode 100644 vendor/knative.dev/serving/pkg/reconciler/route/config/zz_generated.deepcopy.go create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/HEAD create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/dev.config create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/prod.config create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/refs create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/HEAD create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/dev.config create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/prod.config create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/refs create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/HEAD create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/dev.config create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/prod.config create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/refs create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/HEAD create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/dev.config create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/prod.config create mode 120000 vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/refs create mode 100644 vendor/knative.dev/serving/third_party/config/monitoring/logging/elasticsearch/LICENSE create mode 100644 vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/kubernetes/LICENSE create mode 100644 vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/LICENSE create mode 100644 vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/NOTICE create mode 120000 vendor/knative.dev/serving/third_party/istio-1.3-latest create mode 120000 vendor/knative.dev/serving/third_party/istio-1.4-latest diff --git a/Gopkg.lock b/Gopkg.lock index 278a51fa2ac..352c04aa49b 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -227,6 +227,13 @@ pruneopts = "NUT" revision = "6f77996f0c42f7b84e5a2b252227263f93432e9b" +[[projects]] + digest = "1:10aa62acd56f635de190110a836aa261b3774e697b2b6a7af27d8263cf856d47" + name = "github.com/google/go-containerregistry" + packages = ["pkg/name"] + pruneopts = "NUT" + revision = "b02d448a3705facf11018efff34f1d2830be5724" + [[projects]] digest = "1:91099c6f78b1e7bdf9ed06eb4cb7f017174293a3689d76b995a06f4c8d64a7f0" name = "github.com/google/go-github" @@ -383,9 +390,10 @@ [[projects]] branch = "master" - digest = "1:7bbccd3dd7998f2a180264ec1d12e362ed8e02f55ea7b82ac0d0f48ffa2d8888" + digest = "1:7badf75e6ce7d68cb393f84b7b0d02100a8ae414df870fc71dcf617899b5d8cb" name = "github.com/mailru/easyjson" packages = [ + ".", "buffer", "jlexer", "jwriter", @@ -545,12 +553,12 @@ version = "v1.0.5" [[projects]] - digest = "1:435d9fe926ee0d903662215091e27fba6f1b7228d33a30c289cdb5aeff1c8fc8" + branch = "master" + digest = "1:30bbabb7875bb8cc6c2f756e68eecfbb77d58fe2779ef208489012db5a4171a9" name = "github.com/tsenart/vegeta" packages = ["lib"] pruneopts = "NUT" - revision = "9c95632b3e8562be6df690c639a3f5a6f40d3004" - version = "v12.7.0" + revision = "85244b4acb411f39075b7f47533ec04ac438201b" [[projects]] digest = "1:b7d98c64e9467a8e5e67509031cd6baee81fba090ba2c3d30df1ff3d02d1d035" @@ -1403,6 +1411,61 @@ pruneopts = "T" revision = "b51ee347cbd2c26c1af45177d427ffb62b008b39" +[[projects]] + branch = "master" + digest = "1:c9cf1670af44077ad8a75b8fc5d617c668fe5560ac90e7d53147b9ef18b24458" + name = "knative.dev/serving" + packages = [ + "pkg/apis/autoscaling", + "pkg/apis/autoscaling/v1alpha1", + "pkg/apis/config", + "pkg/apis/networking", + "pkg/apis/networking/v1alpha1", + "pkg/apis/serving", + "pkg/apis/serving/v1", + "pkg/apis/serving/v1alpha1", + "pkg/apis/serving/v1beta1", + "pkg/client/clientset/versioned", + "pkg/client/clientset/versioned/fake", + "pkg/client/clientset/versioned/scheme", + "pkg/client/clientset/versioned/typed/autoscaling/v1alpha1", + "pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake", + "pkg/client/clientset/versioned/typed/networking/v1alpha1", + "pkg/client/clientset/versioned/typed/networking/v1alpha1/fake", + "pkg/client/clientset/versioned/typed/serving/v1", + "pkg/client/clientset/versioned/typed/serving/v1/fake", + "pkg/client/clientset/versioned/typed/serving/v1alpha1", + "pkg/client/clientset/versioned/typed/serving/v1alpha1/fake", + "pkg/client/clientset/versioned/typed/serving/v1beta1", + "pkg/client/clientset/versioned/typed/serving/v1beta1/fake", + "pkg/client/informers/externalversions", + "pkg/client/informers/externalversions/autoscaling", + "pkg/client/informers/externalversions/autoscaling/v1alpha1", + "pkg/client/informers/externalversions/internalinterfaces", + "pkg/client/informers/externalversions/networking", + "pkg/client/informers/externalversions/networking/v1alpha1", + "pkg/client/informers/externalversions/serving", + "pkg/client/informers/externalversions/serving/v1", + "pkg/client/informers/externalversions/serving/v1alpha1", + "pkg/client/informers/externalversions/serving/v1beta1", + "pkg/client/injection/client", + "pkg/client/injection/client/fake", + "pkg/client/injection/informers/factory", + "pkg/client/injection/informers/factory/fake", + "pkg/client/injection/informers/serving/v1/service", + "pkg/client/injection/informers/serving/v1/service/fake", + "pkg/client/listers/autoscaling/v1alpha1", + "pkg/client/listers/networking/v1alpha1", + "pkg/client/listers/serving/v1", + "pkg/client/listers/serving/v1alpha1", + "pkg/client/listers/serving/v1beta1", + "pkg/gc", + "pkg/network", + "pkg/reconciler/route/config", + ] + pruneopts = "NUT" + revision = "dbe73573742cfbc83a971e966705d51a36793fba" + [[projects]] branch = "master" digest = "1:4ba0f80b3feed917d2c9a1aa79ea95836c3aef84589431cff77ffd01615a1150" @@ -1587,6 +1650,15 @@ "knative.dev/pkg/webhook/resourcesemantics", "knative.dev/pkg/webhook/resourcesemantics/defaulting", "knative.dev/pkg/webhook/resourcesemantics/validation", + "knative.dev/serving/pkg/apis/serving", + "knative.dev/serving/pkg/apis/serving/v1", + "knative.dev/serving/pkg/client/clientset/versioned", + "knative.dev/serving/pkg/client/clientset/versioned/fake", + "knative.dev/serving/pkg/client/injection/client", + "knative.dev/serving/pkg/client/injection/client/fake", + "knative.dev/serving/pkg/client/injection/informers/serving/v1/service", + "knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake", + "knative.dev/serving/pkg/client/listers/serving/v1", "knative.dev/test-infra/scripts", "knative.dev/test-infra/tools/dep-collector", ] diff --git a/Gopkg.toml b/Gopkg.toml index 9e292769a95..1fc78ead538 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -39,6 +39,10 @@ required = [ name = "knative.dev/pkg" branch = "master" +[[override]] + name = "knative.dev/serving" + branch = "master" + # TODO why is this overridden? [[override]] name = "gopkg.in/yaml.v2" @@ -120,7 +124,7 @@ required = [ [[constraint]] name = "github.com/tsenart/vegeta" - version = "12.7.0" + version = "master" [[constraint]] name = "contrib.go.opencensus.io/exporter/ocagent" diff --git a/config/200-controller-clusterrole.yaml b/config/200-controller-clusterrole.yaml deleted file mode 120000 index db8a566437d..00000000000 --- a/config/200-controller-clusterrole.yaml +++ /dev/null @@ -1 +0,0 @@ -core/roles/controller-clusterroles.yaml \ No newline at end of file diff --git a/config/200-controller-clusterrole.yaml b/config/200-controller-clusterrole.yaml new file mode 100644 index 00000000000..0a84d0ec14a --- /dev/null +++ b/config/200-controller-clusterrole.yaml @@ -0,0 +1,132 @@ +# 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. + +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: knative-eventing-controller + labels: + eventing.knative.dev/release: devel +rules: + - apiGroups: + - "" + resources: + - "namespaces" + - "secrets" + - "configmaps" + - "services" + - "events" + - "serviceaccounts" + verbs: &everything + - "get" + - "list" + - "create" + - "update" + - "delete" + - "patch" + - "watch" + + # Brokers and the namespace annotation controllers manipulate Deployments. + - apiGroups: + - "apps" + resources: + - "deployments" + verbs: *everything + + # The namespace annotation controller needs to manipulate RoleBindings. + - apiGroups: + - "rbac.authorization.k8s.io" + resources: + - "rolebindings" + verbs: *everything + + - apiGroups: + - serving.knative.dev + resources: + - services + verbs: *everything + + # Our own resources and statuses we care about. + - apiGroups: + - "eventing.knative.dev" + resources: + - "brokers" + - "brokers/status" + - "triggers" + - "triggers/status" + - "eventtypes" + - "eventtypes/status" + verbs: *everything + + # Eventing resources and finalizers we care about. + - apiGroups: + - "eventing.knative.dev" + resources: + - "brokers/finalizers" + - "triggers/finalizers" + verbs: + - "update" + + # Our own resources and statuses we care about. + - apiGroups: + - "messaging.knative.dev" + resources: + - "sequences" + - "sequences/status" + - "channels" + - "channels/status" + - "parallels" + - "parallels/status" + - "subscriptions" + - "subscriptions/status" + verbs: *everything + + # Flow resources and statuses we care about. + - apiGroups: + - "flows.knative.dev" + resources: + - "sequences" + - "sequences/status" + - "parallels" + - "parallels/status" + verbs: *everything + + # Messaging resources and finalizers we care about. + - apiGroups: + - "messaging.knative.dev" + resources: + - "sequences/finalizers" + - "parallels/finalizers" + - "channels/finalizers" + verbs: + - "update" + + # Flows resources and finalizers we care about. + - apiGroups: + - "flows.knative.dev" + resources: + - "sequences/finalizers" + - "parallels/finalizers" + verbs: + - "update" + + # The subscription controller needs to retrieve and watch CustomResourceDefinitions. + - apiGroups: + - "apiextensions.k8s.io" + resources: + - "customresourcedefinitions" + verbs: + - "get" + - "list" + - "watch" diff --git a/pkg/apis/eventing/v1alpha1/broker_lifecycle.go b/pkg/apis/eventing/v1alpha1/broker_lifecycle.go index 3737d79967a..37f932965b5 100644 --- a/pkg/apis/eventing/v1alpha1/broker_lifecycle.go +++ b/pkg/apis/eventing/v1alpha1/broker_lifecycle.go @@ -66,6 +66,10 @@ func (bs *BrokerStatus) MarkIngressFailed(reason, format string, args ...interfa brokerCondSet.Manage(bs).MarkFalse(BrokerConditionIngress, reason, format, args...) } +func (bs *BrokerStatus) MarkIngressReady() { + brokerCondSet.Manage(bs).MarkTrue(BrokerConditionIngress) +} + func (bs *BrokerStatus) PropagateIngressDeploymentAvailability(d *appsv1.Deployment) { if duck.DeploymentIsAvailable(&d.Status, true) { brokerCondSet.Manage(bs).MarkTrue(BrokerConditionIngress) @@ -94,6 +98,10 @@ func (bs *BrokerStatus) MarkFilterFailed(reason, format string, args ...interfac brokerCondSet.Manage(bs).MarkFalse(BrokerConditionFilter, reason, format, args...) } +func (bs *BrokerStatus) MarkFilterReady() { + brokerCondSet.Manage(bs).MarkTrue(BrokerConditionFilter) +} + func (bs *BrokerStatus) PropagateFilterDeploymentAvailability(d *appsv1.Deployment) { if duck.DeploymentIsAvailable(&d.Status, true) { brokerCondSet.Manage(bs).MarkTrue(BrokerConditionFilter) diff --git a/pkg/reconciler/broker/broker.go b/pkg/reconciler/broker/broker.go index 6247f065db9..a5ae37fe1f1 100644 --- a/pkg/reconciler/broker/broker.go +++ b/pkg/reconciler/broker/broker.go @@ -23,18 +23,13 @@ import ( "time" "go.uber.org/zap" - v1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/equality" apierrs "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/client-go/dynamic" - appsv1listers "k8s.io/client-go/listers/apps/v1" - corev1listers "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" - "knative.dev/pkg/apis" duckapis "knative.dev/pkg/apis/duck" "knative.dev/pkg/controller" @@ -46,7 +41,6 @@ import ( "knative.dev/eventing/pkg/logging" "knative.dev/eventing/pkg/reconciler" "knative.dev/eventing/pkg/reconciler/broker/resources" - "knative.dev/eventing/pkg/reconciler/names" ) const ( @@ -64,12 +58,12 @@ type Reconciler struct { // listers index properties about resources brokerLister eventinglisters.BrokerLister - serviceLister corev1listers.ServiceLister - deploymentLister appsv1listers.DeploymentLister subscriptionLister messaginglisters.SubscriptionLister channelableTracker duck.ListableTracker + serviceHelper *reconciler.ServiceHelper + ingressImage string ingressServiceAccountName string filterImage string @@ -203,38 +197,64 @@ func (r *Reconciler) reconcile(ctx context.Context, b *v1alpha1.Broker) error { b.Status.TriggerChannel = &triggerChannelObjRef b.Status.PropagateTriggerChannelReadiness(&triggerChan.Status) - filterDeployment, err := r.reconcileFilterDeployment(ctx, b) - if err != nil { - logging.FromContext(ctx).Error("Problem reconciling filter Deployment", zap.Error(err)) - b.Status.MarkFilterFailed("DeploymentFailure", "%v", err) - return err - } - _, err = r.reconcileFilterService(ctx, b) + filterStatus, err := r.reconcileFilterService(ctx, b) if err != nil { - logging.FromContext(ctx).Error("Problem reconciling filter Service", zap.Error(err)) + logging.FromContext(ctx).Error("Problem reconcile filter service", zap.Error(err)) b.Status.MarkFilterFailed("ServiceFailure", "%v", err) return err } - b.Status.PropagateFilterDeploymentAvailability(filterDeployment) - - ingressDeployment, err := r.reconcileIngressDeployment(ctx, b, triggerChan) - if err != nil { - logging.FromContext(ctx).Error("Problem reconciling ingress Deployment", zap.Error(err)) - b.Status.MarkIngressFailed("DeploymentFailure", "%v", err) - return err + if filterStatus.IsReady { + b.Status.MarkFilterReady() + } else { + b.Status.MarkFilterFailed(filterStatus.Reason, filterStatus.Message) } - svc, err := r.reconcileIngressService(ctx, b) + ingressStatus, err := r.reconcileIngressService(ctx, b, triggerChan) if err != nil { - logging.FromContext(ctx).Error("Problem reconciling ingress Service", zap.Error(err)) + logging.FromContext(ctx).Error("Problem reconcile ingress service", zap.Error(err)) b.Status.MarkIngressFailed("ServiceFailure", "%v", err) return err } - b.Status.PropagateIngressDeploymentAvailability(ingressDeployment) - b.Status.SetAddress(&apis.URL{ - Scheme: "http", - Host: names.ServiceHostName(svc.Name, svc.Namespace), - }) + if ingressStatus.IsReady { + b.Status.MarkIngressReady() + } else { + b.Status.MarkIngressFailed(ingressStatus.Reason, ingressStatus.Message) + } + + b.Status.SetAddress(ingressStatus.URL) + + // filterDeployment, err := r.reconcileFilterDeployment(ctx, b) + // if err != nil { + // logging.FromContext(ctx).Error("Problem reconciling filter Deployment", zap.Error(err)) + // b.Status.MarkFilterFailed("DeploymentFailure", "%v", err) + // return err + // } + // _, err = r.reconcileFilterService(ctx, b) + // if err != nil { + // logging.FromContext(ctx).Error("Problem reconciling filter Service", zap.Error(err)) + // b.Status.MarkFilterFailed("ServiceFailure", "%v", err) + // return err + // } + // b.Status.PropagateFilterDeploymentAvailability(filterDeployment) + + // ingressDeployment, err := r.reconcileIngressDeployment(ctx, b, triggerChan) + // if err != nil { + // logging.FromContext(ctx).Error("Problem reconciling ingress Deployment", zap.Error(err)) + // b.Status.MarkIngressFailed("DeploymentFailure", "%v", err) + // return err + // } + + // svc, err := r.reconcileIngressService(ctx, b) + // if err != nil { + // logging.FromContext(ctx).Error("Problem reconciling ingress Service", zap.Error(err)) + // b.Status.MarkIngressFailed("ServiceFailure", "%v", err) + // return err + // } + // b.Status.PropagateIngressDeploymentAvailability(ingressDeployment) + // b.Status.SetAddress(&apis.URL{ + // Scheme: "http", + // Host: names.ServiceHostName(svc.Name, svc.Namespace), + // }) return nil } @@ -269,22 +289,41 @@ func (r *Reconciler) updateStatus(ctx context.Context, desired *v1alpha1.Broker) return b, err } -// reconcileFilterDeployment reconciles Broker's 'b' filter deployment. -func (r *Reconciler) reconcileFilterDeployment(ctx context.Context, b *v1alpha1.Broker) (*v1.Deployment, error) { - expected := resources.MakeFilterDeployment(&resources.FilterArgs{ +func (r *Reconciler) reconcileFilterService(ctx context.Context, b *v1alpha1.Broker) (*reconciler.ServiceStatus, error) { + svcArgs := resources.MakeFilterServiceArgs(&resources.FilterArgs{ Broker: b, Image: r.filterImage, ServiceAccountName: r.filterServiceAccountName, }) - return r.reconcileDeployment(ctx, expected) + return r.serviceHelper.ReconcileService(ctx, b, *svcArgs) } -// reconcileFilterService reconciles Broker's 'b' filter service. -func (r *Reconciler) reconcileFilterService(ctx context.Context, b *v1alpha1.Broker) (*corev1.Service, error) { - expected := resources.MakeFilterService(b) - return r.reconcileService(ctx, expected) +func (r *Reconciler) reconcileIngressService(ctx context.Context, b *v1alpha1.Broker, c *duckv1alpha1.Channelable) (*reconciler.ServiceStatus, error) { + svcArgs := resources.MakeIngressServiceArgs(&resources.IngressArgs{ + Broker: b, + Image: r.ingressImage, + ServiceAccountName: r.ingressServiceAccountName, + ChannelAddress: c.Status.Address.GetURL().Host, + }) + return r.serviceHelper.ReconcileService(ctx, b, *svcArgs) } +// reconcileFilterDeployment reconciles Broker's 'b' filter deployment. +// func (r *Reconciler) reconcileFilterDeployment(ctx context.Context, b *v1alpha1.Broker) (*v1.Deployment, error) { +// expected := resources.MakeFilterDeployment(&resources.FilterArgs{ +// Broker: b, +// Image: r.filterImage, +// ServiceAccountName: r.filterServiceAccountName, +// }) +// return r.reconcileDeployment(ctx, expected) +// } + +// // reconcileFilterService reconciles Broker's 'b' filter service. +// func (r *Reconciler) reconcileFilterService(ctx context.Context, b *v1alpha1.Broker) (*corev1.Service, error) { +// expected := resources.MakeFilterService(b) +// return r.reconcileService(ctx, expected) +// } + func newTriggerChannel(b *v1alpha1.Broker) (*unstructured.Unstructured, error) { return resources.NewChannel("trigger", b, TriggerChannelLabels(b.Name)) } @@ -347,71 +386,71 @@ func TriggerChannelLabels(brokerName string) map[string]string { } // reconcileDeployment reconciles the K8s Deployment 'd'. -func (r *Reconciler) reconcileDeployment(ctx context.Context, d *v1.Deployment) (*v1.Deployment, error) { - current, err := r.deploymentLister.Deployments(d.Namespace).Get(d.Name) - if apierrs.IsNotFound(err) { - current, err = r.KubeClientSet.AppsV1().Deployments(d.Namespace).Create(d) - if err != nil { - return nil, err - } - return current, nil - } else if err != nil { - return nil, err - } - - if !equality.Semantic.DeepDerivative(d.Spec, current.Spec) { - // Don't modify the informers copy. - desired := current.DeepCopy() - desired.Spec = d.Spec - current, err = r.KubeClientSet.AppsV1().Deployments(current.Namespace).Update(desired) - if err != nil { - return nil, err - } - } - return current, nil -} - -// reconcileService reconciles the K8s Service 'svc'. -func (r *Reconciler) reconcileService(ctx context.Context, svc *corev1.Service) (*corev1.Service, error) { - current, err := r.serviceLister.Services(svc.Namespace).Get(svc.Name) - if apierrs.IsNotFound(err) { - current, err = r.KubeClientSet.CoreV1().Services(svc.Namespace).Create(svc) - if err != nil { - return nil, err - } - return current, nil - } else if err != nil { - return nil, err - } - - // spec.clusterIP is immutable and is set on existing services. If we don't set this to the same value, we will - // encounter an error while updating. - svc.Spec.ClusterIP = current.Spec.ClusterIP - if !equality.Semantic.DeepDerivative(svc.Spec, current.Spec) { - // Don't modify the informers copy. - desired := current.DeepCopy() - desired.Spec = svc.Spec - current, err = r.KubeClientSet.CoreV1().Services(current.Namespace).Update(desired) - if err != nil { - return nil, err - } - } - return current, nil -} +// func (r *Reconciler) reconcileDeployment(ctx context.Context, d *v1.Deployment) (*v1.Deployment, error) { +// current, err := r.deploymentLister.Deployments(d.Namespace).Get(d.Name) +// if apierrs.IsNotFound(err) { +// current, err = r.KubeClientSet.AppsV1().Deployments(d.Namespace).Create(d) +// if err != nil { +// return nil, err +// } +// return current, nil +// } else if err != nil { +// return nil, err +// } + +// if !equality.Semantic.DeepDerivative(d.Spec, current.Spec) { +// // Don't modify the informers copy. +// desired := current.DeepCopy() +// desired.Spec = d.Spec +// current, err = r.KubeClientSet.AppsV1().Deployments(current.Namespace).Update(desired) +// if err != nil { +// return nil, err +// } +// } +// return current, nil +// } + +// // reconcileService reconciles the K8s Service 'svc'. +// func (r *Reconciler) reconcileService(ctx context.Context, svc *corev1.Service) (*corev1.Service, error) { +// current, err := r.serviceLister.Services(svc.Namespace).Get(svc.Name) +// if apierrs.IsNotFound(err) { +// current, err = r.KubeClientSet.CoreV1().Services(svc.Namespace).Create(svc) +// if err != nil { +// return nil, err +// } +// return current, nil +// } else if err != nil { +// return nil, err +// } + +// // spec.clusterIP is immutable and is set on existing services. If we don't set this to the same value, we will +// // encounter an error while updating. +// svc.Spec.ClusterIP = current.Spec.ClusterIP +// if !equality.Semantic.DeepDerivative(svc.Spec, current.Spec) { +// // Don't modify the informers copy. +// desired := current.DeepCopy() +// desired.Spec = svc.Spec +// current, err = r.KubeClientSet.CoreV1().Services(current.Namespace).Update(desired) +// if err != nil { +// return nil, err +// } +// } +// return current, nil +// } // reconcileIngressDeploymentCRD reconciles the Ingress Deployment for a CRD backed channel. -func (r *Reconciler) reconcileIngressDeployment(ctx context.Context, b *v1alpha1.Broker, c *duckv1alpha1.Channelable) (*v1.Deployment, error) { - expected := resources.MakeIngress(&resources.IngressArgs{ - Broker: b, - Image: r.ingressImage, - ServiceAccountName: r.ingressServiceAccountName, - ChannelAddress: c.Status.Address.GetURL().Host, - }) - return r.reconcileDeployment(ctx, expected) -} - -// reconcileIngressService reconciles the Ingress Service. -func (r *Reconciler) reconcileIngressService(ctx context.Context, b *v1alpha1.Broker) (*corev1.Service, error) { - expected := resources.MakeIngressService(b) - return r.reconcileService(ctx, expected) -} +// func (r *Reconciler) reconcileIngressDeployment(ctx context.Context, b *v1alpha1.Broker, c *duckv1alpha1.Channelable) (*v1.Deployment, error) { +// expected := resources.MakeIngress(&resources.IngressArgs{ +// Broker: b, +// Image: r.ingressImage, +// ServiceAccountName: r.ingressServiceAccountName, +// ChannelAddress: c.Status.Address.GetURL().Host, +// }) +// return r.reconcileDeployment(ctx, expected) +// } + +// // reconcileIngressService reconciles the Ingress Service. +// func (r *Reconciler) reconcileIngressService(ctx context.Context, b *v1alpha1.Broker) (*corev1.Service, error) { +// expected := resources.MakeIngressService(b) +// return r.reconcileService(ctx, expected) +// } diff --git a/pkg/reconciler/broker/broker_test.go b/pkg/reconciler/broker/broker_test.go index 76aedd28643..7226462cbd9 100644 --- a/pkg/reconciler/broker/broker_test.go +++ b/pkg/reconciler/broker/broker_test.go @@ -28,6 +28,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/client-go/kubernetes/scheme" @@ -51,9 +52,9 @@ const ( brokerName = "test-broker" filterImage = "filter-image" - filterSA = "filter-SA" + filterSA = "filter-sa" ingressImage = "ingress-image" - ingressSA = "ingress-SA" + ingressSA = "ingress-sa" filterContainerName = "filter" ingressContainerName = "ingress" @@ -74,8 +75,10 @@ var ( filterDeploymentName = fmt.Sprintf("%s-broker-filter", brokerName) filterServiceName = fmt.Sprintf("%s-broker-filter", brokerName) + filterRevisionName = fmt.Sprintf("%s-broker-filter-rev", brokerName) ingressDeploymentName = fmt.Sprintf("%s-broker-ingress", brokerName) ingressServiceName = fmt.Sprintf("%s-broker", brokerName) + ingressRevisionName = fmt.Sprintf("%s-broker-ingress-rev", brokerName) ingressSubscriptionGenerateName = fmt.Sprintf("internal-ingress-%s-", brokerName) @@ -203,7 +206,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.FilterLabels(brokerName)), WithDeploymentServiceAccount(filterSA), - WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(), readinessProbe(), envVars(filterContainerName), containerPorts(8080))), + WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(true), readinessProbe(true), envVars(filterContainerName), containerPorts(8080, true))), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, @@ -211,10 +214,10 @@ func TestReconcile(t *testing.T) { WithInitBrokerConditions, WithTriggerChannelReady(), WithBrokerTriggerChannel(createTriggerChannelRef()), - WithFilterFailed("DeploymentFailure", "inducing failure for create deployments")), + WithFilterFailed("ServiceFailure", "failed to create deployment: inducing failure for create deployments")), }}, WantEvents: []string{ - Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "inducing failure for create deployments"), + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to create deployment: inducing failure for create deployments"), }, WantErr: true, }, @@ -230,7 +233,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.FilterLabels(brokerName)), WithDeploymentServiceAccount(filterSA), - WithDeploymentContainer(filterContainerName, "some-other-image", livenessProbe(), readinessProbe(), envVars(filterContainerName), containerPorts(8080))), + WithDeploymentContainer(filterContainerName, "some-other-image", livenessProbe(true), readinessProbe(true), envVars(filterContainerName), containerPorts(8080, true))), }, WithReactors: []clientgotesting.ReactionFunc{ InduceFailure("update", "deployments"), @@ -241,17 +244,17 @@ func TestReconcile(t *testing.T) { WithInitBrokerConditions, WithTriggerChannelReady(), WithBrokerTriggerChannel(createTriggerChannelRef()), - WithFilterFailed("DeploymentFailure", "inducing failure for update deployments")), + WithFilterFailed("ServiceFailure", "failed to update deployment: inducing failure for update deployments")), }}, WantUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewDeployment(filterDeploymentName, testNS, WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.FilterLabels(brokerName)), WithDeploymentServiceAccount(filterSA), - WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(), readinessProbe(), envVars(filterContainerName), containerPorts(8080))), + WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(true), readinessProbe(true), envVars(filterContainerName), containerPorts(8080, true))), }}, WantEvents: []string{ - Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "inducing failure for update deployments"), + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to update deployment: inducing failure for update deployments"), }, WantErr: true, }, @@ -267,7 +270,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.FilterLabels(brokerName)), WithDeploymentServiceAccount(filterSA), - WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(), readinessProbe(), envVars(filterContainerName), containerPorts(8080))), + WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(true), readinessProbe(true), envVars(filterContainerName), containerPorts(8080, true))), }, WithReactors: []clientgotesting.ReactionFunc{ InduceFailure("create", "services"), @@ -284,10 +287,10 @@ func TestReconcile(t *testing.T) { WithInitBrokerConditions, WithTriggerChannelReady(), WithBrokerTriggerChannel(createTriggerChannelRef()), - WithFilterFailed("ServiceFailure", "inducing failure for create services")), + WithFilterFailed("ServiceFailure", "failed to create service: inducing failure for create services")), }}, WantEvents: []string{ - Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "inducing failure for create services"), + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to create service: inducing failure for create services"), }, WantErr: true, }, @@ -303,7 +306,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.FilterLabels(brokerName)), WithDeploymentServiceAccount(filterSA), - WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(), readinessProbe(), envVars(filterContainerName), containerPorts(8080))), + WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(true), readinessProbe(true), envVars(filterContainerName), containerPorts(8080, true))), NewService(filterServiceName, testNS, WithServiceOwnerReferences(ownerReferences()), WithServiceLabels(resources.FilterLabels(brokerName)), @@ -324,10 +327,10 @@ func TestReconcile(t *testing.T) { WithInitBrokerConditions, WithTriggerChannelReady(), WithBrokerTriggerChannel(createTriggerChannelRef()), - WithFilterFailed("ServiceFailure", "inducing failure for update services")), + WithFilterFailed("ServiceFailure", "failed to update service: inducing failure for update services")), }}, WantEvents: []string{ - Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "inducing failure for update services"), + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to update service: inducing failure for update services"), }, WantErr: true, }, @@ -343,7 +346,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.FilterLabels(brokerName)), WithDeploymentServiceAccount(filterSA), - WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(), readinessProbe(), envVars(filterContainerName), containerPorts(8080))), + WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(true), readinessProbe(true), envVars(filterContainerName), containerPorts(8080, true))), NewService(filterServiceName, testNS, WithServiceOwnerReferences(ownerReferences()), WithServiceLabels(resources.FilterLabels(brokerName)), @@ -357,7 +360,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.IngressLabels(brokerName)), WithDeploymentServiceAccount(ingressSA), - WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(), nil, envVars(ingressContainerName), containerPorts(8080)), + WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(true), nil, envVars(ingressContainerName), containerPorts(8080, true)), ), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ @@ -367,10 +370,10 @@ func TestReconcile(t *testing.T) { WithTriggerChannelReady(), WithFilterDeploymentAvailable(), WithBrokerTriggerChannel(createTriggerChannelRef()), - WithIngressFailed("DeploymentFailure", "inducing failure for create deployments")), + WithIngressFailed("ServiceFailure", "failed to create deployment: inducing failure for create deployments")), }}, WantEvents: []string{ - Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "inducing failure for create deployments"), + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to create deployment: inducing failure for create deployments"), }, WantErr: true, }, @@ -388,7 +391,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.FilterLabels(brokerName)), WithDeploymentServiceAccount(filterSA), - WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(), readinessProbe(), envVars(filterContainerName), containerPorts(8080))), + WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(true), readinessProbe(true), envVars(filterContainerName), containerPorts(8080, true))), NewService(filterServiceName, testNS, WithServiceOwnerReferences(ownerReferences()), WithServiceLabels(resources.FilterLabels(brokerName)), @@ -397,7 +400,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.IngressLabels(brokerName)), WithDeploymentServiceAccount(ingressSA), - WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(), nil, envVars(ingressContainerName), containerPorts(9090))), + WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(true), nil, envVars(ingressContainerName), containerPorts(9090, true))), }, WithReactors: []clientgotesting.ReactionFunc{ InduceFailure("update", "deployments"), @@ -407,7 +410,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.IngressLabels(brokerName)), WithDeploymentServiceAccount(ingressSA), - WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(), nil, envVars(ingressContainerName), containerPorts(8080))), + WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(true), nil, envVars(ingressContainerName), containerPorts(8080, true))), }}, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, @@ -418,10 +421,10 @@ func TestReconcile(t *testing.T) { WithTriggerChannelReady(), WithFilterDeploymentAvailable(), WithBrokerTriggerChannel(createTriggerChannelRef()), - WithIngressFailed("DeploymentFailure", "inducing failure for update deployments")), + WithIngressFailed("ServiceFailure", "failed to update deployment: inducing failure for update deployments")), }}, WantEvents: []string{ - Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "inducing failure for update deployments"), + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to update deployment: inducing failure for update deployments"), }, WantErr: true, }, @@ -437,7 +440,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.FilterLabels(brokerName)), WithDeploymentServiceAccount(filterSA), - WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(), readinessProbe(), envVars(filterContainerName), containerPorts(8080))), + WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(true), readinessProbe(true), envVars(filterContainerName), containerPorts(8080, true))), NewService(filterServiceName, testNS, WithServiceOwnerReferences(ownerReferences()), WithServiceLabels(resources.FilterLabels(brokerName)), @@ -446,7 +449,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.IngressLabels(brokerName)), WithDeploymentServiceAccount(ingressSA), - WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(), nil, envVars(ingressContainerName), containerPorts(8080))), + WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(true), nil, envVars(ingressContainerName), containerPorts(8080, true))), }, WithReactors: []clientgotesting.ReactionFunc{ InduceFailure("create", "services"), @@ -464,10 +467,10 @@ func TestReconcile(t *testing.T) { WithTriggerChannelReady(), WithFilterDeploymentAvailable(), WithBrokerTriggerChannel(createTriggerChannelRef()), - WithIngressFailed("ServiceFailure", "inducing failure for create services")), + WithIngressFailed("ServiceFailure", "failed to create service: inducing failure for create services")), }}, WantEvents: []string{ - Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "inducing failure for create services"), + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to create service: inducing failure for create services"), }, WantErr: true, }, @@ -483,7 +486,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.FilterLabels(brokerName)), WithDeploymentServiceAccount(filterSA), - WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(), readinessProbe(), envVars(filterContainerName), containerPorts(8080))), + WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(true), readinessProbe(true), envVars(filterContainerName), containerPorts(8080, true))), NewService(filterServiceName, testNS, WithServiceOwnerReferences(ownerReferences()), WithServiceLabels(resources.FilterLabels(brokerName)), @@ -492,7 +495,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.IngressLabels(brokerName)), WithDeploymentServiceAccount(ingressSA), - WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(), nil, envVars(ingressContainerName), containerPorts(8080))), + WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(true), nil, envVars(ingressContainerName), containerPorts(8080, true))), NewService(ingressServiceName, testNS, WithServiceOwnerReferences(ownerReferences()), WithServiceLabels(resources.IngressLabels(brokerName)), @@ -514,10 +517,10 @@ func TestReconcile(t *testing.T) { WithTriggerChannelReady(), WithFilterDeploymentAvailable(), WithBrokerTriggerChannel(createTriggerChannelRef()), - WithIngressFailed("ServiceFailure", "inducing failure for update services")), + WithIngressFailed("ServiceFailure", "failed to update service: inducing failure for update services")), }}, WantEvents: []string{ - Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "inducing failure for update services"), + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to update service: inducing failure for update services"), }, WantErr: true, }, @@ -533,7 +536,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.FilterLabels(brokerName)), WithDeploymentServiceAccount(filterSA), - WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(), readinessProbe(), envVars(filterContainerName), containerPorts(8080))), + WithDeploymentContainer(filterContainerName, filterImage, livenessProbe(true), readinessProbe(true), envVars(filterContainerName), containerPorts(8080, true))), NewService(filterServiceName, testNS, WithServiceOwnerReferences(ownerReferences()), WithServiceLabels(resources.FilterLabels(brokerName)), @@ -542,7 +545,7 @@ func TestReconcile(t *testing.T) { WithDeploymentOwnerReferences(ownerReferences()), WithDeploymentLabels(resources.IngressLabels(brokerName)), WithDeploymentServiceAccount(ingressSA), - WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(), nil, envVars(ingressContainerName), containerPorts(8080))), + WithDeploymentContainer(ingressContainerName, ingressImage, livenessProbe(true), nil, envVars(ingressContainerName), containerPorts(8080, true))), NewService(ingressServiceName, testNS, WithServiceOwnerReferences(ownerReferences()), WithServiceLabels(resources.IngressLabels(brokerName)), @@ -565,12 +568,13 @@ func TestReconcile(t *testing.T) { logger := logtesting.TestLogger(t) table.Test(t, MakeFactory(func(ctx context.Context, listers *Listers, cmw configmap.Watcher) controller.Reconciler { ctx = channelable.WithDuck(ctx) + sh := reconciler.NewServiceHelper( + ctx, listers.GetDeploymentLister(), listers.GetK8sServiceLister(), listers.GetServingServiceLister()) return &Reconciler{ Base: reconciler.NewBase(ctx, controllerAgentName, cmw), subscriptionLister: listers.GetSubscriptionLister(), brokerLister: listers.GetBrokerLister(), - serviceLister: listers.GetK8sServiceLister(), - deploymentLister: listers.GetDeploymentLister(), + serviceHelper: sh, filterImage: filterImage, filterServiceAccountName: filterSA, ingressImage: ingressImage, @@ -583,6 +587,258 @@ func TestReconcile(t *testing.T) { )) } +func TestReconcileWithServingService(t *testing.T) { + table := TableTest{ + { + Name: "Filter Service.Create error", + Key: testKey, + Objects: []runtime.Object{ + NewBroker(brokerName, testNS, + WithBrokerChannel(channel()), + WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithInitBrokerConditions), + createChannel(testNS, triggerChannel, true), + }, + WithReactors: []clientgotesting.ReactionFunc{ + InduceFailure("create", "services"), + }, + WantCreates: []runtime.Object{ + NewServingService(filterServiceName, testNS, filterRevisionName, + WithServingServiceOwnerReferences(ownerReferences()), + WithServingServiceLabels(resources.FilterLabels(brokerName)), + WithServingServiceLabels(map[string]string{"serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(resources.FilterLabels(brokerName)), + WithServingServiceServiceAccount(filterSA), + WithServingServiceContainer(filterContainerName, filterImage, livenessProbe(false), readinessProbe(false), envVars(filterContainerName), containerPorts(8080, false))), + }, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewBroker(brokerName, testNS, + WithBrokerChannel(channel()), + WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithInitBrokerConditions, + WithTriggerChannelReady(), + WithBrokerTriggerChannel(createTriggerChannelRef()), + WithFilterFailed("ServiceFailure", "failed to create serving service: inducing failure for create services")), + }}, + WantEvents: []string{ + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to create serving service: inducing failure for create services"), + }, + WantErr: true, + }, + { + Name: "Filter Service.Update error", + Key: testKey, + Objects: []runtime.Object{ + NewBroker(brokerName, testNS, + WithBrokerChannel(channel()), + WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithInitBrokerConditions), + createChannel(testNS, triggerChannel, true), + NewServingService(filterServiceName, testNS, filterRevisionName, + WithServingServiceOwnerReferences(ownerReferences()), + WithServingServiceLabels(resources.FilterLabels(brokerName)), + WithServingServiceLabels(map[string]string{"serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(resources.FilterLabels(brokerName)), + WithServingServiceServiceAccount(filterSA), + WithServingServiceContainer(filterContainerName, "some-other-image", livenessProbe(false), readinessProbe(false), envVars(filterContainerName), containerPorts(8080, false))), + }, + WithReactors: []clientgotesting.ReactionFunc{ + InduceFailure("update", "services"), + }, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewBroker(brokerName, testNS, + WithBrokerChannel(channel()), + WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithInitBrokerConditions, + WithTriggerChannelReady(), + WithBrokerTriggerChannel(createTriggerChannelRef()), + WithFilterFailed("ServiceFailure", "failed to update serving service: inducing failure for update services")), + }}, + WantUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewServingService(filterServiceName, testNS, filterRevisionName, + WithServingServiceOwnerReferences(ownerReferences()), + WithServingServiceLabels(resources.FilterLabels(brokerName)), + WithServingServiceLabels(map[string]string{"serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(resources.FilterLabels(brokerName)), + WithServingServiceServiceAccount(filterSA), + WithServingServiceContainer(filterContainerName, filterImage, livenessProbe(false), readinessProbe(false), envVars(filterContainerName), containerPorts(8080, false))), + }}, + WantEvents: []string{ + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to update serving service: inducing failure for update services"), + }, + WantErr: true, + }, + { + Name: "Ingress Service.Create error", + Key: testKey, + Objects: []runtime.Object{ + NewBroker(brokerName, testNS, + WithBrokerChannel(channel()), + WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithInitBrokerConditions), + createChannel(testNS, triggerChannel, true), + NewServingService(filterServiceName, testNS, filterRevisionName, + WithServingServiceOwnerReferences(ownerReferences()), + WithServingServiceLabels(resources.FilterLabels(brokerName)), + WithServingServiceLabels(map[string]string{"serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(resources.FilterLabels(brokerName)), + WithServingServiceServiceAccount(filterSA), + WithServingServiceReady(), + WithServingServiceContainer(filterContainerName, filterImage, livenessProbe(false), readinessProbe(false), envVars(filterContainerName), containerPorts(8080, false))), + }, + WithReactors: []clientgotesting.ReactionFunc{ + InduceFailure("create", "services"), + }, + WantCreates: []runtime.Object{ + NewServingService(ingressServiceName, testNS, ingressRevisionName, + WithServingServiceOwnerReferences(ownerReferences()), + WithServingServiceLabels(resources.IngressLabels(brokerName)), + WithServingServiceLabels(map[string]string{"serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(resources.IngressLabels(brokerName)), + WithServingServiceServiceAccount(ingressSA), + WithServingServiceContainer(ingressContainerName, ingressImage, livenessProbe(false), nil, envVars(ingressContainerName), containerPorts(8080, false))), + }, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewBroker(brokerName, testNS, + WithBrokerChannel(channel()), + WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithInitBrokerConditions, + WithTriggerChannelReady(), + WithFilterDeploymentAvailable(), + WithBrokerTriggerChannel(createTriggerChannelRef()), + WithIngressFailed("ServiceFailure", "failed to create serving service: inducing failure for create services")), + }}, + WantEvents: []string{ + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to create serving service: inducing failure for create services"), + }, + WantErr: true, + }, + { + Name: "Ingress Service.Update error", + Key: testKey, + Objects: []runtime.Object{ + NewBroker(brokerName, testNS, + WithBrokerChannel(channel()), + WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithInitBrokerConditions, + WithBrokerGeneration(brokerGeneration), + ), + createChannel(testNS, triggerChannel, true), + NewServingService(filterServiceName, testNS, filterRevisionName, + WithServingServiceOwnerReferences(ownerReferences()), + WithServingServiceLabels(resources.FilterLabels(brokerName)), + WithServingServiceLabels(map[string]string{"serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(resources.FilterLabels(brokerName)), + WithServingServiceServiceAccount(filterSA), + WithServingServiceReady(), + WithServingServiceContainer(filterContainerName, filterImage, livenessProbe(false), readinessProbe(false), envVars(filterContainerName), containerPorts(8080, false))), + NewServingService(ingressServiceName, testNS, ingressRevisionName, + WithServingServiceOwnerReferences(ownerReferences()), + WithServingServiceLabels(resources.IngressLabels(brokerName)), + WithServingServiceLabels(map[string]string{"serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(resources.IngressLabels(brokerName)), + WithServingServiceServiceAccount(ingressSA), + WithServingServiceContainer(ingressContainerName, "some-other-image", livenessProbe(false), nil, envVars(ingressContainerName), containerPorts(8080, false))), + }, + WithReactors: []clientgotesting.ReactionFunc{ + InduceFailure("update", "services"), + }, + WantUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewServingService(ingressServiceName, testNS, ingressRevisionName, + WithServingServiceOwnerReferences(ownerReferences()), + WithServingServiceLabels(resources.IngressLabels(brokerName)), + WithServingServiceLabels(map[string]string{"serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(resources.IngressLabels(brokerName)), + WithServingServiceServiceAccount(ingressSA), + WithServingServiceContainer(ingressContainerName, ingressImage, livenessProbe(false), nil, envVars(ingressContainerName), containerPorts(8080, false))), + }}, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewBroker(brokerName, testNS, + WithBrokerChannel(channel()), + WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithInitBrokerConditions, + WithBrokerGeneration(brokerGeneration), + WithBrokerStatusObservedGeneration(brokerGeneration), + WithTriggerChannelReady(), + WithFilterDeploymentAvailable(), + WithBrokerTriggerChannel(createTriggerChannelRef()), + WithIngressFailed("ServiceFailure", "failed to update serving service: inducing failure for update services")), + }}, + WantEvents: []string{ + Eventf(corev1.EventTypeWarning, brokerReconcileError, "Broker reconcile error: %v", "failed to update serving service: inducing failure for update services"), + }, + WantErr: true, + }, + { + Name: "Successful Reconciliation", + Key: testKey, + Objects: []runtime.Object{ + NewBroker(brokerName, testNS, + WithBrokerChannel(channel()), + WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithInitBrokerConditions), + createChannel(testNS, triggerChannel, true), + NewServingService(filterServiceName, testNS, filterRevisionName, + WithServingServiceOwnerReferences(ownerReferences()), + WithServingServiceLabels(resources.FilterLabels(brokerName)), + WithServingServiceLabels(map[string]string{"serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(resources.FilterLabels(brokerName)), + WithServingServiceServiceAccount(filterSA), + WithServingServiceReady(), + WithServingServiceContainer(filterContainerName, filterImage, livenessProbe(false), readinessProbe(false), envVars(filterContainerName), containerPorts(8080, false))), + NewServingService(ingressServiceName, testNS, ingressRevisionName, + WithServingServiceOwnerReferences(ownerReferences()), + WithServingServiceLabels(resources.IngressLabels(brokerName)), + WithServingServiceLabels(map[string]string{"serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(resources.IngressLabels(brokerName)), + WithServingServiceServiceAccount(ingressSA), + WithServingServiceReady(), + WithServingServiceContainer(ingressContainerName, ingressImage, livenessProbe(false), nil, envVars(ingressContainerName), containerPorts(8080, false))), + }, + WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ + Object: NewBroker(brokerName, testNS, + WithBrokerChannel(channel()), + WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerReady, + WithBrokerTriggerChannel(createTriggerChannelRef()), + WithBrokerAddress(fmt.Sprintf("%s.%s.svc.%s", ingressServiceName, testNS, utils.GetClusterDomainName())), + ), + }}, + WantEvents: []string{ + Eventf(corev1.EventTypeNormal, brokerReadinessChanged, "Broker %q became ready", brokerName), + }, + }, + } + + logger := logtesting.TestLogger(t) + table.Test(t, MakeFactory(func(ctx context.Context, listers *Listers, cmw configmap.Watcher) controller.Reconciler { + ctx = channelable.WithDuck(ctx) + sh := reconciler.NewServiceHelper( + ctx, listers.GetDeploymentLister(), listers.GetK8sServiceLister(), listers.GetServingServiceLister()) + sh.APIChecker = &fakeAPIChecker{} + return &Reconciler{ + Base: reconciler.NewBase(ctx, controllerAgentName, cmw), + subscriptionLister: listers.GetSubscriptionLister(), + brokerLister: listers.GetBrokerLister(), + serviceHelper: sh, + filterImage: filterImage, + filterServiceAccountName: filterSA, + ingressImage: ingressImage, + ingressServiceAccountName: ingressSA, + channelableTracker: duck.NewListableTracker(ctx, channelable.Get, func(types.NamespacedName) {}, 0), + } + }, + false, + logger, + )) +} + +type fakeAPIChecker struct{} + +func (c *fakeAPIChecker) Exists(s schema.GroupVersion) error { + return nil +} + func ownerReferences() []metav1.OwnerReference { return []metav1.OwnerReference{{ APIVersion: v1alpha1.SchemeGroupVersion.String(), @@ -600,30 +856,42 @@ func channel() metav1.TypeMeta { } } -func livenessProbe() *corev1.Probe { - return &corev1.Probe{ +func livenessProbe(withPort bool) *corev1.Probe { + p := &corev1.Probe{ Handler: corev1.Handler{ HTTPGet: &corev1.HTTPGetAction{ Path: "/healthz", - Port: intstr.IntOrString{Type: intstr.Int, IntVal: 8080}, }, }, InitialDelaySeconds: 5, PeriodSeconds: 2, + FailureThreshold: 3, + TimeoutSeconds: 10, + SuccessThreshold: 1, + } + if withPort { + p.Handler.HTTPGet.Port = intstr.IntOrString{Type: intstr.Int, IntVal: 8080} } + return p } -func readinessProbe() *corev1.Probe { - return &corev1.Probe{ +func readinessProbe(withPort bool) *corev1.Probe { + p := &corev1.Probe{ Handler: corev1.Handler{ HTTPGet: &corev1.HTTPGetAction{ Path: "/readyz", - Port: intstr.IntOrString{Type: intstr.Int, IntVal: 8080}, }, }, InitialDelaySeconds: 5, PeriodSeconds: 2, + FailureThreshold: 3, + TimeoutSeconds: 10, + SuccessThreshold: 1, + } + if withPort { + p.Handler.HTTPGet.Port = intstr.IntOrString{Type: intstr.Int, IntVal: 8080} } + return p } func envVars(containerName string) []corev1.EnvVar { @@ -635,20 +903,12 @@ func envVars(containerName string) []corev1.EnvVar { Value: system.Namespace(), }, { - Name: "NAMESPACE", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.namespace", - }, - }, + Name: "NAMESPACE", + Value: testNS, }, { - Name: "POD_NAME", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.name", - }, - }, + Name: "POD_NAME", + Value: "test-broker-broker-filter", }, { Name: "CONTAINER_NAME", @@ -670,20 +930,12 @@ func envVars(containerName string) []corev1.EnvVar { Value: system.Namespace(), }, { - Name: "NAMESPACE", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.namespace", - }, - }, + Name: "NAMESPACE", + Value: testNS, }, { - Name: "POD_NAME", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.name", - }, - }, + Name: "POD_NAME", + Value: "test-broker-broker-ingress", }, { Name: "CONTAINER_NAME", @@ -710,31 +962,26 @@ func envVars(containerName string) []corev1.EnvVar { return []corev1.EnvVar{} } -func containerPorts(httpInternal int32) []corev1.ContainerPort { - return []corev1.ContainerPort{ +func containerPorts(httpInternal int32, named bool) []corev1.ContainerPort { + p := []corev1.ContainerPort{ { - Name: "http", ContainerPort: httpInternal, }, - { - Name: "metrics", - ContainerPort: 9090, - }, } + if named { + p[0].Name = "http" + } + return p } func servicePorts(httpInternal int) []corev1.ServicePort { - svcPorts := []corev1.ServicePort{ + return []corev1.ServicePort{ { Name: "http", Port: 80, TargetPort: intstr.FromInt(httpInternal), - }, { - Name: "http-metrics", - Port: 9090, }, } - return svcPorts } func createChannel(namespace string, t channelType, ready bool) *unstructured.Unstructured { diff --git a/pkg/reconciler/broker/controller.go b/pkg/reconciler/broker/controller.go index 3aea9271e68..a52ece05828 100644 --- a/pkg/reconciler/broker/controller.go +++ b/pkg/reconciler/broker/controller.go @@ -34,6 +34,7 @@ import ( subscriptioninformer "knative.dev/eventing/pkg/client/injection/informers/messaging/v1alpha1/subscription" deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment" serviceinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/service" + servinginformer "knative.dev/serving/pkg/client/injection/informers/serving/v1/service" ) const ( @@ -67,17 +68,18 @@ func NewController( brokerInformer := brokerinformer.Get(ctx) subscriptionInformer := subscriptioninformer.Get(ctx) serviceInformer := serviceinformer.Get(ctx) + servingInformer := servinginformer.Get(ctx) r := &Reconciler{ Base: reconciler.NewBase(ctx, controllerAgentName, cmw), brokerLister: brokerInformer.Lister(), - serviceLister: serviceInformer.Lister(), - deploymentLister: deploymentInformer.Lister(), subscriptionLister: subscriptionInformer.Lister(), ingressImage: env.IngressImage, ingressServiceAccountName: env.IngressServiceAccount, filterImage: env.FilterImage, filterServiceAccountName: env.FilterServiceAccount, + serviceHelper: reconciler.NewServiceHelper( + ctx, deploymentInformer.Lister(), serviceInformer.Lister(), servingInformer.Lister()), } impl := controller.NewImpl(r, r.Logger, ReconcilerName) @@ -97,5 +99,10 @@ func NewController( Handler: controller.HandleAll(impl.EnqueueControllerOf), }) + servingInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ + FilterFunc: controller.Filter(v1alpha1.SchemeGroupVersion.WithKind("Broker")), + Handler: controller.HandleAll(impl.EnqueueControllerOf), + }) + return impl } diff --git a/pkg/reconciler/broker/controller_test.go b/pkg/reconciler/broker/controller_test.go index 1511eb0a7b6..23205d464da 100644 --- a/pkg/reconciler/broker/controller_test.go +++ b/pkg/reconciler/broker/controller_test.go @@ -29,6 +29,7 @@ import ( _ "knative.dev/eventing/pkg/client/injection/informers/messaging/v1alpha1/subscription/fake" _ "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment/fake" _ "knative.dev/pkg/client/injection/kube/informers/core/v1/service/fake" + _ "knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake" ) func TestNew(t *testing.T) { diff --git a/pkg/reconciler/broker/resources/filter.go b/pkg/reconciler/broker/resources/filter.go index 20193978c67..4fbe4cedd92 100644 --- a/pkg/reconciler/broker/resources/filter.go +++ b/pkg/reconciler/broker/resources/filter.go @@ -19,15 +19,12 @@ package resources import ( "fmt" - "knative.dev/pkg/kmeta" "knative.dev/pkg/system" - appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/util/intstr" - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + "knative.dev/eventing/pkg/reconciler" ) const ( @@ -41,126 +38,82 @@ type FilterArgs struct { ServiceAccountName string } -// MakeFilterDeployment creates the in-memory representation of the Broker's filter Deployment. -func MakeFilterDeployment(args *FilterArgs) *appsv1.Deployment { - return &appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: args.Broker.Namespace, - Name: fmt.Sprintf("%s-broker-filter", args.Broker.Name), - OwnerReferences: []metav1.OwnerReference{ - *kmeta.NewControllerRef(args.Broker), - }, - Labels: FilterLabels(args.Broker.Name), - }, - Spec: appsv1.DeploymentSpec{ - Selector: &metav1.LabelSelector{ - MatchLabels: FilterLabels(args.Broker.Name), - }, - Template: corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: FilterLabels(args.Broker.Name), - }, - Spec: corev1.PodSpec{ - ServiceAccountName: args.ServiceAccountName, - Containers: []corev1.Container{ - { - Name: filterContainerName, - Image: args.Image, - LivenessProbe: &corev1.Probe{ - Handler: corev1.Handler{ - HTTPGet: &corev1.HTTPGetAction{ - Path: "/healthz", - Port: intstr.IntOrString{Type: intstr.Int, IntVal: 8080}, - }, - }, - InitialDelaySeconds: 5, - PeriodSeconds: 2, - }, - ReadinessProbe: &corev1.Probe{ - Handler: corev1.Handler{ - HTTPGet: &corev1.HTTPGetAction{ - Path: "/readyz", - Port: intstr.IntOrString{Type: intstr.Int, IntVal: 8080}, - }, - }, - InitialDelaySeconds: 5, - PeriodSeconds: 2, - }, - Env: []corev1.EnvVar{ - { - Name: system.NamespaceEnvKey, - Value: system.Namespace(), - }, - { - Name: "NAMESPACE", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.namespace", - }, - }, - }, - { - Name: "POD_NAME", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.name", - }, - }, - }, - { - Name: "CONTAINER_NAME", - Value: filterContainerName, - }, - { - Name: "BROKER", - Value: args.Broker.Name, - }, - // Used for StackDriver only. - { - Name: "METRICS_DOMAIN", - Value: "knative.dev/internal/eventing", - }, - }, - Ports: []corev1.ContainerPort{ - { - ContainerPort: 8080, - Name: "http", - }, - { - ContainerPort: 9090, - Name: "metrics", - }, - }, - }, - }, - }, - }, - }, +func MakeFilterServiceMeta(b *eventingv1alpha1.Broker) metav1.ObjectMeta { + return metav1.ObjectMeta{ + Namespace: b.Namespace, + Name: fmt.Sprintf("%s-broker-filter", b.Name), + Labels: FilterLabels(b.Name), } } -// MakeFilterService creates the in-memory representation of the Broker's filter Service. -func MakeFilterService(b *eventingv1alpha1.Broker) *corev1.Service { - return &corev1.Service{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: b.Namespace, - Name: fmt.Sprintf("%s-broker-filter", b.Name), - Labels: FilterLabels(b.Name), - OwnerReferences: []metav1.OwnerReference{ - *kmeta.NewControllerRef(b), - }, - }, - Spec: corev1.ServiceSpec{ - Selector: FilterLabels(b.Name), - Ports: []corev1.ServicePort{ - { - Name: "http", - Port: 80, - TargetPort: intstr.FromInt(8080), - }, +func MakeFilterServiceArgs(args *FilterArgs) *reconciler.ServiceArgs { + return &reconciler.ServiceArgs{ + ServiceMeta: MakeFilterServiceMeta(args.Broker), + DeployMeta: MakeFilterServiceMeta(args.Broker), + PodSpec: corev1.PodSpec{ + ServiceAccountName: args.ServiceAccountName, + Containers: []corev1.Container{ { - Name: "http-metrics", - Port: 9090, + Name: filterContainerName, + Image: args.Image, + LivenessProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/healthz", + // Port should be the same as the container port. + }, + }, + InitialDelaySeconds: 5, + PeriodSeconds: 2, + FailureThreshold: 3, + TimeoutSeconds: 10, + SuccessThreshold: 1, + }, + ReadinessProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/readyz", + // Port should be the same as the container port. + }, + }, + InitialDelaySeconds: 5, + PeriodSeconds: 2, + FailureThreshold: 3, + TimeoutSeconds: 10, + SuccessThreshold: 1, + }, + Env: []corev1.EnvVar{ + { + Name: system.NamespaceEnvKey, + Value: system.Namespace(), + }, + { + Name: "NAMESPACE", + Value: args.Broker.Namespace, + }, + { + Name: "POD_NAME", + Value: fmt.Sprintf("%s-broker-filter", args.Broker.Name), + }, + { + Name: "CONTAINER_NAME", + Value: filterContainerName, + }, + { + Name: "BROKER", + Value: args.Broker.Name, + }, + // Used for StackDriver only. + { + Name: "METRICS_DOMAIN", + Value: "knative.dev/internal/eventing", + }, + }, + Ports: []corev1.ContainerPort{ + { + ContainerPort: 8080, + }, + }, }, }, }, diff --git a/pkg/reconciler/broker/resources/filter_test.go b/pkg/reconciler/broker/resources/filter_test.go deleted file mode 100644 index c0169ee2871..00000000000 --- a/pkg/reconciler/broker/resources/filter_test.go +++ /dev/null @@ -1,277 +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 resources - -import ( - "encoding/json" - "testing" - - "github.com/google/go-cmp/cmp" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/eventing/pkg/apis/eventing/v1alpha1" - - _ "knative.dev/pkg/system/testing" -) - -func TestMakeFilterDeployment(t *testing.T) { - testCases := map[string]struct { - args FilterArgs - want []byte - }{ - "happy": { - args: FilterArgs{ - Broker: &v1alpha1.Broker{ - ObjectMeta: v1.ObjectMeta{ - Name: "happy", - }, - Spec: v1alpha1.BrokerSpec{}, - Status: v1alpha1.BrokerStatus{}, - }, - Image: "image-uri", - ServiceAccountName: "service-account-name", - }, - want: []byte(`{ - "metadata": { - "name": "happy-broker-filter", - "creationTimestamp": null, - "labels": { - "eventing.knative.dev/broker": "happy", - "eventing.knative.dev/brokerRole": "filter" - }, - "ownerReferences": [ - { - "apiVersion": "eventing.knative.dev/v1alpha1", - "kind": "Broker", - "name": "happy", - "uid": "", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "selector": { - "matchLabels": { - "eventing.knative.dev/broker": "happy", - "eventing.knative.dev/brokerRole": "filter" - } - }, - "template": { - "metadata": { - "creationTimestamp": null, - "labels": { - "eventing.knative.dev/broker": "happy", - "eventing.knative.dev/brokerRole": "filter" - } - }, - "spec": { - "containers": [ - { - "name": "filter", - "image": "image-uri", - "ports": [ - { - "name": "http", - "containerPort": 8080 - }, - { - "name": "metrics", - "containerPort": 9090 - } - ], - "env": [ - { - "name": "SYSTEM_NAMESPACE", - "value": "knative-testing" - }, - { - "name": "NAMESPACE", - "valueFrom": { - "fieldRef": { - "fieldPath": "metadata.namespace" - } - } - }, - { - "name": "POD_NAME", - "valueFrom": { - "fieldRef": { - "fieldPath": "metadata.name" - } - } - }, - { - "name": "CONTAINER_NAME", - "value": "filter" - }, - { - "name": "BROKER", - "value": "happy" - }, - { - "name": "METRICS_DOMAIN", - "value": "knative.dev/internal/eventing" - } - ], - "resources": {}, - "livenessProbe": { - "httpGet": { - "path": "/healthz", - "port": 8080 - }, - "initialDelaySeconds": 5, - "periodSeconds": 2 - }, - "readinessProbe": { - "httpGet": { - "path": "/readyz", - "port": 8080 - }, - "initialDelaySeconds": 5, - "periodSeconds": 2 - } - } - ], - "serviceAccountName": "service-account-name" - } - }, - "strategy": {} - }, - "status": {} -}`), - }, - } - for n, tc := range testCases { - t.Run(n, func(t *testing.T) { - dep := MakeFilterDeployment(&tc.args) - - got, err := json.MarshalIndent(dep, "", " ") - if err != nil { - t.Errorf("failed to marshal deployment, %s", err) - } - - if diff := cmp.Diff(tc.want, got); diff != "" { - t.Log(string(got)) - t.Errorf("unexpected deployment (-want, +got) = %v", diff) - } - }) - } -} - -func TestMakeFilterService(t *testing.T) { - testCases := map[string]struct { - broker v1alpha1.Broker - want []byte - }{ - "happy": { - broker: v1alpha1.Broker{ - ObjectMeta: v1.ObjectMeta{ - Name: "happy", - }, - Spec: v1alpha1.BrokerSpec{}, - Status: v1alpha1.BrokerStatus{}, - }, - want: []byte(`{ - "metadata": { - "name": "happy-broker-filter", - "creationTimestamp": null, - "labels": { - "eventing.knative.dev/broker": "happy", - "eventing.knative.dev/brokerRole": "filter" - }, - "ownerReferences": [ - { - "apiVersion": "eventing.knative.dev/v1alpha1", - "kind": "Broker", - "name": "happy", - "uid": "", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "ports": [ - { - "name": "http", - "port": 80, - "targetPort": 8080 - }, - { - "name": "http-metrics", - "port": 9090, - "targetPort": 0 - } - ], - "selector": { - "eventing.knative.dev/broker": "happy", - "eventing.knative.dev/brokerRole": "filter" - } - }, - "status": { - "loadBalancer": {} - } -}`), - }, - } - for n, tc := range testCases { - t.Run(n, func(t *testing.T) { - dep := MakeFilterService(&tc.broker) - - got, err := json.MarshalIndent(dep, "", " ") - if err != nil { - t.Errorf("failed to marshal deployment, %s", err) - } - - if diff := cmp.Diff(tc.want, got); diff != "" { - t.Log(string(got)) - t.Errorf("unexpected deployment (-want, +got) = %v", diff) - } - }) - } -} - -func TestMakeFilterLabels(t *testing.T) { - testCases := map[string]struct { - name string - want map[string]string - }{ - "with name": { - name: "brokerName", - want: map[string]string{ - "eventing.knative.dev/broker": "brokerName", - "eventing.knative.dev/brokerRole": "filter", - }, - }, - "name empty": { - name: "", - want: map[string]string{ - "eventing.knative.dev/broker": "", - "eventing.knative.dev/brokerRole": "filter", - }, - }, - } - for n, tc := range testCases { - t.Run(n, func(t *testing.T) { - got := FilterLabels(tc.name) - - if diff := cmp.Diff(tc.want, got); diff != "" { - t.Errorf("unexpected labels (-want, +got) = %v", diff) - } - }) - } -} diff --git a/pkg/reconciler/broker/resources/ingress.go b/pkg/reconciler/broker/resources/ingress.go index 9efbd7f5840..038396b1c24 100644 --- a/pkg/reconciler/broker/resources/ingress.go +++ b/pkg/reconciler/broker/resources/ingress.go @@ -19,15 +19,12 @@ package resources import ( "fmt" - "knative.dev/pkg/kmeta" "knative.dev/pkg/system" - appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/util/intstr" - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + "knative.dev/eventing/pkg/reconciler" ) const ( @@ -42,125 +39,77 @@ type IngressArgs struct { ChannelAddress string } -// MakeIngress creates the in-memory representation of the Broker's ingress Deployment. -func MakeIngress(args *IngressArgs) *appsv1.Deployment { - return &appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ +func MakeIngressServiceArgs(args *IngressArgs) *reconciler.ServiceArgs { + return &reconciler.ServiceArgs{ + ServiceMeta: metav1.ObjectMeta{ + Namespace: args.Broker.Namespace, + Name: fmt.Sprintf("%s-broker", args.Broker.Name), + Labels: IngressLabels(args.Broker.Name), + }, + DeployMeta: metav1.ObjectMeta{ Namespace: args.Broker.Namespace, Name: fmt.Sprintf("%s-broker-ingress", args.Broker.Name), - OwnerReferences: []metav1.OwnerReference{ - *kmeta.NewControllerRef(args.Broker), - }, - Labels: IngressLabels(args.Broker.Name), + Labels: IngressLabels(args.Broker.Name), }, - Spec: appsv1.DeploymentSpec{ - Selector: &metav1.LabelSelector{ - MatchLabels: IngressLabels(args.Broker.Name), - }, - Template: corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: IngressLabels(args.Broker.Name), - }, - Spec: corev1.PodSpec{ - ServiceAccountName: args.ServiceAccountName, - Containers: []corev1.Container{ - { - Image: args.Image, - Name: ingressContainerName, - LivenessProbe: &corev1.Probe{ - Handler: corev1.Handler{ - HTTPGet: &corev1.HTTPGetAction{ - Path: "/healthz", - Port: intstr.IntOrString{Type: intstr.Int, IntVal: 8080}, - }, - }, - InitialDelaySeconds: 5, - PeriodSeconds: 2, - }, - Env: []corev1.EnvVar{ - { - Name: system.NamespaceEnvKey, - Value: system.Namespace(), - }, - { - Name: "NAMESPACE", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.namespace", - }, - }, - }, - { - Name: "POD_NAME", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{ - FieldPath: "metadata.name", - }, - }, - }, - { - Name: "CONTAINER_NAME", - Value: ingressContainerName, - }, - { - Name: "FILTER", - Value: "", // TODO Add one. - }, - { - Name: "CHANNEL", - Value: args.ChannelAddress, - }, - { - Name: "BROKER", - Value: args.Broker.Name, - }, - // Used for StackDriver only. - { - Name: "METRICS_DOMAIN", - Value: "knative.dev/internal/eventing", - }, - }, - Ports: []corev1.ContainerPort{ - { - ContainerPort: 8080, - Name: "http", - }, - { - ContainerPort: 9090, - Name: "metrics", - }, + PodSpec: corev1.PodSpec{ + ServiceAccountName: args.ServiceAccountName, + Containers: []corev1.Container{ + { + Image: args.Image, + Name: ingressContainerName, + LivenessProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/healthz", + // Port should be the same as the container port. }, }, + InitialDelaySeconds: 5, + PeriodSeconds: 2, + FailureThreshold: 3, + TimeoutSeconds: 10, + SuccessThreshold: 1, + }, + Env: []corev1.EnvVar{ + { + Name: system.NamespaceEnvKey, + Value: system.Namespace(), + }, + { + Name: "NAMESPACE", + Value: args.Broker.Namespace, + }, + { + Name: "POD_NAME", + Value: fmt.Sprintf("%s-broker-ingress", args.Broker.Name), + }, + { + Name: "CONTAINER_NAME", + Value: ingressContainerName, + }, + { + Name: "FILTER", + Value: "", // TODO Add one. + }, + { + Name: "CHANNEL", + Value: args.ChannelAddress, + }, + { + Name: "BROKER", + Value: args.Broker.Name, + }, + // Used for StackDriver only. + { + Name: "METRICS_DOMAIN", + Value: "knative.dev/internal/eventing", + }, + }, + Ports: []corev1.ContainerPort{ + { + ContainerPort: 8080, + }, }, - }, - }, - }, - } -} - -// MakeIngressService creates the in-memory representation of the Broker's ingress Service. -func MakeIngressService(b *eventingv1alpha1.Broker) *corev1.Service { - return &corev1.Service{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: b.Namespace, - // TODO add -ingress to the name to be consistent with the filter service naming. - Name: fmt.Sprintf("%s-broker", b.Name), - Labels: IngressLabels(b.Name), - OwnerReferences: []metav1.OwnerReference{ - *kmeta.NewControllerRef(b), - }, - }, - Spec: corev1.ServiceSpec{ - Selector: IngressLabels(b.Name), - Ports: []corev1.ServicePort{ - { - Name: "http", - Port: 80, - TargetPort: intstr.FromInt(8080), - }, - { - Name: "http-metrics", - Port: 9090, }, }, }, diff --git a/pkg/reconciler/service_helper.go b/pkg/reconciler/service_helper.go new file mode 100644 index 00000000000..c880f678f30 --- /dev/null +++ b/pkg/reconciler/service_helper.go @@ -0,0 +1,360 @@ +/* +Copyright 2020 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 + + https://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 reconciler + +import ( + "context" + "fmt" + "strings" + + v1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/client-go/discovery" + "k8s.io/client-go/kubernetes" + appsv1listers "k8s.io/client-go/listers/apps/v1" + corev1listers "k8s.io/client-go/listers/core/v1" + + "knative.dev/eventing/pkg/apis/duck" + "knative.dev/eventing/pkg/reconciler/names" + "knative.dev/pkg/apis" + kubeclient "knative.dev/pkg/client/injection/kube/client" + "knative.dev/pkg/kmeta" + servingcommon "knative.dev/serving/pkg/apis/serving" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + servingclientset "knative.dev/serving/pkg/client/clientset/versioned" + servingclient "knative.dev/serving/pkg/client/injection/client" + servinglisters "knative.dev/serving/pkg/client/listers/serving/v1" +) + +type ServiceStatus struct { + IsReady bool + URL *apis.URL + Reason string + Message string +} + +type ServiceArgs struct { + ServiceMeta metav1.ObjectMeta + DeployMeta metav1.ObjectMeta + PodSpec corev1.PodSpec +} + +type ServiceHelper struct { + kubeClientSet kubernetes.Interface + servingClientSet servingclientset.Interface + serviceLister corev1listers.ServiceLister + deploymentLister appsv1listers.DeploymentLister + servingLister servinglisters.ServiceLister + APIChecker APIChecker +} + +func NewServiceHelper(ctx context.Context, deploymentLister appsv1listers.DeploymentLister, serviceLister corev1listers.ServiceLister, servingLister servinglisters.ServiceLister) *ServiceHelper { + return &ServiceHelper{ + kubeClientSet: kubeclient.Get(ctx), + servingClientSet: servingclient.Get(ctx), + deploymentLister: deploymentLister, + serviceLister: serviceLister, + servingLister: servingLister, + APIChecker: &apiCheckerImpl{kubeClientSet: kubeclient.Get(ctx)}, + } +} + +type APIChecker interface { + Exists(schema.GroupVersion) error +} + +type apiCheckerImpl struct { + kubeClientSet kubernetes.Interface +} + +func (c *apiCheckerImpl) Exists(s schema.GroupVersion) error { + return discovery.ServerSupportsVersion(c.kubeClientSet.Discovery(), servingv1.SchemeGroupVersion) +} + +func (h *ServiceHelper) ServiceStatus(ctx context.Context, owner kmeta.OwnerRefable, serviceMeta metav1.ObjectMeta) (*ServiceStatus, error) { + useServing, err := h.useServingService(ctx, owner) + if err != nil { + return nil, err + } + + if useServing { + existing, err := h.servingLister.Services(serviceMeta.Namespace).Get(serviceMeta.Name) + if err != nil { + return nil, err + } + return servingServiceStatus(existing), nil + } + + existing, err := h.serviceLister.Services(serviceMeta.Namespace).Get(serviceMeta.Name) + if err != nil { + return nil, err + } + return &ServiceStatus{ + IsReady: true, + URL: &apis.URL{ + Scheme: "http", + Host: names.ServiceHostName(existing.Name, existing.Namespace), + }, + }, nil +} + +func (h *ServiceHelper) ReconcileService(ctx context.Context, owner kmeta.OwnerRefable, args ServiceArgs) (*ServiceStatus, error) { + if err := validateArgs(args); err != nil { + return nil, err + } + + useServing, err := h.useServingService(ctx, owner) + if err != nil { + return nil, err + } + + // Make sure the service metadata has proper owner reference. + args.ServiceMeta.OwnerReferences = append(args.ServiceMeta.OwnerReferences, *kmeta.NewControllerRef(owner)) + + if useServing { + return h.reconcileServingService(ctx, args) + } + + return h.reconcileDeploymentService(ctx, owner, args) +} + +func validateArgs(args ServiceArgs) error { + if !strings.HasPrefix(args.DeployMeta.Name, args.ServiceMeta.Name) { + return fmt.Errorf("service name must be a prefix of deployment name") + } + if err := servingcommon.ValidatePodSpec(args.PodSpec); err != nil { + return err + } + if len(args.PodSpec.Containers[0].Ports) == 0 { + args.PodSpec.Containers[0].Ports = []corev1.ContainerPort{ + { + ContainerPort: 8080, + }, + } + } + return nil +} + +func (h *ServiceHelper) reconcileServingService(ctx context.Context, args ServiceArgs) (*ServiceStatus, error) { + // Serving service requires a strict prefix. + // Add "-rev" to make it strict prefix. + args.DeployMeta.Name = args.DeployMeta.Name + "-rev" + + // Just for testing purpose. + // if args.DeployMeta.Annotations == nil { + // args.DeployMeta.Annotations = make(map[string]string) + // } + // args.DeployMeta.Annotations["autoscaling.knative.dev/minScale"] = "1" + + // Always use cluster local service. + if args.ServiceMeta.Labels == nil { + args.ServiceMeta.Labels = make(map[string]string) + } + args.ServiceMeta.Labels["serving.knative.dev/visibility"] = "cluster-local" + + svc := &servingv1.Service{ + ObjectMeta: args.ServiceMeta, + Spec: servingv1.ServiceSpec{ + ConfigurationSpec: servingv1.ConfigurationSpec{ + Template: servingv1.RevisionTemplateSpec{ + ObjectMeta: args.DeployMeta, + Spec: servingv1.RevisionSpec{ + PodSpec: args.PodSpec, + }, + }, + }, + }, + } + + existing, err := h.servingLister.Services(args.ServiceMeta.Namespace).Get(args.ServiceMeta.Name) + if apierrors.IsNotFound(err) { + existing, err = h.servingClientSet.ServingV1().Services(args.ServiceMeta.Namespace).Create(svc) + if err != nil { + return nil, fmt.Errorf("failed to create serving service: %w", err) + } + return servingServiceStatus(existing), nil + } else if err != nil { + return nil, fmt.Errorf("failed to get existing serving service: %w", err) + } + + if !equality.Semantic.DeepDerivative(svc.Spec, existing.Spec) { + desired := existing.DeepCopy() + desired.Spec = svc.Spec + existing, err = h.servingClientSet.ServingV1().Services(args.ServiceMeta.Namespace).Update(desired) + if err != nil { + return nil, fmt.Errorf("failed to update serving service: %w", err) + } + } + + return servingServiceStatus(existing), nil +} + +func servingServiceStatus(svc *servingv1.Service) *ServiceStatus { + cond := svc.Status.GetCondition(apis.ConditionReady) + ss := &ServiceStatus{ + IsReady: svc.Status.IsReady(), + URL: svc.Status.URL, + } + if cond != nil { + ss.Message = cond.Message + ss.Reason = cond.Reason + } + return ss +} + +func (h *ServiceHelper) reconcileDeploymentService(ctx context.Context, owner kmeta.OwnerRefable, args ServiceArgs) (*ServiceStatus, error) { + // Make sure the deployment metadata has proper owner reference. + args.DeployMeta.OwnerReferences = append(args.DeployMeta.OwnerReferences, *kmeta.NewControllerRef(owner)) + args.PodSpec.Containers[0].Ports[0].Name = "http" + userPort := args.PodSpec.Containers[0].Ports[0].ContainerPort + + if args.PodSpec.Containers[0].LivenessProbe != nil { + if args.PodSpec.Containers[0].LivenessProbe.HTTPGet != nil { + args.PodSpec.Containers[0].LivenessProbe.HTTPGet.Port = intstr.FromInt(int(userPort)) + } + } + if args.PodSpec.Containers[0].ReadinessProbe != nil { + if args.PodSpec.Containers[0].ReadinessProbe.HTTPGet != nil { + args.PodSpec.Containers[0].ReadinessProbe.HTTPGet.Port = intstr.FromInt(int(userPort)) + } + } + + d := &v1.Deployment{ + ObjectMeta: args.DeployMeta, + Spec: v1.DeploymentSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: args.DeployMeta.Labels, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: args.DeployMeta.Labels, + }, + Spec: args.PodSpec, + }, + }, + } + rd, err := h.reconcileDeployment(ctx, d) + if err != nil { + return nil, err + } + + svc := &corev1.Service{ + ObjectMeta: args.ServiceMeta, + Spec: corev1.ServiceSpec{ + Selector: args.DeployMeta.Labels, + Ports: []corev1.ServicePort{ + { + Name: "http", + Port: 80, + TargetPort: intstr.FromInt(int(userPort)), + }, + }, + }, + } + rsvc, err := h.reconcileService(ctx, svc) + if err != nil { + return nil, err + } + + if duck.DeploymentIsAvailable(&rd.Status, true) { + return &ServiceStatus{ + IsReady: true, + URL: &apis.URL{ + Scheme: "http", + Host: names.ServiceHostName(rsvc.Name, rsvc.Namespace), + }, + }, nil + } + + return &ServiceStatus{ + IsReady: false, + Reason: "DeploymentUnavailable", + Message: fmt.Sprintf("The Deployment %q is unavailable", rd.Name), + }, nil +} + +func (h *ServiceHelper) reconcileDeployment(ctx context.Context, d *v1.Deployment) (*v1.Deployment, error) { + existing, err := h.deploymentLister.Deployments(d.Namespace).Get(d.Name) + if apierrors.IsNotFound(err) { + existing, err = h.kubeClientSet.AppsV1().Deployments(d.Namespace).Create(d) + if err != nil { + return nil, fmt.Errorf("failed to create deployment: %w", err) + } + return existing, nil + } else if err != nil { + return nil, fmt.Errorf("failed to get existing deployment: %w", err) + } + + if !equality.Semantic.DeepDerivative(d.Spec, existing.Spec) { + // Don't modify the informers copy. + desired := existing.DeepCopy() + desired.Spec = d.Spec + existing, err = h.kubeClientSet.AppsV1().Deployments(existing.Namespace).Update(desired) + if err != nil { + return nil, fmt.Errorf("failed to update deployment: %w", err) + } + } + return existing, nil +} + +// reconcileService reconciles the K8s Service 'svc'. +func (h *ServiceHelper) reconcileService(ctx context.Context, svc *corev1.Service) (*corev1.Service, error) { + existing, err := h.serviceLister.Services(svc.Namespace).Get(svc.Name) + if apierrors.IsNotFound(err) { + existing, err = h.kubeClientSet.CoreV1().Services(svc.Namespace).Create(svc) + if err != nil { + return nil, fmt.Errorf("failed to create service: %w", err) + } + return existing, nil + } else if err != nil { + return nil, fmt.Errorf("failed to get existing service: %w", err) + } + + // spec.clusterIP is immutable and is set on existing services. If we don't set this to the same value, we will + // encounter an error while updating. + svc.Spec.ClusterIP = existing.Spec.ClusterIP + if !equality.Semantic.DeepDerivative(svc.Spec, existing.Spec) { + // Don't modify the informers copy. + desired := existing.DeepCopy() + desired.Spec = svc.Spec + existing, err = h.kubeClientSet.CoreV1().Services(existing.Namespace).Update(desired) + if err != nil { + return nil, fmt.Errorf("failed to update service: %w", err) + } + } + return existing, nil +} + +func (h *ServiceHelper) useServingService(ctx context.Context, owner kmeta.OwnerRefable) (bool, error) { + if v, ok := owner.GetObjectMeta().GetAnnotations()["eventing.knative.dev/serviceFlavor"]; !ok && v != "knative" { + return false, nil + } + + if err := h.APIChecker.Exists(servingv1.SchemeGroupVersion); err != nil { + if strings.Contains(err.Error(), "server does not support API version") { + return false, err + } + return false, fmt.Errorf("failed to check serving API version: %w", err) + } + + return true, nil +} diff --git a/pkg/reconciler/testing/broker.go b/pkg/reconciler/testing/broker.go index b70d29faeea..ea0e35589f7 100644 --- a/pkg/reconciler/testing/broker.go +++ b/pkg/reconciler/testing/broker.go @@ -45,6 +45,12 @@ func NewBroker(name, namespace string, o ...BrokerOption) *v1alpha1.Broker { return b } +func WithBrokerAnnotations(annotations map[string]string) BrokerOption { + return func(s *v1alpha1.Broker) { + s.Annotations = annotations + } +} + // WithInitBrokerConditions initializes the Broker's conditions. func WithInitBrokerConditions(b *v1alpha1.Broker) { b.Status.InitializeConditions() diff --git a/pkg/reconciler/testing/factory.go b/pkg/reconciler/testing/factory.go index 76100354ea0..7c0cf5fb464 100644 --- a/pkg/reconciler/testing/factory.go +++ b/pkg/reconciler/testing/factory.go @@ -38,6 +38,7 @@ import ( fakelegacyclient "knative.dev/eventing/pkg/legacyclient/injection/client/fake" fakekubeclient "knative.dev/pkg/client/injection/kube/client/fake" fakedynamicclient "knative.dev/pkg/injection/clients/dynamicclient/fake" + fakeservingclient "knative.dev/serving/pkg/client/injection/client/fake" . "knative.dev/pkg/reconciler/testing" ) @@ -62,6 +63,7 @@ func MakeFactory(ctor Ctor, unstructured bool, logger *zap.SugaredLogger) Factor ctx, kubeClient := fakekubeclient.With(ctx, ls.GetKubeObjects()...) ctx, client := fakeeventingclient.With(ctx, ls.GetEventingObjects()...) ctx, legacy := fakelegacyclient.With(ctx, ls.GetLegacyObjects()...) + ctx, servingclient := fakeservingclient.With(ctx, ls.GetServingObjects()...) ctx, dynamicClient := fakedynamicclient.With(ctx, NewScheme(), ToUnstructured(t, r.Objects)...) @@ -90,6 +92,7 @@ func MakeFactory(ctor Ctor, unstructured bool, logger *zap.SugaredLogger) Factor kubeClient.PrependReactor("*", "*", reactor) client.PrependReactor("*", "*", reactor) legacy.PrependReactor("*", "*", reactor) + servingclient.PrependReactor("*", "*", reactor) dynamicClient.PrependReactor("*", "*", reactor) } @@ -109,7 +112,7 @@ func MakeFactory(ctor Ctor, unstructured bool, logger *zap.SugaredLogger) Factor return ValidateUpdates(ctx, action) }) - actionRecorderList := ActionRecorderList{dynamicClient, client, kubeClient, legacy} + actionRecorderList := ActionRecorderList{dynamicClient, client, kubeClient, legacy, servingclient} eventList := EventList{Recorder: eventRecorder} return c, actionRecorderList, eventList, statsReporter diff --git a/pkg/reconciler/testing/listers.go b/pkg/reconciler/testing/listers.go index ed2e2a6a974..921c9a443e3 100644 --- a/pkg/reconciler/testing/listers.go +++ b/pkg/reconciler/testing/listers.go @@ -46,6 +46,9 @@ import ( fakelegacyclientset "knative.dev/eventing/pkg/legacyclient/clientset/versioned/fake" legacysourcelisters "knative.dev/eventing/pkg/legacyclient/listers/legacysources/v1alpha1" "knative.dev/pkg/reconciler/testing" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + fakeservingclientset "knative.dev/serving/pkg/client/clientset/versioned/fake" + servinglisters "knative.dev/serving/pkg/client/listers/serving/v1" ) var subscriberAddToScheme = func(scheme *runtime.Scheme) error { @@ -58,6 +61,7 @@ var clientSetSchemes = []func(*runtime.Scheme) error{ fakeeventingclientset.AddToScheme, fakelegacyclientset.AddToScheme, fakeapiextensionsclientset.AddToScheme, + fakeservingclientset.AddToScheme, subscriberAddToScheme, } @@ -110,11 +114,16 @@ func (l *Listers) GetSubscriberObjects() []runtime.Object { return l.sorter.ObjectsForSchemeFunc(subscriberAddToScheme) } +func (l *Listers) GetServingObjects() []runtime.Object { + return l.sorter.ObjectsForSchemeFunc(fakeservingclientset.AddToScheme) +} + func (l *Listers) GetAllObjects() []runtime.Object { all := l.GetSubscriberObjects() all = append(all, l.GetEventingObjects()...) all = append(all, l.GetLegacyObjects()...) all = append(all, l.GetKubeObjects()...) + all = append(all, l.GetServingObjects()...) return all } @@ -209,3 +218,7 @@ func (l *Listers) GetCustomResourceDefinitionLister() apiextensionsv1beta1lister func (l *Listers) GetConfigMapPropagationLister() configslisters.ConfigMapPropagationLister { return configslisters.NewConfigMapPropagationLister(l.indexerFor(&configsv1alpha1.ConfigMapPropagation{})) } + +func (l *Listers) GetServingServiceLister() servinglisters.ServiceLister { + return servinglisters.NewServiceLister(l.indexerFor(&servingv1.Service{})) +} diff --git a/pkg/reconciler/testing/serving_service.go b/pkg/reconciler/testing/serving_service.go new file mode 100644 index 00000000000..92149f9763a --- /dev/null +++ b/pkg/reconciler/testing/serving_service.go @@ -0,0 +1,125 @@ +/* +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 testing + +import ( + "fmt" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/eventing/pkg/utils" + "knative.dev/pkg/apis" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// DeploymentOption enables further configuration of a Deployment. +type ServingServiceOption func(*servingv1.Service) + +// NewDeployment creates a Deployment with DeploymentOptions. +func NewServingService(name, namespace, revisionName string, do ...ServingServiceOption) *servingv1.Service { + svc := &servingv1.Service{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: namespace, + Name: name, + }, + Spec: servingv1.ServiceSpec{ + ConfigurationSpec: servingv1.ConfigurationSpec{ + Template: servingv1.RevisionTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Name: revisionName, + Namespace: namespace, + }, + Spec: servingv1.RevisionSpec{ + PodSpec: corev1.PodSpec{ + Containers: []corev1.Container{{}}, + }, + }, + }, + }, + }, + } + for _, opt := range do { + opt(svc) + } + return svc +} + +func WithServingServiceLabels(labels map[string]string) ServingServiceOption { + return func(svc *servingv1.Service) { + if svc.ObjectMeta.Labels == nil { + svc.ObjectMeta.Labels = make(map[string]string) + } + for k, v := range labels { + svc.ObjectMeta.Labels[k] = v + } + } +} + +func WithServingServiceTemplateLabels(labels map[string]string) ServingServiceOption { + return func(svc *servingv1.Service) { + if svc.Spec.Template.Labels == nil { + svc.Spec.Template.Labels = make(map[string]string) + } + for k, v := range labels { + svc.Spec.Template.Labels[k] = v + } + } +} + +func WithServingServiceOwnerReferences(ownerReferences []metav1.OwnerReference) ServingServiceOption { + return func(svc *servingv1.Service) { + svc.OwnerReferences = ownerReferences + } +} + +func WithServingServiceAnnotations(annotations map[string]string) ServingServiceOption { + return func(svc *servingv1.Service) { + svc.Annotations = annotations + } +} + +func WithServingServiceServiceAccount(serviceAccountName string) ServingServiceOption { + return func(svc *servingv1.Service) { + svc.Spec.Template.Spec.ServiceAccountName = serviceAccountName + } +} + +func WithServingServiceContainer(name, image string, liveness *corev1.Probe, readiness *corev1.Probe, envVars []corev1.EnvVar, containerPorts []corev1.ContainerPort) ServingServiceOption { + return func(svc *servingv1.Service) { + svc.Spec.Template.Spec.Containers[0].Name = name + svc.Spec.Template.Spec.Containers[0].Image = image + svc.Spec.Template.Spec.Containers[0].LivenessProbe = liveness + svc.Spec.Template.Spec.Containers[0].ReadinessProbe = readiness + svc.Spec.Template.Spec.Containers[0].Env = envVars + svc.Spec.Template.Spec.Containers[0].Ports = containerPorts + } +} + +func WithServingServiceReady() ServingServiceOption { + return func(svc *servingv1.Service) { + svc.Status.Conditions = []apis.Condition{ + apis.Condition{ + Type: apis.ConditionReady, + Status: corev1.ConditionTrue, + }, + } + svc.Status.URL = &apis.URL{ + Scheme: "http", + Host: fmt.Sprintf("%s.%s.svc.%s", svc.ObjectMeta.Name, svc.ObjectMeta.Namespace, utils.GetClusterDomainName()), + } + } +} diff --git a/pkg/reconciler/trigger/controller.go b/pkg/reconciler/trigger/controller.go index 76e9651ada2..c7ad5f2de33 100644 --- a/pkg/reconciler/trigger/controller.go +++ b/pkg/reconciler/trigger/controller.go @@ -31,11 +31,14 @@ import ( "knative.dev/eventing/pkg/apis/eventing/v1alpha1" "knative.dev/eventing/pkg/duck" "knative.dev/eventing/pkg/reconciler" - "knative.dev/pkg/client/injection/kube/informers/core/v1/service" "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/broker" "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/trigger" "knative.dev/eventing/pkg/client/injection/informers/messaging/v1alpha1/subscription" + + deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment" + serviceinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/service" + servinginformer "knative.dev/serving/pkg/client/injection/informers/serving/v1/service" ) const ( @@ -57,16 +60,19 @@ func NewController( triggerInformer := trigger.Get(ctx) subscriptionInformer := subscription.Get(ctx) brokerInformer := broker.Get(ctx) - serviceInformer := service.Get(ctx) namespaceInformer := namespace.Get(ctx) + deploymentInformer := deploymentinformer.Get(ctx) + serviceInformer := serviceinformer.Get(ctx) + servingInformer := servinginformer.Get(ctx) r := &Reconciler{ Base: reconciler.NewBase(ctx, controllerAgentName, cmw), triggerLister: triggerInformer.Lister(), subscriptionLister: subscriptionInformer.Lister(), brokerLister: brokerInformer.Lister(), - serviceLister: serviceInformer.Lister(), namespaceLister: namespaceInformer.Lister(), + serviceHelper: reconciler.NewServiceHelper( + ctx, deploymentInformer.Lister(), serviceInformer.Lister(), servingInformer.Lister()), } impl := controller.NewImpl(r, r.Logger, ReconcilerName) diff --git a/pkg/reconciler/trigger/controller_test.go b/pkg/reconciler/trigger/controller_test.go index dae713f64e5..953773a18ba 100644 --- a/pkg/reconciler/trigger/controller_test.go +++ b/pkg/reconciler/trigger/controller_test.go @@ -30,8 +30,10 @@ import ( _ "knative.dev/pkg/client/injection/ducks/duck/v1/conditions/fake" _ "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/addressable/fake" _ "knative.dev/pkg/client/injection/ducks/duck/v1beta1/addressable/fake" + _ "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment/fake" _ "knative.dev/pkg/client/injection/kube/informers/core/v1/namespace/fake" _ "knative.dev/pkg/client/injection/kube/informers/core/v1/service/fake" + _ "knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake" ) func TestNew(t *testing.T) { diff --git a/pkg/reconciler/trigger/trigger.go b/pkg/reconciler/trigger/trigger.go index 987110287fb..49907dc443d 100644 --- a/pkg/reconciler/trigger/trigger.go +++ b/pkg/reconciler/trigger/trigger.go @@ -31,6 +31,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" corev1listers "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" + "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/controller" "knative.dev/pkg/resolver" @@ -44,7 +45,6 @@ import ( "knative.dev/eventing/pkg/logging" "knative.dev/eventing/pkg/reconciler" brokerresources "knative.dev/eventing/pkg/reconciler/broker/resources" - "knative.dev/eventing/pkg/reconciler/names" "knative.dev/eventing/pkg/reconciler/trigger/path" "knative.dev/eventing/pkg/reconciler/trigger/resources" ) @@ -68,7 +68,6 @@ type Reconciler struct { triggerLister listers.TriggerLister subscriptionLister messaginglisters.SubscriptionLister brokerLister listers.BrokerLister - serviceLister corev1listers.ServiceLister namespaceLister corev1listers.NamespaceLister // Regular tracker to track static resources. In particular, it tracks Broker's changes. tracker tracker.Interface @@ -77,6 +76,8 @@ type Reconciler struct { // Dynamic tracker to track AddressableTypes. In particular, it tracks Trigger subscribers. addressableTracker duck.ListableTracker uriResolver *resolver.URIResolver + + serviceHelper *reconciler.ServiceHelper } var brokerGVK = v1alpha1.SchemeGroupVersion.WithKind("Broker") @@ -190,7 +191,7 @@ func (r *Reconciler) reconcile(ctx context.Context, t *v1alpha1.Trigger) error { } // Get Broker filter service. - filterSvc, err := r.getBrokerFilterService(ctx, b) + filterSvcStatus, err := r.serviceHelper.ServiceStatus(ctx, b, brokerresources.MakeFilterServiceMeta(b)) if err != nil { if apierrs.IsNotFound(err) { logging.FromContext(ctx).Error("can not find Broker's Filter service", zap.Error(err)) @@ -220,7 +221,7 @@ func (r *Reconciler) reconcile(ctx context.Context, t *v1alpha1.Trigger) error { t.Status.SubscriberURI = subscriberURI t.Status.MarkSubscriberResolvedSucceeded() - sub, err := r.subscribeToBrokerChannel(ctx, b, t, brokerTrigger, &brokerObjRef, filterSvc) + sub, err := r.subscribeToBrokerChannel(ctx, b, t, brokerTrigger, &brokerObjRef, filterSvcStatus.URL) if err != nil { logging.FromContext(ctx).Error("Unable to Subscribe", zap.Error(err)) t.Status.MarkNotSubscribed("NotSubscribed", "%v", err) @@ -334,18 +335,11 @@ func (r *Reconciler) labelNamespace(ctx context.Context, t *v1alpha1.Trigger) er return nil } -// getBrokerFilterService returns the K8s service for trigger 't' if exists, -// otherwise it returns an error. -func (r *Reconciler) getBrokerFilterService(ctx context.Context, b *v1alpha1.Broker) (*corev1.Service, error) { - svcName := brokerresources.MakeFilterService(b).Name - return r.serviceLister.Services(b.Namespace).Get(svcName) -} - // subscribeToBrokerChannel subscribes service 'svc' to the Broker's channels. -func (r *Reconciler) subscribeToBrokerChannel(ctx context.Context, b *v1alpha1.Broker, t *v1alpha1.Trigger, brokerTrigger, brokerRef *corev1.ObjectReference, svc *corev1.Service) (*messagingv1alpha1.Subscription, error) { +func (r *Reconciler) subscribeToBrokerChannel(ctx context.Context, b *v1alpha1.Broker, t *v1alpha1.Trigger, brokerTrigger, brokerRef *corev1.ObjectReference, filterSvcURL *apis.URL) (*messagingv1alpha1.Subscription, error) { uri := &url.URL{ - Scheme: "http", - Host: names.ServiceHostName(svc.Name, svc.Namespace), + Scheme: filterSvcURL.Scheme, + Host: filterSvcURL.Host, Path: path.Generate(t), } expected := resources.NewSubscription(t, brokerTrigger, brokerRef, uri, b.Spec.Delivery) diff --git a/pkg/reconciler/trigger/trigger_test.go b/pkg/reconciler/trigger/trigger_test.go index c4f39d2a890..c17e30e6b5c 100644 --- a/pkg/reconciler/trigger/trigger_test.go +++ b/pkg/reconciler/trigger/trigger_test.go @@ -32,6 +32,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" clientgotesting "k8s.io/client-go/testing" @@ -54,6 +55,7 @@ import ( "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" . "knative.dev/eventing/pkg/reconciler/testing" . "knative.dev/pkg/reconciler/testing" @@ -138,6 +140,16 @@ func init() { } func TestAllCases(t *testing.T) { + testAllCases(t, makeBroker(), makeBrokerFilterService()) +} + +func TestAllCasesWithServingServiceBroker(t *testing.T) { + b := makeBroker() + b.Annotations = map[string]string{"eventing.knative.dev/serviceFlavor": "knative"} + testAllCases(t, b, makeBrokerFilterServingService()) +} + +func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Object) { triggerKey := testNS + "/" + triggerName table := TableTest{ { @@ -274,7 +286,7 @@ func TestAllCases(t *testing.T) { Name: "Default broker found, with injection annotation enabled", Key: triggerKey, Objects: []runtime.Object{ - makeReadyDefaultBroker(), + makeReadyDefaultBroker(b), reconciletesting.NewTrigger(triggerName, testNS, "default", reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberURI(subscriberURI), @@ -350,7 +362,7 @@ func TestAllCases(t *testing.T) { Name: "The status of Broker is Unknown", Key: triggerKey, Objects: []runtime.Object{ - makeUnknownStatusBroker(), + makeUnknownStatusBroker(b), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberURI(subscriberURI)), @@ -387,7 +399,7 @@ func TestAllCases(t *testing.T) { Name: "No Broker Trigger Channel", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBrokerNoTriggerChannel(), + makeReadyBrokerNoTriggerChannel(b), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberURI(subscriberURI), @@ -412,7 +424,7 @@ func TestAllCases(t *testing.T) { Name: "No Broker Filter Service", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), + makeReadyBroker(b), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberURI(subscriberURI), @@ -440,8 +452,8 @@ func TestAllCases(t *testing.T) { Name: "Subscription not owned by Trigger", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeIngressSubscriptionNotOwnedByTrigger(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -468,8 +480,8 @@ func TestAllCases(t *testing.T) { Name: "Subscription create fail", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberURI(subscriberURI), @@ -502,8 +514,8 @@ func TestAllCases(t *testing.T) { Name: "Subscription delete fail", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeDifferentReadySubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -537,8 +549,8 @@ func TestAllCases(t *testing.T) { Name: "Subscription create after delete fail", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeDifferentReadySubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -575,8 +587,8 @@ func TestAllCases(t *testing.T) { Name: "Subscription updated works", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeDifferentReadySubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -611,8 +623,8 @@ func TestAllCases(t *testing.T) { Name: "Subscription Created, not ready", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberURI(subscriberURI), @@ -643,8 +655,8 @@ func TestAllCases(t *testing.T) { Name: "Trigger has subscriber ref exists", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeSubscriberAddressableAsUnstructured(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -676,8 +688,8 @@ func TestAllCases(t *testing.T) { Name: "Trigger has subscriber ref exists and URI", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeSubscriberAddressableAsUnstructured(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -709,8 +721,8 @@ func TestAllCases(t *testing.T) { Name: "Trigger has subscriber ref exists kubernetes Service", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeSubscriberKubernetesServiceAsUnstructured(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -742,8 +754,8 @@ func TestAllCases(t *testing.T) { Name: "Trigger has subscriber ref doesn't exist", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberRef(subscriberGVK, subscriberName), @@ -768,8 +780,8 @@ func TestAllCases(t *testing.T) { Name: "Subscription not ready, trigger marked not ready", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeFalseStatusSubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -798,8 +810,8 @@ func TestAllCases(t *testing.T) { Name: "Subscription ready, trigger marked ready", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeReadySubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -829,8 +841,8 @@ func TestAllCases(t *testing.T) { Name: "Dependency doesn't exist", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeReadySubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -861,8 +873,8 @@ func TestAllCases(t *testing.T) { Name: "The status of Dependency is False", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeReadySubscription(), makeFalseStatusCronJobSource(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -893,8 +905,8 @@ func TestAllCases(t *testing.T) { Name: "The status of Dependency is Unknown", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeReadySubscription(), makeUnknownStatusCronJobSource(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -926,8 +938,8 @@ func TestAllCases(t *testing.T) { Name: "Dependency generation not equal", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeReadySubscription(), makeGenerationNotEqualCronJobSource(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -958,8 +970,8 @@ func TestAllCases(t *testing.T) { Name: "Dependency ready", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(), - makeBrokerFilterService(), + makeReadyBroker(b), + brokerFilterSvc, makeReadySubscription(), makeReadyCronJobSource(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -996,17 +1008,20 @@ func TestAllCases(t *testing.T) { ctx = v1b1addr.WithDuck(ctx) ctx = v1addr.WithDuck(ctx) ctx = conditions.WithDuck(ctx) + sh := reconciler.NewServiceHelper( + ctx, listers.GetDeploymentLister(), listers.GetK8sServiceLister(), listers.GetServingServiceLister()) + sh.APIChecker = &fakeAPIChecker{} return &Reconciler{ Base: reconciler.NewBase(ctx, controllerAgentName, cmw), triggerLister: listers.GetTriggerLister(), subscriptionLister: listers.GetSubscriptionLister(), brokerLister: listers.GetBrokerLister(), - serviceLister: listers.GetK8sServiceLister(), namespaceLister: listers.GetNamespaceLister(), tracker: tracker.New(func(types.NamespacedName) {}, 0), addressableTracker: duck.NewListableTracker(ctx, v1a1addr.Get, func(types.NamespacedName) {}, 0), kresourceTracker: duck.NewListableTracker(ctx, conditions.Get, func(types.NamespacedName) {}, 0), uriResolver: resolver.NewURIResolver(ctx, func(types.NamespacedName) {}), + serviceHelper: sh, } }, false, @@ -1014,6 +1029,12 @@ func TestAllCases(t *testing.T) { )) } +type fakeAPIChecker struct{} + +func (c *fakeAPIChecker) Exists(s schema.GroupVersion) error { + return nil +} + func makeTrigger() *v1alpha1.Trigger { return &v1alpha1.Trigger{ TypeMeta: metav1.TypeMeta{ @@ -1062,27 +1083,28 @@ func makeEmptyDelivery() *eventingduckv1alpha1.DeliverySpec { return nil } -func makeReadyBrokerNoTriggerChannel() *v1alpha1.Broker { - b := makeBroker() +func makeReadyBrokerNoTriggerChannel(seed *v1alpha1.Broker) *v1alpha1.Broker { + b := seed.DeepCopy() b.Status = *v1alpha1.TestHelper.ReadyBrokerStatus() return b } -func makeReadyBroker() *v1alpha1.Broker { - b := makeBroker() +func makeReadyBroker(seed *v1alpha1.Broker) *v1alpha1.Broker { + b := seed.DeepCopy() b.Status = *v1alpha1.TestHelper.ReadyBrokerStatus() b.Status.TriggerChannel = makeTriggerChannelRef() return b } -func makeUnknownStatusBroker() *v1alpha1.Broker { - b := makeBroker() +func makeUnknownStatusBroker(seed *v1alpha1.Broker) *v1alpha1.Broker { + b := seed.DeepCopy() b.Status = *v1alpha1.TestHelper.UnknownBrokerStatus() return b } -func makeReadyDefaultBroker() *v1alpha1.Broker { - b := makeReadyBroker() +func makeReadyDefaultBroker(seed *v1alpha1.Broker) *v1alpha1.Broker { + b := seed.DeepCopy() + b = makeReadyBroker(seed) b.Name = "default" return b } @@ -1137,13 +1159,29 @@ func makeSubscriberKubernetesServiceAsUnstructured() *unstructured.Unstructured } func makeBrokerFilterService() *corev1.Service { - return brokerresources.MakeFilterService(makeBroker()) + args := brokerresources.MakeFilterServiceArgs(&brokerresources.FilterArgs{ + Broker: makeBroker(), + Image: "test-image", + }) + return NewService(args.ServiceMeta.Name, args.ServiceMeta.Namespace) +} + +func makeBrokerFilterServingService() *servingv1.Service { + args := brokerresources.MakeFilterServiceArgs(&brokerresources.FilterArgs{ + Broker: makeBroker(), + Image: "test-image", + }) + return NewServingService( + args.ServiceMeta.Name, + args.ServiceMeta.Namespace, + args.DeployMeta.Name+"-rev", + WithServingServiceReady()) } func makeServiceURI() *url.URL { return &url.URL{ Scheme: "http", - Host: fmt.Sprintf("%s.%s.svc.%s", makeBrokerFilterService().Name, testNS, utils.GetClusterDomainName()), + Host: fmt.Sprintf("%s.%s.svc.%s", brokerresources.MakeFilterServiceMeta(makeBroker()).Name, testNS, utils.GetClusterDomainName()), Path: fmt.Sprintf("/triggers/%s/%s/%s", testNS, triggerName, triggerUID), } } diff --git a/third_party/VENDOR-LICENSE b/third_party/VENDOR-LICENSE index 1978523090c..720ec2b8e8d 100644 --- a/third_party/VENDOR-LICENSE +++ b/third_party/VENDOR-LICENSE @@ -2322,6 +2322,213 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +=========================================================== +Import: knative.dev/eventing/vendor/github.com/google/go-containerregistry + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + =========================================================== Import: knative.dev/eventing/vendor/github.com/google/go-github @@ -8749,6 +8956,214 @@ Import: knative.dev/eventing/vendor/knative.dev/pkg +=========================================================== +Import: knative.dev/eventing/vendor/knative.dev/serving + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + =========================================================== Import: knative.dev/eventing/vendor/sigs.k8s.io/yaml diff --git a/vendor/github.com/google/go-containerregistry/LICENSE b/vendor/github.com/google/go-containerregistry/LICENSE new file mode 100644 index 00000000000..7a4a3ea2424 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/check.go b/vendor/github.com/google/go-containerregistry/pkg/name/check.go new file mode 100644 index 00000000000..01b03e56262 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/check.go @@ -0,0 +1,43 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package name + +import ( + "strings" + "unicode/utf8" +) + +// stripRunesFn returns a function which returns -1 (i.e. a value which +// signals deletion in strings.Map) for runes in 'runes', and the rune otherwise. +func stripRunesFn(runes string) func(rune) rune { + return func(r rune) rune { + if strings.ContainsRune(runes, r) { + return -1 + } + return r + } +} + +// checkElement checks a given named element matches character and length restrictions. +// Returns true if the given element adheres to the given restrictions, false otherwise. +func checkElement(name, element, allowedRunes string, minRunes, maxRunes int) error { + numRunes := utf8.RuneCountInString(element) + if (numRunes < minRunes) || (maxRunes < numRunes) { + return NewErrBadName("%s must be between %d and %d runes in length: %s", name, minRunes, maxRunes, element) + } else if len(strings.Map(stripRunesFn(allowedRunes), element)) != 0 { + return NewErrBadName("%s can only contain the runes `%s`: %s", name, allowedRunes, element) + } + return nil +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/digest.go b/vendor/github.com/google/go-containerregistry/pkg/name/digest.go new file mode 100644 index 00000000000..2dc0f7f3716 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/digest.go @@ -0,0 +1,90 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package name + +import ( + "strings" +) + +const ( + // These have the form: sha256: + // TODO(dekkagaijin): replace with opencontainers/go-digest or docker/distribution's validation. + digestChars = "sh:0123456789abcdef" + digestDelim = "@" +) + +// Digest stores a digest name in a structured form. +type Digest struct { + Repository + digest string +} + +// Ensure Digest implements Reference +var _ Reference = (*Digest)(nil) + +// Context implements Reference. +func (d Digest) Context() Repository { + return d.Repository +} + +// Identifier implements Reference. +func (d Digest) Identifier() string { + return d.DigestStr() +} + +// DigestStr returns the digest component of the Digest. +func (d Digest) DigestStr() string { + return d.digest +} + +// Name returns the name from which the Digest was derived. +func (d Digest) Name() string { + return d.Repository.Name() + digestDelim + d.DigestStr() +} + +func (d Digest) String() string { + return d.Name() +} + +func checkDigest(name string) error { + return checkElement("digest", name, digestChars, 7+64, 7+64) +} + +// NewDigest returns a new Digest representing the given name. +func NewDigest(name string, opts ...Option) (Digest, error) { + // Split on "@" + parts := strings.Split(name, digestDelim) + if len(parts) != 2 { + return Digest{}, NewErrBadName("a digest must contain exactly one '@' separator (e.g. registry/repository@digest) saw: %s", name) + } + base := parts[0] + digest := parts[1] + + // Always check that the digest is valid. + if err := checkDigest(digest); err != nil { + return Digest{}, err + } + + tag, err := NewTag(base, opts...) + if err == nil { + base = tag.Repository.Name() + } + + repo, err := NewRepository(base, opts...) + if err != nil { + return Digest{}, err + } + return Digest{repo, digest}, nil +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/doc.go b/vendor/github.com/google/go-containerregistry/pkg/name/doc.go new file mode 100644 index 00000000000..b294794dc12 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/doc.go @@ -0,0 +1,42 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package name defines structured types for representing image references. +// +// What's in a name? For image references, not nearly enough! +// +// Image references look a lot like URLs, but they differ in that they don't +// contain the scheme (http or https), they can end with a :tag or a @digest +// (the latter being validated), and they perform defaulting for missing +// components. +// +// Since image references don't contain the scheme, we do our best to infer +// if we use http or https from the given hostname. We allow http fallback for +// any host that looks like localhost (localhost, 127.0.0.1, ::1), ends in +// ".local", or is in the "private" address space per RFC 1918. For everything +// else, we assume https only. To override this heuristic, use the Insecure +// option. +// +// Image references with a digest signal to us that we should verify the content +// of the image matches the digest. E.g. when pulling a Digest reference, we'll +// calculate the sha256 of the manifest returned by the registry and error out +// if it doesn't match what we asked for. +// +// For defaulting, we interpret "ubuntu" as +// "index.docker.io/library/ubuntu:latest" because we add the missing repo +// "library", the missing registry "index.docker.io", and the missing tag +// "latest". To disable this defaulting, use the StrictValidation option. This +// is useful e.g. to only allow image references that explicitly set a tag or +// digest, so that you don't accidentally pull "latest". +package name diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/errors.go b/vendor/github.com/google/go-containerregistry/pkg/name/errors.go new file mode 100644 index 00000000000..7847cc5d1ef --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/errors.go @@ -0,0 +1,37 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package name + +import "fmt" + +// ErrBadName is an error for when a bad docker name is supplied. +type ErrBadName struct { + info string +} + +func (e *ErrBadName) Error() string { + return e.info +} + +// NewErrBadName returns a ErrBadName which returns the given formatted string from Error(). +func NewErrBadName(fmtStr string, args ...interface{}) *ErrBadName { + return &ErrBadName{fmt.Sprintf(fmtStr, args...)} +} + +// IsErrBadName returns true if the given error is an ErrBadName. +func IsErrBadName(err error) bool { + _, ok := err.(*ErrBadName) + return ok +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/options.go b/vendor/github.com/google/go-containerregistry/pkg/name/options.go new file mode 100644 index 00000000000..98beaae1102 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/options.go @@ -0,0 +1,49 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package name + +type options struct { + strict bool // weak by default + insecure bool // secure by default +} + +func makeOptions(opts ...Option) options { + opt := options{} + for _, o := range opts { + o(&opt) + } + return opt +} + +// Option is a functional option for name parsing. +type Option func(*options) + +// StrictValidation is an Option that requires image references to be fully +// specified; i.e. no defaulting for registry (dockerhub), repo (library), +// or tag (latest). +func StrictValidation(opts *options) { + opts.strict = true +} + +// WeakValidation is an Option that sets defaults when parsing names, see +// StrictValidation. +func WeakValidation(opts *options) { + opts.strict = false +} + +// Insecure is an Option that allows image references to be fetched without TLS. +func Insecure(opts *options) { + opts.insecure = true +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/ref.go b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go new file mode 100644 index 00000000000..c02d82e5df4 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go @@ -0,0 +1,49 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package name + +import ( + "fmt" +) + +// Reference defines the interface that consumers use when they can +// take either a tag or a digest. +type Reference interface { + fmt.Stringer + + // Context accesses the Repository context of the reference. + Context() Repository + + // Identifier accesses the type-specific portion of the reference. + Identifier() string + + // Name is the fully-qualified reference name. + Name() string + + // Scope is the scope needed to access this reference. + Scope(string) string +} + +// ParseReference parses the string as a reference, either by tag or digest. +func ParseReference(s string, opts ...Option) (Reference, error) { + if t, err := NewTag(s, opts...); err == nil { + return t, nil + } + if d, err := NewDigest(s, opts...); err == nil { + return d, nil + } + // TODO: Combine above errors into something more useful? + return nil, NewErrBadName("could not parse reference") +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/registry.go b/vendor/github.com/google/go-containerregistry/pkg/name/registry.go new file mode 100644 index 00000000000..c12dd46c2c6 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/registry.go @@ -0,0 +1,142 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package name + +import ( + "net" + "net/url" + "regexp" + "strings" +) + +const ( + // DefaultRegistry is Docker Hub, assumed when a hostname is omitted. + DefaultRegistry = "index.docker.io" + defaultRegistryAlias = "docker.io" +) + +// Detect more complex forms of local references. +var reLocal = regexp.MustCompile(`.*\.local(?:host)?(?::\d{1,5})?$`) + +// Detect the loopback IP (127.0.0.1) +var reLoopback = regexp.MustCompile(regexp.QuoteMeta("127.0.0.1")) + +// Detect the loopback IPV6 (::1) +var reipv6Loopback = regexp.MustCompile(regexp.QuoteMeta("::1")) + +// Registry stores a docker registry name in a structured form. +type Registry struct { + insecure bool + registry string +} + +// RegistryStr returns the registry component of the Registry. +func (r Registry) RegistryStr() string { + if r.registry != "" { + return r.registry + } + return DefaultRegistry +} + +// Name returns the name from which the Registry was derived. +func (r Registry) Name() string { + return r.RegistryStr() +} + +func (r Registry) String() string { + return r.Name() +} + +// Scope returns the scope required to access the registry. +func (r Registry) Scope(string) string { + // The only resource under 'registry' is 'catalog'. http://goo.gl/N9cN9Z + return "registry:catalog:*" +} + +func (r Registry) isRFC1918() bool { + ipStr := strings.Split(r.Name(), ":")[0] + ip := net.ParseIP(ipStr) + if ip == nil { + return false + } + for _, cidr := range []string{"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"} { + _, block, _ := net.ParseCIDR(cidr) + if block.Contains(ip) { + return true + } + } + return false +} + +// Scheme returns https scheme for all the endpoints except localhost or when explicitly defined. +func (r Registry) Scheme() string { + if r.insecure { + return "http" + } + if r.isRFC1918() { + return "http" + } + if strings.HasPrefix(r.Name(), "localhost:") { + return "http" + } + if reLocal.MatchString(r.Name()) { + return "http" + } + if reLoopback.MatchString(r.Name()) { + return "http" + } + if reipv6Loopback.MatchString(r.Name()) { + return "http" + } + return "https" +} + +func checkRegistry(name string) error { + // Per RFC 3986, registries (authorities) are required to be prefixed with "//" + // url.Host == hostname[:port] == authority + if url, err := url.Parse("//" + name); err != nil || url.Host != name { + return NewErrBadName("registries must be valid RFC 3986 URI authorities: %s", name) + } + return nil +} + +// NewRegistry returns a Registry based on the given name. +// Strict validation requires explicit, valid RFC 3986 URI authorities to be given. +func NewRegistry(name string, opts ...Option) (Registry, error) { + opt := makeOptions(opts...) + if opt.strict && len(name) == 0 { + return Registry{}, NewErrBadName("strict validation requires the registry to be explicitly defined") + } + + if err := checkRegistry(name); err != nil { + return Registry{}, err + } + + // Rewrite "docker.io" to "index.docker.io". + // See: https://github.com/google/go-containerregistry/issues/68 + if name == defaultRegistryAlias { + name = DefaultRegistry + } + + return Registry{registry: name, insecure: opt.insecure}, nil +} + +// NewInsecureRegistry returns an Insecure Registry based on the given name. +// +// Deprecated: Use the Insecure Option with NewRegistry instead. +func NewInsecureRegistry(name string, opts ...Option) (Registry, error) { + opts = append(opts, Insecure) + return NewRegistry(name, opts...) +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/repository.go b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go new file mode 100644 index 00000000000..5eeb8ace978 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go @@ -0,0 +1,101 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package name + +import ( + "fmt" + "strings" +) + +const ( + defaultNamespace = "library" + repositoryChars = "abcdefghijklmnopqrstuvwxyz0123456789_-./" + regRepoDelimiter = "/" +) + +// Repository stores a docker repository name in a structured form. +type Repository struct { + Registry + repository string +} + +// See https://docs.docker.com/docker-hub/official_repos +func hasImplicitNamespace(repo string, reg Registry) bool { + return !strings.ContainsRune(repo, '/') && reg.RegistryStr() == DefaultRegistry +} + +// RepositoryStr returns the repository component of the Repository. +func (r Repository) RepositoryStr() string { + if hasImplicitNamespace(r.repository, r.Registry) { + return fmt.Sprintf("%s/%s", defaultNamespace, r.repository) + } + return r.repository +} + +// Name returns the name from which the Repository was derived. +func (r Repository) Name() string { + regName := r.Registry.Name() + if regName != "" { + return regName + regRepoDelimiter + r.RepositoryStr() + } + // TODO: As far as I can tell, this is unreachable. + return r.RepositoryStr() +} + +func (r Repository) String() string { + return r.Name() +} + +// Scope returns the scope required to perform the given action on the registry. +// TODO(jonjohnsonjr): consider moving scopes to a separate package. +func (r Repository) Scope(action string) string { + return fmt.Sprintf("repository:%s:%s", r.RepositoryStr(), action) +} + +func checkRepository(repository string) error { + return checkElement("repository", repository, repositoryChars, 2, 255) +} + +// NewRepository returns a new Repository representing the given name, according to the given strictness. +func NewRepository(name string, opts ...Option) (Repository, error) { + opt := makeOptions(opts...) + if len(name) == 0 { + return Repository{}, NewErrBadName("a repository name must be specified") + } + + var registry string + repo := name + parts := strings.SplitN(name, regRepoDelimiter, 2) + if len(parts) == 2 && (strings.ContainsRune(parts[0], '.') || strings.ContainsRune(parts[0], ':')) { + // The first part of the repository is treated as the registry domain + // iff it contains a '.' or ':' character, otherwise it is all repository + // and the domain defaults to Docker Hub. + registry = parts[0] + repo = parts[1] + } + + if err := checkRepository(repo); err != nil { + return Repository{}, err + } + + reg, err := NewRegistry(registry, opts...) + if err != nil { + return Repository{}, err + } + if hasImplicitNamespace(repo, reg) && opt.strict { + return Repository{}, NewErrBadName("strict validation requires the full repository path (missing 'library')") + } + return Repository{reg, repo}, nil +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/tag.go b/vendor/github.com/google/go-containerregistry/pkg/name/tag.go new file mode 100644 index 00000000000..e6cce34dbd7 --- /dev/null +++ b/vendor/github.com/google/go-containerregistry/pkg/name/tag.go @@ -0,0 +1,102 @@ +// Copyright 2018 Google LLC All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package name + +import ( + "strings" +) + +const ( + defaultTag = "latest" + // TODO(dekkagaijin): use the docker/distribution regexes for validation. + tagChars = "abcdefghijklmnopqrstuvwxyz0123456789_-.ABCDEFGHIJKLMNOPQRSTUVWXYZ" + tagDelim = ":" +) + +// Tag stores a docker tag name in a structured form. +type Tag struct { + Repository + tag string +} + +// Ensure Tag implements Reference +var _ Reference = (*Tag)(nil) + +// Context implements Reference. +func (t Tag) Context() Repository { + return t.Repository +} + +// Identifier implements Reference. +func (t Tag) Identifier() string { + return t.TagStr() +} + +// TagStr returns the tag component of the Tag. +func (t Tag) TagStr() string { + if t.tag != "" { + return t.tag + } + return defaultTag +} + +// Name returns the name from which the Tag was derived. +func (t Tag) Name() string { + return t.Repository.Name() + tagDelim + t.TagStr() +} + +func (t Tag) String() string { + return t.Name() +} + +// Scope returns the scope required to perform the given action on the tag. +func (t Tag) Scope(action string) string { + return t.Repository.Scope(action) +} + +func checkTag(name string) error { + return checkElement("tag", name, tagChars, 1, 127) +} + +// NewTag returns a new Tag representing the given name, according to the given strictness. +func NewTag(name string, opts ...Option) (Tag, error) { + opt := makeOptions(opts...) + base := name + tag := "" + + // Split on ":" + parts := strings.Split(name, tagDelim) + // Verify that we aren't confusing a tag for a hostname w/ port for the purposes of weak validation. + if len(parts) > 1 && !strings.Contains(parts[len(parts)-1], regRepoDelimiter) { + base = strings.Join(parts[:len(parts)-1], tagDelim) + tag = parts[len(parts)-1] + } + + // We don't require a tag, but if we get one check it's valid, + // even when not being strict. + // If we are being strict, we want to validate the tag regardless in case + // it's empty. + if tag != "" || opt.strict { + if err := checkTag(tag); err != nil { + return Tag{}, err + } + } + + repo, err := NewRepository(base, opts...) + if err != nil { + return Tag{}, err + } + return Tag{repo, tag}, nil +} diff --git a/vendor/github.com/mailru/easyjson/helpers.go b/vendor/github.com/mailru/easyjson/helpers.go new file mode 100644 index 00000000000..b86b87d228a --- /dev/null +++ b/vendor/github.com/mailru/easyjson/helpers.go @@ -0,0 +1,78 @@ +// Package easyjson contains marshaler/unmarshaler interfaces and helper functions. +package easyjson + +import ( + "io" + "io/ioutil" + "net/http" + "strconv" + + "github.com/mailru/easyjson/jlexer" + "github.com/mailru/easyjson/jwriter" +) + +// Marshaler is an easyjson-compatible marshaler interface. +type Marshaler interface { + MarshalEasyJSON(w *jwriter.Writer) +} + +// Marshaler is an easyjson-compatible unmarshaler interface. +type Unmarshaler interface { + UnmarshalEasyJSON(w *jlexer.Lexer) +} + +// Optional defines an undefined-test method for a type to integrate with 'omitempty' logic. +type Optional interface { + IsDefined() bool +} + +// Marshal returns data as a single byte slice. Method is suboptimal as the data is likely to be copied +// from a chain of smaller chunks. +func Marshal(v Marshaler) ([]byte, error) { + w := jwriter.Writer{} + v.MarshalEasyJSON(&w) + return w.BuildBytes() +} + +// MarshalToWriter marshals the data to an io.Writer. +func MarshalToWriter(v Marshaler, w io.Writer) (written int, err error) { + jw := jwriter.Writer{} + v.MarshalEasyJSON(&jw) + return jw.DumpTo(w) +} + +// MarshalToHTTPResponseWriter sets Content-Length and Content-Type headers for the +// http.ResponseWriter, and send the data to the writer. started will be equal to +// false if an error occurred before any http.ResponseWriter methods were actually +// invoked (in this case a 500 reply is possible). +func MarshalToHTTPResponseWriter(v Marshaler, w http.ResponseWriter) (started bool, written int, err error) { + jw := jwriter.Writer{} + v.MarshalEasyJSON(&jw) + if jw.Error != nil { + return false, 0, jw.Error + } + w.Header().Set("Content-Type", "application/json") + w.Header().Set("Content-Length", strconv.Itoa(jw.Size())) + + started = true + written, err = jw.DumpTo(w) + return +} + +// Unmarshal decodes the JSON in data into the object. +func Unmarshal(data []byte, v Unmarshaler) error { + l := jlexer.Lexer{Data: data} + v.UnmarshalEasyJSON(&l) + return l.Error() +} + +// UnmarshalFromReader reads all the data in the reader and decodes as JSON into the object. +func UnmarshalFromReader(r io.Reader, v Unmarshaler) error { + data, err := ioutil.ReadAll(r) + if err != nil { + return err + } + l := jlexer.Lexer{Data: data} + v.UnmarshalEasyJSON(&l) + return l.Error() +} diff --git a/vendor/github.com/mailru/easyjson/raw.go b/vendor/github.com/mailru/easyjson/raw.go new file mode 100644 index 00000000000..81bd002e19f --- /dev/null +++ b/vendor/github.com/mailru/easyjson/raw.go @@ -0,0 +1,45 @@ +package easyjson + +import ( + "github.com/mailru/easyjson/jlexer" + "github.com/mailru/easyjson/jwriter" +) + +// RawMessage is a raw piece of JSON (number, string, bool, object, array or +// null) that is extracted without parsing and output as is during marshaling. +type RawMessage []byte + +// MarshalEasyJSON does JSON marshaling using easyjson interface. +func (v *RawMessage) MarshalEasyJSON(w *jwriter.Writer) { + if len(*v) == 0 { + w.RawString("null") + } else { + w.Raw(*v, nil) + } +} + +// UnmarshalEasyJSON does JSON unmarshaling using easyjson interface. +func (v *RawMessage) UnmarshalEasyJSON(l *jlexer.Lexer) { + *v = RawMessage(l.Raw()) +} + +// UnmarshalJSON implements encoding/json.Unmarshaler interface. +func (v *RawMessage) UnmarshalJSON(data []byte) error { + *v = data + return nil +} + +var nullBytes = []byte("null") + +// MarshalJSON implements encoding/json.Marshaler interface. +func (v RawMessage) MarshalJSON() ([]byte, error) { + if len(v) == 0 { + return nullBytes, nil + } + return v, nil +} + +// IsDefined is required for integration with omitempty easyjson logic. +func (v *RawMessage) IsDefined() bool { + return len(*v) > 0 +} diff --git a/vendor/github.com/tsenart/vegeta/lib/attack.go b/vendor/github.com/tsenart/vegeta/lib/attack.go index 51c4957db46..b44fa94fefb 100644 --- a/vendor/github.com/tsenart/vegeta/lib/attack.go +++ b/vendor/github.com/tsenart/vegeta/lib/attack.go @@ -28,6 +28,7 @@ type Attacker struct { seqmu sync.Mutex seq uint64 began time.Time + chunked bool } const ( @@ -113,6 +114,12 @@ func Connections(n int) func(*Attacker) { } } +// ChunkedBody returns a functional option which makes the attacker send the +// body of each request with the chunked transfer encoding. +func ChunkedBody(b bool) func(*Attacker) { + return func(a *Attacker) { a.chunked = b } +} + // Redirects returns a functional option which sets the maximum // number of redirects an Attacker will follow. func Redirects(n int) func(*Attacker) { @@ -229,6 +236,16 @@ func Client(c *http.Client) func(*Attacker) { return func(a *Attacker) { a.client = *c } } +// ProxyHeader returns a functional option that allows you to add your own +// Proxy CONNECT headers +func ProxyHeader(h http.Header) func(*Attacker) { + return func(a *Attacker) { + if tr, ok := a.client.Transport.(*http.Transport); ok { + tr.ProxyConnectHeader = h + } + } +} + // Attack reads its Targets from the passed Targeter and attacks them at // the rate specified by the Pacer. When the duration is zero the attack // runs until Stop is called. Results are sent to the returned channel as soon @@ -336,11 +353,18 @@ func (a *Attacker) hit(tr Targeter, name string) *Result { return &res } + res.Method = tgt.Method + res.URL = tgt.URL + req, err := tgt.Request() if err != nil { return &res } + if a.chunked { + req.TransferEncoding = append(req.TransferEncoding, "chunked") + } + r, err := a.client.Do(req) if err != nil { return &res diff --git a/vendor/github.com/tsenart/vegeta/lib/attack_fuzz.go b/vendor/github.com/tsenart/vegeta/lib/attack_fuzz.go new file mode 100644 index 00000000000..e14eef61f07 --- /dev/null +++ b/vendor/github.com/tsenart/vegeta/lib/attack_fuzz.go @@ -0,0 +1,154 @@ +// +build gofuzz + +package vegeta + +import ( + "encoding/binary" + "fmt" + "io/ioutil" + "net" + "net/http" + "os" + "time" +) + +// FuzzAttackerTCP fuzzes binary responses to attacker. +func FuzzAttackerTCP(fuzz []byte) int { + // Ignore empty fuzz + if len(fuzz) == 0 { + return -1 + } + + // Start server + directory, err := ioutil.TempDir("/tmp", "fuzz") + if err != nil { + panic(err.Error()) + } + socket := fmt.Sprintf("%s/attacker.sock", directory) + listener, err := net.Listen("unix", socket) + if err != nil { + panic(err.Error()) + } + go func() { + connection, err := listener.Accept() + if err != nil { + panic(err.Error()) + } + _, err = connection.Write(fuzz) + if err != nil { + panic(err.Error()) + } + err = connection.Close() + if err != nil { + panic(err.Error()) + } + }() + defer listener.Close() + defer os.RemoveAll(directory) + + // Setup targeter + targeter := Targeter(func(target *Target) error { + target.Method = "GET" + target.URL = "http://vegeta.test" + return nil + }) + + // Deliver a single hit + attacker := NewAttacker( + UnixSocket(socket), + Workers(1), + MaxWorkers(1), + Timeout(time.Second), + KeepAlive(false), + ) + result := attacker.hit(targeter, "fuzz") + if result.Error != "" { + return 0 + } + return 1 +} + +// FuzzAttackerHTTP fuzzes valid HTTP responses to attacker. +func FuzzAttackerHTTP(fuzz []byte) int { + // Decode response + code, headers, body, ok := decodeFuzzResponse(fuzz) + if !ok { + return -1 + } + + // Start server + directory, err := ioutil.TempDir("/tmp", "fuzz") + if err != nil { + panic(err.Error()) + } + socket := fmt.Sprintf("%s/attacker.sock", directory) + listener, err := net.Listen("unix", socket) + if err != nil { + panic(err.Error()) + } + handler := func(response http.ResponseWriter, request *http.Request) { + for name, values := range headers { + for _, value := range values { + response.Header().Add(name, value) + } + } + response.WriteHeader(int(code)) + _, err := response.Write(body) + if err != nil { + panic(err.Error()) + } + } + server := http.Server{ + Handler: http.HandlerFunc(handler), + } + defer server.Close() + defer listener.Close() + defer os.RemoveAll(directory) + go server.Serve(listener) + + // Setup targeter + targeter := Targeter(func(target *Target) error { + target.Method = "GET" + target.URL = "http://vegeta.test" + return nil + }) + + // Deliver a single hit + attacker := NewAttacker( + UnixSocket(socket), + Workers(1), + MaxWorkers(1), + Timeout(time.Second), + KeepAlive(false), + ) + result := attacker.hit(targeter, "fuzz") + if result.Error != "" { + return 0 + } + return 1 +} + +func decodeFuzzResponse(fuzz []byte) ( + code int, + headers map[string][]string, + body []byte, + ok bool, +) { + if len(fuzz) < 2 { + return + } + headers = make(map[string][]string) + body = []byte{} + code = int(binary.LittleEndian.Uint16(fuzz[0:2])) + if len(fuzz) == 2 { + ok = true + return + } + fuzz, ok = decodeFuzzHeaders(fuzz[2:], headers) + if !ok { + return + } + body = fuzz + ok = true + return +} diff --git a/vendor/github.com/tsenart/vegeta/lib/metrics.go b/vendor/github.com/tsenart/vegeta/lib/metrics.go index 5b3cd626a07..5d7dbf9b25d 100644 --- a/vendor/github.com/tsenart/vegeta/lib/metrics.go +++ b/vendor/github.com/tsenart/vegeta/lib/metrics.go @@ -89,6 +89,11 @@ func (m *Metrics) Add(r *Result) { // derived summary metrics which don't need to be run on every Add call. func (m *Metrics) Close() { m.init() + + if m.Requests == 0 { + return + } + m.Rate = float64(m.Requests) m.Throughput = float64(m.success) m.Duration = m.Latest.Sub(m.Earliest) @@ -104,6 +109,7 @@ func (m *Metrics) Close() { m.Success = float64(m.success) / float64(m.Requests) m.Latencies.Mean = time.Duration(float64(m.Latencies.Total) / float64(m.Requests)) m.Latencies.P50 = m.Latencies.Quantile(0.50) + m.Latencies.P90 = m.Latencies.Quantile(0.90) m.Latencies.P95 = m.Latencies.Quantile(0.95) m.Latencies.P99 = m.Latencies.Quantile(0.99) } @@ -130,12 +136,16 @@ type LatencyMetrics struct { Mean time.Duration `json:"mean"` // P50 is the 50th percentile request latency. P50 time.Duration `json:"50th"` + // P90 is the 90th percentile request latency. + P90 time.Duration `json:"90th"` // P95 is the 95th percentile request latency. P95 time.Duration `json:"95th"` // P99 is the 99th percentile request latency. P99 time.Duration `json:"99th"` // Max is the maximum observed request latency. Max time.Duration `json:"max"` + // Min is the minimum observed request latency. + Min time.Duration `json:"min"` estimator estimator } @@ -146,6 +156,9 @@ func (l *LatencyMetrics) Add(latency time.Duration) { if l.Total += latency; latency > l.Max { l.Max = latency } + if latency < l.Min || l.Min == 0 { + l.Min = latency + } l.estimator.Add(float64(latency)) } diff --git a/vendor/github.com/tsenart/vegeta/lib/pacer.go b/vendor/github.com/tsenart/vegeta/lib/pacer.go index a094995d65e..97c8310be74 100644 --- a/vendor/github.com/tsenart/vegeta/lib/pacer.go +++ b/vendor/github.com/tsenart/vegeta/lib/pacer.go @@ -217,3 +217,63 @@ func (sp SinePacer) hits(t time.Duration) float64 { } return sp.Mean.hitsPerNs()*float64(t) + sp.ampHits()*(math.Cos(sp.StartAt)-math.Cos(sp.radians(t))) } + +// LinearPacer paces an attack by starting at a given request rate +// and increasing linearly with the given slope. +type LinearPacer struct { + StartAt Rate + Slope float64 +} + +// Pace determines the length of time to sleep until the next hit is sent. +func (p LinearPacer) Pace(elapsed time.Duration, hits uint64) (time.Duration, bool) { + switch { + case p.StartAt.Per == 0 || p.StartAt.Freq == 0: + return 0, false // Zero value = infinite rate + case p.StartAt.Per < 0 || p.StartAt.Freq < 0: + return 0, true + } + + expectedHits := p.hits(elapsed) + if hits == 0 || hits < uint64(expectedHits) { + // Running behind, send next hit immediately. + return 0, false + } + + rate := p.rate(elapsed) + interval := math.Round(1e9 / rate) + + if n := uint64(interval); n != 0 && math.MaxInt64/n < hits { + // We would overflow wait if we continued, so stop the attack. + return 0, true + } + + delta := float64(hits+1) - expectedHits + wait := time.Duration(interval * delta) + + return wait, false +} + +// hits returns the number of hits that have been sent during an attack +// lasting t nanoseconds. It returns a float so we can tell exactly how +// much we've missed our target by when solving numerically in Pace. +func (p LinearPacer) hits(t time.Duration) float64 { + if t < 0 { + return 0 + } + + a := p.Slope + b := p.StartAt.hitsPerNs() * 1e9 + x := t.Seconds() + + return (a*math.Pow(x, 2))/2 + b*x +} + +// rate calculates the instantaneous rate of attack at +// t nanoseconds after the attack began. +func (p LinearPacer) rate(t time.Duration) float64 { + a := p.Slope + x := t.Seconds() + b := p.StartAt.hitsPerNs() * 1e9 + return a*x + b +} diff --git a/vendor/github.com/tsenart/vegeta/lib/reporters.go b/vendor/github.com/tsenart/vegeta/lib/reporters.go index e86a8fbdfe4..973423591cf 100644 --- a/vendor/github.com/tsenart/vegeta/lib/reporters.go +++ b/vendor/github.com/tsenart/vegeta/lib/reporters.go @@ -57,7 +57,7 @@ func NewHistogramReporter(h *Histogram) Reporter { func NewTextReporter(m *Metrics) Reporter { const fmtstr = "Requests\t[total, rate, throughput]\t%d, %.2f, %.2f\n" + "Duration\t[total, attack, wait]\t%s, %s, %s\n" + - "Latencies\t[mean, 50, 95, 99, max]\t%s, %s, %s, %s, %s\n" + + "Latencies\t[min, mean, 50, 90, 95, 99, max]\t%s, %s, %s, %s, %s, %s, %s\n" + "Bytes In\t[total, mean]\t%d, %.2f\n" + "Bytes Out\t[total, mean]\t%d, %.2f\n" + "Success\t[ratio]\t%.2f%%\n" + @@ -68,7 +68,7 @@ func NewTextReporter(m *Metrics) Reporter { if _, err = fmt.Fprintf(tw, fmtstr, m.Requests, m.Rate, m.Throughput, m.Duration+m.Wait, m.Duration, m.Wait, - m.Latencies.Mean, m.Latencies.P50, m.Latencies.P95, m.Latencies.P99, m.Latencies.Max, + m.Latencies.Min, m.Latencies.Mean, m.Latencies.P50, m.Latencies.P90, m.Latencies.P95, m.Latencies.P99, m.Latencies.Max, m.BytesIn.Total, m.BytesIn.Mean, m.BytesOut.Total, m.BytesOut.Mean, m.Success*100, diff --git a/vendor/github.com/tsenart/vegeta/lib/results.go b/vendor/github.com/tsenart/vegeta/lib/results.go index 2754cb51860..0bdc6555528 100644 --- a/vendor/github.com/tsenart/vegeta/lib/results.go +++ b/vendor/github.com/tsenart/vegeta/lib/results.go @@ -30,6 +30,8 @@ type Result struct { BytesIn uint64 `json:"bytes_in"` Error string `json:"error"` Body []byte `json:"body"` + Method string `json:"method"` + URL string `json:"url"` } // End returns the time at which a Result ended. @@ -45,7 +47,9 @@ func (r Result) Equal(other Result) bool { r.BytesIn == other.BytesIn && r.BytesOut == other.BytesOut && r.Error == other.Error && - bytes.Equal(r.Body, other.Body) + bytes.Equal(r.Body, other.Body) && + r.Method == other.Method && + r.URL == other.URL } // Results is a slice of Result type elements. @@ -150,8 +154,9 @@ func NewCSVEncoder(w io.Writer) Encoder { base64.StdEncoding.EncodeToString(r.Body), r.Attack, strconv.FormatUint(r.Seq, 10), + r.Method, + r.URL, }) - if err != nil { return err } @@ -163,9 +168,9 @@ func NewCSVEncoder(w io.Writer) Encoder { } // NewCSVDecoder returns a Decoder that decodes CSV encoded Results. -func NewCSVDecoder(rd io.Reader) Decoder { - dec := csv.NewReader(rd) - dec.FieldsPerRecord = 9 +func NewCSVDecoder(r io.Reader) Decoder { + dec := csv.NewReader(r) + dec.FieldsPerRecord = 11 dec.TrimLeadingSpace = true return func(r *Result) error { @@ -201,23 +206,32 @@ func NewCSVDecoder(rd io.Reader) Decoder { } r.Error = rec[5] - r.Body, err = base64.StdEncoding.DecodeString(rec[6]) + if r.Body, err = base64.StdEncoding.DecodeString(rec[6]); err != nil { + return err + } r.Attack = rec[7] if r.Seq, err = strconv.ParseUint(rec[8], 10, 64); err != nil { return err } + r.Method = rec[9] + r.URL = rec[10] + return err } } +//go:generate easyjson -no_std_marshalers -output_filename results_easyjson.go results.go +//easyjson:json +type jsonResult Result + // NewJSONEncoder returns an Encoder that dumps the given *Results as a JSON // object. func NewJSONEncoder(w io.Writer) Encoder { var jw jwriter.Writer return func(r *Result) error { - (*jsonResult)(r).encode(&jw) + (*jsonResult)(r).MarshalEasyJSON(&jw) if jw.Error != nil { return jw.Error } @@ -232,10 +246,10 @@ func NewJSONDecoder(r io.Reader) Decoder { rd := bufio.NewReader(r) return func(r *Result) (err error) { var jl jlexer.Lexer - if jl.Data, err = rd.ReadSlice('\n'); err != nil { + if jl.Data, err = rd.ReadBytes('\n'); err != nil { return err } - (*jsonResult)(r).decode(&jl) + (*jsonResult)(r).UnmarshalEasyJSON(&jl) return jl.Error() } } diff --git a/vendor/github.com/tsenart/vegeta/lib/results_easyjson.go b/vendor/github.com/tsenart/vegeta/lib/results_easyjson.go index b1594bdc381..12273ffb99a 100644 --- a/vendor/github.com/tsenart/vegeta/lib/results_easyjson.go +++ b/vendor/github.com/tsenart/vegeta/lib/results_easyjson.go @@ -1,18 +1,24 @@ -// This file has been modified from the original generated code to make it work with -// type alias jsonResult so that the methods aren't exposed in Result. +// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT. package vegeta import ( - "time" - - "github.com/mailru/easyjson/jlexer" - "github.com/mailru/easyjson/jwriter" + json "encoding/json" + easyjson "github.com/mailru/easyjson" + jlexer "github.com/mailru/easyjson/jlexer" + jwriter "github.com/mailru/easyjson/jwriter" + time "time" ) -type jsonResult Result +// suppress unused package warning +var ( + _ *json.RawMessage + _ *jlexer.Lexer + _ *jwriter.Writer + _ easyjson.Marshaler +) -func (r *jsonResult) decode(in *jlexer.Lexer) { +func easyjsonBd1621b8DecodeGithubComTsenartVegetaLib(in *jlexer.Lexer, out *jsonResult) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -32,30 +38,34 @@ func (r *jsonResult) decode(in *jlexer.Lexer) { } switch key { case "attack": - r.Attack = string(in.String()) + out.Attack = string(in.String()) case "seq": - r.Seq = uint64(in.Uint64()) + out.Seq = uint64(in.Uint64()) case "code": - r.Code = uint16(in.Uint16()) + out.Code = uint16(in.Uint16()) case "timestamp": if data := in.Raw(); in.Ok() { - in.AddError((r.Timestamp).UnmarshalJSON(data)) + in.AddError((out.Timestamp).UnmarshalJSON(data)) } case "latency": - r.Latency = time.Duration(in.Int64()) + out.Latency = time.Duration(in.Int64()) case "bytes_out": - r.BytesOut = uint64(in.Uint64()) + out.BytesOut = uint64(in.Uint64()) case "bytes_in": - r.BytesIn = uint64(in.Uint64()) + out.BytesIn = uint64(in.Uint64()) case "error": - r.Error = string(in.String()) + out.Error = string(in.String()) case "body": if in.IsNull() { in.Skip() - r.Body = nil + out.Body = nil } else { - r.Body = in.Bytes() + out.Body = in.Bytes() } + case "method": + out.Method = string(in.String()) + case "url": + out.URL = string(in.String()) default: in.SkipRecursive() } @@ -66,100 +76,74 @@ func (r *jsonResult) decode(in *jlexer.Lexer) { in.Consumed() } } - -func (r jsonResult) encode(out *jwriter.Writer) { +func easyjsonBd1621b8EncodeGithubComTsenartVegetaLib(out *jwriter.Writer, in jsonResult) { out.RawByte('{') first := true _ = first { const prefix string = ",\"attack\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(r.Attack)) + out.RawString(prefix[1:]) + out.String(string(in.Attack)) } { const prefix string = ",\"seq\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(r.Seq)) + out.RawString(prefix) + out.Uint64(uint64(in.Seq)) } { const prefix string = ",\"code\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint16(uint16(r.Code)) + out.RawString(prefix) + out.Uint16(uint16(in.Code)) } { const prefix string = ",\"timestamp\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Raw((r.Timestamp).MarshalJSON()) + out.RawString(prefix) + out.Raw((in.Timestamp).MarshalJSON()) } { const prefix string = ",\"latency\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Int64(int64(r.Latency)) + out.RawString(prefix) + out.Int64(int64(in.Latency)) } { const prefix string = ",\"bytes_out\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(r.BytesOut)) + out.RawString(prefix) + out.Uint64(uint64(in.BytesOut)) } { const prefix string = ",\"bytes_in\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Uint64(uint64(r.BytesIn)) + out.RawString(prefix) + out.Uint64(uint64(in.BytesIn)) } { const prefix string = ",\"error\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.String(string(r.Error)) + out.RawString(prefix) + out.String(string(in.Error)) } { const prefix string = ",\"body\":" - if first { - first = false - out.RawString(prefix[1:]) - } else { - out.RawString(prefix) - } - out.Base64Bytes(r.Body) + out.RawString(prefix) + out.Base64Bytes(in.Body) + } + { + const prefix string = ",\"method\":" + out.RawString(prefix) + out.String(string(in.Method)) + } + { + const prefix string = ",\"url\":" + out.RawString(prefix) + out.String(string(in.URL)) } out.RawByte('}') } + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v jsonResult) MarshalEasyJSON(w *jwriter.Writer) { + easyjsonBd1621b8EncodeGithubComTsenartVegetaLib(w, v) +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *jsonResult) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjsonBd1621b8DecodeGithubComTsenartVegetaLib(l, v) +} diff --git a/vendor/github.com/tsenart/vegeta/lib/results_fuzz.go b/vendor/github.com/tsenart/vegeta/lib/results_fuzz.go new file mode 100644 index 00000000000..fced203da4a --- /dev/null +++ b/vendor/github.com/tsenart/vegeta/lib/results_fuzz.go @@ -0,0 +1,63 @@ +// +build gofuzz + +package vegeta + +import ( + "bytes" + "io" +) + +// FuzzResultsFormatDetection tests result list format detection. +func FuzzResultsFormatDetection(fuzz []byte) int { + decoder := DecoderFor(bytes.NewReader(fuzz)) + if decoder == nil { + return 0 + } + ok := readAllResults(decoder) + if !ok { + return 0 + } + return 1 +} + +// FuzzGobDecoder tests decoding a gob format result list. +func FuzzGobDecoder(fuzz []byte) int { + decoder := NewDecoder(bytes.NewReader(fuzz)) + ok := readAllResults(decoder) + if !ok { + return 0 + } + return 1 +} + +// FuzzCSVDecoder tests decoding a CSV format result list. +func FuzzCSVDecoder(fuzz []byte) int { + decoder := NewCSVDecoder(bytes.NewReader(fuzz)) + ok := readAllResults(decoder) + if !ok { + return 0 + } + return 1 +} + +// FuzzJSONDecoder tests decoding a JSON format result list. +func FuzzJSONDecoder(fuzz []byte) int { + decoder := NewJSONDecoder(bytes.NewReader(fuzz)) + ok := readAllResults(decoder) + if !ok { + return 0 + } + return 1 +} + +func readAllResults(decoder Decoder) (ok bool) { + for { + result := &Result{} + err := decoder.Decode(result) + if err == io.EOF { + return true + } else if err != nil { + return false + } + } +} diff --git a/vendor/github.com/tsenart/vegeta/lib/targets.go b/vendor/github.com/tsenart/vegeta/lib/targets.go index 41415ffb51f..2cb5dc2cfb5 100644 --- a/vendor/github.com/tsenart/vegeta/lib/targets.go +++ b/vendor/github.com/tsenart/vegeta/lib/targets.go @@ -270,7 +270,7 @@ func NewHTTPTargeter(src io.Reader, body []byte, hdr http.Header) Targeter { } line = strings.TrimSpace(sc.Text()) - if len(line) != 0 && line[0] != '#'{ + if len(line) != 0 && line[0] != '#' { break } } @@ -300,6 +300,8 @@ func NewHTTPTargeter(src io.Reader, body []byte, hdr http.Header) Targeter { for sc.Scan() { if line = strings.TrimSpace(sc.Text()); line == "" { break + } else if strings.HasPrefix(line, "#") { + continue } else if strings.HasPrefix(line, "@") { if tgt.Body, err = ioutil.ReadFile(line[1:]); err != nil { return fmt.Errorf("bad body: %s", err) @@ -327,7 +329,7 @@ func NewHTTPTargeter(src io.Reader, body []byte, hdr http.Header) Targeter { } } -var httpMethodChecker = regexp.MustCompile("^[A-Z]+\\s") +var httpMethodChecker = regexp.MustCompile(`^[A-Z]+\s`) // A line starts with an http method when the first word is uppercase ascii // followed by a space. diff --git a/vendor/github.com/tsenart/vegeta/lib/targets_fuzz.go b/vendor/github.com/tsenart/vegeta/lib/targets_fuzz.go new file mode 100644 index 00000000000..87a925fe1b2 --- /dev/null +++ b/vendor/github.com/tsenart/vegeta/lib/targets_fuzz.go @@ -0,0 +1,68 @@ +// +build gofuzz + +package vegeta + +import ( + "bytes" + "net/http" +) + +// FuzzHTTPTargeter tests decoding an HTTP encoded target list. +func FuzzHTTPTargeter(fuzz []byte) int { + headers, body, fuzz, ok := decodeFuzzTargetDefaults(fuzz) + if !ok { + return -1 + } + targeter := NewHTTPTargeter( + bytes.NewReader(fuzz), + body, + headers, + ) + _, err := ReadAllTargets(targeter) + if err != nil { + return 0 + } + return 1 +} + +// FuzzJSONTargeter tests decoding a JSON encoded target list. +func FuzzJSONTargeter(fuzz []byte) int { + headers, body, fuzz, ok := decodeFuzzTargetDefaults(fuzz) + if !ok { + return -1 + } + targeter := NewJSONTargeter( + bytes.NewReader(fuzz), + body, + headers, + ) + _, err := ReadAllTargets(targeter) + if err != nil { + return 0 + } + return 1 +} + +func decodeFuzzTargetDefaults(fuzz []byte) ( + headers http.Header, + body []byte, + rest []byte, + ok bool, +) { + if len(fuzz) < 2 { + return + } + headers = make(map[string][]string) + body = []byte{} + rest = []byte{} + rest, ok = decodeFuzzHeaders(fuzz, headers) + if !ok { + return + } + if len(rest) == 0 { + ok = true + return + } + body, rest, ok = extractFuzzByteString(rest) + return +} diff --git a/vendor/github.com/tsenart/vegeta/lib/util_fuzz.go b/vendor/github.com/tsenart/vegeta/lib/util_fuzz.go new file mode 100644 index 00000000000..60c758feac1 --- /dev/null +++ b/vendor/github.com/tsenart/vegeta/lib/util_fuzz.go @@ -0,0 +1,120 @@ +// +build gofuzz + +package vegeta + +func decodeFuzzHeaders(fuzz []byte, headers map[string][]string) ( + rest []byte, + ok bool, +) { + rest = fuzz + for { + if len(rest) == 0 { + // Consumed all fuzz + ok = true + return + } + if fuzz[0] == 0 { + // Headers terminated + if len(rest) == 1 { + rest = []byte{} + } else { + rest = rest[1:] + } + ok = true + return + } + if len(fuzz) == 1 { + // Invalid headers encoding + return + } + rest, ok = decodeFuzzHeader(rest[1:], headers) + if !ok { + return + } + } +} + +func decodeFuzzHeader(fuzz []byte, headers map[string][]string) ( + rest []byte, + ok bool, +) { + if len(fuzz) == 0 { + ok = true + return + } + name, rest, ok := extractFuzzString(fuzz) + if !ok { + return + } + value, rest, ok := extractFuzzString(rest) + if !ok { + return + } + if header, ok := headers[name]; ok { + headers[name] = append(header, value) + } else { + headers[name] = []string{value} + } + ok = true + return +} + +func extractFuzzString(fuzz []byte) ( + value string, + rest []byte, + ok bool, +) { + if len(fuzz) < 2 { + // Invalid string encoding + return + } + length := int(fuzz[0]) + if length == 0 { + // Invalid length + return + } + if len(fuzz) < (length + 1) { + // Insufficient fuzz + return + } + value = string(fuzz[1 : length+1]) + if len(fuzz) == (length + 1) { + // Consumed all fuzz + rest = []byte{} + } else { + // More fuzz + rest = fuzz[length+1:] + } + ok = true + return +} + +func extractFuzzByteString(fuzz []byte) ( + value []byte, + rest []byte, + ok bool, +) { + if len(fuzz) < 2 { + // Invalid byte string encoding + return + } + length := int(fuzz[0]) + if length == 0 { + // Invalid length + return + } + if len(fuzz) < (length + 1) { + // Insufficient fuzz + return + } + value = fuzz[1 : length+1] + if len(fuzz) == (length + 1) { + // Consumed all fuzz + rest = []byte{} + } else { + // More fuzz + rest = fuzz[length+1:] + } + ok = true + return +} diff --git a/vendor/go.opencensus.io/trace/trace.go b/vendor/go.opencensus.io/trace/trace.go index 2622382a074..3f8977b41b4 100644 --- a/vendor/go.opencensus.io/trace/trace.go +++ b/vendor/go.opencensus.io/trace/trace.go @@ -261,13 +261,6 @@ func startSpanInternal(name string, hasParent bool, parent SpanContext, remotePa return span } -func (s *Span) SetSpanID(spanID SpanID) { - if s.data != nil { - s.data.SpanID = spanID - } - s.spanContext.SpanID = spanID -} - // End ends the span. func (s *Span) End() { if s == nil { diff --git a/vendor/k8s.io/code-generator/Godeps/OWNERS b/vendor/k8s.io/code-generator/Godeps/OWNERS new file mode 100644 index 00000000000..0f5d2f6734e --- /dev/null +++ b/vendor/k8s.io/code-generator/Godeps/OWNERS @@ -0,0 +1,4 @@ +# See the OWNERS docs at https://go.k8s.io/owners + +approvers: +- dep-approvers diff --git a/vendor/k8s.io/code-generator/OWNERS b/vendor/k8s.io/code-generator/OWNERS new file mode 100644 index 00000000000..6f7abe3edb1 --- /dev/null +++ b/vendor/k8s.io/code-generator/OWNERS @@ -0,0 +1,13 @@ +# See the OWNERS docs at https://go.k8s.io/owners + +approvers: +- lavalamp +- wojtek-t +- sttts +reviewers: +- lavalamp +- wojtek-t +- sttts +labels: +- sig/api-machinery +- area/code-generation diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/OWNERS b/vendor/k8s.io/code-generator/cmd/client-gen/OWNERS new file mode 100644 index 00000000000..62866d0b194 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/client-gen/OWNERS @@ -0,0 +1,10 @@ +# See the OWNERS docs at https://go.k8s.io/owners + +approvers: +- lavalamp +- wojtek-t +- caesarxuchao +reviewers: +- lavalamp +- wojtek-t +- caesarxuchao diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS new file mode 100644 index 00000000000..613659162a9 --- /dev/null +++ b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS @@ -0,0 +1,6 @@ +# See the OWNERS docs at https://go.k8s.io/owners + +approvers: +- smarterclayton +reviewers: +- smarterclayton diff --git a/vendor/knative.dev/pkg/OWNERS b/vendor/knative.dev/pkg/OWNERS new file mode 100644 index 00000000000..030df98f78d --- /dev/null +++ b/vendor/knative.dev/pkg/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- pkg-approvers diff --git a/vendor/knative.dev/pkg/OWNERS_ALIASES b/vendor/knative.dev/pkg/OWNERS_ALIASES new file mode 100644 index 00000000000..7a8145f0240 --- /dev/null +++ b/vendor/knative.dev/pkg/OWNERS_ALIASES @@ -0,0 +1,67 @@ +aliases: + pkg-approvers: + - evankanderson + - mattmoor + - vaikas + + apis-approvers: + - mattmoor + - vaikas + - n3wscott + + apis-duck-approvers: + - mattmoor + - vaikas + + configmap-approvers: + - mattmoor + - mdemirhan + - dprotaso + + controller-approvers: + - dgerd + - grantr + - mattmoor + - tcnghia + - vagababov + + kmeta-approvers: + - mattmoor + - dgerd + - vagababov + + logging-approvers: + - mdemirhan + - n3wscott + - yanweiguo + + metrics-approvers: + - mdemirhan + - yanweiguo + + network-approvers: + - markusthoemmes + - tcnghia + - vagababov + + productivity-approvers: + - adrcunha + - chaodaiG + - chizhg + productivity-reviewers: + - adrcunha + - chaodaiG + - coryrc + - chizhg + - steuhs + - yt3liu + + source-approvers: + - n3wscott + - vaikas + + webhook-approvers: + - mattmoor + - grantr + - tcnghia + diff --git a/vendor/knative.dev/pkg/apis/OWNERS b/vendor/knative.dev/pkg/apis/OWNERS new file mode 100644 index 00000000000..a25420ebc0d --- /dev/null +++ b/vendor/knative.dev/pkg/apis/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- apis-approvers diff --git a/vendor/knative.dev/pkg/apis/duck/OWNERS b/vendor/knative.dev/pkg/apis/duck/OWNERS new file mode 100644 index 00000000000..ad4d83c51e4 --- /dev/null +++ b/vendor/knative.dev/pkg/apis/duck/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- apis-duck-approvers diff --git a/vendor/knative.dev/pkg/configmap/OWNERS b/vendor/knative.dev/pkg/configmap/OWNERS new file mode 100644 index 00000000000..2480fc6d43f --- /dev/null +++ b/vendor/knative.dev/pkg/configmap/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- configmap-approvers diff --git a/vendor/knative.dev/pkg/controller/OWNERS b/vendor/knative.dev/pkg/controller/OWNERS new file mode 100644 index 00000000000..afa22257a26 --- /dev/null +++ b/vendor/knative.dev/pkg/controller/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- controller-approvers diff --git a/vendor/knative.dev/pkg/hack/OWNERS b/vendor/knative.dev/pkg/hack/OWNERS new file mode 100644 index 00000000000..c50adc84930 --- /dev/null +++ b/vendor/knative.dev/pkg/hack/OWNERS @@ -0,0 +1,10 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- productivity-approvers + +reviewers: +- productivity-reviewers + +labels: +- area/test-and-release diff --git a/vendor/knative.dev/pkg/injection/OWNERS b/vendor/knative.dev/pkg/injection/OWNERS new file mode 100644 index 00000000000..dda47512a47 --- /dev/null +++ b/vendor/knative.dev/pkg/injection/OWNERS @@ -0,0 +1,5 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- mattmoor +- n3wscott diff --git a/vendor/knative.dev/pkg/kmeta/OWNERS b/vendor/knative.dev/pkg/kmeta/OWNERS new file mode 100644 index 00000000000..29b0d9f2562 --- /dev/null +++ b/vendor/knative.dev/pkg/kmeta/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- kmeta-approvers diff --git a/vendor/knative.dev/pkg/logging/OWNERS b/vendor/knative.dev/pkg/logging/OWNERS new file mode 100644 index 00000000000..fa4854ba0a5 --- /dev/null +++ b/vendor/knative.dev/pkg/logging/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- logging-approvers diff --git a/vendor/knative.dev/pkg/metrics/OWNERS b/vendor/knative.dev/pkg/metrics/OWNERS new file mode 100644 index 00000000000..6d3966df44e --- /dev/null +++ b/vendor/knative.dev/pkg/metrics/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- metrics-approvers diff --git a/vendor/knative.dev/pkg/network/OWNERS b/vendor/knative.dev/pkg/network/OWNERS new file mode 100644 index 00000000000..b14ac5308ea --- /dev/null +++ b/vendor/knative.dev/pkg/network/OWNERS @@ -0,0 +1,5 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- tcnghia +- vagababov diff --git a/vendor/knative.dev/pkg/reconciler/OWNERS b/vendor/knative.dev/pkg/reconciler/OWNERS new file mode 100644 index 00000000000..afa22257a26 --- /dev/null +++ b/vendor/knative.dev/pkg/reconciler/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- controller-approvers diff --git a/vendor/knative.dev/pkg/resolver/OWNERS b/vendor/knative.dev/pkg/resolver/OWNERS new file mode 100644 index 00000000000..acf2ee2c1cf --- /dev/null +++ b/vendor/knative.dev/pkg/resolver/OWNERS @@ -0,0 +1,5 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- n3wscott +- vaikas-google diff --git a/vendor/knative.dev/pkg/source/OWNERS b/vendor/knative.dev/pkg/source/OWNERS new file mode 100644 index 00000000000..8d16912160d --- /dev/null +++ b/vendor/knative.dev/pkg/source/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- source-approvers diff --git a/vendor/knative.dev/pkg/test/OWNERS b/vendor/knative.dev/pkg/test/OWNERS new file mode 100644 index 00000000000..c50adc84930 --- /dev/null +++ b/vendor/knative.dev/pkg/test/OWNERS @@ -0,0 +1,10 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- productivity-approvers + +reviewers: +- productivity-reviewers + +labels: +- area/test-and-release diff --git a/vendor/knative.dev/pkg/testutils/OWNERS b/vendor/knative.dev/pkg/testutils/OWNERS new file mode 100644 index 00000000000..46b7acf91e9 --- /dev/null +++ b/vendor/knative.dev/pkg/testutils/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- productivity-approvers diff --git a/vendor/knative.dev/pkg/webhook/OWNERS b/vendor/knative.dev/pkg/webhook/OWNERS new file mode 100644 index 00000000000..b87878d94ae --- /dev/null +++ b/vendor/knative.dev/pkg/webhook/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- webhook-approvers diff --git a/vendor/knative.dev/pkg/websocket/OWNERS b/vendor/knative.dev/pkg/websocket/OWNERS new file mode 100644 index 00000000000..c3fa6ca63cd --- /dev/null +++ b/vendor/knative.dev/pkg/websocket/OWNERS @@ -0,0 +1,4 @@ +# The OWNERS file is used by prow to automatically merge approved PRs. + +approvers: +- network-approvers diff --git a/vendor/knative.dev/serving/AUTHORS b/vendor/knative.dev/serving/AUTHORS new file mode 100644 index 00000000000..f42714c4eca --- /dev/null +++ b/vendor/knative.dev/serving/AUTHORS @@ -0,0 +1,11 @@ +# This is the list of Knative authors for copyright purposes. +# +# This does not necessarily list everyone who has contributed code, since in +# some cases, their employer may be the copyright holder. To see the full list +# of contributors, see the revision history in source control. +Google LLC +Pivotal Software, Inc. +IBM Corp +Red Hat, Inc. +Cisco Systems, Inc. +VMware, Inc. diff --git a/vendor/knative.dev/serving/LICENSE b/vendor/knative.dev/serving/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/vendor/knative.dev/serving/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/knative.dev/serving/cmd/activator/kodata/HEAD b/vendor/knative.dev/serving/cmd/activator/kodata/HEAD new file mode 120000 index 00000000000..8f63681d362 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/activator/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/activator/kodata/LICENSE b/vendor/knative.dev/serving/cmd/activator/kodata/LICENSE new file mode 120000 index 00000000000..5853aaea53b --- /dev/null +++ b/vendor/knative.dev/serving/cmd/activator/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/activator/kodata/VENDOR-LICENSE b/vendor/knative.dev/serving/cmd/activator/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..3cc89764519 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/activator/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/activator/kodata/refs b/vendor/knative.dev/serving/cmd/activator/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/activator/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/HEAD b/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/HEAD new file mode 120000 index 00000000000..8f63681d362 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/LICENSE b/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/LICENSE new file mode 120000 index 00000000000..5853aaea53b --- /dev/null +++ b/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/VENDOR-LICENSE b/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..3cc89764519 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/refs b/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/autoscaler-hpa/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/autoscaler/kodata/HEAD b/vendor/knative.dev/serving/cmd/autoscaler/kodata/HEAD new file mode 120000 index 00000000000..8f63681d362 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/autoscaler/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/autoscaler/kodata/LICENSE b/vendor/knative.dev/serving/cmd/autoscaler/kodata/LICENSE new file mode 120000 index 00000000000..5853aaea53b --- /dev/null +++ b/vendor/knative.dev/serving/cmd/autoscaler/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/autoscaler/kodata/VENDOR-LICENSE b/vendor/knative.dev/serving/cmd/autoscaler/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..3cc89764519 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/autoscaler/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/autoscaler/kodata/refs b/vendor/knative.dev/serving/cmd/autoscaler/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/autoscaler/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/controller/kodata/HEAD b/vendor/knative.dev/serving/cmd/controller/kodata/HEAD new file mode 120000 index 00000000000..8f63681d362 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/controller/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/controller/kodata/LICENSE b/vendor/knative.dev/serving/cmd/controller/kodata/LICENSE new file mode 120000 index 00000000000..5853aaea53b --- /dev/null +++ b/vendor/knative.dev/serving/cmd/controller/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/controller/kodata/VENDOR-LICENSE b/vendor/knative.dev/serving/cmd/controller/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..3cc89764519 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/controller/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/controller/kodata/refs b/vendor/knative.dev/serving/cmd/controller/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/controller/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/HEAD b/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/HEAD new file mode 120000 index 00000000000..481bd4eff49 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/HEAD @@ -0,0 +1 @@ +../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/LICENSE b/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/LICENSE new file mode 120000 index 00000000000..14776154326 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/LICENSE @@ -0,0 +1 @@ +../../../../LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/VENDOR-LICENSE b/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..7322c09d957 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/refs b/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/refs new file mode 120000 index 00000000000..fe164fe40f7 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/certmanager/kodata/refs @@ -0,0 +1 @@ +../../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/istio/kodata/HEAD b/vendor/knative.dev/serving/cmd/networking/istio/kodata/HEAD new file mode 120000 index 00000000000..481bd4eff49 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/istio/kodata/HEAD @@ -0,0 +1 @@ +../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/istio/kodata/LICENSE b/vendor/knative.dev/serving/cmd/networking/istio/kodata/LICENSE new file mode 120000 index 00000000000..14776154326 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/istio/kodata/LICENSE @@ -0,0 +1 @@ +../../../../LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/istio/kodata/VENDOR-LICENSE b/vendor/knative.dev/serving/cmd/networking/istio/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..7322c09d957 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/istio/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/istio/kodata/refs b/vendor/knative.dev/serving/cmd/networking/istio/kodata/refs new file mode 120000 index 00000000000..fe164fe40f7 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/istio/kodata/refs @@ -0,0 +1 @@ +../../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/nscert/kodata/HEAD b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/HEAD new file mode 120000 index 00000000000..481bd4eff49 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/HEAD @@ -0,0 +1 @@ +../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/nscert/kodata/LICENSE b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/LICENSE new file mode 120000 index 00000000000..14776154326 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/LICENSE @@ -0,0 +1 @@ +../../../../LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/networking/nscert/kodata/VENDOR-LICENSE b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..7322c09d957 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/networking/nscert/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/queue/kodata/HEAD b/vendor/knative.dev/serving/cmd/queue/kodata/HEAD new file mode 120000 index 00000000000..8f63681d362 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/queue/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/queue/kodata/LICENSE b/vendor/knative.dev/serving/cmd/queue/kodata/LICENSE new file mode 120000 index 00000000000..5853aaea53b --- /dev/null +++ b/vendor/knative.dev/serving/cmd/queue/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/queue/kodata/VENDOR-LICENSE b/vendor/knative.dev/serving/cmd/queue/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..3cc89764519 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/queue/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/queue/kodata/refs b/vendor/knative.dev/serving/cmd/queue/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/queue/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/webhook/kodata/HEAD b/vendor/knative.dev/serving/cmd/webhook/kodata/HEAD new file mode 120000 index 00000000000..8f63681d362 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/webhook/kodata/HEAD @@ -0,0 +1 @@ +../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/webhook/kodata/LICENSE b/vendor/knative.dev/serving/cmd/webhook/kodata/LICENSE new file mode 120000 index 00000000000..5853aaea53b --- /dev/null +++ b/vendor/knative.dev/serving/cmd/webhook/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/webhook/kodata/VENDOR-LICENSE b/vendor/knative.dev/serving/cmd/webhook/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..3cc89764519 --- /dev/null +++ b/vendor/knative.dev/serving/cmd/webhook/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../third_party/VENDOR-LICENSE \ No newline at end of file diff --git a/vendor/knative.dev/serving/cmd/webhook/kodata/refs b/vendor/knative.dev/serving/cmd/webhook/kodata/refs new file mode 120000 index 00000000000..739d35bf96a --- /dev/null +++ b/vendor/knative.dev/serving/cmd/webhook/kodata/refs @@ -0,0 +1 @@ +../../../.git/refs \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/100-namespace.yaml b/vendor/knative.dev/serving/config/100-namespace.yaml new file mode 120000 index 00000000000..edab691b932 --- /dev/null +++ b/vendor/knative.dev/serving/config/100-namespace.yaml @@ -0,0 +1 @@ +core/100-namespace.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/200-addressable-resolvers-clusterrole.yaml b/vendor/knative.dev/serving/config/200-addressable-resolvers-clusterrole.yaml new file mode 120000 index 00000000000..dcd8f992592 --- /dev/null +++ b/vendor/knative.dev/serving/config/200-addressable-resolvers-clusterrole.yaml @@ -0,0 +1 @@ +core/rbac/200-addressable-resolvers-clusterrole.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/200-clusterrole-certmanager.yaml b/vendor/knative.dev/serving/config/200-clusterrole-certmanager.yaml new file mode 120000 index 00000000000..8eddd094dd2 --- /dev/null +++ b/vendor/knative.dev/serving/config/200-clusterrole-certmanager.yaml @@ -0,0 +1 @@ +cert-manager/200-clusterrole.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/200-clusterrole-istio.yaml b/vendor/knative.dev/serving/config/200-clusterrole-istio.yaml new file mode 120000 index 00000000000..8b996e07e92 --- /dev/null +++ b/vendor/knative.dev/serving/config/200-clusterrole-istio.yaml @@ -0,0 +1 @@ +istio-ingress/200-clusterrole.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/200-clusterrole-metrics.yaml b/vendor/knative.dev/serving/config/200-clusterrole-metrics.yaml new file mode 120000 index 00000000000..41ac79309d5 --- /dev/null +++ b/vendor/knative.dev/serving/config/200-clusterrole-metrics.yaml @@ -0,0 +1 @@ +hpa-autoscaling/200-clusterrole-metrics.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/200-clusterrole-namespaced.yaml b/vendor/knative.dev/serving/config/200-clusterrole-namespaced.yaml new file mode 120000 index 00000000000..f555e4e9a6f --- /dev/null +++ b/vendor/knative.dev/serving/config/200-clusterrole-namespaced.yaml @@ -0,0 +1 @@ +core/rbac/200-clusterrole-namespaced.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/200-clusterrole.yaml b/vendor/knative.dev/serving/config/200-clusterrole.yaml new file mode 120000 index 00000000000..b8ceb9d2195 --- /dev/null +++ b/vendor/knative.dev/serving/config/200-clusterrole.yaml @@ -0,0 +1 @@ +core/rbac/200-clusterrole.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/200-podspecable-bindings-clusterrole.yaml b/vendor/knative.dev/serving/config/200-podspecable-bindings-clusterrole.yaml new file mode 120000 index 00000000000..51cbb49ec9c --- /dev/null +++ b/vendor/knative.dev/serving/config/200-podspecable-bindings-clusterrole.yaml @@ -0,0 +1 @@ +core/rbac/200-podspecable-bindings-clusterrole.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/200-serviceaccount.yaml b/vendor/knative.dev/serving/config/200-serviceaccount.yaml new file mode 120000 index 00000000000..151307ac841 --- /dev/null +++ b/vendor/knative.dev/serving/config/200-serviceaccount.yaml @@ -0,0 +1 @@ +core/rbac/200-serviceaccount.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/201-clusterrolebinding-metrics-server.yaml b/vendor/knative.dev/serving/config/201-clusterrolebinding-metrics-server.yaml new file mode 120000 index 00000000000..cfcb33b68bf --- /dev/null +++ b/vendor/knative.dev/serving/config/201-clusterrolebinding-metrics-server.yaml @@ -0,0 +1 @@ +hpa-autoscaling/201-clusterrolebinding-metrics-server.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/201-clusterrolebinding-metrics.yaml b/vendor/knative.dev/serving/config/201-clusterrolebinding-metrics.yaml new file mode 120000 index 00000000000..2d10d8a06d0 --- /dev/null +++ b/vendor/knative.dev/serving/config/201-clusterrolebinding-metrics.yaml @@ -0,0 +1 @@ +hpa-autoscaling/201-clusterrolebinding-metrics.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/201-clusterrolebinding.yaml b/vendor/knative.dev/serving/config/201-clusterrolebinding.yaml new file mode 120000 index 00000000000..badb803bb35 --- /dev/null +++ b/vendor/knative.dev/serving/config/201-clusterrolebinding.yaml @@ -0,0 +1 @@ +core/rbac/201-clusterrolebinding.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/201-rolebinding-metrics-server.yaml b/vendor/knative.dev/serving/config/201-rolebinding-metrics-server.yaml new file mode 120000 index 00000000000..50208a006fa --- /dev/null +++ b/vendor/knative.dev/serving/config/201-rolebinding-metrics-server.yaml @@ -0,0 +1 @@ +hpa-autoscaling/201-rolebinding-metrics-server.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/202-gateway.yaml b/vendor/knative.dev/serving/config/202-gateway.yaml new file mode 120000 index 00000000000..4e530b44ee7 --- /dev/null +++ b/vendor/knative.dev/serving/config/202-gateway.yaml @@ -0,0 +1 @@ +istio-ingress/202-gateway.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/203-local-gateway.yaml b/vendor/knative.dev/serving/config/203-local-gateway.yaml new file mode 120000 index 00000000000..8296e3ecb13 --- /dev/null +++ b/vendor/knative.dev/serving/config/203-local-gateway.yaml @@ -0,0 +1 @@ +istio-ingress/203-local-gateway.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/300-certificate.yaml b/vendor/knative.dev/serving/config/300-certificate.yaml new file mode 120000 index 00000000000..ac41200ebfc --- /dev/null +++ b/vendor/knative.dev/serving/config/300-certificate.yaml @@ -0,0 +1 @@ +core/resources/certificate.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/300-configuration.yaml b/vendor/knative.dev/serving/config/300-configuration.yaml new file mode 120000 index 00000000000..f8c14777661 --- /dev/null +++ b/vendor/knative.dev/serving/config/300-configuration.yaml @@ -0,0 +1 @@ +core/resources/configuration.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/300-imagecache.yaml b/vendor/knative.dev/serving/config/300-imagecache.yaml new file mode 120000 index 00000000000..70e20bf2706 --- /dev/null +++ b/vendor/knative.dev/serving/config/300-imagecache.yaml @@ -0,0 +1 @@ +../vendor/knative.dev/caching/config/image.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/300-ingress.yaml b/vendor/knative.dev/serving/config/300-ingress.yaml new file mode 120000 index 00000000000..dcabdf0cb35 --- /dev/null +++ b/vendor/knative.dev/serving/config/300-ingress.yaml @@ -0,0 +1 @@ +core/resources/ingress.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/300-metric.yaml b/vendor/knative.dev/serving/config/300-metric.yaml new file mode 120000 index 00000000000..f4ac600fca5 --- /dev/null +++ b/vendor/knative.dev/serving/config/300-metric.yaml @@ -0,0 +1 @@ +core/resources/metric.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/300-pa.yaml b/vendor/knative.dev/serving/config/300-pa.yaml new file mode 120000 index 00000000000..3d214c7f816 --- /dev/null +++ b/vendor/knative.dev/serving/config/300-pa.yaml @@ -0,0 +1 @@ +core/resources/podautoscaler.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/300-revision.yaml b/vendor/knative.dev/serving/config/300-revision.yaml new file mode 120000 index 00000000000..8256c9b2282 --- /dev/null +++ b/vendor/knative.dev/serving/config/300-revision.yaml @@ -0,0 +1 @@ +core/resources/revision.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/300-route.yaml b/vendor/knative.dev/serving/config/300-route.yaml new file mode 120000 index 00000000000..f6e9d50a018 --- /dev/null +++ b/vendor/knative.dev/serving/config/300-route.yaml @@ -0,0 +1 @@ +core/resources/route.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/300-service.yaml b/vendor/knative.dev/serving/config/300-service.yaml new file mode 120000 index 00000000000..2148b818998 --- /dev/null +++ b/vendor/knative.dev/serving/config/300-service.yaml @@ -0,0 +1 @@ +core/resources/service.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/300-sks.yaml b/vendor/knative.dev/serving/config/300-sks.yaml new file mode 120000 index 00000000000..6fcdada6862 --- /dev/null +++ b/vendor/knative.dev/serving/config/300-sks.yaml @@ -0,0 +1 @@ +core/resources/serverlessservice.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/500-webhook-configmap-validation.yaml b/vendor/knative.dev/serving/config/500-webhook-configmap-validation.yaml new file mode 120000 index 00000000000..948218552b5 --- /dev/null +++ b/vendor/knative.dev/serving/config/500-webhook-configmap-validation.yaml @@ -0,0 +1 @@ +./core/webhooks/configmap-validation.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/500-webhook-defaulting.yaml b/vendor/knative.dev/serving/config/500-webhook-defaulting.yaml new file mode 120000 index 00000000000..604b1f814b4 --- /dev/null +++ b/vendor/knative.dev/serving/config/500-webhook-defaulting.yaml @@ -0,0 +1 @@ +./core/webhooks/defaulting.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/500-webhook-resource-validation.yaml b/vendor/knative.dev/serving/config/500-webhook-resource-validation.yaml new file mode 120000 index 00000000000..68f024380ed --- /dev/null +++ b/vendor/knative.dev/serving/config/500-webhook-resource-validation.yaml @@ -0,0 +1 @@ +./core/webhooks/resource-validation.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/500-webhook-secret.yaml b/vendor/knative.dev/serving/config/500-webhook-secret.yaml new file mode 120000 index 00000000000..c8b148a1f34 --- /dev/null +++ b/vendor/knative.dev/serving/config/500-webhook-secret.yaml @@ -0,0 +1 @@ +./core/webhooks/secret.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/999-cache.yaml b/vendor/knative.dev/serving/config/999-cache.yaml new file mode 120000 index 00000000000..c004bf36f14 --- /dev/null +++ b/vendor/knative.dev/serving/config/999-cache.yaml @@ -0,0 +1 @@ +core/999-cache.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/activator-hpa.yaml b/vendor/knative.dev/serving/config/activator-hpa.yaml new file mode 120000 index 00000000000..15a3555cadd --- /dev/null +++ b/vendor/knative.dev/serving/config/activator-hpa.yaml @@ -0,0 +1 @@ +core/deployments/activator-hpa.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/activator.yaml b/vendor/knative.dev/serving/config/activator.yaml new file mode 120000 index 00000000000..aa5465250cc --- /dev/null +++ b/vendor/knative.dev/serving/config/activator.yaml @@ -0,0 +1 @@ +core/deployments/activator.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/autoscaler-hpa.yaml b/vendor/knative.dev/serving/config/autoscaler-hpa.yaml new file mode 120000 index 00000000000..9c7c8d6859b --- /dev/null +++ b/vendor/knative.dev/serving/config/autoscaler-hpa.yaml @@ -0,0 +1 @@ +hpa-autoscaling/controller.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/autoscaler.yaml b/vendor/knative.dev/serving/config/autoscaler.yaml new file mode 120000 index 00000000000..3f670846525 --- /dev/null +++ b/vendor/knative.dev/serving/config/autoscaler.yaml @@ -0,0 +1 @@ +core/deployments/autoscaler.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-autoscaler.yaml b/vendor/knative.dev/serving/config/config-autoscaler.yaml new file mode 120000 index 00000000000..a3ad66dd0e1 --- /dev/null +++ b/vendor/knative.dev/serving/config/config-autoscaler.yaml @@ -0,0 +1 @@ +core/configmaps/autoscaler.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-certmanager.yaml b/vendor/knative.dev/serving/config/config-certmanager.yaml new file mode 120000 index 00000000000..42575fa7c37 --- /dev/null +++ b/vendor/knative.dev/serving/config/config-certmanager.yaml @@ -0,0 +1 @@ +cert-manager/config.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-defaults.yaml b/vendor/knative.dev/serving/config/config-defaults.yaml new file mode 120000 index 00000000000..cdce59640f4 --- /dev/null +++ b/vendor/knative.dev/serving/config/config-defaults.yaml @@ -0,0 +1 @@ +core/configmaps/defaults.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-deployment.yaml b/vendor/knative.dev/serving/config/config-deployment.yaml new file mode 120000 index 00000000000..ac8682ddec7 --- /dev/null +++ b/vendor/knative.dev/serving/config/config-deployment.yaml @@ -0,0 +1 @@ +core/configmaps/deployment.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-domain.yaml b/vendor/knative.dev/serving/config/config-domain.yaml new file mode 120000 index 00000000000..1702a3b1388 --- /dev/null +++ b/vendor/knative.dev/serving/config/config-domain.yaml @@ -0,0 +1 @@ +core/configmaps/domain.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-gc.yaml b/vendor/knative.dev/serving/config/config-gc.yaml new file mode 120000 index 00000000000..bb86ac4f73d --- /dev/null +++ b/vendor/knative.dev/serving/config/config-gc.yaml @@ -0,0 +1 @@ +core/configmaps/gc.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-istio.yaml b/vendor/knative.dev/serving/config/config-istio.yaml new file mode 120000 index 00000000000..0598b6e30fa --- /dev/null +++ b/vendor/knative.dev/serving/config/config-istio.yaml @@ -0,0 +1 @@ +istio-ingress/config.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-logging.yaml b/vendor/knative.dev/serving/config/config-logging.yaml new file mode 120000 index 00000000000..fdd487354e4 --- /dev/null +++ b/vendor/knative.dev/serving/config/config-logging.yaml @@ -0,0 +1 @@ +core/configmaps/logging.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-network.yaml b/vendor/knative.dev/serving/config/config-network.yaml new file mode 120000 index 00000000000..e4e48d42d4c --- /dev/null +++ b/vendor/knative.dev/serving/config/config-network.yaml @@ -0,0 +1 @@ +core/configmaps/network.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-observability.yaml b/vendor/knative.dev/serving/config/config-observability.yaml new file mode 120000 index 00000000000..972be50a8c5 --- /dev/null +++ b/vendor/knative.dev/serving/config/config-observability.yaml @@ -0,0 +1 @@ +core/configmaps/observability.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/config-tracing.yaml b/vendor/knative.dev/serving/config/config-tracing.yaml new file mode 120000 index 00000000000..8a578ada956 --- /dev/null +++ b/vendor/knative.dev/serving/config/config-tracing.yaml @@ -0,0 +1 @@ +core/configmaps/tracing.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/controller.yaml b/vendor/knative.dev/serving/config/controller.yaml new file mode 120000 index 00000000000..a3175117ed7 --- /dev/null +++ b/vendor/knative.dev/serving/config/controller.yaml @@ -0,0 +1 @@ +core/deployments/controller.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/custom-metrics-apiservice.yaml b/vendor/knative.dev/serving/config/custom-metrics-apiservice.yaml new file mode 120000 index 00000000000..3fe4a2a46c7 --- /dev/null +++ b/vendor/knative.dev/serving/config/custom-metrics-apiservice.yaml @@ -0,0 +1 @@ +hpa-autoscaling/custom-metrics-apiservice.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/networking-certmanager.yaml b/vendor/knative.dev/serving/config/networking-certmanager.yaml new file mode 120000 index 00000000000..a4f43e8b42e --- /dev/null +++ b/vendor/knative.dev/serving/config/networking-certmanager.yaml @@ -0,0 +1 @@ +cert-manager/controller.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/networking-istio.yaml b/vendor/knative.dev/serving/config/networking-istio.yaml new file mode 120000 index 00000000000..2bf1688b9c2 --- /dev/null +++ b/vendor/knative.dev/serving/config/networking-istio.yaml @@ -0,0 +1 @@ +istio-ingress/controller.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/networking-ns-cert.yaml b/vendor/knative.dev/serving/config/networking-ns-cert.yaml new file mode 120000 index 00000000000..37ae032bc56 --- /dev/null +++ b/vendor/knative.dev/serving/config/networking-ns-cert.yaml @@ -0,0 +1 @@ +namespace-wildcard-certs/controller.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/config/webhook.yaml b/vendor/knative.dev/serving/config/webhook.yaml new file mode 120000 index 00000000000..4aedde6aca0 --- /dev/null +++ b/vendor/knative.dev/serving/config/webhook.yaml @@ -0,0 +1 @@ +core/deployments/webhook.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go new file mode 100644 index 00000000000..cfbd9a255b8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/annotation_validation.go @@ -0,0 +1,146 @@ +/* +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 autoscaling + +import ( + "fmt" + "math" + "strconv" + "time" + + "knative.dev/pkg/apis" +) + +func getIntGE0(m map[string]string, k string) (int64, *apis.FieldError) { + v, ok := m[k] + if !ok { + return 0, nil + } + i, err := strconv.ParseInt(v, 10, 32) + if err != nil || i < 0 { + return 0, apis.ErrOutOfBoundsValue(v, 1, math.MaxInt32, k) + } + return i, nil +} + +func ValidateAnnotations(anns map[string]string) *apis.FieldError { + if len(anns) == 0 { + return nil + } + return validateMinMaxScale(anns).Also(validateFloats(anns)).Also(validateWindows(anns).Also(validateMetric(anns))) +} + +func validateFloats(annotations map[string]string) *apis.FieldError { + var errs *apis.FieldError + if v, ok := annotations[PanicWindowPercentageAnnotationKey]; ok { + if fv, err := strconv.ParseFloat(v, 64); err != nil { + errs = errs.Also(apis.ErrInvalidValue(v, PanicWindowPercentageAnnotationKey)) + } else if fv < PanicWindowPercentageMin || fv > PanicWindowPercentageMax { + errs = apis.ErrOutOfBoundsValue(v, PanicWindowPercentageMin, + PanicWindowPercentageMax, PanicWindowPercentageAnnotationKey) + } + } + if v, ok := annotations[PanicThresholdPercentageAnnotationKey]; ok { + if fv, err := strconv.ParseFloat(v, 64); err != nil { + errs = errs.Also(apis.ErrInvalidValue(v, PanicThresholdPercentageAnnotationKey)) + } else if fv < PanicThresholdPercentageMin || fv > PanicThresholdPercentageMax { + errs = errs.Also(apis.ErrOutOfBoundsValue(v, PanicThresholdPercentageMin, PanicThresholdPercentageMax, + PanicThresholdPercentageAnnotationKey)) + } + } + + if v, ok := annotations[TargetAnnotationKey]; ok { + if fv, err := strconv.ParseFloat(v, 64); err != nil || fv < TargetMin { + errs = errs.Also(apis.ErrInvalidValue(v, TargetAnnotationKey)) + } + } + + if v, ok := annotations[TargetUtilizationPercentageKey]; ok { + if fv, err := strconv.ParseFloat(v, 64); err != nil { + errs = errs.Also(apis.ErrInvalidValue(v, TargetUtilizationPercentageKey)) + } else if fv < 1 || fv > 100 { + errs = errs.Also(apis.ErrOutOfBoundsValue(v, 1, 100, TargetUtilizationPercentageKey)) + } + } + + if v, ok := annotations[TargetBurstCapacityKey]; ok { + if fv, err := strconv.ParseFloat(v, 64); err != nil || fv < 0 && fv != -1 { + errs = errs.Also(apis.ErrInvalidValue(v, TargetBurstCapacityKey)) + } + } + return errs +} + +func validateWindows(annotations map[string]string) *apis.FieldError { + var errs *apis.FieldError + if w, ok := annotations[WindowAnnotationKey]; ok { + if annotations[ClassAnnotationKey] == HPA && annotations[MetricAnnotationKey] == CPU { + return apis.ErrInvalidKeyName(WindowAnnotationKey, fmt.Sprintf("%s for %s %s", HPA, MetricAnnotationKey, CPU)) + } + d, err := time.ParseDuration(w) + if err != nil { + errs = apis.ErrInvalidValue(w, WindowAnnotationKey) + } else if d < WindowMin || d > WindowMax { + errs = apis.ErrOutOfBoundsValue(w, WindowMin, WindowMax, WindowAnnotationKey) + } + } + return errs +} + +func validateMinMaxScale(annotations map[string]string) *apis.FieldError { + var errs *apis.FieldError + + min, err := getIntGE0(annotations, MinScaleAnnotationKey) + errs = errs.Also(err) + + max, err := getIntGE0(annotations, MaxScaleAnnotationKey) + errs = errs.Also(err) + + if max != 0 && max < min { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("maxScale=%d is less than minScale=%d", max, min), + Paths: []string{MaxScaleAnnotationKey, MinScaleAnnotationKey}, + }) + } + return errs +} + +func validateMetric(annotations map[string]string) *apis.FieldError { + if metric, ok := annotations[MetricAnnotationKey]; ok { + classValue := KPA + if c, ok := annotations[ClassAnnotationKey]; ok { + classValue = c + } + switch classValue { + case KPA: + switch metric { + case Concurrency, RPS: + return nil + } + case HPA: + switch metric { + case CPU, Concurrency, RPS: + return nil + } + default: + // Leave other classes of PodAutoscaler alone. + return nil + } + return apis.ErrInvalidValue(metric, MetricAnnotationKey) + } + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go new file mode 100644 index 00000000000..88526ce583b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/register.go @@ -0,0 +1,160 @@ +/* +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 autoscaling + +import "time" + +const ( + // The internal autoscaling group name. This is used for CRDs. + InternalGroupName = "autoscaling.internal.knative.dev" + + // The publuc autoscaling group name. This is used for annotations, labels, etc. + GroupName = "autoscaling.knative.dev" + + // ClassAnnotationKey is the annotation for the explicit class of autoscaler + // that a particular resource has opted into. For example, + // autoscaling.knative.dev/class: foo + // This uses a different domain because unlike the resource, it is user-facing. + ClassAnnotationKey = GroupName + "/class" + // KPA is Knative Horizontal Pod Autoscaler + KPA = "kpa.autoscaling.knative.dev" + // HPA is Kubernetes Horizontal Pod Autoscaler + HPA = "hpa.autoscaling.knative.dev" + + // MinScaleAnnotationKey is the annotation to specify the minimum number of Pods + // the PodAutoscaler should provision. For example, + // autoscaling.knative.dev/minScale: "1" + MinScaleAnnotationKey = GroupName + "/minScale" + // MaxScaleAnnotationKey is the annotation to specify the maximum number of Pods + // the PodAutoscaler should provision. For example, + // autoscaling.knative.dev/maxScale: "10" + MaxScaleAnnotationKey = GroupName + "/maxScale" + + // MetricAnnotationKey is the annotation to specify what metric the PodAutoscaler + // should be scaled on. For example, + // autoscaling.knative.dev/metric: cpu + MetricAnnotationKey = GroupName + "/metric" + // Concurrency is the number of requests in-flight at any given time. + Concurrency = "concurrency" + // CPU is the amount of the requested cpu actually being consumed by the Pod. + CPU = "cpu" + // RPS is the requests per second reaching the Pod. + RPS = "rps" + + // TargetAnnotationKey is the annotation to specify what metric value the + // PodAutoscaler should attempt to maintain. For example, + // autoscaling.knative.dev/metric: cpu + // autoscaling.knative.dev/target: "75" # target 75% cpu utilization + TargetAnnotationKey = GroupName + "/target" + // TargetMin is the minimum allowable target. Values less than + // zero don't make sense. + TargetMin = 1 + + // WindowAnnotationKey is the annotation to specify the time + // interval over which to calculate the average metric. Larger + // values result in more smoothing. For example, + // autoscaling.knative.dev/metric: concurrency + // autoscaling.knative.dev/window: "2m" + // Only the kpa.autoscaling.knative.dev class autoscaler supports + // the window annotation. + WindowAnnotationKey = GroupName + "/window" + // WindowMin is the minimum allowable stable autoscaling + // window. KPA-class autoscalers calculate the desired replica + // count every 2 seconds (tick-interval in config-autoscaler) so + // the closer the window gets to that value, the more likely data + // points will be missed entirely by the panic window which is + // smaller than the stable window. Anything less than 6 second + // isn't going to work well. + WindowMin = 6 * time.Second + // WindowMax is the maximum permitted stable autoscaling window. + // This keeps the event horizon to a resonable enough limit. + WindowMax = 1 * time.Hour + + // TargetUtilizationPercentageKey is the annotation which specifies the + // desired target resource utilization for the revision. + // TargetUtilization is a percentage in the 1 <= TU <= 100 range. + // This annotation takes precedence over the config map value. + TargetUtilizationPercentageKey = GroupName + "/targetUtilizationPercentage" + + // TargetBurstCapacityKey specifies the desired burst capacity for the + // revision. Possible values are: + // -1 -- infinite; + // 0 -- no TBC; + // >0 -- actual TBC. + // <0 && != -1 -- an error. + TargetBurstCapacityKey = GroupName + "/targetBurstCapacity" + + // PanicWindowPercentageAnnotationKey is the annotation to + // specify the time interval over which to calculate the average + // metric during a spike. Where a spike is defined as the metric + // reaching panic level within the panic window (e.g. panic + // mode). Lower values make panic mode more sensitive. Note: + // Panic threshold can be overridden with the + // PanicThresholdPercentageAnnotationKey. For example, + // autoscaling.knative.dev/panicWindowPercentage: "5.0" + // autoscaling.knative.dev/panicThresholdPercentage: "150.0" + // Only the kpa.autoscaling.knative.dev class autoscaler supports + // the panicWindowPercentage annotation. + // Panic window is specified as a percentag to maintain the + // autoscaler's algorithm behavior when only the stable window is + // specified. The panic window will change along with the stable + // window at the default percentage. + PanicWindowPercentageAnnotationKey = GroupName + "/panicWindowPercentage" + // PanicWindowPercentageMin is the minimum allowable panic window + // percentage. The autoscaler calculates desired replicas every 2 + // seconds (tick-interval in config-autoscaler), so a panic + // window less than 2 seconds will be missing data points. One + // percent is a very small ratio and would require a stable + // window of at least 3.4 minutes. Anything less doesn't make + // sense. + PanicWindowPercentageMin = 1.0 + // PanicWindowPercentageMax is the maximum allowable panic window + // percentage. The KPA autoscaler's panic feature allows the + // autoscaler to be more responsive over a smaller time scale + // when necessary. So the panic window cannot be larger than the + // stable window. + PanicWindowPercentageMax = 100.0 + + // PanicThresholdPercentageAnnotationKey is the annotation to specify + // the level at what level panic mode will engage when reached within + // in the panic window. The level is defined as a percentage of + // the metric target. Lower values make panic mode more + // sensitive. For example, + // autoscaling.knative.dev/panicWindowPercentage: "5.0" + // autoscaling.knative.dev/panicThresholdPercentage: "150.0" + // Only the kpa.autoscaling.knative.dev class autoscaler supports + // the panicThresholdPercentage annotation + PanicThresholdPercentageAnnotationKey = GroupName + "/panicThresholdPercentage" + // PanicThresholdPercentageMin is the minimum allowable panic + // threshold percentage. The KPA autoscaler's panic feature + // allows the autoscaler to be more responsive over a smaller + // time scale when necessary. To prevent flapping, during panic + // mode the autoscaler never decreases the number of replicas. If + // the panic threshold was as small as the stable target, the + // autoscaler would always be panicking and the autoscaler would + // never scale down. One hundred and ten percent is about the + // smallest useful value. + PanicThresholdPercentageMin = 110.0 + + // PanicThresholdPercentageMax is the counterpart to the PanicThresholdPercentageMin + // but bounding from above. + PanicThresholdPercentageMax = 1000.0 + + // KPALabelKey is the label key attached to a K8s Service to hint to the KPA + // which services/endpoints should trigger reconciles. + KPALabelKey = GroupName + "/kpa" +) diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/doc.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/doc.go new file mode 100644 index 00000000000..bcdf80570a8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/doc.go @@ -0,0 +1,19 @@ +/* +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 +// +groupName=autoscaling.internal.knative.dev +package v1alpha1 diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_defaults.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_defaults.go new file mode 100644 index 00000000000..635297923aa --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_defaults.go @@ -0,0 +1,31 @@ +/* +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" +) + +// SetDefaults sets defaults on the entire Metric if applicable. +func (m *Metric) SetDefaults(ctx context.Context) { + m.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults sets defaults on the Metric's Spec if applicable. +func (ms *MetricSpec) SetDefaults(ctx context.Context) {} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_lifecycle.go new file mode 100644 index 00000000000..838577a5b9f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_lifecycle.go @@ -0,0 +1,73 @@ +/* +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 ( + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +const ( + // MetricConditionReady is set when the Metric's latest + // underlying revision has reported readiness. + MetricConditionReady = apis.ConditionReady +) + +var condSet = apis.NewLivingConditionSet( + MetricConditionReady, +) + +// GetGroupVersionKind implements OwnerRefable. +func (m *Metric) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Metric") +} + +// GetCondition gets the condition `t`. +func (ms *MetricStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return condSet.Manage(ms).GetCondition(t) +} + +// InitializeConditions initializes the conditions of the Metric. +func (ms *MetricStatus) InitializeConditions() { + condSet.Manage(ms).InitializeConditions() +} + +// MarkMetricReady marks the metric status as ready +func (ms *MetricStatus) MarkMetricReady() { + condSet.Manage(ms).MarkTrue(MetricConditionReady) +} + +// MarkMetricNotReady marks the metric status as ready == Unknown +func (ms *MetricStatus) MarkMetricNotReady(reason, message string) { + condSet.Manage(ms).MarkUnknown(MetricConditionReady, reason, message) +} + +// MarkMetricFailed marks the metric status as failed +func (ms *MetricStatus) MarkMetricFailed(reason, message string) { + condSet.Manage(ms).MarkFalse(MetricConditionReady, reason, message) +} + +// IsReady looks at the conditions and if the condition MetricConditionReady +// is true +func (ms *MetricStatus) IsReady() bool { + return condSet.Manage(ms.duck()).IsHappy() +} + +func (ms *MetricStatus) duck() *duckv1.Status { + return (*duckv1.Status)(&ms.Status) +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_types.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_types.go new file mode 100644 index 00000000000..dca3e6d7c74 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_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 ( + "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// Metric represents a resource to configure the metric collector with. +// +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type Metric struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Metric (from the client). + // +optional + Spec MetricSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Metric (from the controller). + // +optional + Status MetricStatus `json:"status,omitempty"` +} + +// Verify that Metric adheres to the appropriate interfaces. +var ( + // Check that Metric can be validated and can be defaulted. + _ apis.Validatable = (*Metric)(nil) + _ apis.Defaultable = (*Metric)(nil) + + // Check that we can create OwnerReferences to a Metric. + _ kmeta.OwnerRefable = (*Metric)(nil) +) + +// MetricSpec contains all values a metric collector needs to operate. +type MetricSpec struct { + // StableWindow is the aggregation window for metrics in a stable state. + StableWindow time.Duration `json:"stableWindow"` + // PanicWindow is the aggregation window for metrics where quick reactions are needed. + PanicWindow time.Duration `json:"panicWindow"` + // ScrapeTarget is the K8s service that publishes the metric endpoint. + ScrapeTarget string `json:"scrapeTarget"` +} + +// MetricStatus reflects the status of metric collection for this specific entity. +type MetricStatus struct { + duckv1.Status `json:",inline"` +} + +// MetricList is a list of Metric resources +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type MetricList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Metric `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go new file mode 100644 index 00000000000..e0c8d182d95 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/metric_validation.go @@ -0,0 +1,39 @@ +/* +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" + + "k8s.io/apimachinery/pkg/api/equality" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +// Validate validates the entire Metric. +func (m *Metric) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(m.GetObjectMeta()).ViaField("metadata") + return errs.Also(m.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) +} + +// Validate validates Metric's Spec. +func (ms *MetricSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(ms, &MetricSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go new file mode 100644 index 00000000000..92131163519 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_defaults.go @@ -0,0 +1,52 @@ +/* +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 v1alpha1 + +import ( + "context" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/autoscaling" +) + +func defaultMetric(class string) string { + switch class { + case autoscaling.KPA: + return autoscaling.Concurrency + case autoscaling.HPA: + return autoscaling.CPU + default: + return "" + } +} + +func (r *PodAutoscaler) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) + if r.Annotations == nil { + r.Annotations = make(map[string]string) + } + if _, ok := r.Annotations[autoscaling.ClassAnnotationKey]; !ok { + // Default class to KPA. + r.Annotations[autoscaling.ClassAnnotationKey] = autoscaling.KPA + } + // Default metric per class + if _, ok := r.Annotations[autoscaling.MetricAnnotationKey]; !ok { + r.Annotations[autoscaling.MetricAnnotationKey] = defaultMetric(r.Class()) + } +} + +func (rs *PodAutoscalerSpec) SetDefaults(ctx context.Context) {} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go new file mode 100644 index 00000000000..53203e56fb0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_lifecycle.go @@ -0,0 +1,237 @@ +/* +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 ( + "fmt" + "strconv" + "time" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/serving/pkg/apis/autoscaling" +) + +var podCondSet = apis.NewLivingConditionSet( + PodAutoscalerConditionActive, +) + +func (pa *PodAutoscaler) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("PodAutoscaler") +} + +func (pa *PodAutoscaler) Class() string { + if c, ok := pa.Annotations[autoscaling.ClassAnnotationKey]; ok { + return c + } + // Default to "kpa" class for backward compatibility. + return autoscaling.KPA +} + +// Metric returns the contents of the metric annotation or a default. +func (pa *PodAutoscaler) Metric() string { + if m, ok := pa.Annotations[autoscaling.MetricAnnotationKey]; ok { + return m + } + // TODO: defaulting here is awkward and is already taken care of by defaulting logic. + return defaultMetric(pa.Class()) +} + +func (pa *PodAutoscaler) annotationInt32(key string) int32 { + if s, ok := pa.Annotations[key]; ok { + // no error check: relying on validation + i, _ := strconv.ParseInt(s, 10, 32) + if i < 0 { + return 0 + } + return int32(i) + } + return 0 +} + +func (pa *PodAutoscaler) annotationFloat64(key string) (float64, bool) { + if s, ok := pa.Annotations[key]; ok { + f, err := strconv.ParseFloat(s, 64) + return f, err == nil + } + return 0.0, false +} + +// ScaleBounds returns scale bounds annotations values as a tuple: +// `(min, max int32)`. The value of 0 for any of min or max means the bound is +// not set. +// Note: min will be ignored if the PA is not reachable +func (pa *PodAutoscaler) ScaleBounds() (min, max int32) { + if pa.Spec.Reachability != ReachabilityUnreachable { + min = pa.annotationInt32(autoscaling.MinScaleAnnotationKey) + } + max = pa.annotationInt32(autoscaling.MaxScaleAnnotationKey) + + return +} + +// Target returns the target annotation value or false if not present, or invalid. +func (pa *PodAutoscaler) Target() (float64, bool) { + return pa.annotationFloat64(autoscaling.TargetAnnotationKey) +} + +// TargetUtilization returns the target capacity utilization as a fraction, +// if the corresponding annotation is set. +func (pa *PodAutoscaler) TargetUtilization() (float64, bool) { + if tu, ok := pa.annotationFloat64(autoscaling.TargetUtilizationPercentageKey); ok { + return tu / 100, true + } + return 0, false +} + +// TargetBC returns the target burst capacity, +// if the corresponding annotation is set. +func (pa *PodAutoscaler) TargetBC() (float64, bool) { + // The value is validated in the webhook. + return pa.annotationFloat64(autoscaling.TargetBurstCapacityKey) +} + +// Window returns the window annotation value or false if not present. +func (pa *PodAutoscaler) Window() (window time.Duration, ok bool) { + // The value is validated in the webhook. + if s, ok := pa.Annotations[autoscaling.WindowAnnotationKey]; ok { + d, err := time.ParseDuration(s) + return d, err == nil + } + return 0, false +} + +// PanicWindowPercentage returns panic window annotation value or false if not present. +func (pa *PodAutoscaler) PanicWindowPercentage() (percentage float64, ok bool) { + // The value is validated in the webhook. + return pa.annotationFloat64(autoscaling.PanicWindowPercentageAnnotationKey) +} + +// PanicThresholdPercentage return the panic target annotation value or false if not present. +func (pa *PodAutoscaler) PanicThresholdPercentage() (percentage float64, ok bool) { + // The value is validated in the webhook. + return pa.annotationFloat64(autoscaling.PanicThresholdPercentageAnnotationKey) +} + +// IsReady looks at the conditions and if the Status has a condition +// PodAutoscalerConditionReady returns true if ConditionStatus is True +func (pas *PodAutoscalerStatus) IsReady() bool { + return podCondSet.Manage(pas.duck()).IsHappy() +} + +// IsActivating returns true if the pod autoscaler is Activating if it is neither +// Active nor Inactive +func (pas *PodAutoscalerStatus) IsActivating() bool { + cond := pas.GetCondition(PodAutoscalerConditionActive) + return cond != nil && cond.Status == corev1.ConditionUnknown +} + +// IsInactive returns true if the pod autoscaler is Inactive. +func (pas *PodAutoscalerStatus) IsInactive() bool { + cond := pas.GetCondition(PodAutoscalerConditionActive) + return cond != nil && cond.Status == corev1.ConditionFalse +} + +// GetCondition gets the condition `t`. +func (pas *PodAutoscalerStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return podCondSet.Manage(pas.duck()).GetCondition(t) +} + +// InitializeConditions initializes the conditionhs of the PA. +func (pas *PodAutoscalerStatus) InitializeConditions() { + podCondSet.Manage(pas.duck()).InitializeConditions() +} + +// MarkActive marks the PA active. +func (pas *PodAutoscalerStatus) MarkActive() { + podCondSet.Manage(pas.duck()).MarkTrue(PodAutoscalerConditionActive) +} + +// MarkActivating marks the PA as activating. +func (pas *PodAutoscalerStatus) MarkActivating(reason, message string) { + podCondSet.Manage(pas.duck()).MarkUnknown(PodAutoscalerConditionActive, reason, message) +} + +// MarkInactive marks the PA as inactive. +func (pas *PodAutoscalerStatus) MarkInactive(reason, message string) { + podCondSet.Manage(pas.duck()).MarkFalse(PodAutoscalerConditionActive, reason, message) +} + +// MarkResourceNotOwned changes the "Active" condition to false to reflect that the +// resource of the given kind and name has already been created, and we do not own it. +func (pas *PodAutoscalerStatus) MarkResourceNotOwned(kind, name string) { + pas.MarkInactive("NotOwned", + fmt.Sprintf("There is an existing %s %q that we do not own.", kind, name)) +} + +// MarkResourceFailedCreation changes the "Active" condition to false to reflect that a +// critical resource of the given kind and name was unable to be created. +func (pas *PodAutoscalerStatus) MarkResourceFailedCreation(kind, name string) { + pas.MarkInactive("FailedCreate", + fmt.Sprintf("Failed to create %s %q.", kind, name)) +} + +// CanScaleToZero checks whether the pod autoscaler has been in an inactive state +// for at least the specified grace period. +func (pas *PodAutoscalerStatus) CanScaleToZero(now time.Time, gracePeriod time.Duration) bool { + return pas.inStatusFor(corev1.ConditionFalse, now, gracePeriod) > 0 +} + +// ActiveFor returns the time PA spent being active. +func (pas *PodAutoscalerStatus) ActiveFor(now time.Time) time.Duration { + return pas.inStatusFor(corev1.ConditionTrue, now, 0) +} + +// CanFailActivation checks whether the pod autoscaler has been activating +// for at least the specified idle period. +func (pas *PodAutoscalerStatus) CanFailActivation(now time.Time, idlePeriod time.Duration) bool { + return pas.inStatusFor(corev1.ConditionUnknown, now, idlePeriod) > 0 +} + +// inStatusFor returns positive duration if the PodAutoscalerStatus's Active condition has stayed in +// the specified status for at least the specified duration. Otherwise it returns negative duration, +// including when the status is undetermined (Active condition is not found.) +func (pas *PodAutoscalerStatus) inStatusFor(status corev1.ConditionStatus, now time.Time, dur time.Duration) time.Duration { + cond := pas.GetCondition(PodAutoscalerConditionActive) + if cond == nil || cond.Status != status { + return -1 + } + return now.Sub(cond.LastTransitionTime.Inner.Add(dur)) +} + +func (pas *PodAutoscalerStatus) duck() *duckv1.Status { + return (*duckv1.Status)(&pas.Status) +} + +// GetDesiredScale returns the desired scale if ever set, or -1. +func (pas *PodAutoscalerStatus) GetDesiredScale() int32 { + if pas.DesiredScale != nil { + return *pas.DesiredScale + } + return -1 +} + +// GetActualScale returns the desired scale if ever set, or -1. +func (pas *PodAutoscalerStatus) GetActualScale() int32 { + if pas.ActualScale != nil { + return *pas.ActualScale + } + return -1 +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go new file mode 100644 index 00000000000..9f0545417b3 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_types.go @@ -0,0 +1,142 @@ +/* +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 v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" + net "knative.dev/serving/pkg/apis/networking" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodAutoscaler is a Knative abstraction that encapsulates the interface by which Knative +// components instantiate autoscalers. This definition is an abstraction that may be backed +// by multiple definitions. For more information, see the Knative Pluggability presentation: +// https://docs.google.com/presentation/d/10KWynvAJYuOEWy69VBa6bHJVCqIsz1TNdEKosNvcpPY/edit +type PodAutoscaler struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the PodAutoscaler (from the client). + // +optional + Spec PodAutoscalerSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the PodAutoscaler (from the controller). + // +optional + Status PodAutoscalerStatus `json:"status,omitempty"` +} + +// Verify that PodAutoscaler adheres to the appropriate interfaces. +var ( + // Check that PodAutoscaler can be validated and can be defaulted. + _ apis.Validatable = (*PodAutoscaler)(nil) + _ apis.Defaultable = (*PodAutoscaler)(nil) + + // Check that we can create OwnerReferences to a PodAutoscaler. + _ kmeta.OwnerRefable = (*PodAutoscaler)(nil) +) + +// ReachabilityType is the enumeration type for the different states of reachability +// to the `ScaleTarget` of a `PodAutoscaler` +type ReachabilityType string + +const ( + // ReachabilityUnknown means the reachability of the `ScaleTarget` is unknown. + // Used when the reachability cannot be determined, eg. during activation. + ReachabilityUnknown ReachabilityType = "" + + // ReachabilityReachable means the `ScaleTarget` is reachable, ie. it has an active route. + ReachabilityReachable ReachabilityType = "Reachable" + + // ReachabilityReachable means the `ScaleTarget` is not reachable, ie. it does not have an active route. + ReachabilityUnreachable ReachabilityType = "Unreachable" +) + +// PodAutoscalerSpec holds the desired state of the PodAutoscaler (from the client). +type PodAutoscalerSpec struct { + // DeprecatedGeneration was used prior in Kubernetes versions <1.11 + // when metadata.generation was not being incremented by the api server + // + // This property will be dropped in future Knative releases and should + // not be used - use metadata.generation + // + // Tracking issue: https://github.com/knative/serving/issues/643 + // + // +optional + DeprecatedGeneration int64 `json:"generation,omitempty"` + + // ContainerConcurrency specifies the maximum allowed + // in-flight (concurrent) requests per container of the Revision. + // Defaults to `0` which means unlimited concurrency. + // +optional + ContainerConcurrency int64 `json:"containerConcurrency,omitempty"` + + // ScaleTargetRef defines the /scale-able resource that this PodAutoscaler + // is responsible for quickly right-sizing. + ScaleTargetRef corev1.ObjectReference `json:"scaleTargetRef"` + + // Reachable specifies whether or not the `ScaleTargetRef` can be reached (ie. has a route). + // Defaults to `ReachabilityUnknown` + // +optional + Reachability ReachabilityType `json:"reachability,omitempty"` + + // The application-layer protocol. Matches `ProtocolType` inferred from the revision spec. + ProtocolType net.ProtocolType `json:"protocolType"` +} + +const ( + // PodAutoscalerConditionReady is set when the revision is starting to materialize + // runtime resources, and becomes true when those resources are ready. + PodAutoscalerConditionReady = apis.ConditionReady + // PodAutoscalerConditionActive is set when the PodAutoscaler's ScaleTargetRef is receiving traffic. + PodAutoscalerConditionActive apis.ConditionType = "Active" +) + +// PodAutoscalerStatus communicates the observed state of the PodAutoscaler (from the controller). +type PodAutoscalerStatus struct { + duckv1.Status `json:",inline"` + + // ServiceName is the K8s Service name that serves the revision, scaled by this PA. + // The service is created and owned by the ServerlessService object owned by this PA. + ServiceName string `json:"serviceName"` + + // MetricsServiceName is the K8s Service name that provides revision metrics. + // The service is managed by the PA object. + MetricsServiceName string `json:"metricsServiceName"` + + // DesiredScale shows the current desired number of replicas for the revision. + DesiredScale *int32 `json:"desiredScale,omitempty"` + + // ActualScale shows the actual number of replicas for the revision. + ActualScale *int32 `json:"actualScale,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodAutoscalerList is a list of PodAutoscaler resources +type PodAutoscalerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []PodAutoscaler `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go new file mode 100644 index 00000000000..31b2bb957a5 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/pa_validation.go @@ -0,0 +1,42 @@ +/* +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 v1alpha1 + +import ( + "context" + + "k8s.io/apimachinery/pkg/api/equality" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +func (pa *PodAutoscaler) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(pa.GetObjectMeta()).ViaField("metadata") + return errs.Also(pa.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) +} + +// Validate validates PodAutoscaler Spec. +func (pa *PodAutoscalerSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(pa, &PodAutoscalerSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + return serving.ValidateNamespacedObjectReference(&pa.ScaleTargetRef).ViaField("scaleTargetRef").Also(serving.ValidateContainerConcurrency(&pa.ContainerConcurrency).ViaField("containerConcurrency")).Also(validateSKSFields(ctx, pa)) +} + +func validateSKSFields(ctx context.Context, rs *PodAutoscalerSpec) (errs *apis.FieldError) { + return errs.Also(rs.ProtocolType.Validate(ctx)).ViaField("protocolType") +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/podscalable_types.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/podscalable_types.go new file mode 100644 index 00000000000..b6d05a7b73b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/podscalable_types.go @@ -0,0 +1,113 @@ +/* +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" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/duck" +) + +// +genduck +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodScalable is a duck type that the resources referenced by the +// PodAutoscaler's ScaleTargetRef must implement. They must also +// implement the `/scale` sub-resource for use with `/scale` based +// implementations (e.g. HPA), but this further constrains the shape +// the referenced resources may take. +type PodScalable struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec PodScalableSpec `json:"spec"` + Status PodScalableStatus `json:"status"` +} + +// PodScalableSpec is the specification for the desired state of a +// PodScalable (or at least our shared portion). +type PodScalableSpec struct { + Replicas *int32 `json:"replicas,omitempty"` + Selector *metav1.LabelSelector `json:"selector"` + Template corev1.PodTemplateSpec `json:"template"` +} + +// PodScalableStatus is the observed state of a PodScalable (or at +// least our shared portion). +type PodScalableStatus struct { + Replicas int32 `json:"replicas,omitempty"` +} + +var _ duck.Populatable = (*PodScalable)(nil) +var _ duck.Implementable = (*PodScalable)(nil) +var _ apis.Listable = (*PodScalable)(nil) + +// GetFullType implements duck.Implementable +func (*PodScalable) GetFullType() duck.Populatable { + return &PodScalable{} +} + +// Populate implements duck.Populatable +func (t *PodScalable) Populate() { + twelve := int32(12) + t.Spec = PodScalableSpec{ + Replicas: &twelve, + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "foo": "bar", + }, + MatchExpressions: []metav1.LabelSelectorRequirement{{ + Key: "foo", + Operator: "In", + Values: []string{"baz", "blah"}, + }}, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "foo": "bar", + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{{ + Name: "container-name", + Image: "container-image:latest", + }}, + }, + }, + } + t.Status = PodScalableStatus{ + Replicas: 42, + } +} + +// GetListType implements apis.Listable +func (*PodScalable) GetListType() runtime.Object { + return &PodScalableList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// PodScalableList is a list of PodScalable resources +type PodScalableList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []PodScalable `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/register.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/register.go new file mode 100644 index 00000000000..1a90e867e22 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/register.go @@ -0,0 +1,55 @@ +/* +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 v1alpha1 + +import ( + "knative.dev/serving/pkg/apis/autoscaling" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: autoscaling.InternalGroupName, 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 { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &PodAutoscaler{}, + &PodAutoscalerList{}, + &Metric{}, + &MetricList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..a4a822dfa96 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,329 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 ( + 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 *Metric) DeepCopyInto(out *Metric) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metric. +func (in *Metric) DeepCopy() *Metric { + if in == nil { + return nil + } + out := new(Metric) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Metric) 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 *MetricList) DeepCopyInto(out *MetricList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Metric, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricList. +func (in *MetricList) DeepCopy() *MetricList { + if in == nil { + return nil + } + out := new(MetricList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *MetricList) 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 *MetricSpec) DeepCopyInto(out *MetricSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricSpec. +func (in *MetricSpec) DeepCopy() *MetricSpec { + if in == nil { + return nil + } + out := new(MetricSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricStatus) DeepCopyInto(out *MetricStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricStatus. +func (in *MetricStatus) DeepCopy() *MetricStatus { + if in == nil { + return nil + } + out := new(MetricStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodAutoscaler) DeepCopyInto(out *PodAutoscaler) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscaler. +func (in *PodAutoscaler) DeepCopy() *PodAutoscaler { + if in == nil { + return nil + } + out := new(PodAutoscaler) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodAutoscaler) 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 *PodAutoscalerList) DeepCopyInto(out *PodAutoscalerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PodAutoscaler, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscalerList. +func (in *PodAutoscalerList) DeepCopy() *PodAutoscalerList { + if in == nil { + return nil + } + out := new(PodAutoscalerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodAutoscalerList) 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 *PodAutoscalerSpec) DeepCopyInto(out *PodAutoscalerSpec) { + *out = *in + out.ScaleTargetRef = in.ScaleTargetRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscalerSpec. +func (in *PodAutoscalerSpec) DeepCopy() *PodAutoscalerSpec { + if in == nil { + return nil + } + out := new(PodAutoscalerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodAutoscalerStatus) DeepCopyInto(out *PodAutoscalerStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.DesiredScale != nil { + in, out := &in.DesiredScale, &out.DesiredScale + *out = new(int32) + **out = **in + } + if in.ActualScale != nil { + in, out := &in.ActualScale, &out.ActualScale + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodAutoscalerStatus. +func (in *PodAutoscalerStatus) DeepCopy() *PodAutoscalerStatus { + if in == nil { + return nil + } + out := new(PodAutoscalerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodScalable) DeepCopyInto(out *PodScalable) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalable. +func (in *PodScalable) DeepCopy() *PodScalable { + if in == nil { + return nil + } + out := new(PodScalable) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodScalable) 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 *PodScalableList) DeepCopyInto(out *PodScalableList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]PodScalable, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalableList. +func (in *PodScalableList) DeepCopy() *PodScalableList { + if in == nil { + return nil + } + out := new(PodScalableList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PodScalableList) 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 *PodScalableSpec) DeepCopyInto(out *PodScalableSpec) { + *out = *in + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalableSpec. +func (in *PodScalableSpec) DeepCopy() *PodScalableSpec { + if in == nil { + return nil + } + out := new(PodScalableSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PodScalableStatus) DeepCopyInto(out *PodScalableStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodScalableStatus. +func (in *PodScalableStatus) DeepCopy() *PodScalableStatus { + if in == nil { + return nil + } + out := new(PodScalableStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/serving/pkg/apis/config/defaults.go b/vendor/knative.dev/serving/pkg/apis/config/defaults.go new file mode 100644 index 00000000000..fe1820dec3a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/config/defaults.go @@ -0,0 +1,172 @@ +/* +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 + + https://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 config + +import ( + "bytes" + "context" + "fmt" + "io/ioutil" + "strconv" + "text/template" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "knative.dev/pkg/apis" +) + +const ( + // DefaultsConfigName is the name of config map for the defaults. + DefaultsConfigName = "config-defaults" + + // DefaultRevisionTimeoutSeconds will be set if timeoutSeconds not specified. + DefaultRevisionTimeoutSeconds = 5 * 60 + + // DefaultMaxRevisionTimeoutSeconds will be set if MaxRevisionTimeoutSeconds is not specified. + DefaultMaxRevisionTimeoutSeconds = 10 * 60 + + // DefaultUserContainerName is the default name we give to the container + // specified by the user, if `name:` is omitted. + DefaultUserContainerName = "user-container" + + // DefaultContainerConcurrency is the default container concurrency. It will be set if ContainerConcurrency is not specified. + DefaultContainerConcurrency int64 = 0 + + // DefaultMaxRevisionContainerConcurrency is the maximum configurable + // container concurrency. + DefaultMaxRevisionContainerConcurrency int64 = 1000 +) + +// NewDefaultsConfigFromMap creates a Defaults from the supplied Map +func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { + nc := &Defaults{} + + // Process int64 fields + for _, i64 := range []struct { + key string + field *int64 + // specified exactly when optional + defaultValue int64 + }{{ + key: "revision-timeout-seconds", + field: &nc.RevisionTimeoutSeconds, + defaultValue: DefaultRevisionTimeoutSeconds, + }, { + key: "max-revision-timeout-seconds", + field: &nc.MaxRevisionTimeoutSeconds, + defaultValue: DefaultMaxRevisionTimeoutSeconds, + }, { + key: "container-concurrency", + field: &nc.ContainerConcurrency, + defaultValue: DefaultContainerConcurrency, + }} { + if raw, ok := data[i64.key]; !ok { + *i64.field = i64.defaultValue + } else if val, err := strconv.ParseInt(raw, 10, 64); err != nil { + return nil, err + } else { + *i64.field = val + } + } + + if nc.RevisionTimeoutSeconds > nc.MaxRevisionTimeoutSeconds { + return nil, fmt.Errorf("revision-timeout-seconds (%d) cannot be greater than max-revision-timeout-seconds (%d)", nc.RevisionTimeoutSeconds, nc.MaxRevisionTimeoutSeconds) + } + + if nc.ContainerConcurrency < 0 || nc.ContainerConcurrency > DefaultMaxRevisionContainerConcurrency { + return nil, apis.ErrOutOfBoundsValue(nc.ContainerConcurrency, 0, DefaultMaxRevisionContainerConcurrency, "containerConcurrency") + } + + // Process resource quantity fields + for _, rsrc := range []struct { + key string + field **resource.Quantity + }{{ + key: "revision-cpu-request", + field: &nc.RevisionCPURequest, + }, { + key: "revision-memory-request", + field: &nc.RevisionMemoryRequest, + }, { + key: "revision-cpu-limit", + field: &nc.RevisionCPULimit, + }, { + key: "revision-memory-limit", + field: &nc.RevisionMemoryLimit, + }} { + if raw, ok := data[rsrc.key]; !ok { + *rsrc.field = nil + } else if val, err := resource.ParseQuantity(raw); err != nil { + return nil, err + } else { + *rsrc.field = &val + } + } + + if raw, ok := data["container-name-template"]; !ok { + nc.UserContainerNameTemplate = DefaultUserContainerName + } else { + tmpl, err := template.New("user-container").Parse(raw) + if err != nil { + return nil, err + } + // Check that the template properly applies to ObjectMeta. + if err := tmpl.Execute(ioutil.Discard, metav1.ObjectMeta{}); err != nil { + return nil, fmt.Errorf("error executing template: %w", err) + } + // We store the raw template because we run deepcopy-gen on the + // config and that doesn't copy nicely. + nc.UserContainerNameTemplate = raw + } + + return nc, nil +} + +// NewDefaultsConfigFromConfigMap creates a Defaults from the supplied configMap +func NewDefaultsConfigFromConfigMap(config *corev1.ConfigMap) (*Defaults, error) { + return NewDefaultsConfigFromMap(config.Data) +} + +// Defaults includes the default values to be populated by the webhook. +type Defaults struct { + RevisionTimeoutSeconds int64 + // This is the timeout set for cluster ingress. + // RevisionTimeoutSeconds must be less than this value. + MaxRevisionTimeoutSeconds int64 + + UserContainerNameTemplate string + + ContainerConcurrency int64 + + RevisionCPURequest *resource.Quantity + RevisionCPULimit *resource.Quantity + RevisionMemoryRequest *resource.Quantity + RevisionMemoryLimit *resource.Quantity +} + +// UserContainerName returns the name of the user container based on the context. +func (d *Defaults) UserContainerName(ctx context.Context) string { + tmpl := template.Must( + template.New("user-container").Parse(d.UserContainerNameTemplate)) + buf := &bytes.Buffer{} + if err := tmpl.Execute(buf, apis.ParentMeta(ctx)); err != nil { + return "" + } + return buf.String() +} diff --git a/vendor/knative.dev/serving/pkg/apis/config/doc.go b/vendor/knative.dev/serving/pkg/apis/config/doc.go new file mode 100644 index 00000000000..8a8d1a75801 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/config/doc.go @@ -0,0 +1,21 @@ +/* +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. +*/ + +// +k8s:deepcopy-gen=package + +// Package config holds the typed objects that define the schemas for +// ConfigMap objects that pertain to our API objects. +package config diff --git a/vendor/knative.dev/serving/pkg/apis/config/store.go b/vendor/knative.dev/serving/pkg/apis/config/store.go new file mode 100644 index 00000000000..38f21bc66d7 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/config/store.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 config + +import ( + "context" + + "knative.dev/pkg/configmap" +) + +type cfgKey struct{} + +// Config holds the collection of configurations that we attach to contexts. +// +k8s:deepcopy-gen=false +type Config struct { + Defaults *Defaults +} + +// FromContext extracts a Config from the provided context. +func FromContext(ctx context.Context) *Config { + x, ok := ctx.Value(cfgKey{}).(*Config) + if ok { + return x + } + return nil +} + +// FromContextOrDefaults is like FromContext, but when no Config is attached it +// returns a Config populated with the defaults for each of the Config fields. +func FromContextOrDefaults(ctx context.Context) *Config { + if cfg := FromContext(ctx); cfg != nil { + return cfg + } + defaults, _ := NewDefaultsConfigFromMap(map[string]string{}) + return &Config{ + Defaults: defaults, + } +} + +// ToContext attaches the provided Config to the provided context, returning the +// new context with the Config attached. +func ToContext(ctx context.Context, c *Config) context.Context { + return context.WithValue(ctx, cfgKey{}, c) +} + +// Store is a typed wrapper around configmap.Untyped store to handle our configmaps. +// +k8s:deepcopy-gen=false +type Store struct { + *configmap.UntypedStore +} + +// NewStore creates a new store of Configs and optionally calls functions when ConfigMaps are updated. +func NewStore(logger configmap.Logger, onAfterStore ...func(name string, value interface{})) *Store { + store := &Store{ + UntypedStore: configmap.NewUntypedStore( + "defaults", + logger, + configmap.Constructors{ + DefaultsConfigName: NewDefaultsConfigFromConfigMap, + }, + onAfterStore..., + ), + } + + return store +} + +// ToContext attaches the current Config state to the provided context. +func (s *Store) ToContext(ctx context.Context) context.Context { + return ToContext(ctx, s.Load()) +} + +// Load creates a Config from the current config state of the Store. +func (s *Store) Load() *Config { + return &Config{ + Defaults: s.UntypedLoad(DefaultsConfigName).(*Defaults).DeepCopy(), + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/config/testdata/config-defaults.yaml b/vendor/knative.dev/serving/pkg/apis/config/testdata/config-defaults.yaml new file mode 120000 index 00000000000..4e958fe2929 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/config/testdata/config-defaults.yaml @@ -0,0 +1 @@ +../../../../config/core/configmaps/defaults.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/apis/config/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/config/zz_generated.deepcopy.go new file mode 100644 index 00000000000..341f6334baa --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/config/zz_generated.deepcopy.go @@ -0,0 +1,57 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 config + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Defaults) DeepCopyInto(out *Defaults) { + *out = *in + if in.RevisionCPURequest != nil { + in, out := &in.RevisionCPURequest, &out.RevisionCPURequest + x := (*in).DeepCopy() + *out = &x + } + if in.RevisionCPULimit != nil { + in, out := &in.RevisionCPULimit, &out.RevisionCPULimit + x := (*in).DeepCopy() + *out = &x + } + if in.RevisionMemoryRequest != nil { + in, out := &in.RevisionMemoryRequest, &out.RevisionMemoryRequest + x := (*in).DeepCopy() + *out = &x + } + if in.RevisionMemoryLimit != nil { + in, out := &in.RevisionMemoryLimit, &out.RevisionMemoryLimit + x := (*in).DeepCopy() + *out = &x + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Defaults. +func (in *Defaults) DeepCopy() *Defaults { + if in == nil { + return nil + } + out := new(Defaults) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/generic_types.go b/vendor/knative.dev/serving/pkg/apis/networking/generic_types.go new file mode 100644 index 00000000000..82685b1e440 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/generic_types.go @@ -0,0 +1,48 @@ +/* +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 networking + +import ( + "context" + + "knative.dev/pkg/apis" +) + +// This files contains the versionless types and enums that are strongly +// unlikely to change from version to version. + +// ProtocolType is an enumeration of the supported application-layer protocols +// See also: https://github.com/knative/serving/blob/master/docs/runtime-contract.md#protocols-and-ports +type ProtocolType string + +const ( + // ProtocolHTTP1 maps to HTTP/1.1. + ProtocolHTTP1 ProtocolType = "http1" + // ProtocolH2C maps to HTTP/2 with Prior Knowledge. + ProtocolH2C ProtocolType = "h2c" +) + +// Validate validates that ProtocolType has a correct enum value. +func (p ProtocolType) Validate(context.Context) *apis.FieldError { + switch p { + case ProtocolH2C, ProtocolHTTP1: + return nil + case ProtocolType(""): + return apis.ErrMissingField(apis.CurrentField) + } + return apis.ErrInvalidValue(p, apis.CurrentField) +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/ports.go b/vendor/knative.dev/serving/pkg/apis/networking/ports.go new file mode 100644 index 00000000000..c8f19bb20be --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/ports.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 networking + +// The ports we setup on our services. +const ( + // ServiceHTTPPort is the port that we setup our Serving and Activator K8s services for + // HTTP/1 endpoints. + ServiceHTTPPort = 80 + + // ServiceHTTP2Port is the port that we setup our Serving and Activator K8s services for + // HTTP/2 endpoints. + ServiceHTTP2Port = 81 + + // BackendHTTPPort is the backend, i.e. `targetPort` that we setup for HTTP services. + BackendHTTPPort = 8012 + + // BackendHTTP2Port is the backend, i.e. `targetPort` that we setup for HTTP services. + BackendHTTP2Port = 8013 + + // QueueAdminPort specifies the port number for + // health check and lifecycle hooks for queue-proxy. + QueueAdminPort = 8022 + + // AutoscalingQueueMetricsPort specifies the port number for metrics emitted + // by queue-proxy for autoscaler. + AutoscalingQueueMetricsPort = 9090 + + // UserQueueMetricsPort specifies the port number for metrics emitted + // by queue-proxy for end user. + UserQueueMetricsPort = 9091 + + // ServicePortNameHTTP1 is the name of the external port of the service for HTTP/1.1 + ServicePortNameHTTP1 = "http" + + // ServicePortNameH2C is the name of the external port of the service for HTTP/2 + ServicePortNameH2C = "http2" +) + +// ServicePortName returns the port for the app level protocol. +func ServicePortName(proto ProtocolType) string { + if proto == ProtocolH2C { + return ServicePortNameH2C + } + return ServicePortNameHTTP1 +} + +// ServicePort chooses the service (load balancer) port for the public service. +func ServicePort(proto ProtocolType) int { + if proto == ProtocolH2C { + return ServiceHTTP2Port + } + return ServiceHTTPPort +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/register.go b/vendor/knative.dev/serving/pkg/apis/networking/register.go new file mode 100644 index 00000000000..4ab10998a0a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/register.go @@ -0,0 +1,111 @@ +/* +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 networking + +const ( + // GroupName is the name for the networking API group. + GroupName = "networking.internal.knative.dev" + + // IngressClassAnnotationKey is the annotation for the + // explicit class of Ingress that a particular resource has + // opted into. For example, + // + // networking.knative.dev/ingress.class: some-network-impl + // + // This uses a different domain because unlike the resource, it is + // user-facing. + // + // The parent resource may use its own annotations to choose the + // annotation value for the Ingress it uses. Based on such + // value a different reconciliation logic may be used (for examples, + // Istio-based Ingress will reconcile into a VirtualService). + IngressClassAnnotationKey = "networking.knative.dev/ingress.class" + + // IngressLabelKey is the label key attached to underlying network programming + // resources to indicate which Ingress triggered their creation. + IngressLabelKey = GroupName + "/ingress" + + // SKSLabelKey is the label key that SKS Controller attaches to the + // underlying resources it controls. + SKSLabelKey = GroupName + "/serverlessservice" + + // ServiceTypeKey is the label key attached to a service specifying the type of service. + // e.g. Public, Metrics + ServiceTypeKey = GroupName + "/serviceType" + + // OriginSecretNameLabelKey is the label key attached to the TLS secret to indicate + // the name of the origin secret that the TLS secret is copied from. + OriginSecretNameLabelKey = GroupName + "/originSecretName" + + // OriginSecretNamespaceLabelKey is the label key attached to the TLS secret + // to indicate the namespace of the origin secret that the TLS secret is copied from. + OriginSecretNamespaceLabelKey = GroupName + "/originSecretNamespace" + + // CertificateClassAnnotationKey is the annotation for the + // explicit class of Certificate that a particular resource has + // opted into. For example, + // + // networking.internal.knative.dev/certificate.class: some-network-impl + // + // This uses a different domain because unlike the resource, it is + // user-facing. + // + // The parent resource may use its own annotations to choose the + // annotation value for the Certificate it uses. Based on such + // value a different reconciliation logic may be used (for examples, + // Cert-Manager-based Certificate will reconcile into a Cert-Manager Certificate). + CertificateClassAnnotationKey = GroupName + "/certificate.class" + + // ActivatorServiceName is the name of the activator Kubernetes service. + ActivatorServiceName = "activator-service" + + // DisableWildcardCertLabelKey is the label key attached to a namespace to indicate that + // a wildcard certificate should be not created for it. + DisableWildcardCertLabelKey = GroupName + "/disableWildcardCert" + + // WildcardCertDomainLabelKey is the label key attached to a certificate to indicate the + // domain for which it was issued. + WildcardCertDomainLabelKey = "networking.knative.dev/wildcardDomain" + + // KnativeIngressGateway is the name of the ingress gateway + KnativeIngressGateway = "knative-ingress-gateway" + // ClusterLocalGateway is the name of the local gateway + ClusterLocalGateway = "cluster-local-gateway" +) + +// ServiceType is the enumeration type for the Kubernetes services +// that we have in our system, classified by usage purpose. +type ServiceType string + +const ( + // ServiceTypePrivate is the label value for internal only services + // for user applications. + ServiceTypePrivate ServiceType = "Private" + // ServiceTypePublic is the label value for externally reachable + // services for user applications. + ServiceTypePublic ServiceType = "Public" + // ServiceTypeMetrics is the label value for Metrics services. Such services + // are used for meric scraping. + // TODO(5900): Remove after 0.12 is cut. + ServiceTypeMetrics ServiceType = "Metrics" +) + +// Pseudo-constants +var ( + // DefaultRetryCount will be set if Attempts not specified. + DefaultRetryCount = 3 +) diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_defaults.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_defaults.go new file mode 100644 index 00000000000..c270d818873 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_defaults.go @@ -0,0 +1,24 @@ +/* +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 sets the default values for Certificate. +// Currently it is required that all of the fields of Certificate are +// provisioned by the client. Therefore, SetDefaults does nothing right now. +func (c *Certificate) SetDefaults(context.Context) {} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go new file mode 100644 index 00000000000..38b77a9615e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_lifecycle.go @@ -0,0 +1,80 @@ +/* +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 ( + "fmt" + + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +// InitializeConditions initializes the certificate conditions. +func (cs *CertificateStatus) InitializeConditions() { + certificateCondSet.Manage(cs).InitializeConditions() +} + +// MarkReady marks the certificate as ready to use. +func (cs *CertificateStatus) MarkReady() { + certificateCondSet.Manage(cs).MarkTrue(CertificateConditionReady) +} + +// MarkNotReady marks the certificate status as unknown. +func (cs *CertificateStatus) MarkNotReady(reason, message string) { + certificateCondSet.Manage(cs).MarkUnknown(CertificateConditionReady, reason, message) +} + +// MarkFailed marks the certificate as not ready. +func (cs *CertificateStatus) MarkFailed(reason, message string) { + certificateCondSet.Manage(cs).MarkFalse(CertificateConditionReady, reason, message) +} + +// MarkResourceNotOwned changes the ready condition to false to reflect that we don't own the +// resource of the given kind and name. +func (cs *CertificateStatus) MarkResourceNotOwned(kind, name string) { + certificateCondSet.Manage(cs).MarkFalse(CertificateConditionReady, "NotOwned", + fmt.Sprintf("There is an existing %s %q that we do not own.", kind, name)) +} + +// IsReady returns true is the Certificate is ready. +func (cs *CertificateStatus) IsReady() bool { + return certificateCondSet.Manage(cs).IsHappy() +} + +// GetCondition gets a speicifc condition of the Certificate status. +func (cs *CertificateStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return certificateCondSet.Manage(cs).GetCondition(t) +} + +// ConditionType represents a Certificate condition value +const ( + // CertificateConditionReady is set when the requested certificate + // is provisioned and valid. + CertificateConditionReady = apis.ConditionReady +) + +var certificateCondSet = apis.NewLivingConditionSet(CertificateConditionReady) + +// GetGroupVersionKind returns the GroupVersionKind of Certificate. +func (c *Certificate) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Certificate") +} + +func (cs *CertificateStatus) duck() *duckv1.Status { + return &cs.Status +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_types.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_types.go new file mode 100644 index 00000000000..9bf98cce46f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_types.go @@ -0,0 +1,117 @@ +/* +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/util/intstr" + "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 + +// Certificate is responsible for provisioning a SSL certificate for the +// given hosts. It is a Knative abstraction for various SSL certificate +// provisioning solutions (such as cert-manager or self-signed SSL certificate). +type Certificate struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec is the desired state of the Certificate. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + // +optional + Spec CertificateSpec `json:"spec,omitempty"` + + // Status is the current state of the Certificate. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + // +optional + Status CertificateStatus `json:"status,omitempty"` +} + +// Verify that Certificate adheres to the appropriate interfaces. +var ( + // Check that Certificate may be validated and defaulted. + _ apis.Validatable = (*Certificate)(nil) + _ apis.Defaultable = (*Certificate)(nil) + + // Check that we can create OwnerReferences to a Certificate.. + _ kmeta.OwnerRefable = (*Certificate)(nil) +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CertificateList is a collection of `Certificate`. +type CertificateList struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // Items is the list of `Certificate`. + Items []Certificate `json:"items"` +} + +// CertificateSpec defines the desired state of a `Certificate`. +type CertificateSpec struct { + // DNSNames is a list of DNS names the Certificate could support. + // The wildcard format of DNSNames (e.g. *.default.example.com) is supported. + DNSNames []string `json:"dnsNames"` + + // SecretName is the name of the secret resource to store the SSL certificate in. + SecretName string `json:"secretName"` +} + +// CertificateStatus defines the observed state of a `Certificate`. +type CertificateStatus struct { + // When Certificate status is ready, it means: + // - The target secret exists + // - The target secret contains a certificate that has not expired + // - The target secret contains a private key valid for the certificate + duckv1.Status `json:",inline"` + + // The expiration time of the TLS certificate stored in the secret named + // by this resource in spec.secretName. + // +optional + NotAfter *metav1.Time `json:"notAfter,omitempty"` + + // HTTP01Challenges is a list of HTTP01 challenges that need to be fulfilled + // in order to get the TLS certificate.. + HTTP01Challenges []HTTP01Challenge `json:"http01Challenges,omitempty"` +} + +// HTTP01Challenge defines the status of a HTTP01 challenge that a certificate needs +// to fulfill. +type HTTP01Challenge struct { + // URL is the URL that the HTTP01 challenge is expected to serve on. + URL *apis.URL `json:"url,omitempty"` + + // ServiceName is the name of the service to serve HTTP01 challenge requests. + ServiceName string `json:"serviceName,omitempty"` + + // ServiceNamespace is the namespace of the service to serve HTTP01 challenge requests. + ServiceNamespace string `json:"serviceNamespace,omitempty"` + + // ServicePort is the port of the service to serve HTTP01 challenge requests. + ServicePort intstr.IntOrString `json:"servicePort,omitempty"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_validation.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_validation.go new file mode 100644 index 00000000000..e529bc169a0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/certificate_validation.go @@ -0,0 +1,49 @@ +/* +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 inspects and validates Certificate object. +func (c *Certificate) Validate(ctx context.Context) *apis.FieldError { + return c.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") +} + +// Validate inspects and validates CertificateSpec object. +func (spec *CertificateSpec) Validate(ctx context.Context) *apis.FieldError { + var all *apis.FieldError + // Spec must have at least one DNS Name. + if len(spec.DNSNames) == 0 { + all = all.Also(apis.ErrMissingField("dnsNames")) + } else { + for index, dnsName := range spec.DNSNames { + if len(dnsName) == 0 { + all = all.Also(apis.ErrInvalidArrayValue("", "dnsNames", index)) + } + } + } + + // Spec must have secretName. + if len(spec.SecretName) == 0 { + all = all.Also(apis.ErrMissingField("secretName")) + } + return all +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/doc.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/doc.go new file mode 100644 index 00000000000..2663a50e6a2 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/doc.go @@ -0,0 +1,24 @@ +/* +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 +// +groupName=networking.internal.knative.dev +package v1alpha1 + +// Ingress is heavily based on K8s Ingress +// https://godoc.org/k8s.io/api/networking/v1beta1#Ingress with some +// highlighted modifications. See ingress_types.go for more +// information about the modifications that we made. diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_defaults.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_defaults.go new file mode 100644 index 00000000000..b0a724991d6 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_defaults.go @@ -0,0 +1,94 @@ +/* +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" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + + "knative.dev/serving/pkg/apis/config" + "knative.dev/serving/pkg/apis/networking" +) + +var ( + defaultMaxRevisionTimeout = time.Duration(config.DefaultMaxRevisionTimeoutSeconds) * time.Second +) + +// SetDefaults populates default values in Ingress +func (i *Ingress) SetDefaults(ctx context.Context) { + i.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults populates default values in IngressSpec +func (s *IngressSpec) SetDefaults(ctx context.Context) { + for i := range s.TLS { + s.TLS[i].SetDefaults(ctx) + } + for i := range s.Rules { + s.Rules[i].SetDefaults(ctx) + } + if s.Visibility == "" { + s.Visibility = IngressVisibilityExternalIP + } +} + +// SetDefaults populates default values in IngressTLS +func (t *IngressTLS) SetDefaults(ctx context.Context) { + // Deprecated, do not use. + t.DeprecatedServerCertificate = "" + t.DeprecatedPrivateKey = "" +} + +// SetDefaults populates default values in IngressRule +func (r *IngressRule) SetDefaults(ctx context.Context) { + r.HTTP.SetDefaults(ctx) +} + +// SetDefaults populates default values in HTTPIngressRuleValue +func (r *HTTPIngressRuleValue) SetDefaults(ctx context.Context) { + for i := range r.Paths { + r.Paths[i].SetDefaults(ctx) + } +} + +// SetDefaults populates default values in HTTPIngressPath +func (p *HTTPIngressPath) SetDefaults(ctx context.Context) { + // If only one split is specified, we default to 100. + if len(p.Splits) == 1 && p.Splits[0].Percent == 0 { + p.Splits[0].Percent = 100 + } + + cfg := config.FromContextOrDefaults(ctx) + maxTimeout := time.Duration(cfg.Defaults.MaxRevisionTimeoutSeconds) * time.Second + + if p.Timeout == nil { + p.Timeout = &metav1.Duration{Duration: maxTimeout} + } + + if p.Retries == nil { + p.Retries = &HTTPRetry{ + PerTryTimeout: &metav1.Duration{Duration: maxTimeout}, + Attempts: networking.DefaultRetryCount, + } + } + if p.Retries.PerTryTimeout == nil { + p.Retries.PerTryTimeout = &metav1.Duration{Duration: maxTimeout} + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go new file mode 100644 index 00000000000..c6fd1b9e28d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_lifecycle.go @@ -0,0 +1,99 @@ +/* +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 ( + "fmt" + + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +var ingressCondSet = apis.NewLivingConditionSet( + IngressConditionNetworkConfigured, + IngressConditionLoadBalancerReady, +) + +// GetGroupVersionKind returns SchemeGroupVersion of an Ingress +func (i *Ingress) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Ingress") +} + +// IsPublic returns whether the Ingress should be exposed publicly. +func (i *Ingress) IsPublic() bool { + return i.Spec.Visibility == "" || i.Spec.Visibility == IngressVisibilityExternalIP +} + +// GetCondition returns the current condition of a given condition type +func (is *IngressStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return ingressCondSet.Manage(is).GetCondition(t) +} + +// InitializeConditions initializes conditions of an IngressStatus +func (is *IngressStatus) InitializeConditions() { + ingressCondSet.Manage(is).InitializeConditions() +} + +// MarkNetworkConfigured set IngressConditionNetworkConfigured in IngressStatus as true +func (is *IngressStatus) MarkNetworkConfigured() { + ingressCondSet.Manage(is).MarkTrue(IngressConditionNetworkConfigured) +} + +// MarkResourceNotOwned changes the "NetworkConfigured" condition to false to reflect that the +// resource of the given kind and name has already been created, and we do not own it. +func (is *IngressStatus) MarkResourceNotOwned(kind, name string) { + ingressCondSet.Manage(is).MarkFalse(IngressConditionNetworkConfigured, "NotOwned", + fmt.Sprintf("There is an existing %s %q that we do not own.", kind, name)) +} + +// MarkLoadBalancerReady marks the Ingress with IngressConditionLoadBalancerReady, +// and also populate the address of the load balancer. +func (is *IngressStatus) MarkLoadBalancerReady(lbs []LoadBalancerIngressStatus, publicLbs []LoadBalancerIngressStatus, privateLbs []LoadBalancerIngressStatus) { + is.LoadBalancer = &LoadBalancerStatus{Ingress: lbs} + is.PublicLoadBalancer = &LoadBalancerStatus{Ingress: publicLbs} + is.PrivateLoadBalancer = &LoadBalancerStatus{Ingress: privateLbs} + + ingressCondSet.Manage(is).MarkTrue(IngressConditionLoadBalancerReady) +} + +// MarkLoadBalancerNotReady marks the "IngressConditionLoadBalancerReady" condition to unknown to +// reflect that the load balancer is not ready yet. +func (is *IngressStatus) MarkLoadBalancerNotReady() { + ingressCondSet.Manage(is).MarkUnknown(IngressConditionLoadBalancerReady, "Uninitialized", + "Waiting for load balancer to be ready") +} + +// MarkLoadBalancerFailed marks the "IngressConditionLoadBalancerReady" condition to false. +func (is *IngressStatus) MarkLoadBalancerFailed(reason, message string) { + ingressCondSet.Manage(is).MarkFalse(IngressConditionLoadBalancerReady, reason, message) +} + +// MarkIngressNotReady marks the "IngressConditionReady" condition to unknown. +func (is *IngressStatus) MarkIngressNotReady(reason, message string) { + ingressCondSet.Manage(is).MarkUnknown(IngressConditionReady, reason, message) +} + +// IsReady looks at the conditions and if the Status has a condition +// IngressConditionReady returns true if ConditionStatus is True +func (is *IngressStatus) IsReady() bool { + return ingressCondSet.Manage(is).IsHappy() +} + +func (is *IngressStatus) duck() *duckv1.Status { + return &is.Status +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go new file mode 100644 index 00000000000..f779bef9ef8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_types.go @@ -0,0 +1,343 @@ +/* +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/util/intstr" + "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 + +// Ingress is a collection of rules that allow inbound connections to reach the endpoints defined +// by a backend. An Ingress can be configured to give services externally-reachable URLs, load +// balance traffic, offer name based virtual hosting, etc. +// +// This is heavily based on K8s Ingress https://godoc.org/k8s.io/api/networking/v1beta1#Ingress +// which some highlighted modifications. +type Ingress struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec is the desired state of the Ingress. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status + // +optional + Spec IngressSpec `json:"spec,omitempty"` + + // Status is the current state of the Ingress. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status + // +optional + Status IngressStatus `json:"status,omitempty"` +} + +// Verify that Ingress adheres to the appropriate interfaces. +var ( + // Check that Ingress may be validated and defaulted. + _ apis.Validatable = (*Ingress)(nil) + _ apis.Defaultable = (*Ingress)(nil) + + // Check that we can create OwnerReferences to a Ingress. + _ kmeta.OwnerRefable = (*Ingress)(nil) +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// IngressList is a collection of Ingress objects. +type IngressList struct { + metav1.TypeMeta `json:",inline"` + // Standard object metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // Items is the list of Ingress objects. + Items []Ingress `json:"items"` +} + +// IngressSpec describes the Ingress the user wishes to exist. +// +// In general this follows the same shape as K8s Ingress. +// Some notable differences: +// - Backends now can have namespace: +// - Traffic can be split across multiple backends. +// - Timeout & Retry can be configured. +// - Headers can be appended. +type IngressSpec struct { + // DeprecatedGeneration was used prior in Kubernetes versions <1.11 + // when metadata.generation was not being incremented by the api server + // + // This property will be dropped in future Knative releases and should + // not be used - use metadata.generation + // + // Tracking issue: https://github.com/knative/serving/issues/643 + // + // +optional + DeprecatedGeneration int64 `json:"generation,omitempty"` + + // TLS configuration. Currently Ingress only supports a single TLS + // port: 443. If multiple members of this list specify different hosts, they + // will be multiplexed on the same port according to the hostname specified + // through the SNI TLS extension, if the ingress controller fulfilling the + // ingress supports SNI. + // +optional + TLS []IngressTLS `json:"tls,omitempty"` + + // A list of host rules used to configure the Ingress. + // +optional + Rules []IngressRule `json:"rules,omitempty"` + + // Visibility setting. + Visibility IngressVisibility `json:"visibility,omitempty"` +} + +// IngressVisibility describes whether the Ingress should be exposed to +// public gateways or not. +type IngressVisibility string + +const ( + // IngressVisibilityExternalIP is used to denote that the Ingress + // should be exposed via an external IP, for example a LoadBalancer + // Service. This is the default value for IngressVisibility. + IngressVisibilityExternalIP IngressVisibility = "ExternalIP" + // IngressVisibilityClusterLocal is used to denote that the Ingress + // should be only be exposed locally to the cluster. + IngressVisibilityClusterLocal IngressVisibility = "ClusterLocal" +) + +// IngressTLS describes the transport layer security associated with an Ingress. +type IngressTLS struct { + // Hosts is a list of hosts included in the TLS certificate. The values in + // this list must match the name/s used in the tlsSecret. Defaults to the + // wildcard host setting for the loadbalancer controller fulfilling this + // Ingress, if left unspecified. + // +optional + Hosts []string `json:"hosts,omitempty"` + + // SecretName is the name of the secret used to terminate SSL traffic. + SecretName string `json:"secretName,omitempty"` + + // SecretNamespace is the namespace of the secret used to terminate SSL traffic. + SecretNamespace string `json:"secretNamespace,omitempty"` + + // ServerCertificate identifies the certificate filename in the secret. + // Defaults to `tls.crt`. + // +optional + DeprecatedServerCertificate string `json:"serverCertificate,omitempty"` + + // PrivateKey identifies the private key filename in the secret. + // Defaults to `tls.key`. + // +optional + DeprecatedPrivateKey string `json:"privateKey,omitempty"` +} + +// IngressRule represents the rules mapping the paths under a specified host to +// the related backend services. Incoming requests are first evaluated for a host +// match, then routed to the backend associated with the matching IngressRuleValue. +type IngressRule struct { + // Host is the fully qualified domain name of a network host, as defined + // by RFC 3986. Note the following deviations from the "host" part of the + // URI as defined in the RFC: + // 1. IPs are not allowed. Currently a rule value can only apply to the + // IP in the Spec of the parent . + // 2. The `:` delimiter is not respected because ports are not allowed. + // Currently the port of an Ingress is implicitly :80 for http and + // :443 for https. + // Both these may change in the future. + // If the host is unspecified, the Ingress routes all traffic based on the + // specified IngressRuleValue. + // If multiple matching Hosts were provided, the first rule will take precedent. + // +optional + Hosts []string `json:"hosts,omitempty"` + + // Visibility signifies whether this rule should `ClusterLocal`. If it's not + // specified then it defaults to `ExternalIP`. + // +optional + Visibility IngressVisibility `json:"visibility,omitempty"` + + // HTTP represents a rule to apply against incoming requests. If the + // rule is satisfied, the request is routed to the specified backend. + HTTP *HTTPIngressRuleValue `json:"http,omitempty"` +} + +// HTTPIngressRuleValue is a list of http selectors pointing to backends. +// In the example: http:///? -> backend where +// where parts of the url correspond to RFC 3986, this resource will be used +// to match against everything after the last '/' and before the first '?' +// or '#'. +type HTTPIngressRuleValue struct { + // A collection of paths that map requests to backends. + // + // If they are multiple matching paths, the first match takes precendent. + Paths []HTTPIngressPath `json:"paths"` + + // TODO: Consider adding fields for ingress-type specific global + // options usable by a loadbalancer, like http keep-alive. +} + +// HTTPIngressPath associates a path regex with a backend. Incoming URLs matching +// the path are forwarded to the backend. +type HTTPIngressPath struct { + // Path is an extended POSIX regex as defined by IEEE Std 1003.1, + // (i.e this follows the egrep/unix syntax, not the perl syntax) + // matched against the path of an incoming request. Currently it can + // contain characters disallowed from the conventional "path" + // part of a URL as defined by RFC 3986. Paths must begin with + // a '/'. If unspecified, the path defaults to a catch all sending + // traffic to the backend. + // +optional + Path string `json:"path,omitempty"` + + // Splits defines the referenced service endpoints to which the traffic + // will be forwarded to. + Splits []IngressBackendSplit `json:"splits"` + + // AppendHeaders allow specifying additional HTTP headers to add + // before forwarding a request to the destination service. + // + // NOTE: This differs from K8s Ingress which doesn't allow header appending. + // +optional + AppendHeaders map[string]string `json:"appendHeaders,omitempty"` + + // Timeout for HTTP requests. + // + // NOTE: This differs from K8s Ingress which doesn't allow setting timeouts. + // +optional + Timeout *metav1.Duration `json:"timeout,omitempty"` + + // Retry policy for HTTP requests. + // + // NOTE: This differs from K8s Ingress which doesn't allow retry settings. + // +optional + Retries *HTTPRetry `json:"retries,omitempty"` +} + +// IngressBackendSplit describes all endpoints for a given service and port. +type IngressBackendSplit struct { + // Specifies the backend receiving the traffic split. + IngressBackend `json:",inline"` + + // Specifies the split percentage, a number between 0 and 100. If + // only one split is specified, we default to 100. + // + // NOTE: This differs from K8s Ingress to allow percentage split. + Percent int `json:"percent,omitempty"` + + // AppendHeaders allow specifying additional HTTP headers to add + // before forwarding a request to the destination service. + // + // NOTE: This differs from K8s Ingress which doesn't allow header appending. + // +optional + AppendHeaders map[string]string `json:"appendHeaders,omitempty"` +} + +// IngressBackend describes all endpoints for a given service and port. +type IngressBackend struct { + // Specifies the namespace of the referenced service. + // + // NOTE: This differs from K8s Ingress to allow routing to different namespaces. + ServiceNamespace string `json:"serviceNamespace"` + + // Specifies the name of the referenced service. + ServiceName string `json:"serviceName"` + + // Specifies the port of the referenced service. + ServicePort intstr.IntOrString `json:"servicePort"` +} + +// HTTPRetry describes the retry policy to use when a HTTP request fails. +type HTTPRetry struct { + // Number of retries for a given request. + Attempts int `json:"attempts"` + + // Timeout per retry attempt for a given request. format: 1h/1m/1s/1ms. MUST BE >=1ms. + PerTryTimeout *metav1.Duration `json:"perTryTimeout"` +} + +// IngressStatus describe the current state of the Ingress. +type IngressStatus struct { + duckv1.Status `json:",inline"` + + // LoadBalancer contains the current status of the load-balancer. + // This is to be superseded by the combination of `PublicLoadBalancer` and `PrivateLoadBalancer` + // +optional + LoadBalancer *LoadBalancerStatus `json:"loadBalancer,omitempty"` + + // PublicLoadBalancer contains the current status of the load-balancer. + // +optional + PublicLoadBalancer *LoadBalancerStatus `json:"publicLoadBalancer,omitempty"` + + // PrivateLoadBalancer contains the current status of the load-balancer. + // +optional + PrivateLoadBalancer *LoadBalancerStatus `json:"privateLoadBalancer,omitempty"` +} + +// LoadBalancerStatus represents the status of a load-balancer. +type LoadBalancerStatus struct { + // Ingress is a list containing ingress points for the load-balancer. + // Traffic intended for the service should be sent to these ingress points. + // +optional + Ingress []LoadBalancerIngressStatus `json:"ingress,omitempty"` +} + +// LoadBalancerIngressStatus represents the status of a load-balancer ingress point: +// traffic intended for the service should be sent to an ingress point. +type LoadBalancerIngressStatus struct { + // IP is set for load-balancer ingress points that are IP based + // (typically GCE or OpenStack load-balancers) + // +optional + IP string `json:"ip,omitempty"` + + // Domain is set for load-balancer ingress points that are DNS based + // (typically AWS load-balancers) + // +optional + Domain string `json:"domain,omitempty"` + + // DomainInternal is set if there is a cluster-local DNS name to access the Ingress. + // + // NOTE: This differs from K8s Ingress, since we also desire to have a cluster-local + // DNS name to allow routing in case of not having a mesh. + // + // +optional + DomainInternal string `json:"domainInternal,omitempty"` + + // MeshOnly is set if the Ingress is only load-balanced through a Service mesh. + // +optional + MeshOnly bool `json:"meshOnly,omitempty"` +} + +// ConditionType represents a Ingress condition value +const ( + // IngressConditionReady is set when the Ingress networking setting is + // configured and it has a load balancer address. + IngressConditionReady = apis.ConditionReady + + // IngressConditionNetworkConfigured is set when the Ingress's underlying + // network programming has been configured. This doesn't include conditions of the + // backends, so even if this should remain true when network is configured and backends + // are not ready. + IngressConditionNetworkConfigured apis.ConditionType = "NetworkConfigured" + + // IngressConditionLoadBalancerReady is set when the Ingress has a ready LoadBalancer. + IngressConditionLoadBalancerReady apis.ConditionType = "LoadBalancerReady" +) diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_validation.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_validation.go new file mode 100644 index 00000000000..dfad48ad215 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/ingress_validation.go @@ -0,0 +1,174 @@ +/* +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" + "strconv" + + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/util/intstr" + "knative.dev/pkg/apis" +) + +// Validate inspects and validates Ingress object. +func (i *Ingress) Validate(ctx context.Context) *apis.FieldError { + return i.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") +} + +// Validate inspects and validates IngressSpec object. +func (spec *IngressSpec) Validate(ctx context.Context) *apis.FieldError { + // Spec must not be empty. + if equality.Semantic.DeepEqual(spec, &IngressSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + // Spec must have at least one rule. + if len(spec.Rules) == 0 { + all = all.Also(apis.ErrMissingField("rules")) + } + // Validate each rule. + for idx, rule := range spec.Rules { + all = all.Also(rule.Validate(ctx).ViaFieldIndex("rules", idx)) + } + // TLS settings are optional. However, all provided settings should be valid. + for idx, tls := range spec.TLS { + all = all.Also(tls.Validate(ctx).ViaFieldIndex("tls", idx)) + } + return all +} + +// Validate inspects and validates IngressRule object. +func (r *IngressRule) Validate(ctx context.Context) *apis.FieldError { + // Provided rule must not be empty. + if equality.Semantic.DeepEqual(r, &IngressRule{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + if r.HTTP == nil { + all = all.Also(apis.ErrMissingField("http")) + } else { + all = all.Also(r.HTTP.Validate(ctx).ViaField("http")) + } + return all +} + +// Validate inspects and validates HTTPIngressRuleValue object. +func (h *HTTPIngressRuleValue) Validate(ctx context.Context) *apis.FieldError { + if len(h.Paths) == 0 { + return apis.ErrMissingField("paths") + } + var all *apis.FieldError + for idx, path := range h.Paths { + all = all.Also(path.Validate(ctx).ViaFieldIndex("paths", idx)) + } + return all +} + +// Validate inspects and validates HTTPIngressPath object. +func (h HTTPIngressPath) Validate(ctx context.Context) *apis.FieldError { + // Provided rule must not be empty. + if equality.Semantic.DeepEqual(h, HTTPIngressPath{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + // Must provide as least one split. + if len(h.Splits) == 0 { + all = all.Also(apis.ErrMissingField("splits")) + } else { + totalPct := 0 + for idx, split := range h.Splits { + if err := split.Validate(ctx); err != nil { + return err.ViaFieldIndex("splits", idx) + } + totalPct += split.Percent + } + // If a single split is provided we allow missing Percent, and + // interpret as 100%. + if (len(h.Splits) != 1 || totalPct != 0) && totalPct != 100 { + // Total traffic split percentage must sum up to 100%. + all = all.Also(&apis.FieldError{ + Message: "Traffic split percentage must total to 100, but was " + strconv.Itoa(totalPct), + Paths: []string{"splits"}, + }) + } + } + if h.Retries != nil { + all = all.Also(h.Retries.Validate(ctx).ViaField("retries")) + } + return all +} + +// Validate inspects and validates HTTPIngressPath object. +func (s IngressBackendSplit) Validate(ctx context.Context) *apis.FieldError { + // Must not be empty. + if equality.Semantic.DeepEqual(s, IngressBackendSplit{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + // Percent must be between 0 and 100. + if s.Percent < 0 || s.Percent > 100 { + all = all.Also(apis.ErrInvalidValue(s.Percent, "percent")) + } + return all.Also(s.IngressBackend.Validate(ctx)) +} + +// Validate inspects the fields of the type IngressBackend +// to determine if they are valid. +func (b IngressBackend) Validate(ctx context.Context) *apis.FieldError { + // Must not be empty. + if equality.Semantic.DeepEqual(b, IngressBackend{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + if b.ServiceNamespace == "" { + all = all.Also(apis.ErrMissingField("serviceNamespace")) + } + if b.ServiceName == "" { + all = all.Also(apis.ErrMissingField("serviceName")) + } + if equality.Semantic.DeepEqual(b.ServicePort, intstr.IntOrString{}) { + all = all.Also(apis.ErrMissingField("servicePort")) + } + return all +} + +// Validate inspects and validates HTTPRetry object. +func (r *HTTPRetry) Validate(ctx context.Context) *apis.FieldError { + // Attempts must be greater than 0. + if r.Attempts < 0 { + return apis.ErrInvalidValue(r.Attempts, "attempts") + } + return nil +} + +// Validate inspects and validates IngressTLS object. +func (t *IngressTLS) Validate(ctx context.Context) *apis.FieldError { + // Provided TLS setting must not be empty. + if equality.Semantic.DeepEqual(t, &IngressTLS{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + // SecretName and SecretNamespace must not be empty. + if t.SecretName == "" { + all = all.Also(apis.ErrMissingField("secretName")) + } + if t.SecretNamespace == "" { + all = all.Also(apis.ErrMissingField("secretNamespace")) + } + return all +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/register.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/register.go new file mode 100644 index 00000000000..6aa855801dd --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/register.go @@ -0,0 +1,56 @@ +/* +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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/serving/pkg/apis/networking" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: networking.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 { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Ingress{}, + &IngressList{}, + &ServerlessService{}, + &ServerlessServiceList{}, + &Certificate{}, + &CertificateList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_defaults.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_defaults.go new file mode 100644 index 00000000000..a92f091ed21 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_defaults.go @@ -0,0 +1,29 @@ +/* +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 sets default values on the ServerlessServiceSpec. +func (c *ServerlessService) SetDefaults(ctx context.Context) { + c.Spec.SetDefaults(ctx) +} + +// SetDefaults sets default values on the ServerlessServiceSpec. +func (c *ServerlessServiceSpec) SetDefaults(ctx context.Context) { + // Nothing is defaultable so far. +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go new file mode 100644 index 00000000000..e8ad84fdc5f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_lifecycle.go @@ -0,0 +1,106 @@ +/* +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 ( + "time" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +var serverlessServiceCondSet = apis.NewLivingConditionSet( + ServerlessServiceConditionEndspointsPopulated, +) + +// GetGroupVersionKind returns the GVK for the ServerlessService. +func (ss *ServerlessService) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("ServerlessService") +} + +// GetCondition returns the value of the condition `t`. +func (sss *ServerlessServiceStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return serverlessServiceCondSet.Manage(sss).GetCondition(t) +} + +// InitializeConditions initializes the conditions. +func (sss *ServerlessServiceStatus) InitializeConditions() { + serverlessServiceCondSet.Manage(sss).InitializeConditions() +} + +// MarkEndpointsReady marks the ServerlessServiceStatus endpoints populated condition to true. +func (sss *ServerlessServiceStatus) MarkEndpointsReady() { + serverlessServiceCondSet.Manage(sss).MarkTrue(ServerlessServiceConditionEndspointsPopulated) +} + +// MarkEndpointsNotOwned marks that we don't own K8s service. +func (sss *ServerlessServiceStatus) MarkEndpointsNotOwned(kind, name string) { + serverlessServiceCondSet.Manage(sss).MarkFalse( + ServerlessServiceConditionEndspointsPopulated, "NotOwned", + "Resource %s of type %s is not owned by SKS", name, kind) +} + +// MarkActivatorEndpointsPopulated is setting the ActivatorEndpointsPopulated to True. +func (sss *ServerlessServiceStatus) MarkActivatorEndpointsPopulated() { + serverlessServiceCondSet.Manage(sss).SetCondition(apis.Condition{ + Type: ActivatorEndpointsPopulated, + Status: corev1.ConditionTrue, + Severity: apis.ConditionSeverityInfo, + Reason: "ActivatorEndpointsPopulated", + Message: "Revision is backed by Activator", + }) +} + +// MarkActivatorEndpointsRemoved is setting the ActivatorEndpointsPopulated to False. +func (sss *ServerlessServiceStatus) MarkActivatorEndpointsRemoved() { + serverlessServiceCondSet.Manage(sss).SetCondition(apis.Condition{ + Type: ActivatorEndpointsPopulated, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityInfo, + Reason: "ActivatorEndpointsPopulated", + Message: "Revision is backed by Activator", + }) +} + +// MarkEndpointsNotReady marks the ServerlessServiceStatus endpoints populated condition to unknown. +func (sss *ServerlessServiceStatus) MarkEndpointsNotReady(reason string) { + serverlessServiceCondSet.Manage(sss).MarkUnknown( + ServerlessServiceConditionEndspointsPopulated, reason, + "K8s Service is not ready") +} + +// IsReady returns true if ServerlessService is ready. +func (sss *ServerlessServiceStatus) IsReady() bool { + return serverlessServiceCondSet.Manage(sss).IsHappy() +} + +func (sss *ServerlessServiceStatus) duck() *duckv1.Status { + return &sss.Status +} + +// ProxyFor returns how long it has been since Activator was moved +// to the request path. +func (sss *ServerlessServiceStatus) ProxyFor() time.Duration { + cond := sss.GetCondition(ActivatorEndpointsPopulated) + if cond == nil || cond.Status != corev1.ConditionTrue { + return 0 + } + return time.Since(cond.LastTransitionTime.Inner.Time) +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_types.go new file mode 100644 index 00000000000..264d942e871 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_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" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" + networking "knative.dev/serving/pkg/apis/networking" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ServerlessService is a proxy for the K8s service objects containing the +// endpoints for the revision, whether those are endpoints of the activator or +// revision pods. +// See: https://knative.page.link/naxz for details. +type ServerlessService struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec is the desired state of the ServerlessService. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status + // +optional + Spec ServerlessServiceSpec `json:"spec,omitempty"` + + // Status is the current state of the ServerlessService. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status + // +optional + Status ServerlessServiceStatus `json:"status,omitempty"` +} + +// Verify that ServerlessService adheres to the appropriate interfaces. +var ( + // Check that ServerlessService may be validated and defaulted. + _ apis.Validatable = (*ServerlessService)(nil) + _ apis.Defaultable = (*ServerlessService)(nil) + + // Check that we can create OwnerReferences to a ServerlessService. + _ kmeta.OwnerRefable = (*ServerlessService)(nil) +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ServerlessServiceList is a collection of ServerlessService. +type ServerlessServiceList struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // Items is the list of ServerlessService. + Items []ServerlessService `json:"items"` +} + +// ServerlessServiceOperationMode is an enumeration of the modes of operation +// for the ServerlessService. +type ServerlessServiceOperationMode string + +const ( + // SKSOperationModeServe is reserved for the state when revision + // pods are serving using traffic. + SKSOperationModeServe ServerlessServiceOperationMode = "Serve" + + // SKSOperationModeProxy is reserved for the state when activator + // pods are serving using traffic. + SKSOperationModeProxy ServerlessServiceOperationMode = "Proxy" +) + +// ServerlessServiceSpec describes the ServerlessService. +type ServerlessServiceSpec struct { + // Mode describes the mode of operation of the ServerlessService. + Mode ServerlessServiceOperationMode `json:"mode,omitempty"` + + // ObjectRef defines the resource that this ServerlessService + // is responsible for making "serverless". + ObjectRef corev1.ObjectReference `json:"objectRef"` + + // The application-layer protocol. Matches `RevisionProtocolType` set on the owning pa/revision. + // serving imports networking, so just use string. + ProtocolType networking.ProtocolType +} + +// ServerlessServiceStatus describes the current state of the ServerlessService. +type ServerlessServiceStatus struct { + duckv1.Status `json:",inline"` + + // ServiceName holds the name of a core K8s Service resource that + // load balances over the pods backing this Revision (activator or revision). + // +optional + ServiceName string `json:"serviceName,omitempty"` + + // PrivateServiceName holds the name of a core K8s Service resource that + // load balances over the user service pods backing this Revision. + // +optional + PrivateServiceName string `json:"privateServiceName,omitempty"` +} + +// ConditionType represents a ServerlessService condition value +const ( + // ServerlessServiceConditionReady is set when the ingress networking setting is + // configured and it has a load balancer address. + ServerlessServiceConditionReady = apis.ConditionReady + + // ServerlessServiceConditionEndspointsPopulated is set when the ServerlessService's underlying + // Revision K8s Service has been populated with endpoints. + ServerlessServiceConditionEndspointsPopulated apis.ConditionType = "EndpointsPopulated" + + // ActivatorEndpointsPopulated is an informational status that reports + // when the revision is backed by activator points. This might happen even if + // revision is active (no pods yet created) or even when it has healthy pods + // (e.g. due to target burst capacity settings). + ActivatorEndpointsPopulated apis.ConditionType = "ActivatorEndpointsPopulated" +) diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go new file mode 100644 index 00000000000..ebace729dcf --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/serverlessservice_validation.go @@ -0,0 +1,52 @@ +/* +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" + + "k8s.io/apimachinery/pkg/api/equality" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +// Validate inspects and validates ClusterServerlessService object. +func (ci *ServerlessService) Validate(ctx context.Context) *apis.FieldError { + return ci.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") +} + +// Validate inspects and validates ServerlessServiceSpec object. +func (spec *ServerlessServiceSpec) Validate(ctx context.Context) *apis.FieldError { + // Spec must not be empty. + if equality.Semantic.DeepEqual(spec, &ServerlessServiceSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + var all *apis.FieldError + // Spec mode must be from the enum and + switch spec.Mode { + case SKSOperationModeProxy, SKSOperationModeServe: + break + case "": + all = all.Also(apis.ErrMissingField("mode")) + default: + all = all.Also(apis.ErrInvalidValue(spec.Mode, "mode")) + } + + all = all.Also(serving.ValidateNamespacedObjectReference(&spec.ObjectRef).ViaField("objectRef")) + + return all.Also(spec.ProtocolType.Validate(ctx).ViaField("protocolType")) +} diff --git a/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..0f4641d8b75 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/networking/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,586 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + apis "knative.dev/pkg/apis" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Certificate) DeepCopyInto(out *Certificate) { + *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 Certificate. +func (in *Certificate) DeepCopy() *Certificate { + if in == nil { + return nil + } + out := new(Certificate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Certificate) 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 *CertificateList) DeepCopyInto(out *CertificateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Certificate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CertificateList. +func (in *CertificateList) DeepCopy() *CertificateList { + if in == nil { + return nil + } + out := new(CertificateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CertificateList) 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 *CertificateSpec) DeepCopyInto(out *CertificateSpec) { + *out = *in + if in.DNSNames != nil { + in, out := &in.DNSNames, &out.DNSNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CertificateSpec. +func (in *CertificateSpec) DeepCopy() *CertificateSpec { + if in == nil { + return nil + } + out := new(CertificateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CertificateStatus) DeepCopyInto(out *CertificateStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.NotAfter != nil { + in, out := &in.NotAfter, &out.NotAfter + *out = (*in).DeepCopy() + } + if in.HTTP01Challenges != nil { + in, out := &in.HTTP01Challenges, &out.HTTP01Challenges + *out = make([]HTTP01Challenge, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CertificateStatus. +func (in *CertificateStatus) DeepCopy() *CertificateStatus { + if in == nil { + return nil + } + out := new(CertificateStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTP01Challenge) DeepCopyInto(out *HTTP01Challenge) { + *out = *in + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + out.ServicePort = in.ServicePort + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTP01Challenge. +func (in *HTTP01Challenge) DeepCopy() *HTTP01Challenge { + if in == nil { + return nil + } + out := new(HTTP01Challenge) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPIngressPath) DeepCopyInto(out *HTTPIngressPath) { + *out = *in + if in.Splits != nil { + in, out := &in.Splits, &out.Splits + *out = make([]IngressBackendSplit, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.AppendHeaders != nil { + in, out := &in.AppendHeaders, &out.AppendHeaders + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Timeout != nil { + in, out := &in.Timeout, &out.Timeout + *out = new(v1.Duration) + **out = **in + } + if in.Retries != nil { + in, out := &in.Retries, &out.Retries + *out = new(HTTPRetry) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPIngressPath. +func (in *HTTPIngressPath) DeepCopy() *HTTPIngressPath { + if in == nil { + return nil + } + out := new(HTTPIngressPath) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPIngressRuleValue) DeepCopyInto(out *HTTPIngressRuleValue) { + *out = *in + if in.Paths != nil { + in, out := &in.Paths, &out.Paths + *out = make([]HTTPIngressPath, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPIngressRuleValue. +func (in *HTTPIngressRuleValue) DeepCopy() *HTTPIngressRuleValue { + if in == nil { + return nil + } + out := new(HTTPIngressRuleValue) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPRetry) DeepCopyInto(out *HTTPRetry) { + *out = *in + if in.PerTryTimeout != nil { + in, out := &in.PerTryTimeout, &out.PerTryTimeout + *out = new(v1.Duration) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPRetry. +func (in *HTTPRetry) DeepCopy() *HTTPRetry { + if in == nil { + return nil + } + out := new(HTTPRetry) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Ingress) DeepCopyInto(out *Ingress) { + *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 Ingress. +func (in *Ingress) DeepCopy() *Ingress { + if in == nil { + return nil + } + out := new(Ingress) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Ingress) 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 *IngressBackend) DeepCopyInto(out *IngressBackend) { + *out = *in + out.ServicePort = in.ServicePort + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressBackend. +func (in *IngressBackend) DeepCopy() *IngressBackend { + if in == nil { + return nil + } + out := new(IngressBackend) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressBackendSplit) DeepCopyInto(out *IngressBackendSplit) { + *out = *in + out.IngressBackend = in.IngressBackend + if in.AppendHeaders != nil { + in, out := &in.AppendHeaders, &out.AppendHeaders + *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 IngressBackendSplit. +func (in *IngressBackendSplit) DeepCopy() *IngressBackendSplit { + if in == nil { + return nil + } + out := new(IngressBackendSplit) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressList) DeepCopyInto(out *IngressList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Ingress, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressList. +func (in *IngressList) DeepCopy() *IngressList { + if in == nil { + return nil + } + out := new(IngressList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IngressList) 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 *IngressRule) DeepCopyInto(out *IngressRule) { + *out = *in + if in.Hosts != nil { + in, out := &in.Hosts, &out.Hosts + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.HTTP != nil { + in, out := &in.HTTP, &out.HTTP + *out = new(HTTPIngressRuleValue) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressRule. +func (in *IngressRule) DeepCopy() *IngressRule { + if in == nil { + return nil + } + out := new(IngressRule) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressSpec) DeepCopyInto(out *IngressSpec) { + *out = *in + if in.TLS != nil { + in, out := &in.TLS, &out.TLS + *out = make([]IngressTLS, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Rules != nil { + in, out := &in.Rules, &out.Rules + *out = make([]IngressRule, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressSpec. +func (in *IngressSpec) DeepCopy() *IngressSpec { + if in == nil { + return nil + } + out := new(IngressSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressStatus) DeepCopyInto(out *IngressStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.LoadBalancer != nil { + in, out := &in.LoadBalancer, &out.LoadBalancer + *out = new(LoadBalancerStatus) + (*in).DeepCopyInto(*out) + } + if in.PublicLoadBalancer != nil { + in, out := &in.PublicLoadBalancer, &out.PublicLoadBalancer + *out = new(LoadBalancerStatus) + (*in).DeepCopyInto(*out) + } + if in.PrivateLoadBalancer != nil { + in, out := &in.PrivateLoadBalancer, &out.PrivateLoadBalancer + *out = new(LoadBalancerStatus) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressStatus. +func (in *IngressStatus) DeepCopy() *IngressStatus { + if in == nil { + return nil + } + out := new(IngressStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IngressTLS) DeepCopyInto(out *IngressTLS) { + *out = *in + if in.Hosts != nil { + in, out := &in.Hosts, &out.Hosts + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressTLS. +func (in *IngressTLS) DeepCopy() *IngressTLS { + if in == nil { + return nil + } + out := new(IngressTLS) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerIngressStatus) DeepCopyInto(out *LoadBalancerIngressStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerIngressStatus. +func (in *LoadBalancerIngressStatus) DeepCopy() *LoadBalancerIngressStatus { + if in == nil { + return nil + } + out := new(LoadBalancerIngressStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LoadBalancerStatus) DeepCopyInto(out *LoadBalancerStatus) { + *out = *in + if in.Ingress != nil { + in, out := &in.Ingress, &out.Ingress + *out = make([]LoadBalancerIngressStatus, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LoadBalancerStatus. +func (in *LoadBalancerStatus) DeepCopy() *LoadBalancerStatus { + if in == nil { + return nil + } + out := new(LoadBalancerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServerlessService) DeepCopyInto(out *ServerlessService) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerlessService. +func (in *ServerlessService) DeepCopy() *ServerlessService { + if in == nil { + return nil + } + out := new(ServerlessService) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServerlessService) 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 *ServerlessServiceList) DeepCopyInto(out *ServerlessServiceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ServerlessService, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerlessServiceList. +func (in *ServerlessServiceList) DeepCopy() *ServerlessServiceList { + if in == nil { + return nil + } + out := new(ServerlessServiceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServerlessServiceList) 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 *ServerlessServiceSpec) DeepCopyInto(out *ServerlessServiceSpec) { + *out = *in + out.ObjectRef = in.ObjectRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerlessServiceSpec. +func (in *ServerlessServiceSpec) DeepCopy() *ServerlessServiceSpec { + if in == nil { + return nil + } + out := new(ServerlessServiceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServerlessServiceStatus) DeepCopyInto(out *ServerlessServiceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServerlessServiceStatus. +func (in *ServerlessServiceStatus) DeepCopy() *ServerlessServiceStatus { + if in == nil { + return nil + } + out := new(ServerlessServiceStatus) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/fieldmask.go b/vendor/knative.dev/serving/pkg/apis/serving/fieldmask.go new file mode 100644 index 00000000000..833d0aa2078 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/fieldmask.go @@ -0,0 +1,569 @@ +/* +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 serving + +import ( + corev1 "k8s.io/api/core/v1" +) + +// VolumeMask performs a _shallow_ copy of the Kubernetes Volume object to a new +// Kubernetes Volume object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func VolumeMask(in *corev1.Volume) *corev1.Volume { + if in == nil { + return nil + } + + out := new(corev1.Volume) + + // Allowed fields + out.Name = in.Name + out.VolumeSource = in.VolumeSource + + return out +} + +// VolumeSourceMask performs a _shallow_ copy of the Kubernetes VolumeSource object to a new +// Kubernetes VolumeSource object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func VolumeSourceMask(in *corev1.VolumeSource) *corev1.VolumeSource { + if in == nil { + return nil + } + + out := new(corev1.VolumeSource) + + // Allowed fields + out.Secret = in.Secret + out.ConfigMap = in.ConfigMap + out.Projected = in.Projected + + // Too many disallowed fields to list + + return out +} + +// VolumeProjectionMask performs a _shallow_ copy of the Kubernetes VolumeProjection +// object to a new Kubernetes VolumeProjection object bringing over only the fields allowed +// in the Knative API. This does not validate the contents or the bounds of the provided fields. +func VolumeProjectionMask(in *corev1.VolumeProjection) *corev1.VolumeProjection { + if in == nil { + return nil + } + + out := new(corev1.VolumeProjection) + + // Allowed fields + out.Secret = in.Secret + out.ConfigMap = in.ConfigMap + + // Disallowed fields + // This list is unnecessary, but added here for clarity + out.DownwardAPI = nil + out.ServiceAccountToken = nil + + return out +} + +// ConfigMapProjectionMask performs a _shallow_ copy of the Kubernetes ConfigMapProjection +// object to a new Kubernetes ConfigMapProjection object bringing over only the fields allowed +// in the Knative API. This does not validate the contents or the bounds of the provided fields. +func ConfigMapProjectionMask(in *corev1.ConfigMapProjection) *corev1.ConfigMapProjection { + if in == nil { + return nil + } + + out := new(corev1.ConfigMapProjection) + + // Allowed fields + out.LocalObjectReference = in.LocalObjectReference + out.Items = in.Items + out.Optional = in.Optional + + return out +} + +// SecretProjectionMask performs a _shallow_ copy of the Kubernetes SecretProjection +// object to a new Kubernetes SecretProjection object bringing over only the fields allowed +// in the Knative API. This does not validate the contents or the bounds of the provided fields. +func SecretProjectionMask(in *corev1.SecretProjection) *corev1.SecretProjection { + if in == nil { + return nil + } + + out := new(corev1.SecretProjection) + + // Allowed fields + out.LocalObjectReference = in.LocalObjectReference + out.Items = in.Items + out.Optional = in.Optional + + return out +} + +// KeyToPathMask performs a _shallow_ copy of the Kubernetes KeyToPath +// object to a new Kubernetes KeyToPath object bringing over only the fields allowed +// in the Knative API. This does not validate the contents or the bounds of the provided fields. +func KeyToPathMask(in *corev1.KeyToPath) *corev1.KeyToPath { + if in == nil { + return nil + } + + out := new(corev1.KeyToPath) + + // Allowed fields + out.Key = in.Key + out.Path = in.Path + out.Mode = in.Mode + + return out +} + +// PodSpecMask performs a _shallow_ copy of the Kubernetes PodSpec object to a new +// Kubernetes PodSpec object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func PodSpecMask(in *corev1.PodSpec) *corev1.PodSpec { + if in == nil { + return nil + } + + out := new(corev1.PodSpec) + + // Allowed fields + out.ServiceAccountName = in.ServiceAccountName + out.Containers = in.Containers + out.Volumes = in.Volumes + out.ImagePullSecrets = in.ImagePullSecrets + + // Disallowed fields + // This list is unnecessary, but added here for clarity + out.InitContainers = nil + out.RestartPolicy = "" + out.TerminationGracePeriodSeconds = nil + out.ActiveDeadlineSeconds = nil + out.DNSPolicy = "" + out.NodeSelector = nil + out.AutomountServiceAccountToken = nil + out.NodeName = "" + out.HostNetwork = false + out.HostPID = false + out.HostIPC = false + out.ShareProcessNamespace = nil + out.SecurityContext = nil + out.Hostname = "" + out.Subdomain = "" + out.Affinity = nil + out.SchedulerName = "" + out.Tolerations = nil + out.HostAliases = nil + out.PriorityClassName = "" + out.Priority = nil + out.DNSConfig = nil + out.ReadinessGates = nil + out.RuntimeClassName = nil + // TODO(mattmoor): Coming in 1.13: out.EnableServiceLinks = nil + + return out +} + +// ContainerMask performs a _shallow_ copy of the Kubernetes Container object to a new +// Kubernetes Container object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ContainerMask(in *corev1.Container) *corev1.Container { + if in == nil { + return nil + } + + out := new(corev1.Container) + + // Allowed fields + out.Name = in.Name + out.Args = in.Args + out.Command = in.Command + out.Env = in.Env + out.WorkingDir = in.WorkingDir + out.EnvFrom = in.EnvFrom + out.Image = in.Image + out.ImagePullPolicy = in.ImagePullPolicy + out.LivenessProbe = in.LivenessProbe + out.Ports = in.Ports + out.ReadinessProbe = in.ReadinessProbe + out.Resources = in.Resources + out.SecurityContext = in.SecurityContext + out.TerminationMessagePath = in.TerminationMessagePath + out.TerminationMessagePolicy = in.TerminationMessagePolicy + out.VolumeMounts = in.VolumeMounts + + // Disallowed fields + // This list is unnecessary, but added here for clarity + out.Lifecycle = nil + out.Stdin = false + out.StdinOnce = false + out.TTY = false + out.VolumeDevices = nil + + return out +} + +// VolumeMountMask performs a _shallow_ copy of the Kubernetes VolumeMount object to a new +// Kubernetes VolumeMount object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func VolumeMountMask(in *corev1.VolumeMount) *corev1.VolumeMount { + if in == nil { + return nil + } + + out := new(corev1.VolumeMount) + + // Allowed fields + out.Name = in.Name + out.ReadOnly = in.ReadOnly + out.MountPath = in.MountPath + out.SubPath = in.SubPath + + // Disallowed fields + // This list is unnecessary, but added here for clarity + out.MountPropagation = nil + + return out +} + +// ProbeMask performs a _shallow_ copy of the Kubernetes Probe object to a new +// Kubernetes Probe object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ProbeMask(in *corev1.Probe) *corev1.Probe { + if in == nil { + return nil + } + out := new(corev1.Probe) + + // Allowed fields + out.Handler = in.Handler + out.InitialDelaySeconds = in.InitialDelaySeconds + out.TimeoutSeconds = in.TimeoutSeconds + out.PeriodSeconds = in.PeriodSeconds + out.SuccessThreshold = in.SuccessThreshold + out.FailureThreshold = in.FailureThreshold + + return out +} + +// HandlerMask performs a _shallow_ copy of the Kubernetes Handler object to a new +// Kubernetes Handler object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func HandlerMask(in *corev1.Handler) *corev1.Handler { + if in == nil { + return nil + } + out := new(corev1.Handler) + + // Allowed fields + out.Exec = in.Exec + out.HTTPGet = in.HTTPGet + out.TCPSocket = in.TCPSocket + + return out + +} + +// ExecActionMask performs a _shallow_ copy of the Kubernetes ExecAction object to a new +// Kubernetes ExecAction object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ExecActionMask(in *corev1.ExecAction) *corev1.ExecAction { + if in == nil { + return nil + } + out := new(corev1.ExecAction) + + // Allowed fields + out.Command = in.Command + + return out +} + +// HTTPGetActionMask performs a _shallow_ copy of the Kubernetes HTTPGetAction object to a new +// Kubernetes HTTPGetAction object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func HTTPGetActionMask(in *corev1.HTTPGetAction) *corev1.HTTPGetAction { + if in == nil { + return nil + } + out := new(corev1.HTTPGetAction) + + // Allowed fields + out.Host = in.Host + out.Path = in.Path + out.Scheme = in.Scheme + out.HTTPHeaders = in.HTTPHeaders + + return out +} + +// TCPSocketActionMask performs a _shallow_ copy of the Kubernetes TCPSocketAction object to a new +// Kubernetes TCPSocketAction object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func TCPSocketActionMask(in *corev1.TCPSocketAction) *corev1.TCPSocketAction { + if in == nil { + return nil + } + out := new(corev1.TCPSocketAction) + + // Allowed fields + out.Host = in.Host + + return out +} + +// ContainerPortMask performs a _shallow_ copy of the Kubernetes ContainerPort object to a new +// Kubernetes ContainerPort object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ContainerPortMask(in *corev1.ContainerPort) *corev1.ContainerPort { + if in == nil { + return nil + } + + out := new(corev1.ContainerPort) + + // Allowed fields + out.ContainerPort = in.ContainerPort + out.Name = in.Name + out.Protocol = in.Protocol + + //Disallowed fields + // This list is unnecessary, but added here for clarity + out.HostIP = "" + out.HostPort = 0 + + return out +} + +// EnvVarMask performs a _shallow_ copy of the Kubernetes EnvVar object to a new +// Kubernetes EnvVar object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func EnvVarMask(in *corev1.EnvVar) *corev1.EnvVar { + if in == nil { + return nil + } + + out := new(corev1.EnvVar) + + // Allowed fields + out.Name = in.Name + out.Value = in.Value + out.ValueFrom = in.ValueFrom + + return out +} + +// EnvVarSourceMask performs a _shallow_ copy of the Kubernetes EnvVarSource object to a new +// Kubernetes EnvVarSource object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func EnvVarSourceMask(in *corev1.EnvVarSource) *corev1.EnvVarSource { + if in == nil { + return nil + } + + out := new(corev1.EnvVarSource) + + // Allowed fields + out.ConfigMapKeyRef = in.ConfigMapKeyRef + out.SecretKeyRef = in.SecretKeyRef + + // Disallowed + // This list is unnecessary, but added here for clarity + out.FieldRef = nil + out.ResourceFieldRef = nil + + return out +} + +// LocalObjectReferenceMask performs a _shallow_ copy of the Kubernetes LocalObjectReference object to a new +// Kubernetes LocalObjectReference object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func LocalObjectReferenceMask(in *corev1.LocalObjectReference) *corev1.LocalObjectReference { + if in == nil { + return nil + } + + out := new(corev1.LocalObjectReference) + + out.Name = in.Name + + return out +} + +// ConfigMapKeySelectorMask performs a _shallow_ copy of the Kubernetes ConfigMapKeySelector object to a new +// Kubernetes ConfigMapKeySelector object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ConfigMapKeySelectorMask(in *corev1.ConfigMapKeySelector) *corev1.ConfigMapKeySelector { + if in == nil { + return nil + } + + out := new(corev1.ConfigMapKeySelector) + + // Allowed fields + out.Key = in.Key + out.Optional = in.Optional + out.LocalObjectReference = in.LocalObjectReference + + return out + +} + +// SecretKeySelectorMask performs a _shallow_ copy of the Kubernetes SecretKeySelector object to a new +// Kubernetes SecretKeySelector object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func SecretKeySelectorMask(in *corev1.SecretKeySelector) *corev1.SecretKeySelector { + if in == nil { + return nil + } + + out := new(corev1.SecretKeySelector) + + // Allowed fields + out.Key = in.Key + out.Optional = in.Optional + out.LocalObjectReference = in.LocalObjectReference + + return out + +} + +// ConfigMapEnvSourceMask performs a _shallow_ copy of the Kubernetes ConfigMapEnvSource object to a new +// Kubernetes ConfigMapEnvSource object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ConfigMapEnvSourceMask(in *corev1.ConfigMapEnvSource) *corev1.ConfigMapEnvSource { + if in == nil { + return nil + } + + out := new(corev1.ConfigMapEnvSource) + + // Allowed fields + out.Optional = in.Optional + out.LocalObjectReference = in.LocalObjectReference + + return out + +} + +// SecretEnvSourceMask performs a _shallow_ copy of the Kubernetes SecretEnvSource object to a new +// Kubernetes SecretEnvSource object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func SecretEnvSourceMask(in *corev1.SecretEnvSource) *corev1.SecretEnvSource { + if in == nil { + return nil + } + + out := new(corev1.SecretEnvSource) + + // Allowed fields + out.Optional = in.Optional + out.LocalObjectReference = in.LocalObjectReference + + return out + +} + +// EnvFromSourceMask performs a _shallow_ copy of the Kubernetes EnvFromSource object to a new +// Kubernetes EnvFromSource object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func EnvFromSourceMask(in *corev1.EnvFromSource) *corev1.EnvFromSource { + if in == nil { + return nil + } + + out := new(corev1.EnvFromSource) + + // Allowed fields + out.Prefix = in.Prefix + out.ConfigMapRef = in.ConfigMapRef + out.SecretRef = in.SecretRef + + return out +} + +// ResourceRequirementsMask performs a _shallow_ copy of the Kubernetes ResourceRequirements object to a new +// Kubernetes ResourceRequirements object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func ResourceRequirementsMask(in *corev1.ResourceRequirements) *corev1.ResourceRequirements { + if in == nil { + return nil + } + + out := new(corev1.ResourceRequirements) + + // Allowed fields + out.Limits = in.Limits + out.Requests = in.Requests + + return out + +} + +// SecurityContextMask performs a _shallow_ copy of the Kubernetes SecurityContext object to a new +// Kubernetes SecurityContext object bringing over only the fields allowed in the Knative API. This +// does not validate the contents or the bounds of the provided fields. +func SecurityContextMask(in *corev1.SecurityContext) *corev1.SecurityContext { + if in == nil { + return nil + } + + out := new(corev1.SecurityContext) + + // Allowed fields + out.RunAsUser = in.RunAsUser + + // Disallowed + // This list is unnecessary, but added here for clarity + out.Capabilities = nil + out.Privileged = nil + out.SELinuxOptions = nil + out.RunAsGroup = nil + out.RunAsNonRoot = nil + out.ReadOnlyRootFilesystem = nil + out.AllowPrivilegeEscalation = nil + out.ProcMount = nil + + return out +} + +// NamespacedObjectReferenceMask performs a _shallow_ copy of the Kubernetes ObjectReference +// object to a new Kubernetes ObjectReference object bringing over only the fields allowed in +// the Knative API. This does not validate the contents or the bounds of the provided fields. +func NamespacedObjectReferenceMask(in *corev1.ObjectReference) *corev1.ObjectReference { + if in == nil { + return nil + } + + out := new(corev1.ObjectReference) + + // Allowed fields + out.APIVersion = in.APIVersion + out.Kind = in.Kind + out.Name = in.Name + + // Disallowed + // This list is unnecessary, but added here for clarity + out.Namespace = "" + out.FieldPath = "" + out.ResourceVersion = "" + out.UID = "" + + return out +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/k8s_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/k8s_lifecycle.go new file mode 100644 index 00000000000..f40bfbf9fd1 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/k8s_lifecycle.go @@ -0,0 +1,78 @@ +/* +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 serving + +import ( + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +var depCondSet = apis.NewLivingConditionSet( + DeploymentConditionProgressing, + DeploymentConditionReplicaSetReady, +) + +const ( + // DeploymentConditionReady means the underlying deployment is ready. + DeploymentConditionReady = apis.ConditionReady + // DeploymentConditionReplicaSetready inverts the underlying deployment's + // ReplicaSetFailure condition. + DeploymentConditionReplicaSetReady apis.ConditionType = "ReplicaSetReady" + // DeploymentConditionProgressing reflects the underlying deployment's + // Progressing condition. + DeploymentConditionProgressing apis.ConditionType = "Progressing" +) + +// transformDeploymentStatus transforms the kubernetes DeploymentStatus into a +// duckv1.Status that uses ConditionSets to propagate failures and expose +// a top-level happy state, per our condition conventions. +func TransformDeploymentStatus(ds *appsv1.DeploymentStatus) *duckv1.Status { + s := &duckv1.Status{} + + depCondSet.Manage(s).InitializeConditions() + // The absence of this condition means no failure has occurred. If we find it + // below, we'll ovewrwrite this. + depCondSet.Manage(s).MarkTrue(DeploymentConditionReplicaSetReady) + + for _, cond := range ds.Conditions { + // TODO(jonjohnsonjr): Should we care about appsv1.DeploymentAvailable here? + switch cond.Type { + case appsv1.DeploymentProgressing: + switch cond.Status { + case corev1.ConditionUnknown: + depCondSet.Manage(s).MarkUnknown(DeploymentConditionProgressing, cond.Reason, cond.Message) + case corev1.ConditionTrue: + depCondSet.Manage(s).MarkTrue(DeploymentConditionProgressing) + case corev1.ConditionFalse: + depCondSet.Manage(s).MarkFalse(DeploymentConditionProgressing, cond.Reason, cond.Message) + } + case appsv1.DeploymentReplicaFailure: + switch cond.Status { + case corev1.ConditionUnknown: + depCondSet.Manage(s).MarkUnknown(DeploymentConditionReplicaSetReady, cond.Reason, cond.Message) + case corev1.ConditionTrue: + depCondSet.Manage(s).MarkFalse(DeploymentConditionReplicaSetReady, cond.Reason, cond.Message) + case corev1.ConditionFalse: + depCondSet.Manage(s).MarkTrue(DeploymentConditionReplicaSetReady) + } + } + } + return s +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go new file mode 100644 index 00000000000..09be210985c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/k8s_validation.go @@ -0,0 +1,544 @@ +/* +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 serving + +import ( + "fmt" + "math" + "path/filepath" + "strings" + + "github.com/google/go-containerregistry/pkg/name" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/apimachinery/pkg/util/validation" + "knative.dev/pkg/apis" + "knative.dev/pkg/profiling" + "knative.dev/serving/pkg/apis/networking" +) + +const ( + minUserID = 0 + maxUserID = math.MaxInt32 +) + +var ( + reservedPaths = sets.NewString( + "/", + "/dev", + "/dev/log", // Should be a domain socket + "/tmp", + "/var", + "/var/log", + ) + + reservedContainerNames = sets.NewString( + "queue-proxy", + ) + + reservedEnvVars = sets.NewString( + "PORT", + "K_SERVICE", + "K_CONFIGURATION", + "K_REVISION", + ) + + // The port is named "user-port" on the deployment, but a user cannot set an arbitrary name on the port + // in Configuration. The name field is reserved for content-negotiation. Currently 'h2c' and 'http1' are + // allowed. + // https://github.com/knative/serving/blob/master/docs/runtime-contract.md#inbound-network-connectivity + validPortNames = sets.NewString( + "h2c", + "http1", + "", + ) +) + +func ValidateVolumes(vs []corev1.Volume) (sets.String, *apis.FieldError) { + volumes := sets.NewString() + var errs *apis.FieldError + for i, volume := range vs { + if volumes.Has(volume.Name) { + errs = errs.Also((&apis.FieldError{ + Message: fmt.Sprintf("duplicate volume name %q", volume.Name), + Paths: []string{"name"}, + }).ViaIndex(i)) + } + errs = errs.Also(validateVolume(volume).ViaIndex(i)) + volumes.Insert(volume.Name) + } + return volumes, errs +} + +func validateVolume(volume corev1.Volume) *apis.FieldError { + errs := apis.CheckDisallowedFields(volume, *VolumeMask(&volume)) + if volume.Name == "" { + errs = apis.ErrMissingField("name") + } else if len(validation.IsDNS1123Label(volume.Name)) != 0 { + errs = apis.ErrInvalidValue(volume.Name, "name") + } + + vs := volume.VolumeSource + errs = errs.Also(apis.CheckDisallowedFields(vs, *VolumeSourceMask(&vs))) + specified := []string{} + if vs.Secret != nil { + specified = append(specified, "secret") + for i, item := range vs.Secret.Items { + errs = errs.Also(validateKeyToPath(item).ViaFieldIndex("items", i)) + } + } + if vs.ConfigMap != nil { + specified = append(specified, "configMap") + for i, item := range vs.ConfigMap.Items { + errs = errs.Also(validateKeyToPath(item).ViaFieldIndex("items", i)) + } + } + if vs.Projected != nil { + specified = append(specified, "projected") + for i, proj := range vs.Projected.Sources { + errs = errs.Also(validateProjectedVolumeSource(proj).ViaFieldIndex("projected", i)) + } + } + if len(specified) == 0 { + errs = errs.Also(apis.ErrMissingOneOf("secret", "configMap", "projected")) + } else if len(specified) > 1 { + errs = errs.Also(apis.ErrMultipleOneOf(specified...)) + } + + return errs +} + +func validateProjectedVolumeSource(vp corev1.VolumeProjection) *apis.FieldError { + errs := apis.CheckDisallowedFields(vp, *VolumeProjectionMask(&vp)) + specified := []string{} + if vp.Secret != nil { + specified = append(specified, "secret") + errs = errs.Also(validateSecretProjection(vp.Secret).ViaField("secret")) + } + if vp.ConfigMap != nil { + specified = append(specified, "configMap") + errs = errs.Also(validateConfigMapProjection(vp.ConfigMap).ViaField("configMap")) + } + if len(specified) == 0 { + errs = errs.Also(apis.ErrMissingOneOf("secret", "configMap")) + } else if len(specified) > 1 { + errs = errs.Also(apis.ErrMultipleOneOf(specified...)) + } + return errs +} + +func validateConfigMapProjection(cmp *corev1.ConfigMapProjection) *apis.FieldError { + errs := apis.CheckDisallowedFields(*cmp, *ConfigMapProjectionMask(cmp)) + errs = errs.Also(apis.CheckDisallowedFields( + cmp.LocalObjectReference, *LocalObjectReferenceMask(&cmp.LocalObjectReference))) + if cmp.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } + for i, item := range cmp.Items { + errs = errs.Also(validateKeyToPath(item).ViaFieldIndex("items", i)) + } + return errs +} + +func validateSecretProjection(sp *corev1.SecretProjection) *apis.FieldError { + errs := apis.CheckDisallowedFields(*sp, *SecretProjectionMask(sp)) + errs = errs.Also(apis.CheckDisallowedFields( + sp.LocalObjectReference, *LocalObjectReferenceMask(&sp.LocalObjectReference))) + if sp.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } + for i, item := range sp.Items { + errs = errs.Also(validateKeyToPath(item).ViaFieldIndex("items", i)) + } + return errs +} + +func validateKeyToPath(k2p corev1.KeyToPath) *apis.FieldError { + errs := apis.CheckDisallowedFields(k2p, *KeyToPathMask(&k2p)) + if k2p.Key == "" { + errs = errs.Also(apis.ErrMissingField("key")) + } + if k2p.Path == "" { + errs = errs.Also(apis.ErrMissingField("path")) + } + return errs +} + +func validateEnvValueFrom(source *corev1.EnvVarSource) *apis.FieldError { + if source == nil { + return nil + } + return apis.CheckDisallowedFields(*source, *EnvVarSourceMask(source)) +} + +func validateEnvVar(env corev1.EnvVar) *apis.FieldError { + errs := apis.CheckDisallowedFields(env, *EnvVarMask(&env)) + + if env.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } else if reservedEnvVars.Has(env.Name) { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("%q is a reserved environment variable", env.Name), + Paths: []string{"name"}, + }) + } + + return errs.Also(validateEnvValueFrom(env.ValueFrom).ViaField("valueFrom")) +} + +func validateEnv(envVars []corev1.EnvVar) *apis.FieldError { + var errs *apis.FieldError + for i, env := range envVars { + errs = errs.Also(validateEnvVar(env).ViaIndex(i)) + } + return errs +} + +func validateEnvFrom(envFromList []corev1.EnvFromSource) *apis.FieldError { + var errs *apis.FieldError + for i, envFrom := range envFromList { + errs = errs.Also(apis.CheckDisallowedFields(envFrom, *EnvFromSourceMask(&envFrom)).ViaIndex(i)) + + cm := envFrom.ConfigMapRef + sm := envFrom.SecretRef + if sm != nil { + errs = errs.Also(apis.CheckDisallowedFields(*sm, *SecretEnvSourceMask(sm)).ViaIndex(i)) + errs = errs.Also(apis.CheckDisallowedFields( + sm.LocalObjectReference, *LocalObjectReferenceMask(&sm.LocalObjectReference))).ViaIndex(i).ViaField("secretRef") + } + + if cm != nil { + errs = errs.Also(apis.CheckDisallowedFields(*cm, *ConfigMapEnvSourceMask(cm)).ViaIndex(i)) + errs = errs.Also(apis.CheckDisallowedFields( + cm.LocalObjectReference, *LocalObjectReferenceMask(&cm.LocalObjectReference))).ViaIndex(i).ViaField("configMapRef") + } + if cm != nil && sm != nil { + errs = errs.Also(apis.ErrMultipleOneOf("configMapRef", "secretRef")) + } else if cm == nil && sm == nil { + errs = errs.Also(apis.ErrMissingOneOf("configMapRef", "secretRef")) + } + } + return errs +} + +func ValidatePodSpec(ps corev1.PodSpec) *apis.FieldError { + // This is inlined, and so it makes for a less meaningful + // error message. + // if equality.Semantic.DeepEqual(ps, corev1.PodSpec{}) { + // return apis.ErrMissingField(apis.CurrentField) + // } + + errs := apis.CheckDisallowedFields(ps, *PodSpecMask(&ps)) + + volumes, err := ValidateVolumes(ps.Volumes) + if err != nil { + errs = errs.Also(err.ViaField("volumes")) + } + + switch len(ps.Containers) { + case 0: + errs = errs.Also(apis.ErrMissingField("containers")) + case 1: + errs = errs.Also(ValidateContainer(ps.Containers[0], volumes). + ViaFieldIndex("containers", 0)) + default: + errs = errs.Also(apis.ErrMultipleOneOf("containers")) + } + if ps.ServiceAccountName != "" { + for range validation.IsDNS1123Subdomain(ps.ServiceAccountName) { + errs = errs.Also(apis.ErrInvalidValue("serviceAccountName", ps.ServiceAccountName)) + } + } + return errs +} + +func ValidateContainer(container corev1.Container, volumes sets.String) *apis.FieldError { + if equality.Semantic.DeepEqual(container, corev1.Container{}) { + return apis.ErrMissingField(apis.CurrentField) + } + + errs := apis.CheckDisallowedFields(container, *ContainerMask(&container)) + + if reservedContainerNames.Has(container.Name) { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("%q is a reserved container name", container.Name), + Paths: []string{"name"}, + }) + } + + // Env + errs = errs.Also(validateEnv(container.Env).ViaField("env")) + // EnvFrom + errs = errs.Also(validateEnvFrom(container.EnvFrom).ViaField("envFrom")) + // Image + if container.Image == "" { + errs = errs.Also(apis.ErrMissingField("image")) + } else if _, err := name.ParseReference(container.Image, name.WeakValidation); err != nil { + fe := &apis.FieldError{ + Message: "Failed to parse image reference", + Paths: []string{"image"}, + Details: fmt.Sprintf("image: %q, error: %v", container.Image, err), + } + errs = errs.Also(fe) + } + // Liveness Probes + errs = errs.Also(validateProbe(container.LivenessProbe).ViaField("livenessProbe")) + // Ports + errs = errs.Also(validateContainerPorts(container.Ports).ViaField("ports")) + // Readiness Probes + errs = errs.Also(validateReadinessProbe(container.ReadinessProbe).ViaField("readinessProbe")) + // Resources + errs = errs.Also(validateResources(&container.Resources).ViaField("resources")) + // SecurityContext + errs = errs.Also(validateSecurityContext(container.SecurityContext).ViaField("securityContext")) + // TerminationMessagePolicy + switch container.TerminationMessagePolicy { + case corev1.TerminationMessageReadFile, corev1.TerminationMessageFallbackToLogsOnError, "": + default: + errs = errs.Also(apis.ErrInvalidValue(container.TerminationMessagePolicy, "terminationMessagePolicy")) + } + // VolumeMounts + errs = errs.Also(validateVolumeMounts(container.VolumeMounts, volumes).ViaField("volumeMounts")) + + return errs +} + +func validateResources(resources *corev1.ResourceRequirements) *apis.FieldError { + if resources == nil { + return nil + } + return apis.CheckDisallowedFields(*resources, *ResourceRequirementsMask(resources)) +} + +func validateSecurityContext(sc *corev1.SecurityContext) *apis.FieldError { + if sc == nil { + return nil + } + errs := apis.CheckDisallowedFields(*sc, *SecurityContextMask(sc)) + + if sc.RunAsUser != nil { + uid := *sc.RunAsUser + if uid < minUserID || uid > maxUserID { + errs = errs.Also(apis.ErrOutOfBoundsValue(uid, minUserID, maxUserID, "runAsUser")) + } + } + return errs +} + +func validateVolumeMounts(mounts []corev1.VolumeMount, volumes sets.String) *apis.FieldError { + var errs *apis.FieldError + // Check that volume mounts match names in "volumes", that "volumes" has 100% + // coverage, and the field restrictions. + seenName := sets.NewString() + seenMountPath := sets.NewString() + for i, vm := range mounts { + errs = errs.Also(apis.CheckDisallowedFields(vm, *VolumeMountMask(&vm)).ViaIndex(i)) + // This effectively checks that Name is non-empty because Volume name must be non-empty. + if !volumes.Has(vm.Name) { + errs = errs.Also((&apis.FieldError{ + Message: "volumeMount has no matching volume", + Paths: []string{"name"}, + }).ViaIndex(i)) + } + seenName.Insert(vm.Name) + + if vm.MountPath == "" { + errs = errs.Also(apis.ErrMissingField("mountPath").ViaIndex(i)) + } else if reservedPaths.Has(filepath.Clean(vm.MountPath)) { + errs = errs.Also((&apis.FieldError{ + Message: fmt.Sprintf("mountPath %q is a reserved path", filepath.Clean(vm.MountPath)), + Paths: []string{"mountPath"}, + }).ViaIndex(i)) + } else if !filepath.IsAbs(vm.MountPath) { + errs = errs.Also(apis.ErrInvalidValue(vm.MountPath, "mountPath").ViaIndex(i)) + } else if seenMountPath.Has(filepath.Clean(vm.MountPath)) { + errs = errs.Also(apis.ErrInvalidValue( + fmt.Sprintf("%q must be unique", vm.MountPath), "mountPath").ViaIndex(i)) + } + seenMountPath.Insert(filepath.Clean(vm.MountPath)) + + if !vm.ReadOnly { + errs = errs.Also(apis.ErrMissingField("readOnly").ViaIndex(i)) + } + + } + + if missing := volumes.Difference(seenName); missing.Len() > 0 { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("volumes not mounted: %v", missing.List()), + Paths: []string{apis.CurrentField}, + }) + } + return errs +} + +func validateContainerPorts(ports []corev1.ContainerPort) *apis.FieldError { + if len(ports) == 0 { + return nil + } + + var errs *apis.FieldError + + // user can set container port which names "user-port" to define application's port. + // Queue-proxy will use it to send requests to application + // if user didn't set any port, it will set default port user-port=8080. + if len(ports) > 1 { + errs = errs.Also(&apis.FieldError{ + Message: "More than one container port is set", + Paths: []string{apis.CurrentField}, + Details: "Only a single port is allowed", + }) + } + + userPort := ports[0] + + errs = errs.Also(apis.CheckDisallowedFields(userPort, *ContainerPortMask(&userPort))) + + // Only allow empty (defaulting to "TCP") or explicit TCP for protocol + if userPort.Protocol != "" && userPort.Protocol != corev1.ProtocolTCP { + errs = errs.Also(apis.ErrInvalidValue(userPort.Protocol, "protocol")) + } + + // Don't allow userPort to conflict with QueueProxy sidecar + if userPort.ContainerPort == networking.BackendHTTPPort || + userPort.ContainerPort == networking.BackendHTTP2Port || + userPort.ContainerPort == networking.QueueAdminPort || + userPort.ContainerPort == networking.AutoscalingQueueMetricsPort || + userPort.ContainerPort == networking.UserQueueMetricsPort || + userPort.ContainerPort == profiling.ProfilingPort { + errs = errs.Also(apis.ErrInvalidValue(userPort.ContainerPort, "containerPort")) + } + + if userPort.ContainerPort < 0 || userPort.ContainerPort > 65535 { + errs = errs.Also(apis.ErrOutOfBoundsValue(userPort.ContainerPort, + 0, 65535, "containerPort")) + } + + if !validPortNames.Has(userPort.Name) { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Port name %v is not allowed", ports[0].Name), + Paths: []string{apis.CurrentField}, + Details: "Name must be empty, or one of: 'h2c', 'http1'", + }) + } + + return errs +} + +func validateReadinessProbe(p *corev1.Probe) *apis.FieldError { + if p == nil { + return nil + } + + errs := validateProbe(p) + + if p.PeriodSeconds < 0 { + errs = errs.Also(apis.ErrOutOfBoundsValue(p.PeriodSeconds, 0, math.MaxInt32, "periodSeconds")) + } + + if p.InitialDelaySeconds < 0 { + errs = errs.Also(apis.ErrOutOfBoundsValue(p.InitialDelaySeconds, 0, math.MaxInt32, "initialDelaySeconds")) + } + + if p.SuccessThreshold < 1 { + errs = errs.Also(apis.ErrOutOfBoundsValue(p.SuccessThreshold, 1, math.MaxInt32, "successThreshold")) + } + + // PeriodSeconds == 0 indicates Knative's special probe with aggressive retries + if p.PeriodSeconds == 0 { + if p.FailureThreshold != 0 { + errs = errs.Also(&apis.FieldError{ + Message: "failureThreshold is disallowed when periodSeconds is zero", + Paths: []string{"failureThreshold"}, + }) + } + + if p.TimeoutSeconds != 0 { + errs = errs.Also(&apis.FieldError{ + Message: "timeoutSeconds is disallowed when periodSeconds is zero", + Paths: []string{"timeoutSeconds"}, + }) + } + } else { + if p.TimeoutSeconds < 1 { + errs = errs.Also(apis.ErrOutOfBoundsValue(p.TimeoutSeconds, 1, math.MaxInt32, "timeoutSeconds")) + } + + if p.FailureThreshold < 1 { + errs = errs.Also(apis.ErrOutOfBoundsValue(p.FailureThreshold, 1, math.MaxInt32, "failureThreshold")) + } + } + + return errs +} + +func validateProbe(p *corev1.Probe) *apis.FieldError { + if p == nil { + return nil + } + errs := apis.CheckDisallowedFields(*p, *ProbeMask(p)) + + h := p.Handler + errs = errs.Also(apis.CheckDisallowedFields(h, *HandlerMask(&h))) + + var handlers []string + + if h.HTTPGet != nil { + handlers = append(handlers, "httpGet") + errs = errs.Also(apis.CheckDisallowedFields(*h.HTTPGet, *HTTPGetActionMask(h.HTTPGet))).ViaField("httpGet") + } + if h.TCPSocket != nil { + handlers = append(handlers, "tcpSocket") + errs = errs.Also(apis.CheckDisallowedFields(*h.TCPSocket, *TCPSocketActionMask(h.TCPSocket))).ViaField("tcpSocket") + } + if h.Exec != nil { + handlers = append(handlers, "exec") + errs = errs.Also(apis.CheckDisallowedFields(*h.Exec, *ExecActionMask(h.Exec))).ViaField("exec") + } + + if len(handlers) == 0 { + errs = errs.Also(apis.ErrMissingOneOf("httpGet", "tcpSocket", "exec")) + } else if len(handlers) > 1 { + errs = errs.Also(apis.ErrMultipleOneOf(handlers...)) + } + return errs +} + +func ValidateNamespacedObjectReference(p *corev1.ObjectReference) *apis.FieldError { + if p == nil { + return nil + } + errs := apis.CheckDisallowedFields(*p, *NamespacedObjectReferenceMask(p)) + + if p.APIVersion == "" { + errs = errs.Also(apis.ErrMissingField("apiVersion")) + } else if verrs := validation.IsQualifiedName(p.APIVersion); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "apiVersion")) + } + if p.Kind == "" { + errs = errs.Also(apis.ErrMissingField("kind")) + } else if verrs := validation.IsCIdentifier(p.Kind); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "kind")) + } + if p.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } else if verrs := validation.IsDNS1123Label(p.Name); len(verrs) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(verrs, ", "), "name")) + } + return errs +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go new file mode 100644 index 00000000000..034af7c2317 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/metadata_validation.go @@ -0,0 +1,171 @@ +/* +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 serving + +import ( + "context" + "fmt" + "strconv" + "strings" + + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/api/validation" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/autoscaling" + "knative.dev/serving/pkg/apis/config" + routeconfig "knative.dev/serving/pkg/reconciler/route/config" +) + +var ( + allowedAnnotations = map[string]struct{}{ + UpdaterAnnotation: {}, + CreatorAnnotation: {}, + RevisionLastPinnedAnnotationKey: {}, + GroupNamePrefix + "forceUpgrade": {}, + } +) + +// ValidateObjectMetadata validates that `metadata` stanza of the +// resources is correct. +func ValidateObjectMetadata(meta metav1.Object) *apis.FieldError { + return apis.ValidateObjectMetadata(meta). + Also(autoscaling.ValidateAnnotations(meta.GetAnnotations()). + Also(validateKnativeAnnotations(meta.GetAnnotations())). + ViaField("annotations")) +} + +func validateKnativeAnnotations(annotations map[string]string) (errs *apis.FieldError) { + for key := range annotations { + if _, ok := allowedAnnotations[key]; !ok && strings.HasPrefix(key, GroupNamePrefix) { + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return +} + +// ValidateQueueSidecarAnnotation validates QueueSideCarResourcePercentageAnnotation +func ValidateQueueSidecarAnnotation(annotations map[string]string) *apis.FieldError { + if len(annotations) == 0 { + return nil + } + v, ok := annotations[QueueSideCarResourcePercentageAnnotation] + if !ok { + return nil + } + value, err := strconv.ParseFloat(v, 64) + if err != nil { + return apis.ErrInvalidValue(v, apis.CurrentField).ViaKey(QueueSideCarResourcePercentageAnnotation) + } + if value <= 0.1 || value > 100 { + return apis.ErrOutOfBoundsValue(value, 0.1, 100.0, QueueSideCarResourcePercentageAnnotation) + } + return nil +} + +// ValidateTimeoutSeconds validates timeout by comparing MaxRevisionTimeoutSeconds +func ValidateTimeoutSeconds(ctx context.Context, timeoutSeconds int64) *apis.FieldError { + if timeoutSeconds != 0 { + cfg := config.FromContextOrDefaults(ctx) + if timeoutSeconds > cfg.Defaults.MaxRevisionTimeoutSeconds || timeoutSeconds < 0 { + return apis.ErrOutOfBoundsValue(timeoutSeconds, 0, + cfg.Defaults.MaxRevisionTimeoutSeconds, + "timeoutSeconds") + } + } + return nil +} + +// ValidateContainerConcurrency function validates the ContainerConcurrency field +// TODO(#5007): Move this to autoscaling. +func ValidateContainerConcurrency(containerConcurrency *int64) *apis.FieldError { + if containerConcurrency != nil { + if *containerConcurrency < 0 || *containerConcurrency > config.DefaultMaxRevisionContainerConcurrency { + return apis.ErrOutOfBoundsValue( + *containerConcurrency, 0, config.DefaultMaxRevisionContainerConcurrency, apis.CurrentField) + } + } + return nil +} + +// ValidateClusterVisibilityLabel function validates the visibility label on a Route +func ValidateClusterVisibilityLabel(label string) (errs *apis.FieldError) { + if label != routeconfig.VisibilityClusterLocal { + errs = apis.ErrInvalidValue(label, routeconfig.VisibilityLabelKey) + } + return +} + +// SetUserInfo sets creator and updater annotations +func SetUserInfo(ctx context.Context, oldSpec, newSpec, resource interface{}) { + if ui := apis.GetUserInfo(ctx); ui != nil { + objectMetaAccessor, ok := resource.(metav1.ObjectMetaAccessor) + if !ok { + return + } + ans := objectMetaAccessor.GetObjectMeta().GetAnnotations() + if ans == nil { + ans = map[string]string{} + objectMetaAccessor.GetObjectMeta().SetAnnotations(ans) + } + + if apis.IsInUpdate(ctx) { + if equality.Semantic.DeepEqual(oldSpec, newSpec) { + return + } + ans[UpdaterAnnotation] = ui.Username + } else { + ans[CreatorAnnotation] = ui.Username + ans[UpdaterAnnotation] = ui.Username + } + } +} + +// ValidateRevisionName validates name and generateName for the revisionTemplate +func ValidateRevisionName(ctx context.Context, name, generateName string) *apis.FieldError { + if generateName != "" { + if msgs := validation.NameIsDNS1035Label(generateName, true); len(msgs) > 0 { + return apis.ErrInvalidValue( + fmt.Sprintf("not a DNS 1035 label prefix: %v", msgs), + "metadata.generateName") + } + } + if name != "" { + if msgs := validation.NameIsDNS1035Label(name, false); len(msgs) > 0 { + return apis.ErrInvalidValue( + fmt.Sprintf("not a DNS 1035 label: %v", msgs), + "metadata.name") + } + om := apis.ParentMeta(ctx) + prefix := om.Name + "-" + if om.Name != "" { + // Even if there is GenerateName, allow the use + // of Name post-creation. + } else if om.GenerateName != "" { + // We disallow bringing your own name when the parent + // resource uses generateName (at creation). + return apis.ErrDisallowedFields("metadata.name") + } + + if !strings.HasPrefix(name, prefix) { + return apis.ErrInvalidValue( + fmt.Sprintf("%q must have prefix %q", name, prefix), + "metadata.name") + } + } + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/register.go b/vendor/knative.dev/serving/pkg/apis/serving/register.go new file mode 100644 index 00000000000..a73b45e0c5f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/register.go @@ -0,0 +1,72 @@ +/* +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 serving + +const ( + // GroupName is the group name for knative labels and annotations + GroupName = "serving.knative.dev" + + // GroupNamePrefix is the prefix for label key and annotation key + GroupNamePrefix = GroupName + "/" + + // ConfigurationLabelKey is the label key attached to a Revision indicating by + // which Configuration it is created. + ConfigurationLabelKey = GroupName + "/configuration" + + // RevisionLastPinnedAnnotationKey is the annotation key used for determining when a route has + // pinned a revision + RevisionLastPinnedAnnotationKey = GroupName + "/lastPinned" + + // RouteLabelKey is the label key attached to a Configuration indicating by + // which Route it is configured as traffic target. + // The key can also be attached to Ingress resources to indicate + // which Route triggered their creation. + // The key is also attached to k8s Service resources to indicate which Route + // triggered their creation. + RouteLabelKey = GroupName + "/route" + + // RouteNamespaceLabelKey is the label key attached to a Ingress + // by a Route to indicate which namespace the Route was created in. + RouteNamespaceLabelKey = GroupName + "/routeNamespace" + + // RevisionLabelKey is the label key attached to k8s resources to indicate + // which Revision triggered their creation. + RevisionLabelKey = GroupName + "/revision" + + // RevisionUID is the label key attached to a revision to indicate + // its unique identifier + RevisionUID = GroupName + "/revisionUID" + + // ServiceLabelKey is the label key attached to a Route and Configuration indicating by + // which Service they are created. + ServiceLabelKey = GroupName + "/service" + + // ConfigurationGenerationLabelKey is the label key attached to a Revision indicating the + // metadata generation of the Configuration that created this revision + ConfigurationGenerationLabelKey = GroupName + "/configurationGeneration" + + // CreatorAnnotation is the annotation key to describe the user that + // created the resource. + CreatorAnnotation = GroupName + "/creator" + // UpdaterAnnotation is the annotation key to describe the user that + // last updated the resource. + UpdaterAnnotation = GroupName + "/lastModifier" + + // QueueSideCarResourcePercentageAnnotation is the percentage of user container resources to be used for queue-proxy + // It has to be in [0.1,100] + QueueSideCarResourcePercentageAnnotation = "queue.sidecar." + GroupName + "/resourcePercentage" +) diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_conversion.go new file mode 100644 index 00000000000..05d012ce555 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_conversion.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 v1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Configuration) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Configuration) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_defaults.go new file mode 100644 index 00000000000..6e2527693be --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_defaults.go @@ -0,0 +1,42 @@ +/* +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" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +// SetDefaults implements apis.Defaultable +func (c *Configuration) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, c.ObjectMeta) + c.Spec.SetDefaults(apis.WithinSpec(ctx)) + if c.GetOwnerReferences() == nil { + if apis.IsInUpdate(ctx) { + serving.SetUserInfo(ctx, apis.GetBaseline(ctx).(*Configuration).Spec, c.Spec, c) + } else { + serving.SetUserInfo(ctx, nil, c.Spec, c) + } + } +} + +// SetDefaults implements apis.Defaultable +func (cs *ConfigurationSpec) SetDefaults(ctx context.Context) { + cs.Template.SetDefaults(ctx) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_lifecycle.go new file mode 100644 index 00000000000..93057dacf56 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_lifecycle.go @@ -0,0 +1,35 @@ +/* +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 ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" +) + +var configurationCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Configuration) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Configuration") +} + +// IsReady returns if the configuration is ready to serve the requested configuration. +func (cs *ConfigurationStatus) IsReady() bool { + return configurationCondSet.Manage(cs).IsHappy() +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_types.go new file mode 100644 index 00000000000..dc18e1829d7 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_types.go @@ -0,0 +1,102 @@ +/* +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 ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "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 + +// Configuration represents the "floating HEAD" of a linear history of Revisions. +// Users create new Revisions by updating the Configuration's spec. +// The "latest created" revision's name is available under status, as is the +// "latest ready" revision's name. +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#configuration +type Configuration struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec ConfigurationSpec `json:"spec,omitempty"` + + // +optional + Status ConfigurationStatus `json:"status,omitempty"` +} + +// Verify that Configuration adheres to the appropriate interfaces. +var ( + // Check that Configuration may be validated and defaulted. + _ apis.Validatable = (*Configuration)(nil) + _ apis.Defaultable = (*Configuration)(nil) + + // Check that Configuration can be converted to higher versions. + _ apis.Convertible = (*Configuration)(nil) + + // Check that we can create OwnerReferences to a Configuration. + _ kmeta.OwnerRefable = (*Configuration)(nil) +) + +// ConfigurationSpec holds the desired state of the Configuration (from the client). +type ConfigurationSpec struct { + // Template holds the latest specification for the Revision to be stamped out. + // +optional + Template RevisionTemplateSpec `json:"template"` +} + +const ( + // ConfigurationConditionReady is set when the configuration's latest + // underlying revision has reported readiness. + ConfigurationConditionReady = apis.ConditionReady +) + +// ConfigurationStatusFields holds the fields of Configuration's status that +// are not generally shared. This is defined separately and inlined so that +// other types can readily consume these fields via duck typing. +type ConfigurationStatusFields struct { + // LatestReadyRevisionName holds the name of the latest Revision stamped out + // from this Configuration that has had its "Ready" condition become "True". + // +optional + LatestReadyRevisionName string `json:"latestReadyRevisionName,omitempty"` + + // LatestCreatedRevisionName is the last revision that was created from this + // Configuration. It might not be ready yet, for that use LatestReadyRevisionName. + // +optional + LatestCreatedRevisionName string `json:"latestCreatedRevisionName,omitempty"` +} + +// ConfigurationStatus communicates the observed state of the Configuration (from the controller). +type ConfigurationStatus struct { + duckv1.Status `json:",inline"` + + ConfigurationStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ConfigurationList is a list of Configuration resources +type ConfigurationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Configuration `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go new file mode 100644 index 00000000000..da69563049f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/configuration_validation.go @@ -0,0 +1,98 @@ +/* +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" + "strings" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" + "knative.dev/serving/pkg/reconciler/route/config" +) + +// Validate makes sure that Configuration is properly configured. +func (c *Configuration) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(c.GetObjectMeta()).Also( + c.validateLabels().ViaField("labels")).ViaField("metadata")) + ctx = apis.WithinParent(ctx, c.ObjectMeta) + errs = errs.Also(c.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + errs = errs.Also(c.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Configuration) + // Don't validate annotations(creator and lastModifier) when configuration owned by service + // validate only when configuration created independently. + if c.OwnerReferences == nil { + errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, c.Spec, original.GetAnnotations(), + c.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations")) + } + err := c.Spec.Template.VerifyNameChange(ctx, original.Spec.Template) + errs = errs.Also(err.ViaField("spec.template")) + } + + return errs +} + +// Validate implements apis.Validatable +func (cs *ConfigurationSpec) Validate(ctx context.Context) *apis.FieldError { + return cs.Template.Validate(ctx).ViaField("template") +} + +// Validate implements apis.Validatable +func (cs *ConfigurationStatus) Validate(ctx context.Context) *apis.FieldError { + return cs.ConfigurationStatusFields.Validate(ctx) +} + +// Validate implements apis.Validatable +func (csf *ConfigurationStatusFields) Validate(ctx context.Context) *apis.FieldError { + return nil +} + +// validateLabels function validates configuration labels +func (c *Configuration) validateLabels() (errs *apis.FieldError) { + for key, val := range c.GetLabels() { + switch { + case key == config.VisibilityLabelKey: + errs = errs.Also(validateClusterVisibilityLabel(val)) + case key == serving.RouteLabelKey: + case key == serving.ServiceLabelKey: + errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", c.GetOwnerReferences())) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return +} + +// verifyLabelOwnerRef function verifies the owner references of resource with label key has val value. +func verifyLabelOwnerRef(val, label, resource string, ownerRefs []metav1.OwnerReference) (errs *apis.FieldError) { + for _, ref := range ownerRefs { + if ref.Kind == resource && val == ref.Name { + return + } + } + return errs.Also(apis.ErrMissingField(label)) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/contexts.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/contexts.go new file mode 100644 index 00000000000..2b1076cf333 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/contexts.go @@ -0,0 +1,52 @@ +/* +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" + +// hdcnKey is used as the key for associating information +// with a context.Context. +type hdcnKey struct{} + +// WithDefaultConfigurationName notes on the context for nested validation +// that there is a default configuration name, which affects how an empty +// configurationName is validated. +func WithDefaultConfigurationName(ctx context.Context) context.Context { + return context.WithValue(ctx, hdcnKey{}, struct{}{}) +} + +// HasDefaultConfigurationName checks to see whether the given context has +// been marked as having a default configurationName. +func HasDefaultConfigurationName(ctx context.Context) bool { + return ctx.Value(hdcnKey{}) != nil +} + +// lemonadeKey is used as the key for associating information +// with a context.Context. +type lemonadeKey struct{} + +// WithUpgradeViaDefaulting notes on the context that we want defaulting to rewrite +// from v1alpha1 to v1. +func WithUpgradeViaDefaulting(ctx context.Context) context.Context { + return context.WithValue(ctx, lemonadeKey{}, struct{}{}) +} + +// IsUpgradeViaDefaulting checks whether we should be "defaulting" from v1alpha1 to +// the v1 subset. +func IsUpgradeViaDefaulting(ctx context.Context) bool { + return ctx.Value(lemonadeKey{}) != nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/doc.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/doc.go new file mode 100644 index 00000000000..fab9a24e65b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/doc.go @@ -0,0 +1,21 @@ +/* +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 contains the Serving v1 API types. + +// +k8s:deepcopy-gen=package +// +groupName=serving.knative.dev +package v1 diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/register.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/register.go new file mode 100644 index 00000000000..479507d511b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/register.go @@ -0,0 +1,61 @@ +/* +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 ( + "knative.dev/serving/pkg/apis/serving" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects. +var SchemeGroupVersion = schema.GroupVersion{Group: serving.GroupName, Version: "v1"} + +// 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 { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder registers the addKnownTypes function. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme applies all the stored functions to the scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Revision{}, + &RevisionList{}, + &Configuration{}, + &ConfigurationList{}, + &Route{}, + &RouteList{}, + &Service{}, + &ServiceList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_conversion.go new file mode 100644 index 00000000000..89ed8e5a040 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_conversion.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 v1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Revision) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Revision) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go new file mode 100644 index 00000000000..01df5b62620 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_defaults.go @@ -0,0 +1,102 @@ +/* +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" + "knative.dev/pkg/ptr" + "knative.dev/serving/pkg/apis/config" +) + +// SetDefaults implements apis.Defaultable +func (r *Revision) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults implements apis.Defaultable +func (rts *RevisionTemplateSpec) SetDefaults(ctx context.Context) { + rts.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults implements apis.Defaultable +func (rs *RevisionSpec) SetDefaults(ctx context.Context) { + cfg := config.FromContextOrDefaults(ctx) + + // Default TimeoutSeconds based on our configmap + if rs.TimeoutSeconds == nil || *rs.TimeoutSeconds == 0 { + rs.TimeoutSeconds = ptr.Int64(cfg.Defaults.RevisionTimeoutSeconds) + } + + // Default ContainerConcurrency based on our configmap + if rs.ContainerConcurrency == nil { + rs.ContainerConcurrency = ptr.Int64(cfg.Defaults.ContainerConcurrency) + } + + for idx := range rs.PodSpec.Containers { + if rs.PodSpec.Containers[idx].Name == "" { + rs.PodSpec.Containers[idx].Name = cfg.Defaults.UserContainerName(ctx) + } + + if rs.PodSpec.Containers[idx].Resources.Requests == nil { + rs.PodSpec.Containers[idx].Resources.Requests = corev1.ResourceList{} + } + if _, ok := rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceCPU]; !ok { + if rsrc := cfg.Defaults.RevisionCPURequest; rsrc != nil { + rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceCPU] = *rsrc + } + } + if _, ok := rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceMemory]; !ok { + if rsrc := cfg.Defaults.RevisionMemoryRequest; rsrc != nil { + rs.PodSpec.Containers[idx].Resources.Requests[corev1.ResourceMemory] = *rsrc + } + } + + if rs.PodSpec.Containers[idx].Resources.Limits == nil { + rs.PodSpec.Containers[idx].Resources.Limits = corev1.ResourceList{} + } + if _, ok := rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceCPU]; !ok { + if rsrc := cfg.Defaults.RevisionCPULimit; rsrc != nil { + rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceCPU] = *rsrc + } + } + if _, ok := rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceMemory]; !ok { + if rsrc := cfg.Defaults.RevisionMemoryLimit; rsrc != nil { + rs.PodSpec.Containers[idx].Resources.Limits[corev1.ResourceMemory] = *rsrc + } + } + if rs.PodSpec.Containers[idx].ReadinessProbe == nil { + rs.PodSpec.Containers[idx].ReadinessProbe = &corev1.Probe{} + } + if rs.PodSpec.Containers[idx].ReadinessProbe.TCPSocket == nil && + rs.PodSpec.Containers[idx].ReadinessProbe.HTTPGet == nil && + rs.PodSpec.Containers[idx].ReadinessProbe.Exec == nil { + rs.PodSpec.Containers[idx].ReadinessProbe.TCPSocket = &corev1.TCPSocketAction{} + } + + if rs.PodSpec.Containers[idx].ReadinessProbe.SuccessThreshold == 0 { + rs.PodSpec.Containers[idx].ReadinessProbe.SuccessThreshold = 1 + } + + vms := rs.PodSpec.Containers[idx].VolumeMounts + for i := range vms { + vms[i].ReadOnly = true + } + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go new file mode 100644 index 00000000000..a178edf3538 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go @@ -0,0 +1,55 @@ +/* +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 ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/config" +) + +const ( + // DefaultUserPort is the system default port value exposed on the user-container. + DefaultUserPort = 8080 +) + +var revisionCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Revision) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Revision") +} + +// IsReady returns if the revision is ready to serve the requested configuration. +func (rs *RevisionStatus) IsReady() bool { + return revisionCondSet.Manage(rs).IsHappy() +} + +// GetContainerConcurrency returns the container concurrency. If +// container concurrency is not set, the default value will be returned. +// We use the original default (0) here for backwards compatibility. +// Previous versions of Knative equated unspecified and zero, so to avoid +// changing the value used by Revisions with unspecified values when a different +// default is configured, we use the original default instead of the configured +// default to remain safe across upgrades. +func (rs *RevisionSpec) GetContainerConcurrency() int64 { + if rs.ContainerConcurrency == nil { + return config.DefaultContainerConcurrency + } + return *rs.ContainerConcurrency +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_types.go new file mode 100644 index 00000000000..d4e5deba91e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_types.go @@ -0,0 +1,125 @@ +/* +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 ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "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 + +// Revision is an immutable snapshot of code and configuration. A revision +// references a container image. Revisions are created by updates to a +// Configuration. +// +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#revision +type Revision struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec RevisionSpec `json:"spec,omitempty"` + + // +optional + Status RevisionStatus `json:"status,omitempty"` +} + +// Verify that Revision adheres to the appropriate interfaces. +var ( + // Check that Revision can be validated, can be defaulted, and has immutable fields. + _ apis.Validatable = (*Revision)(nil) + _ apis.Defaultable = (*Revision)(nil) + + // Check that Revision can be converted to higher versions. + _ apis.Convertible = (*Revision)(nil) + + // Check that we can create OwnerReferences to a Revision. + _ kmeta.OwnerRefable = (*Revision)(nil) +) + +// RevisionTemplateSpec describes the data a revision should have when created from a template. +// Based on: https://github.com/kubernetes/api/blob/e771f807/core/v1/types.go#L3179-L3190 +type RevisionTemplateSpec struct { + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec RevisionSpec `json:"spec,omitempty"` +} + +// RevisionSpec holds the desired state of the Revision (from the client). +type RevisionSpec struct { + corev1.PodSpec `json:",inline"` + + // ContainerConcurrency specifies the maximum allowed in-flight (concurrent) + // requests per container of the Revision. Defaults to `0` which means + // concurrency to the application is not limited, and the system decides the + // target concurrency for the autoscaler. + // +optional + ContainerConcurrency *int64 `json:"containerConcurrency,omitempty"` + + // TimeoutSeconds holds the max duration the instance is allowed for + // responding to a request. If unspecified, a system default will + // be provided. + // +optional + TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"` +} + +const ( + // RevisionConditionReady is set when the revision is starting to materialize + // runtime resources, and becomes true when those resources are ready. + RevisionConditionReady = apis.ConditionReady +) + +// RevisionStatus communicates the observed state of the Revision (from the controller). +type RevisionStatus struct { + duckv1.Status `json:",inline"` + + // ServiceName holds the name of a core Kubernetes Service resource that + // load balances over the pods backing this Revision. + // +optional + ServiceName string `json:"serviceName,omitempty"` + + // LogURL specifies the generated logging url for this particular revision + // based on the revision url template specified in the controller's config. + // +optional + LogURL string `json:"logUrl,omitempty"` + + // ImageDigest holds the resolved digest for the image specified + // within .Spec.Container.Image. The digest is resolved during the creation + // of Revision. This field holds the digest value regardless of whether + // a tag or digest was originally specified in the Container object. It + // may be empty if the image comes from a registry listed to skip resolution. + // +optional + ImageDigest string `json:"imageDigest,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RevisionList is a list of Revision resources +type RevisionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Revision `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go new file mode 100644 index 00000000000..d83b3760cb0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_validation.go @@ -0,0 +1,129 @@ +/* +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" + "strings" + + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" + "knative.dev/serving/pkg/apis/autoscaling" + "knative.dev/serving/pkg/apis/serving" +) + +// Validate ensures Revision is properly configured. +func (r *Revision) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).Also( + r.ValidateLabels().ViaField("labels")).ViaField("metadata") + errs = errs.Also(r.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Revision) + if diff, err := kmp.ShortDiff(original.Spec, r.Spec); err != nil { + return &apis.FieldError{ + Message: "Failed to diff Revision", + Paths: []string{"spec"}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: diff, + } + } + } else { + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + return errs +} + +// Validate implements apis.Validatable +func (rts *RevisionTemplateSpec) Validate(ctx context.Context) *apis.FieldError { + errs := rts.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec") + errs = errs.Also(autoscaling.ValidateAnnotations(rts.GetAnnotations()).ViaField("metadata.annotations")) + + // If the RevisionTemplateSpec has a name specified, then check that + // it follows the requirements on the name. + errs = errs.Also(serving.ValidateRevisionName(ctx, rts.Name, rts.GenerateName)) + errs = errs.Also(serving.ValidateQueueSidecarAnnotation(rts.Annotations).ViaField("metadata.annotations")) + return errs +} + +// VerifyNameChange checks that if a user brought their own name previously that it +// changes at the appropriate times. +func (current *RevisionTemplateSpec) VerifyNameChange(ctx context.Context, og RevisionTemplateSpec) *apis.FieldError { + if current.Name == "" { + // We only check that Name changes when the RevisionTemplate changes. + return nil + } + if current.Name != og.Name { + // The name changed, so we're good. + return nil + } + + if diff, err := kmp.ShortDiff(&og, current); err != nil { + return &apis.FieldError{ + Message: "Failed to diff RevisionTemplate", + Paths: []string{apis.CurrentField}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Saw the following changes without a name change (-old +new)", + Paths: []string{"metadata.name"}, + Details: diff, + } + } + return nil +} + +// Validate implements apis.Validatable +func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidatePodSpec(rs.PodSpec) + + if rs.TimeoutSeconds != nil { + errs = errs.Also(serving.ValidateTimeoutSeconds(ctx, *rs.TimeoutSeconds)) + } + + if rs.ContainerConcurrency != nil { + errs = errs.Also(serving.ValidateContainerConcurrency(rs.ContainerConcurrency).ViaField("containerConcurrency")) + } + + return errs +} + +// Validate implements apis.Validatable +func (rs *RevisionStatus) Validate(ctx context.Context) *apis.FieldError { + return nil +} + +// ValidateLabels function validates service labels +func (r *Revision) ValidateLabels() (errs *apis.FieldError) { + for key, val := range r.GetLabels() { + switch { + case key == serving.RouteLabelKey || key == serving.ServiceLabelKey || key == serving.ConfigurationGenerationLabelKey: + case key == serving.ConfigurationLabelKey: + errs = errs.Also(verifyLabelOwnerRef(val, serving.ConfigurationLabelKey, "Configuration", r.GetOwnerReferences())) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, "")) + } + } + return +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_conversion.go new file mode 100644 index 00000000000..7ef3cb1ae51 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_conversion.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 v1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Route) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Route) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_defaults.go new file mode 100644 index 00000000000..55bcc825f56 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_defaults.go @@ -0,0 +1,58 @@ +/* +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" + + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" + "knative.dev/serving/pkg/apis/serving" +) + +// SetDefaults implements apis.Defaultable +func (r *Route) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) + if r.GetOwnerReferences() == nil { + if apis.IsInUpdate(ctx) { + serving.SetUserInfo(ctx, apis.GetBaseline(ctx).(*Route).Spec, r.Spec, r) + } else { + serving.SetUserInfo(ctx, nil, r.Spec, r) + } + } +} + +// SetDefaults implements apis.Defaultable +func (rs *RouteSpec) SetDefaults(ctx context.Context) { + if len(rs.Traffic) == 0 && HasDefaultConfigurationName(ctx) { + rs.Traffic = []TrafficTarget{{ + Percent: ptr.Int64(100), + LatestRevision: ptr.Bool(true), + }} + } + + for idx := range rs.Traffic { + rs.Traffic[idx].SetDefaults(ctx) + } +} + +// SetDefaults implements apis.Defaultable +func (tt *TrafficTarget) SetDefaults(ctx context.Context) { + if tt.LatestRevision == nil { + tt.LatestRevision = ptr.Bool(tt.RevisionName == "") + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_lifecycle.go new file mode 100644 index 00000000000..7b4094b12fa --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_lifecycle.go @@ -0,0 +1,35 @@ +/* +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 ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" +) + +var routeCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Route) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Route") +} + +// IsReady returns if the route is ready to serve the requested configuration. +func (rs *RouteStatus) IsReady() bool { + return routeCondSet.Manage(rs).IsHappy() +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_types.go new file mode 100644 index 00000000000..6a8eed1bb02 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_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 v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "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 + +// Route is responsible for configuring ingress over a collection of Revisions. +// Some of the Revisions a Route distributes traffic over may be specified by +// referencing the Configuration responsible for creating them; in these cases +// the Route is additionally responsible for monitoring the Configuration for +// "latest ready revision" changes, and smoothly rolling out latest revisions. +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#route +type Route struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Route (from the client). + // +optional + Spec RouteSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Route (from the controller). + // +optional + Status RouteStatus `json:"status,omitempty"` +} + +// Verify that Route adheres to the appropriate interfaces. +var ( + // Check that Route may be validated and defaulted. + _ apis.Validatable = (*Route)(nil) + _ apis.Defaultable = (*Route)(nil) + + // Check that Route can be converted to higher versions. + _ apis.Convertible = (*Route)(nil) + + // Check that we can create OwnerReferences to a Route. + _ kmeta.OwnerRefable = (*Route)(nil) +) + +// TrafficTarget holds a single entry of the routing table for a Route. +type TrafficTarget struct { + // Tag is optionally used to expose a dedicated url for referencing + // this target exclusively. + // +optional + Tag string `json:"tag,omitempty"` + + // RevisionName of a specific revision to which to send this portion of + // traffic. This is mutually exclusive with ConfigurationName. + // +optional + RevisionName string `json:"revisionName,omitempty"` + + // ConfigurationName of a configuration to whose latest revision we will send + // this portion of traffic. When the "status.latestReadyRevisionName" of the + // referenced configuration changes, we will automatically migrate traffic + // from the prior "latest ready" revision to the new one. This field is never + // set in Route's status, only its spec. This is mutually exclusive with + // RevisionName. + // +optional + ConfigurationName string `json:"configurationName,omitempty"` + + // LatestRevision may be optionally provided to indicate that the latest + // ready Revision of the Configuration should be used for this traffic + // target. When provided LatestRevision must be true if RevisionName is + // empty; it must be false when RevisionName is non-empty. + // +optional + LatestRevision *bool `json:"latestRevision,omitempty"` + + // Percent indicates that percentage based routing should be used and + // the value indicates the percent of traffic that is be routed to this + // Revision or Configuration. `0` (zero) mean no traffic, `100` means all + // traffic. + // When percentage based routing is being used the follow rules apply: + // - the sum of all percent values must equal 100 + // - when not specified, the implied value for `percent` is zero for + // that particular Revision or Configuration + // +optional + Percent *int64 `json:"percent,omitempty"` + + // URL displays the URL for accessing named traffic targets. URL is displayed in + // status, and is disallowed on spec. URL must contain a scheme (e.g. http://) and + // a hostname, but may not contain anything else (e.g. basic auth, url path, etc.) + // +optional + URL *apis.URL `json:"url,omitempty"` +} + +// RouteSpec holds the desired state of the Route (from the client). +type RouteSpec struct { + // Traffic specifies how to distribute traffic over a collection of + // revisions and configurations. + // +optional + Traffic []TrafficTarget `json:"traffic,omitempty"` +} + +const ( + // RouteConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + RouteConditionReady = apis.ConditionReady +) + +// RouteStatusFields holds the fields of Route's status that +// are not generally shared. This is defined separately and inlined so that +// other types can readily consume these fields via duck typing. +type RouteStatusFields struct { + // URL holds the url that will distribute traffic over the provided traffic targets. + // It generally has the form http[s]://{route-name}.{route-namespace}.{cluster-level-suffix} + // +optional + URL *apis.URL `json:"url,omitempty"` + + // Address holds the information needed for a Route to be the target of an event. + // +optional + Address *duckv1.Addressable `json:"address,omitempty"` + + // Traffic holds the configured traffic distribution. + // These entries will always contain RevisionName references. + // When ConfigurationName appears in the spec, this will hold the + // LatestReadyRevisionName that we last observed. + // +optional + Traffic []TrafficTarget `json:"traffic,omitempty"` +} + +// RouteStatus communicates the observed state of the Route (from the controller). +type RouteStatus struct { + duckv1.Status `json:",inline"` + + RouteStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RouteList is a list of Route resources +type RouteList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Route `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go new file mode 100644 index 00000000000..ec7843dac71 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/route_validation.go @@ -0,0 +1,226 @@ +/* +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" + "fmt" + "strings" + + "k8s.io/apimachinery/pkg/util/validation" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" + "knative.dev/serving/pkg/reconciler/route/config" +) + +// Validate makes sure that Route is properly configured. +func (r *Route) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).Also( + r.validateLabels().ViaField("labels")).ViaField("metadata") + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + errs = errs.Also(r.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Route) + // Don't validate annotations(creator and lastModifier) when route owned by service + // validate only when route created independently. + if r.OwnerReferences == nil { + errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, r.Spec, original.GetAnnotations(), + r.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations")) + } + } + return errs +} + +func validateTrafficList(ctx context.Context, traffic []TrafficTarget) *apis.FieldError { + var errs *apis.FieldError + + // Track the targets of named TrafficTarget entries (to detect duplicates). + trafficMap := make(map[string]int) + + sum := int64(0) + for i, tt := range traffic { + errs = errs.Also(tt.Validate(ctx).ViaIndex(i)) + + if tt.Percent != nil { + sum += *tt.Percent + } + + if tt.Tag == "" { + continue + } + + if idx, ok := trafficMap[tt.Tag]; ok { + // We want only single definition of the route, even if it points + // to the same config or revision. + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Multiple definitions for %q", tt.Tag), + Paths: []string{ + fmt.Sprintf("[%d].tag", i), + fmt.Sprintf("[%d].tag", idx), + }, + }) + } else { + trafficMap[tt.Tag] = i + } + } + + if sum != 100 { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Traffic targets sum to %d, want 100", sum), + Paths: []string{apis.CurrentField}, + }) + } + return errs +} + +// Validate implements apis.Validatable +func (rs *RouteSpec) Validate(ctx context.Context) *apis.FieldError { + return validateTrafficList(ctx, rs.Traffic).ViaField("traffic") +} + +// Validate verifies that TrafficTarget is properly configured. +func (tt *TrafficTarget) Validate(ctx context.Context) *apis.FieldError { + errs := tt.validateLatestRevision(ctx) + errs = tt.validateRevisionAndConfiguration(ctx, errs) + errs = tt.validateTrafficPercentage(errs) + return tt.validateURL(ctx, errs) +} + +func (tt *TrafficTarget) validateRevisionAndConfiguration(ctx context.Context, errs *apis.FieldError) *apis.FieldError { + // We only validate the sense of latestRevision in the context of a Spec, + // and only when it is specified. + switch { + // When we have a default configurationName, we don't + // allow one to be specified. + case HasDefaultConfigurationName(ctx) && tt.ConfigurationName != "": + errs = errs.Also(apis.ErrDisallowedFields("configurationName")) + + // Both revisionName and configurationName are never allowed to + // appear concurrently. + case tt.RevisionName != "" && tt.ConfigurationName != "": + errs = errs.Also(apis.ErrMultipleOneOf( + "revisionName", "configurationName")) + + // When a revisionName appears, we must check that the name is valid. + case tt.RevisionName != "": + if el := validation.IsQualifiedName(tt.RevisionName); len(el) > 0 { + errs = errs.Also(apis.ErrInvalidKeyName( + tt.RevisionName, "revisionName", el...)) + } + + // When revisionName is missing in Status report an error. + case apis.IsInStatus(ctx): + errs = errs.Also(apis.ErrMissingField("revisionName")) + + // When configurationName is specified, we must check that the name is valid. + case tt.ConfigurationName != "": + if el := validation.IsQualifiedName(tt.ConfigurationName); len(el) > 0 { + errs = errs.Also(apis.ErrInvalidKeyName( + tt.ConfigurationName, "configurationName", el...)) + } + + // When we are using a default configurationName, it must be a valid name already. + case HasDefaultConfigurationName(ctx): + + // All other cases are missing one of revisionName or configurationName. + default: + errs = errs.Also(apis.ErrMissingOneOf( + "revisionName", "configurationName")) + } + return errs +} + +func (tt *TrafficTarget) validateTrafficPercentage(errs *apis.FieldError) *apis.FieldError { + // Check that the traffic Percentage is within bounds. + if tt.Percent != nil && (*tt.Percent < 0 || *tt.Percent > 100) { + errs = errs.Also(apis.ErrOutOfBoundsValue( + *tt.Percent, 0, 100, "percent")) + } + return errs +} + +func (tt *TrafficTarget) validateLatestRevision(ctx context.Context) *apis.FieldError { + if apis.IsInSpec(ctx) && tt.LatestRevision != nil { + lr := *tt.LatestRevision + pinned := tt.RevisionName != "" + if pinned == lr { + // The senses for whether to pin to a particular revision or + // float forward to the latest revision must match. + return apis.ErrGeneric(fmt.Sprintf("may not set revisionName %q when latestRevision is %t", tt.RevisionName, lr), "latestRevision") + } + } + return nil +} + +func (tt *TrafficTarget) validateURL(ctx context.Context, errs *apis.FieldError) *apis.FieldError { + // Check that we set the URL appropriately. + if tt.URL.String() != "" { + // URL is not allowed in traffic under spec. + if apis.IsInSpec(ctx) { + errs = errs.Also(apis.ErrDisallowedFields("url")) + } + + // URL is not allowed in any traffic target without a name. + if tt.Tag == "" { + errs = errs.Also(apis.ErrDisallowedFields("url")) + } + } else if tt.Tag != "" { + // URL must be specified in status when name is specified. + if apis.IsInStatus(ctx) { + errs = errs.Also(apis.ErrMissingField("url")) + } + } + return errs +} + +// Validate implements apis.Validatable. +func (rs *RouteStatus) Validate(ctx context.Context) *apis.FieldError { + return rs.RouteStatusFields.Validate(ctx) +} + +// Validate implements apis.Validatable. +func (rsf *RouteStatusFields) Validate(ctx context.Context) *apis.FieldError { + // TODO(mattmoor): Validate other status fields. + + if len(rsf.Traffic) != 0 { + return validateTrafficList(ctx, rsf.Traffic).ViaField("traffic") + } + return nil +} + +func validateClusterVisibilityLabel(label string) (errs *apis.FieldError) { + if label != config.VisibilityClusterLocal { + errs = apis.ErrInvalidValue(label, config.VisibilityLabelKey) + } + return +} + +// validateLabels function validates route labels. +func (r *Route) validateLabels() (errs *apis.FieldError) { + for key, val := range r.GetLabels() { + switch { + case key == config.VisibilityLabelKey: + errs = errs.Also(validateClusterVisibilityLabel(val)) + case key == serving.ServiceLabelKey: + errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", r.GetOwnerReferences())) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_conversion.go new file mode 100644 index 00000000000..efb6605f338 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_conversion.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 v1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Service) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Service) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_defaults.go new file mode 100644 index 00000000000..095ca9c4569 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_defaults.go @@ -0,0 +1,42 @@ +/* +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" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +// SetDefaults implements apis.Defaultable +func (s *Service) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, s.ObjectMeta) + s.Spec.SetDefaults(apis.WithinSpec(ctx)) + + if apis.IsInUpdate(ctx) { + serving.SetUserInfo(ctx, apis.GetBaseline(ctx).(*Service).Spec, s.Spec, s) + } else { + serving.SetUserInfo(ctx, nil, s.Spec, s) + } +} + +// SetDefaults implements apis.Defaultable +func (ss *ServiceSpec) SetDefaults(ctx context.Context) { + ss.ConfigurationSpec.SetDefaults(ctx) + ss.RouteSpec.SetDefaults(WithDefaultConfigurationName(ctx)) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_lifecycle.go new file mode 100644 index 00000000000..f842245478a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_lifecycle.go @@ -0,0 +1,35 @@ +/* +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 ( + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" +) + +var serviceCondSet = apis.NewLivingConditionSet() + +// GetGroupVersionKind returns the GroupVersionKind. +func (s *Service) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Service") +} + +// IsReady returns if the service is ready to serve the requested configuration. +func (ss *ServiceStatus) IsReady() bool { + return serviceCondSet.Manage(ss).IsHappy() +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_types.go new file mode 100644 index 00000000000..0fa860b600d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_types.go @@ -0,0 +1,113 @@ +/* +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 ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "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 + +// Service acts as a top-level container that manages a Route and Configuration +// which implement a network service. Service exists to provide a singular +// abstraction which can be access controlled, reasoned about, and which +// encapsulates software lifecycle decisions such as rollout policy and +// team resource ownership. Service acts only as an orchestrator of the +// underlying Routes and Configurations (much as a kubernetes Deployment +// orchestrates ReplicaSets), and its usage is optional but recommended. +// +// The Service's controller will track the statuses of its owned Configuration +// and Route, reflecting their statuses and conditions as its own. +// +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#service +type Service struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec ServiceSpec `json:"spec,omitempty"` + + // +optional + Status ServiceStatus `json:"status,omitempty"` +} + +// Verify that Service adheres to the appropriate interfaces. +var ( + // Check that Service may be validated and defaulted. + _ apis.Validatable = (*Service)(nil) + _ apis.Defaultable = (*Service)(nil) + + // Check that Service can be converted to higher versions. + _ apis.Convertible = (*Service)(nil) + + // Check that we can create OwnerReferences to a Service. + _ kmeta.OwnerRefable = (*Service)(nil) +) + +// ServiceSpec represents the configuration for the Service object. +// A Service's specification is the union of the specifications for a Route +// and Configuration. The Service restricts what can be expressed in these +// fields, e.g. the Route must reference the provided Configuration; +// however, these limitations also enable friendlier defaulting, +// e.g. Route never needs a Configuration name, and may be defaulted to +// the appropriate "run latest" spec. +type ServiceSpec struct { + // ServiceSpec inlines an unrestricted ConfigurationSpec. + ConfigurationSpec `json:",inline"` + + // ServiceSpec inlines RouteSpec and restricts/defaults its fields + // via webhook. In particular, this spec can only reference this + // Service's configuration and revisions (which also influences + // defaults). + RouteSpec `json:",inline"` +} + +// ConditionType represents a Service condition value +const ( + // ServiceConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + ServiceConditionReady = apis.ConditionReady +) + +// ServiceStatus represents the Status stanza of the Service resource. +type ServiceStatus struct { + duckv1.Status `json:",inline"` + + // In addition to inlining ConfigurationSpec, we also inline the fields + // specific to ConfigurationStatus. + ConfigurationStatusFields `json:",inline"` + + // In addition to inlining RouteSpec, we also inline the fields + // specific to RouteStatus. + RouteStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ServiceList is a list of Service resources +type ServiceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Service `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.go new file mode 100644 index 00000000000..bbe5477bc8c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/service_validation.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 v1 + +import ( + "context" + "strings" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" + "knative.dev/serving/pkg/reconciler/route/config" +) + +// Validate makes sure that Service is properly configured. +func (s *Service) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(s.GetObjectMeta()).Also( + s.validateLabels().ViaField("labels")).ViaField("metadata")) + ctx = apis.WithinParent(ctx, s.ObjectMeta) + errs = errs.Also(s.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + errs = errs.Also(s.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Service) + errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, s.Spec, original.GetAnnotations(), + s.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations")) + err := s.Spec.ConfigurationSpec.Template.VerifyNameChange(ctx, + original.Spec.ConfigurationSpec.Template) + errs = errs.Also(err.ViaField("spec.template")) + } + return errs +} + +// Validate implements apis.Validatable +func (ss *ServiceSpec) Validate(ctx context.Context) *apis.FieldError { + return ss.ConfigurationSpec.Validate(ctx).Also( + // Within the context of Service, the RouteSpec has a default + // configurationName. + ss.RouteSpec.Validate(WithDefaultConfigurationName(ctx))) +} + +// Validate implements apis.Validatable +func (ss *ServiceStatus) Validate(ctx context.Context) *apis.FieldError { + return ss.ConfigurationStatusFields.Validate(ctx).Also( + ss.RouteStatusFields.Validate(ctx)) +} + +// validateLabels function validates service labels +func (s *Service) validateLabels() (errs *apis.FieldError) { + for key, val := range s.GetLabels() { + switch { + case key == config.VisibilityLabelKey: + errs = errs.Also(validateClusterVisibilityLabel(val)) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..bfff38f1978 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/zz_generated.deepcopy.go @@ -0,0 +1,526 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 v1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" + 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. +func (in *Configuration) DeepCopyInto(out *Configuration) { + *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 Configuration. +func (in *Configuration) DeepCopy() *Configuration { + if in == nil { + return nil + } + out := new(Configuration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Configuration) 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 *ConfigurationList) DeepCopyInto(out *ConfigurationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Configuration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationList. +func (in *ConfigurationList) DeepCopy() *ConfigurationList { + if in == nil { + return nil + } + out := new(ConfigurationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ConfigurationList) 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 *ConfigurationSpec) DeepCopyInto(out *ConfigurationSpec) { + *out = *in + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationSpec. +func (in *ConfigurationSpec) DeepCopy() *ConfigurationSpec { + if in == nil { + return nil + } + out := new(ConfigurationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationStatus) DeepCopyInto(out *ConfigurationStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + out.ConfigurationStatusFields = in.ConfigurationStatusFields + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationStatus. +func (in *ConfigurationStatus) DeepCopy() *ConfigurationStatus { + if in == nil { + return nil + } + out := new(ConfigurationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationStatusFields) DeepCopyInto(out *ConfigurationStatusFields) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationStatusFields. +func (in *ConfigurationStatusFields) DeepCopy() *ConfigurationStatusFields { + if in == nil { + return nil + } + out := new(ConfigurationStatusFields) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Revision) DeepCopyInto(out *Revision) { + *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 Revision. +func (in *Revision) DeepCopy() *Revision { + if in == nil { + return nil + } + out := new(Revision) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Revision) 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 *RevisionList) DeepCopyInto(out *RevisionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Revision, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionList. +func (in *RevisionList) DeepCopy() *RevisionList { + if in == nil { + return nil + } + out := new(RevisionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RevisionList) 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 *RevisionSpec) DeepCopyInto(out *RevisionSpec) { + *out = *in + in.PodSpec.DeepCopyInto(&out.PodSpec) + if in.ContainerConcurrency != nil { + in, out := &in.ContainerConcurrency, &out.ContainerConcurrency + *out = new(int64) + **out = **in + } + if in.TimeoutSeconds != nil { + in, out := &in.TimeoutSeconds, &out.TimeoutSeconds + *out = new(int64) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionSpec. +func (in *RevisionSpec) DeepCopy() *RevisionSpec { + if in == nil { + return nil + } + out := new(RevisionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionStatus) DeepCopyInto(out *RevisionStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionStatus. +func (in *RevisionStatus) DeepCopy() *RevisionStatus { + if in == nil { + return nil + } + out := new(RevisionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionTemplateSpec) DeepCopyInto(out *RevisionTemplateSpec) { + *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 RevisionTemplateSpec. +func (in *RevisionTemplateSpec) DeepCopy() *RevisionTemplateSpec { + if in == nil { + return nil + } + out := new(RevisionTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Route) DeepCopyInto(out *Route) { + *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 Route. +func (in *Route) DeepCopy() *Route { + if in == nil { + return nil + } + out := new(Route) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Route) 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 *RouteList) DeepCopyInto(out *RouteList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Route, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteList. +func (in *RouteList) DeepCopy() *RouteList { + if in == nil { + return nil + } + out := new(RouteList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RouteList) 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 *RouteSpec) DeepCopyInto(out *RouteSpec) { + *out = *in + if in.Traffic != nil { + in, out := &in.Traffic, &out.Traffic + *out = make([]TrafficTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteSpec. +func (in *RouteSpec) DeepCopy() *RouteSpec { + if in == nil { + return nil + } + out := new(RouteSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteStatus) DeepCopyInto(out *RouteStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatus. +func (in *RouteStatus) DeepCopy() *RouteStatus { + if in == nil { + return nil + } + out := new(RouteStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteStatusFields) DeepCopyInto(out *RouteStatusFields) { + *out = *in + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + if in.Address != nil { + in, out := &in.Address, &out.Address + *out = new(duckv1.Addressable) + (*in).DeepCopyInto(*out) + } + if in.Traffic != nil { + in, out := &in.Traffic, &out.Traffic + *out = make([]TrafficTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatusFields. +func (in *RouteStatusFields) DeepCopy() *RouteStatusFields { + if in == nil { + return nil + } + out := new(RouteStatusFields) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Service) DeepCopyInto(out *Service) { + *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 Service. +func (in *Service) DeepCopy() *Service { + if in == nil { + return nil + } + out := new(Service) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Service) 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 *ServiceList) DeepCopyInto(out *ServiceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Service, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceList. +func (in *ServiceList) DeepCopy() *ServiceList { + if in == nil { + return nil + } + out := new(ServiceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServiceList) 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 *ServiceSpec) DeepCopyInto(out *ServiceSpec) { + *out = *in + in.ConfigurationSpec.DeepCopyInto(&out.ConfigurationSpec) + in.RouteSpec.DeepCopyInto(&out.RouteSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSpec. +func (in *ServiceSpec) DeepCopy() *ServiceSpec { + if in == nil { + return nil + } + out := new(ServiceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceStatus) DeepCopyInto(out *ServiceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + out.ConfigurationStatusFields = in.ConfigurationStatusFields + in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceStatus. +func (in *ServiceStatus) DeepCopy() *ServiceStatus { + if in == nil { + return nil + } + out := new(ServiceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TrafficTarget) DeepCopyInto(out *TrafficTarget) { + *out = *in + if in.LatestRevision != nil { + in, out := &in.LatestRevision, &out.LatestRevision + *out = new(bool) + **out = **in + } + if in.Percent != nil { + in, out := &in.Percent, &out.Percent + *out = new(int64) + **out = **in + } + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficTarget. +func (in *TrafficTarget) DeepCopy() *TrafficTarget { + if in == nil { + return nil + } + out := new(TrafficTarget) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go new file mode 100644 index 00000000000..a7d804a293c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_conversion.go @@ -0,0 +1,117 @@ +/* +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" + + "knative.dev/pkg/apis" + v1 "knative.dev/serving/pkg/apis/serving/v1" + "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// ConvertUp implements apis.Convertible +func (source *Configuration) ConvertUp(ctx context.Context, obj apis.Convertible) error { + switch sink := obj.(type) { + case *v1beta1.Configuration: + sink.ObjectMeta = source.ObjectMeta + if err := source.Spec.ConvertUp(ctx, &sink.Spec); err != nil { + return err + } + return source.Status.ConvertUp(ctx, &sink.Status) + case *v1.Configuration: + sink.ObjectMeta = source.ObjectMeta + if err := source.Spec.ConvertUp(ctx, &sink.Spec); err != nil { + return err + } + return source.Status.ConvertUp(ctx, &sink.Status) + default: + return fmt.Errorf("unknown version, got: %T", sink) + } +} + +// ConvertUp helps implement apis.Convertible +func (source *ConfigurationSpec) ConvertUp(ctx context.Context, sink *v1.ConfigurationSpec) error { + if source.DeprecatedBuild != nil { + return ConvertErrorf("build", "build cannot be migrated forward.") + } + switch { + case source.DeprecatedRevisionTemplate != nil && source.Template != nil: + return apis.ErrMultipleOneOf("revisionTemplate", "template") + case source.DeprecatedRevisionTemplate != nil: + return source.DeprecatedRevisionTemplate.ConvertUp(ctx, &sink.Template) + case source.Template != nil: + return source.Template.ConvertUp(ctx, &sink.Template) + default: + return apis.ErrMissingOneOf("revisionTemplate", "template") + } +} + +// ConvertUp helps implement apis.Convertible +func (source *ConfigurationStatus) ConvertUp(ctx context.Context, sink *v1.ConfigurationStatus) error { + source.Status.ConvertTo(ctx, &sink.Status) + + return source.ConfigurationStatusFields.ConvertUp(ctx, &sink.ConfigurationStatusFields) +} + +// ConvertUp helps implement apis.Convertible +func (source *ConfigurationStatusFields) ConvertUp(ctx context.Context, sink *v1.ConfigurationStatusFields) error { + sink.LatestReadyRevisionName = source.LatestReadyRevisionName + sink.LatestCreatedRevisionName = source.LatestCreatedRevisionName + return nil +} + +// ConvertDown implements apis.Convertible +func (sink *Configuration) ConvertDown(ctx context.Context, obj apis.Convertible) error { + switch source := obj.(type) { + case *v1beta1.Configuration: + sink.ObjectMeta = source.ObjectMeta + if err := sink.Spec.ConvertDown(ctx, source.Spec); err != nil { + return err + } + return sink.Status.ConvertDown(ctx, source.Status) + case *v1.Configuration: + sink.ObjectMeta = source.ObjectMeta + if err := sink.Spec.ConvertDown(ctx, source.Spec); err != nil { + return err + } + return sink.Status.ConvertDown(ctx, source.Status) + default: + return fmt.Errorf("unknown version, got: %T", source) + } +} + +// ConvertDown helps implement apis.Convertible +func (sink *ConfigurationSpec) ConvertDown(ctx context.Context, source v1.ConfigurationSpec) error { + sink.Template = &RevisionTemplateSpec{} + return sink.Template.ConvertDown(ctx, source.Template) +} + +// ConvertDown helps implement apis.Convertible +func (sink *ConfigurationStatus) ConvertDown(ctx context.Context, source v1.ConfigurationStatus) error { + source.Status.ConvertTo(ctx, &sink.Status) + + return sink.ConfigurationStatusFields.ConvertDown(ctx, source.ConfigurationStatusFields) +} + +// ConvertDown helps implement apis.Convertible +func (sink *ConfigurationStatusFields) ConvertDown(ctx context.Context, source v1.ConfigurationStatusFields) error { + sink.LatestReadyRevisionName = source.LatestReadyRevisionName + sink.LatestCreatedRevisionName = source.LatestCreatedRevisionName + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go new file mode 100644 index 00000000000..56ef58c0622 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_defaults.go @@ -0,0 +1,52 @@ +/* +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 v1alpha1 + +import ( + "context" + + "knative.dev/pkg/apis" + + "knative.dev/serving/pkg/apis/serving" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +func (c *Configuration) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, c.ObjectMeta) + c.Spec.SetDefaults(apis.WithinSpec(ctx)) + if c.GetOwnerReferences() == nil { + if apis.IsInUpdate(ctx) { + serving.SetUserInfo(ctx, apis.GetBaseline(ctx).(*Configuration).Spec, c.Spec, c) + } else { + serving.SetUserInfo(ctx, nil, c.Spec, c) + } + } +} + +func (cs *ConfigurationSpec) SetDefaults(ctx context.Context) { + if v1.IsUpgradeViaDefaulting(ctx) { + v := v1.ConfigurationSpec{} + if cs.ConvertUp(ctx, &v) == nil { + alpha := ConfigurationSpec{} + if alpha.ConvertDown(ctx, v) == nil { + *cs = alpha + } + } + } + + cs.GetTemplate().SetDefaults(ctx) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go new file mode 100644 index 00000000000..25d532de587 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_lifecycle.go @@ -0,0 +1,119 @@ +/* +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" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +var confCondSet = apis.NewLivingConditionSet() + +func (r *Configuration) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Configuration") +} + +// MarkResourceNotConvertible adds a Warning-severity condition to the resource noting that +// it cannot be converted to a higher version. +func (cs *ConfigurationStatus) MarkResourceNotConvertible(err *CannotConvertError) { + confCondSet.Manage(cs).SetCondition(apis.Condition{ + Type: ConditionTypeConvertible, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityWarning, + Reason: err.Field, + Message: err.Message, + }) +} + +// GetTemplate returns a pointer to the relevant RevisionTemplateSpec field. +// It is never nil and should be exactly the specified template as guaranteed +// by validation. +func (cs *ConfigurationSpec) GetTemplate() *RevisionTemplateSpec { + if cs.DeprecatedRevisionTemplate != nil { + return cs.DeprecatedRevisionTemplate + } + if cs.Template != nil { + return cs.Template + } + // Should be unreachable post-validation, but here to ease testing. + return &RevisionTemplateSpec{} +} + +// IsReady looks at the conditions to see if they are happy. +func (cs *ConfigurationStatus) IsReady() bool { + return confCondSet.Manage(cs).IsHappy() +} + +// IsLatestReadyRevisionNameUpToDate returns true if the Configuration is ready +// and LatestCreateRevisionName is equal to LatestReadyRevisionName. Otherwise +// it returns false. +func (cs *ConfigurationStatus) IsLatestReadyRevisionNameUpToDate() bool { + return cs.IsReady() && + cs.LatestCreatedRevisionName == cs.LatestReadyRevisionName +} + +func (cs *ConfigurationStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return confCondSet.Manage(cs).GetCondition(t) +} + +func (cs *ConfigurationStatus) InitializeConditions() { + confCondSet.Manage(cs).InitializeConditions() +} + +func (cs *ConfigurationStatus) SetLatestCreatedRevisionName(name string) { + cs.LatestCreatedRevisionName = name + if cs.LatestReadyRevisionName != name { + confCondSet.Manage(cs).MarkUnknown( + ConfigurationConditionReady, + "", + "") + } +} + +func (cs *ConfigurationStatus) SetLatestReadyRevisionName(name string) { + cs.LatestReadyRevisionName = name + if cs.LatestReadyRevisionName == cs.LatestCreatedRevisionName { + confCondSet.Manage(cs).MarkTrue(ConfigurationConditionReady) + } +} + +func (cs *ConfigurationStatus) MarkLatestCreatedFailed(name, message string) { + confCondSet.Manage(cs).MarkFalse( + ConfigurationConditionReady, + "RevisionFailed", + "Revision %q failed with message: %s.", name, message) +} + +func (cs *ConfigurationStatus) MarkRevisionCreationFailed(message string) { + confCondSet.Manage(cs).MarkFalse( + ConfigurationConditionReady, + "RevisionFailed", + "Revision creation failed with message: %s.", message) +} + +func (cs *ConfigurationStatus) MarkLatestReadyDeleted() { + confCondSet.Manage(cs).MarkFalse( + ConfigurationConditionReady, + "RevisionDeleted", + "Revision %q was deleted.", cs.LatestReadyRevisionName) +} + +func (cs *ConfigurationStatus) duck() *duckv1.Status { + return &cs.Status +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_types.go new file mode 100644 index 00000000000..0bc29f921fa --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_types.go @@ -0,0 +1,131 @@ +/* +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 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" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Configuration represents the "floating HEAD" of a linear history of Revisions, +// and optionally how the containers those revisions reference are built. +// Users create new Revisions by updating the Configuration's spec. +// The "latest created" revision's name is available under status, as is the +// "latest ready" revision's name. +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#configuration +type Configuration struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Configuration (from the client). + // +optional + Spec ConfigurationSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Configuration (from the controller). + // +optional + Status ConfigurationStatus `json:"status,omitempty"` +} + +// Verify that Configuration adheres to the appropriate interfaces. +var ( + // Check that Configuration may be validated and defaulted. + _ apis.Validatable = (*Configuration)(nil) + _ apis.Defaultable = (*Configuration)(nil) + + // Check that Configuration can be converted to higher versions. + _ apis.Convertible = (*Configuration)(nil) + + // Check that we can create OwnerReferences to a Configuration. + _ kmeta.OwnerRefable = (*Configuration)(nil) +) + +// ConfigurationSpec holds the desired state of the Configuration (from the client). +type ConfigurationSpec struct { + // DeprecatedGeneration was used prior in Kubernetes versions <1.11 + // when metadata.generation was not being incremented by the api server + // + // This property will be dropped in future Knative releases and should + // not be used - use metadata.generation + // + // Tracking issue: https://github.com/knative/serving/issues/643 + // + // +optional + DeprecatedGeneration int64 `json:"generation,omitempty"` + + // Build optionally holds the specification for the build to + // perform to produce the Revision's container image. + // +optional + DeprecatedBuild *runtime.RawExtension `json:"build,omitempty"` + + // DeprecatedRevisionTemplate holds the latest specification for the Revision to + // be stamped out. If a Build specification is provided, then the + // DeprecatedRevisionTemplate's BuildName field will be populated with the name of + // the Build object created to produce the container for the Revision. + // DEPRECATED Use Template instead. + // +optional + DeprecatedRevisionTemplate *RevisionTemplateSpec `json:"revisionTemplate,omitempty"` + + // Template holds the latest specification for the Revision to + // be stamped out. + // +optional + Template *RevisionTemplateSpec `json:"template,omitempty"` +} + +const ( + // ConfigurationConditionReady is set when the configuration's latest + // underlying revision has reported readiness. + ConfigurationConditionReady = apis.ConditionReady +) + +// ConfigurationStatusFields holds all of the non-duckv1.Status status fields of a Route. +// These are defined outline so that we can also inline them into Service, and more easily +// copy them. +type ConfigurationStatusFields struct { + // LatestReadyRevisionName holds the name of the latest Revision stamped out + // from this Configuration that has had its "Ready" condition become "True". + // +optional + LatestReadyRevisionName string `json:"latestReadyRevisionName,omitempty"` + + // LatestCreatedRevisionName is the last revision that was created from this + // Configuration. It might not be ready yet, for that use LatestReadyRevisionName. + // +optional + LatestCreatedRevisionName string `json:"latestCreatedRevisionName,omitempty"` +} + +// ConfigurationStatus communicates the observed state of the Configuration (from the controller). +type ConfigurationStatus struct { + duckv1.Status `json:",inline"` + + ConfigurationStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ConfigurationList is a list of Configuration resources +type ConfigurationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Configuration `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_validation.go new file mode 100644 index 00000000000..2704da20b87 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/configuration_validation.go @@ -0,0 +1,84 @@ +/* +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 v1alpha1 + +import ( + "context" + + "k8s.io/apimachinery/pkg/api/equality" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +// Validate makes sure that Configuration is properly configured. +func (c *Configuration) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(c.GetObjectMeta()).ViaField("metadata")) + ctx = apis.WithinParent(ctx, c.ObjectMeta) + errs = errs.Also(c.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Configuration) + // Don't validate annotations(creator and lastModifier) when configuration owned by service + // validate only when configuration created independently. + if c.GetOwnerReferences() == nil { + errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, c.Spec, original.GetAnnotations(), + c.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations")) + } + err := c.Spec.GetTemplate().VerifyNameChange(ctx, + original.Spec.GetTemplate()) + errs = errs.Also(err.ViaField("spec.revisionTemplate")) + } + + return errs +} + +// Validate makes sure that ConfigurationSpec is properly configured. +func (cs *ConfigurationSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(cs, &ConfigurationSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + + errs := apis.CheckDeprecated(ctx, cs) + + // Build support is now disabled. + if cs.DeprecatedBuild != nil { + errs = errs.Also(apis.ErrDisallowedFields("build")) + } + + var templateField string + switch { + case cs.DeprecatedRevisionTemplate != nil && cs.Template != nil: + return apis.ErrMultipleOneOf("revisionTemplate", "template") + case cs.DeprecatedRevisionTemplate != nil: + templateField = "revisionTemplate" + case cs.Template != nil: + templateField = "template" + // Disallow the use of deprecated fields under "template". + ctx = apis.DisallowDeprecated(ctx) + default: + return apis.ErrMissingOneOf("revisionTemplate", "template") + } + + return errs.Also(cs.GetTemplate().Validate(ctx).ViaField(templateField)) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/conversion_error.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/conversion_error.go new file mode 100644 index 00000000000..ddad8e3b225 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/conversion_error.go @@ -0,0 +1,51 @@ +/* +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 ( + "fmt" + + "knative.dev/pkg/apis" +) + +const ( + // ConditionTypeConvertible is a Warning condition that is set on + // resources when they cannot be converted to warn of a forthcoming + // breakage. + ConditionTypeConvertible apis.ConditionType = "Convertible" +) + +// CannotConvertError is returned when a field cannot be converted. +type CannotConvertError struct { + Message string + Field string +} + +var _ error = (*CannotConvertError)(nil) + +// Error implements error +func (cce *CannotConvertError) Error() string { + return cce.Message +} + +// ConvertErrorf creates a CannotConvertError from the field name and format string. +func ConvertErrorf(field, msg string, args ...interface{}) error { + return &CannotConvertError{ + Message: fmt.Sprintf(msg, args...), + Field: field, + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/doc.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/doc.go new file mode 100644 index 00000000000..b0c5ebaf7c1 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/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. +*/ + +// Api versions allow the api contract for a resource to be changed while keeping +// backward compatibility by support multiple concurrent versions +// of the same resource + +// +k8s:deepcopy-gen=package +// +groupName=serving.knative.dev +package v1alpha1 diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/register.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/register.go new file mode 100644 index 00000000000..7f073815705 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/register.go @@ -0,0 +1,59 @@ +/* +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 v1alpha1 + +import ( + "knative.dev/serving/pkg/apis/serving" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: serving.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 { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Revision{}, + &RevisionList{}, + &Configuration{}, + &ConfigurationList{}, + &Route{}, + &RouteList{}, + &Service{}, + &ServiceList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.go new file mode 100644 index 00000000000..b234f4a286d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_conversion.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" + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" + v1 "knative.dev/serving/pkg/apis/serving/v1" + "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// ConvertUp implements apis.Convertible +func (source *Revision) ConvertUp(ctx context.Context, obj apis.Convertible) error { + switch sink := obj.(type) { + case *v1beta1.Revision: + sink.ObjectMeta = source.ObjectMeta + source.Status.ConvertUp(ctx, &sink.Status) + return source.Spec.ConvertUp(ctx, &sink.Spec) + default: + return fmt.Errorf("unknown version, got: %T", sink) + } +} + +// ConvertUp helps implement apis.Convertible +func (source *RevisionTemplateSpec) ConvertUp(ctx context.Context, sink *v1.RevisionTemplateSpec) error { + sink.ObjectMeta = source.ObjectMeta + return source.Spec.ConvertUp(ctx, &sink.Spec) +} + +// ConvertUp helps implement apis.Convertible +func (source *RevisionSpec) ConvertUp(ctx context.Context, sink *v1.RevisionSpec) error { + if source.TimeoutSeconds != nil { + sink.TimeoutSeconds = ptr.Int64(*source.TimeoutSeconds) + } + if source.ContainerConcurrency != nil { + sink.ContainerConcurrency = ptr.Int64(*source.ContainerConcurrency) + } + switch { + case source.DeprecatedContainer != nil && len(source.Containers) > 0: + return apis.ErrMultipleOneOf("container", "containers") + case source.DeprecatedContainer != nil: + sink.PodSpec = corev1.PodSpec{ + ServiceAccountName: source.ServiceAccountName, + Containers: []corev1.Container{*source.DeprecatedContainer}, + Volumes: source.Volumes, + ImagePullSecrets: source.ImagePullSecrets, + } + case len(source.Containers) == 1: + sink.PodSpec = source.PodSpec + case len(source.Containers) > 1: + return apis.ErrMultipleOneOf("containers") + default: + return apis.ErrMissingOneOf("container", "containers") + } + if source.DeprecatedBuildRef != nil { + return ConvertErrorf("buildRef", + "buildRef cannot be migrated forward, got: %#v", source.DeprecatedBuildRef) + } + return nil +} + +// ConvertUp helps implement apis.Convertible +func (source *RevisionStatus) ConvertUp(ctx context.Context, sink *v1.RevisionStatus) { + source.Status.ConvertTo(ctx, &sink.Status) + + sink.ServiceName = source.ServiceName + sink.LogURL = source.LogURL + // TODO(mattmoor): ImageDigest? +} + +// ConvertDown implements apis.Convertible +func (sink *Revision) ConvertDown(ctx context.Context, obj apis.Convertible) error { + switch source := obj.(type) { + case *v1beta1.Revision: + sink.ObjectMeta = source.ObjectMeta + sink.Status.ConvertDown(ctx, source.Status) + return sink.Spec.ConvertDown(ctx, source.Spec) + default: + return fmt.Errorf("unknown version, got: %T", source) + } +} + +// ConvertDown helps implement apis.Convertible +func (sink *RevisionTemplateSpec) ConvertDown(ctx context.Context, source v1.RevisionTemplateSpec) error { + sink.ObjectMeta = source.ObjectMeta + return sink.Spec.ConvertDown(ctx, source.Spec) +} + +// ConvertDown helps implement apis.Convertible +func (sink *RevisionSpec) ConvertDown(ctx context.Context, source v1.RevisionSpec) error { + sink.RevisionSpec = *source.DeepCopy() + return nil +} + +// ConvertDown helps implement apis.Convertible +func (sink *RevisionStatus) ConvertDown(ctx context.Context, source v1.RevisionStatus) { + source.Status.ConvertTo(ctx, &sink.Status) + + sink.ServiceName = source.ServiceName + sink.LogURL = source.LogURL + // TODO(mattmoor): ImageDigest? +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_defaults.go new file mode 100644 index 00000000000..887487fa95a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_defaults.go @@ -0,0 +1,68 @@ +/* +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 v1alpha1 + +import ( + "context" + + corev1 "k8s.io/api/core/v1" + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +func (r *Revision) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +// SetDefaults implements apis.Defaultable +func (rts *RevisionTemplateSpec) SetDefaults(ctx context.Context) { + rts.Spec.SetDefaults(apis.WithinSpec(ctx)) +} + +func (rs *RevisionSpec) SetDefaults(ctx context.Context) { + if v1.IsUpgradeViaDefaulting(ctx) { + v1 := v1.RevisionSpec{} + if rs.ConvertUp(ctx, &v1) == nil { + alpha := RevisionSpec{} + if alpha.ConvertDown(ctx, v1) == nil { + *rs = alpha + } + } + } + + // When ConcurrencyModel is specified but ContainerConcurrency + // is not (`nil`), use the ConcurrencyModel value. + if rs.DeprecatedConcurrencyModel == DeprecatedRevisionRequestConcurrencyModelSingle && rs.ContainerConcurrency == nil { + rs.ContainerConcurrency = ptr.Int64(1) + } + + // When the PodSpec has no containers, move the single Container + // into the PodSpec for the scope of defaulting and then move + // it back as we return. + if len(rs.Containers) == 0 { + if rs.DeprecatedContainer == nil { + rs.DeprecatedContainer = &corev1.Container{} + } + rs.Containers = []corev1.Container{*rs.DeprecatedContainer} + defer func() { + rs.DeprecatedContainer = &rs.Containers[0] + rs.Containers = nil + }() + } + rs.RevisionSpec.SetDefaults(ctx) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go new file mode 100644 index 00000000000..f8ca021bdcb --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_lifecycle.go @@ -0,0 +1,359 @@ +/* +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 ( + "fmt" + "strconv" + "time" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + av1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1" + "knative.dev/serving/pkg/apis/config" + net "knative.dev/serving/pkg/apis/networking" + "knative.dev/serving/pkg/apis/serving" +) + +const ( + // UserPortName is the name that will be used for the Port on the + // Deployment and Pod created by a Revision. This name will be set regardless of if + // a user specifies a port or the default value is chosen. + UserPortName = "user-port" + + // DefaultUserPort is the default port value the QueueProxy will + // use for connecting to the user container. + DefaultUserPort = 8080 + + // QueueAdminPortName specifies the port name for + // health check and lifecycle hooks for queue-proxy. + QueueAdminPortName string = "http-queueadm" + + // AutoscalingQueueMetricsPortName specifies the port name to use for metrics + // emitted by queue-proxy for autoscaler. + AutoscalingQueueMetricsPortName = "queue-metrics" + + // UserQueueMetricsPortName specifies the port name to use for metrics + // emitted by queue-proxy for end user. + UserQueueMetricsPortName = "http-usermetric" +) + +var revCondSet = apis.NewLivingConditionSet( + RevisionConditionResourcesAvailable, + RevisionConditionContainerHealthy, +) + +func (r *Revision) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Revision") +} + +// GetContainer returns a pointer to the relevant corev1.Container field. +// It is never nil and should be exactly the specified container as guaranteed +// by validation. +func (rs *RevisionSpec) GetContainer() *corev1.Container { + if rs.DeprecatedContainer != nil { + return rs.DeprecatedContainer + } + if len(rs.Containers) > 0 { + return &rs.Containers[0] + } + // Should be unreachable post-validation, but here to ease testing. + return &corev1.Container{} +} + +// GetContainerConcurrency returns the container concurrency. If +// container concurrency is not set, the default value will be returned. +// We use the original default (0) here for backwards compatibility. +// Previous versions of Knative equated unspecified and zero, so to avoid +// changing the value used by Revisions with unspecified values when a different +// default is configured, we use the original default instead of the configured +// default to remain safe across upgrades. +func (rs *RevisionSpec) GetContainerConcurrency() int64 { + if rs.ContainerConcurrency == nil { + return config.DefaultContainerConcurrency + } + return *rs.ContainerConcurrency +} + +func (r *Revision) DeprecatedBuildRef() *corev1.ObjectReference { + if r.Spec.DeprecatedBuildRef != nil { + buildRef := r.Spec.DeprecatedBuildRef.DeepCopy() + if buildRef.Namespace == "" { + buildRef.Namespace = r.Namespace + } + return buildRef + } + + if r.Spec.DeprecatedBuildName != "" { + return &corev1.ObjectReference{ + APIVersion: "build.knative.dev/v1alpha1", + Kind: "Build", + Namespace: r.Namespace, + Name: r.Spec.DeprecatedBuildName, + } + } + + return nil +} + +// GetProtocol returns the app level network protocol. +func (r *Revision) GetProtocol() net.ProtocolType { + ports := r.Spec.GetContainer().Ports + if len(ports) > 0 && ports[0].Name == string(net.ProtocolH2C) { + return net.ProtocolH2C + } + + return net.ProtocolHTTP1 +} + +// IsReady looks at the conditions and if the Status has a condition +// RevisionConditionReady returns true if ConditionStatus is True +func (rs *RevisionStatus) IsReady() bool { + return revCondSet.Manage(rs).IsHappy() +} + +// IsActivationRequired returns true if activation is required. +func (rs *RevisionStatus) IsActivationRequired() bool { + if c := revCondSet.Manage(rs).GetCondition(RevisionConditionActive); c != nil { + return c.Status != corev1.ConditionTrue + } + return false +} + +func (rs *RevisionStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return revCondSet.Manage(rs).GetCondition(t) +} + +func (rs *RevisionStatus) InitializeConditions() { + revCondSet.Manage(rs).InitializeConditions() +} + +// MarkResourceNotConvertible adds a Warning-severity condition to the resource noting that +// it cannot be converted to a higher version. +func (rs *RevisionStatus) MarkResourceNotConvertible(err *CannotConvertError) { + revCondSet.Manage(rs).SetCondition(apis.Condition{ + Type: ConditionTypeConvertible, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityWarning, + Reason: err.Field, + Message: err.Message, + }) +} + +const ( + // NotOwned defines the reason for marking revision availability status as + // false due to resource ownership issues. + NotOwned = "NotOwned" + + // Deploying defines the reason for marking revision availability status as + // unknown if the revision is still deploying. + Deploying = "Deploying" + + // ProgressDeadlineExceeded defines the reason for marking revision availability + // status as false if progress has exceeded the deadline. + ProgressDeadlineExceeded = "ProgressDeadlineExceeded" + + // ContainerMissing defines the reason for marking container healthiness status + // as false if the a container image for the revision is missing. + ContainerMissing = "ContainerMissing" +) + +// MarkResourcesAvailableTrue marks ResourcesAvailable status on revision as True +func (rs *RevisionStatus) MarkResourcesAvailableTrue() { + revCondSet.Manage(rs).MarkTrue(RevisionConditionResourcesAvailable) +} + +// MarkResourcesAvailableFalse marks ResourcesAvailable status on revision as False +func (rs *RevisionStatus) MarkResourcesAvailableFalse(reason, message string) { + revCondSet.Manage(rs).MarkFalse(RevisionConditionResourcesAvailable, reason, message) +} + +// MarkResourcesAvailableUnknown marks ResourcesAvailable status on revision as Unknown +func (rs *RevisionStatus) MarkResourcesAvailableUnknown(reason, message string) { + revCondSet.Manage(rs).MarkUnknown(RevisionConditionResourcesAvailable, reason, message) +} + +// MarkContainerHealthyTrue marks ContainerHealthy status on revision as True +func (rs *RevisionStatus) MarkContainerHealthyTrue() { + revCondSet.Manage(rs).MarkTrue(RevisionConditionContainerHealthy) +} + +// MarkContainerHealthyFalse marks ContainerHealthy status on revision as False +func (rs *RevisionStatus) MarkContainerHealthyFalse(reason, message string) { + revCondSet.Manage(rs).MarkFalse(RevisionConditionContainerHealthy, reason, message) +} + +// MarkContainerHealthyUnknown marks ContainerHealthy status on revision as Unknown +func (rs *RevisionStatus) MarkContainerHealthyUnknown(reason, message string) { + revCondSet.Manage(rs).MarkUnknown(RevisionConditionContainerHealthy, reason, message) +} + +// MarkActiveTrue marks Active status on revision as True +func (rs *RevisionStatus) MarkActiveTrue() { + revCondSet.Manage(rs).MarkTrue(RevisionConditionActive) +} + +// MarkActiveFalse marks Active status on revision as False +func (rs *RevisionStatus) MarkActiveFalse(reason, message string) { + revCondSet.Manage(rs).MarkFalse(RevisionConditionActive, reason, message) +} + +// MarkActiveUnknown marks Active status on revision as Unknown +func (rs *RevisionStatus) MarkActiveUnknown(reason, message string) { + revCondSet.Manage(rs).MarkUnknown(RevisionConditionActive, reason, message) +} + +// PropagateAutoscalerStatus propagates autoscaler's status to the revision's status. +func (rs *RevisionStatus) PropagateAutoscalerStatus(ps *av1alpha1.PodAutoscalerStatus) { + // Propagate the service name from the PA. + rs.ServiceName = ps.ServiceName + + // Reflect the PA status in our own. + cond := ps.GetCondition(av1alpha1.PodAutoscalerConditionReady) + if cond == nil { + rs.MarkActiveUnknown("Deploying", "") + return + } + + switch cond.Status { + case corev1.ConditionUnknown: + rs.MarkActiveUnknown(cond.Reason, cond.Message) + case corev1.ConditionFalse: + rs.MarkActiveFalse(cond.Reason, cond.Message) + case corev1.ConditionTrue: + rs.MarkActiveTrue() + + // Precondition for PA being active is SKS being active and + // that entices that |service.endpoints| > 0. + rs.MarkResourcesAvailableTrue() + rs.MarkContainerHealthyTrue() + } +} + +// RevisionContainerMissingMessage constructs the status message if a given image +// cannot be pulled correctly. +func RevisionContainerMissingMessage(image string, message string) string { + return fmt.Sprintf("Unable to fetch image %q: %s", image, message) +} + +// RevisionContainerExitingMessage constructs the status message if a container +// fails to come up. +func RevisionContainerExitingMessage(message string) string { + return fmt.Sprintf("Container failed with: %s", message) +} + +// ResourceNotOwnedMessage constructs the status message if ownership on the +// resource is not right. +func ResourceNotOwnedMessage(kind, name string) string { + return fmt.Sprintf("There is an existing %s %q that we do not own.", kind, name) +} + +// ExitCodeReason constructs the status message from an exit code +func ExitCodeReason(exitCode int32) string { + return fmt.Sprintf("ExitCode%d", exitCode) +} + +const ( + AnnotationParseErrorTypeMissing = "Missing" + AnnotationParseErrorTypeInvalid = "Invalid" + LabelParserErrorTypeMissing = "Missing" + LabelParserErrorTypeInvalid = "Invalid" +) + +// +k8s:deepcopy-gen=false +type AnnotationParseError struct { + Type string + Value string + Err error +} + +// +k8s:deepcopy-gen=false +type LastPinnedParseError AnnotationParseError + +func (e LastPinnedParseError) Error() string { + return fmt.Sprintf("%v lastPinned value: %q", e.Type, e.Value) +} + +func RevisionLastPinnedString(t time.Time) string { + return fmt.Sprintf("%d", t.Unix()) +} + +func (r *Revision) SetLastPinned(t time.Time) { + if r.ObjectMeta.Annotations == nil { + r.ObjectMeta.Annotations = make(map[string]string) + } + + r.ObjectMeta.Annotations[serving.RevisionLastPinnedAnnotationKey] = RevisionLastPinnedString(t) +} + +func (r *Revision) GetLastPinned() (time.Time, error) { + if r.Annotations == nil { + return time.Time{}, LastPinnedParseError{ + Type: AnnotationParseErrorTypeMissing, + } + } + + str, ok := r.ObjectMeta.Annotations[serving.RevisionLastPinnedAnnotationKey] + if !ok { + // If a revision is past the create delay without an annotation it is stale + return time.Time{}, LastPinnedParseError{ + Type: AnnotationParseErrorTypeMissing, + } + } + + secs, err := strconv.ParseInt(str, 10, 64) + if err != nil { + return time.Time{}, LastPinnedParseError{ + Type: AnnotationParseErrorTypeInvalid, + Value: str, + Err: err, + } + } + + return time.Unix(secs, 0), nil +} + +// IsReachable returns whether or not the revision can be reached by a route. +func (r *Revision) IsReachable() bool { + return r.ObjectMeta.Labels[serving.RouteLabelKey] != "" +} + +func (rs *RevisionStatus) duck() *duckv1.Status { + return &rs.Status +} + +// PropagateDeploymentStatus takes the Deployment status and applies its values +// to the Revision status. +func (rs *RevisionStatus) PropagateDeploymentStatus(original *appsv1.DeploymentStatus) { + ds := serving.TransformDeploymentStatus(original) + cond := ds.GetCondition(serving.DeploymentConditionReady) + if cond == nil { + return + } + + switch cond.Status { + case corev1.ConditionUnknown: + revCondSet.Manage(rs).MarkUnknown(RevisionConditionResourcesAvailable, cond.Reason, cond.Message) + case corev1.ConditionTrue: + revCondSet.Manage(rs).MarkTrue(RevisionConditionResourcesAvailable) + case corev1.ConditionFalse: + revCondSet.Manage(rs).MarkFalse(RevisionConditionResourcesAvailable, cond.Reason, cond.Message) + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_types.go new file mode 100644 index 00000000000..e7a90c65710 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_types.go @@ -0,0 +1,205 @@ +/* +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 v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" + + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Revision is an immutable snapshot of code and configuration. A revision +// references a container image, and optionally a build that is responsible for +// materializing that container image from source. Revisions are created by +// updates to a Configuration. +// +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#revision +type Revision struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Revision (from the client). + // +optional + Spec RevisionSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Revision (from the controller). + // +optional + Status RevisionStatus `json:"status,omitempty"` +} + +// Verify that Revision adheres to the appropriate interfaces. +var ( + // Check that Revision can be validated, can be defaulted, and has immutable fields. + _ apis.Validatable = (*Revision)(nil) + _ apis.Defaultable = (*Revision)(nil) + + // Check that Revision can be converted to higher versions. + _ apis.Convertible = (*Revision)(nil) + + // Check that we can create OwnerReferences to a Revision. + _ kmeta.OwnerRefable = (*Revision)(nil) +) + +// RevisionTemplateSpec describes the data a revision should have when created from a template. +// Based on: https://github.com/kubernetes/api/blob/e771f807/core/v1/types.go#L3179-L3190 +type RevisionTemplateSpec struct { + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional + Spec RevisionSpec `json:"spec,omitempty"` +} + +// DeprecatedRevisionServingStateType is an enumeration of the levels of serving readiness of the Revision. +// See also: https://github.com/knative/serving/blob/master/docs/spec/errors.md#error-conditions-and-reporting +type DeprecatedRevisionServingStateType string + +const ( + // The revision is ready to serve traffic. It should have Kubernetes + // resources, and the Istio route should be pointed to the given resources. + DeprecatedRevisionServingStateActive DeprecatedRevisionServingStateType = "Active" + // The revision is not currently serving traffic, but could be made to serve + // traffic quickly. It should have Kubernetes resources, but the Istio route + // should be pointed to the activator. + DeprecatedRevisionServingStateReserve DeprecatedRevisionServingStateType = "Reserve" + // The revision has been decommissioned and is not needed to serve traffic + // anymore. It should not have any Istio routes or Kubernetes resources. + // A Revision may be brought out of retirement, but it may take longer than + // it would from a "Reserve" state. + // Note: currently not set anywhere. See https://github.com/knative/serving/issues/1203 + DeprecatedRevisionServingStateRetired DeprecatedRevisionServingStateType = "Retired" +) + +// DeprecatedRevisionRequestConcurrencyModelType is an enumeration of the +// concurrency models supported by a Revision. +// DEPRECATED in favor of an integer based ContainerConcurrency setting. +// TODO(vagababov): retire completely in 0.9. +type DeprecatedRevisionRequestConcurrencyModelType string + +const ( + // DeprecatedRevisionRequestConcurrencyModelSingle guarantees that only one + // request will be handled at a time (concurrently) per instance + // of Revision Container. + DeprecatedRevisionRequestConcurrencyModelSingle DeprecatedRevisionRequestConcurrencyModelType = "Single" + // DeprecatedRevisionRequestConcurencyModelMulti allows more than one request to + // be handled at a time (concurrently) per instance of Revision + // Container. + DeprecatedRevisionRequestConcurrencyModelMulti DeprecatedRevisionRequestConcurrencyModelType = "Multi" +) + +// RevisionSpec holds the desired state of the Revision (from the client). +type RevisionSpec struct { + v1.RevisionSpec `json:",inline"` + + // DeprecatedGeneration was used prior in Kubernetes versions <1.11 + // when metadata.generation was not being incremented by the api server + // + // This property will be dropped in future Knative releases and should + // not be used - use metadata.generation + // + // Tracking issue: https://github.com/knative/serving/issues/643 + // + // +optional + DeprecatedGeneration int64 `json:"generation,omitempty"` + + // DeprecatedServingState holds a value describing the desired state the Kubernetes + // resources should be in for this Revision. + // Users must not specify this when creating a revision. These values are no longer + // updated by the system. + // +optional + DeprecatedServingState DeprecatedRevisionServingStateType `json:"servingState,omitempty"` + + // DeprecatedConcurrencyModel specifies the desired concurrency model + // (Single or Multi) for the + // Revision. Defaults to Multi. + // Deprecated in favor of ContainerConcurrency. + // +optional + DeprecatedConcurrencyModel DeprecatedRevisionRequestConcurrencyModelType `json:"concurrencyModel,omitempty"` + + // DeprecatedBuildName optionally holds the name of the Build responsible for + // producing the container image for its Revision. + // DEPRECATED: Use DeprecatedBuildRef instead. + // +optional + DeprecatedBuildName string `json:"buildName,omitempty"` + + // DeprecatedBuildRef holds the reference to the build (if there is one) responsible + // for producing the container image for this Revision. Otherwise, nil + // +optional + DeprecatedBuildRef *corev1.ObjectReference `json:"buildRef,omitempty"` + + // Container defines the unit of execution for this Revision. + // In the context of a Revision, we disallow a number of the fields of + // this Container, including: name and lifecycle. + // See also the runtime contract for more information about the execution + // environment: + // https://github.com/knative/serving/blob/master/docs/runtime-contract.md + // +optional + DeprecatedContainer *corev1.Container `json:"container,omitempty"` +} + +const ( + // RevisionConditionReady is set when the revision is starting to materialize + // runtime resources, and becomes true when those resources are ready. + RevisionConditionReady = apis.ConditionReady + // RevisionConditionResourcesAvailable is set when underlying + // Kubernetes resources have been provisioned. + RevisionConditionResourcesAvailable apis.ConditionType = "ResourcesAvailable" + // RevisionConditionContainerHealthy is set when the revision readiness check completes. + RevisionConditionContainerHealthy apis.ConditionType = "ContainerHealthy" + // RevisionConditionActive is set when the revision is receiving traffic. + RevisionConditionActive apis.ConditionType = "Active" +) + +// RevisionStatus communicates the observed state of the Revision (from the controller). +type RevisionStatus struct { + duckv1.Status `json:",inline"` + + // ServiceName holds the name of a core Kubernetes Service resource that + // load balances over the pods backing this Revision. + // +optional + ServiceName string `json:"serviceName,omitempty"` + + // LogURL specifies the generated logging url for this particular revision + // based on the revision url template specified in the controller's config. + // +optional + LogURL string `json:"logUrl,omitempty"` + + // ImageDigest holds the resolved digest for the image specified + // within .Spec.Container.Image. The digest is resolved during the creation + // of Revision. This field holds the digest value regardless of whether + // a tag or digest was originally specified in the Container object. It + // may be empty if the image comes from a registry listed to skip resolution. + // +optional + ImageDigest string `json:"imageDigest,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RevisionList is a list of Revision resources +type RevisionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Revision `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go new file mode 100644 index 00000000000..713c56770b6 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/revision_validation.go @@ -0,0 +1,162 @@ +/* +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 v1alpha1 + +import ( + "context" + + "k8s.io/apimachinery/pkg/api/equality" + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" + "knative.dev/serving/pkg/apis/autoscaling" + "knative.dev/serving/pkg/apis/serving" +) + +func (r *Revision) checkImmutableFields(ctx context.Context, original *Revision) *apis.FieldError { + if diff, err := kmp.ShortDiff(original.Spec, r.Spec); err != nil { + return &apis.FieldError{ + Message: "Failed to diff Revision", + Paths: []string{"spec"}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: diff, + } + } + return nil +} + +// Validate ensures Revision is properly configured. +func (r *Revision) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).ViaField("metadata") + if apis.IsInUpdate(ctx) { + old := apis.GetBaseline(ctx).(*Revision) + errs = errs.Also(r.checkImmutableFields(ctx, old)) + } else { + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + return errs +} + +// Validate ensures RevisionTemplateSpec is properly configured. +func (rt *RevisionTemplateSpec) Validate(ctx context.Context) *apis.FieldError { + errs := rt.Spec.Validate(ctx).ViaField("spec") + errs = errs.Also(autoscaling.ValidateAnnotations(rt.GetAnnotations()).ViaField("metadata.annotations")) + // If the DeprecatedRevisionTemplate has a name specified, then check that + // it follows the requirements on the name. + errs = errs.Also(serving.ValidateRevisionName(ctx, rt.Name, rt.GenerateName)) + errs = errs.Also(serving.ValidateQueueSidecarAnnotation(rt.Annotations).ViaField("metadata.annotations")) + return errs +} + +// VerifyNameChange checks that if a user brought their own name previously that it +// changes at the appropriate times. +func (current *RevisionTemplateSpec) VerifyNameChange(ctx context.Context, og *RevisionTemplateSpec) *apis.FieldError { + if current.Name == "" { + // We only check that Name changes when the DeprecatedRevisionTemplate changes. + return nil + } + if current.Name != og.Name { + // The name changed, so we're good. + return nil + } + + if diff, err := kmp.ShortDiff(og, current); err != nil { + return &apis.FieldError{ + Message: "Failed to diff DeprecatedRevisionTemplate", + Paths: []string{apis.CurrentField}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Saw the following changes without a name change (-old +new)", + Paths: []string{"metadata.name"}, + Details: diff, + } + } + return nil +} + +// Validate ensures RevisionSpec is properly configured. +func (rs *RevisionSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(rs, &RevisionSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + + errs := apis.CheckDeprecated(ctx, rs) + + switch { + case len(rs.PodSpec.Containers) > 0 && rs.DeprecatedContainer != nil: + errs = errs.Also(apis.ErrMultipleOneOf("container", "containers")) + case len(rs.PodSpec.Containers) > 0: + errs = errs.Also(rs.RevisionSpec.Validate(ctx)) + case rs.DeprecatedContainer != nil: + volumes, err := serving.ValidateVolumes(rs.Volumes) + if err != nil { + errs = errs.Also(err.ViaField("volumes")) + } + errs = errs.Also(serving.ValidateContainer( + *rs.DeprecatedContainer, volumes).ViaField("container")) + default: + errs = errs.Also(apis.ErrMissingOneOf("container", "containers")) + } + + if rs.DeprecatedBuildRef != nil { + errs = errs.Also(apis.ErrDisallowedFields("buildRef")) + } + + if err := rs.DeprecatedConcurrencyModel.Validate(ctx).ViaField("concurrencyModel"); err != nil { + errs = errs.Also(err) + } else { + if rs.ContainerConcurrency != nil { + errs = errs.Also(serving.ValidateContainerConcurrency(rs.ContainerConcurrency).ViaField("containerConcurrency")) + } + } + + if rs.TimeoutSeconds != nil { + errs = errs.Also(serving.ValidateTimeoutSeconds(ctx, *rs.TimeoutSeconds)) + } + return errs +} + +// Validate ensures DeprecatedRevisionServingStateType is properly configured. +func (ss DeprecatedRevisionServingStateType) Validate(ctx context.Context) *apis.FieldError { + switch ss { + case DeprecatedRevisionServingStateType(""), + DeprecatedRevisionServingStateRetired, + DeprecatedRevisionServingStateReserve, + DeprecatedRevisionServingStateActive: + return nil + default: + return apis.ErrInvalidValue(ss, apis.CurrentField) + } +} + +// Validate ensures RevisionRequestConcurrencyModelType is properly configured. +func (cm DeprecatedRevisionRequestConcurrencyModelType) Validate(ctx context.Context) *apis.FieldError { + switch cm { + case DeprecatedRevisionRequestConcurrencyModelType(""), + DeprecatedRevisionRequestConcurrencyModelMulti, + DeprecatedRevisionRequestConcurrencyModelSingle: + return nil + default: + return apis.ErrInvalidValue(cm, apis.CurrentField) + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_conversion.go new file mode 100644 index 00000000000..f7fa0ba3197 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_conversion.go @@ -0,0 +1,143 @@ +/* +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" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + v1 "knative.dev/serving/pkg/apis/serving/v1" + "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// ConvertUp implements apis.Convertible +func (source *Route) ConvertUp(ctx context.Context, obj apis.Convertible) error { + switch sink := obj.(type) { + case *v1beta1.Route: + sink.ObjectMeta = source.ObjectMeta + source.Status.ConvertUp(apis.WithinStatus(ctx), &sink.Status) + return source.Spec.ConvertUp(apis.WithinSpec(ctx), &sink.Spec) + default: + return fmt.Errorf("unknown version, got: %T", sink) + } +} + +// ConvertUp helps implement apis.Convertible +func (source *RouteSpec) ConvertUp(ctx context.Context, sink *v1.RouteSpec) error { + sink.Traffic = make([]v1.TrafficTarget, len(source.Traffic)) + for i := range source.Traffic { + if err := source.Traffic[i].ConvertUp(ctx, &sink.Traffic[i]); err != nil { + return err + } + } + return nil +} + +// ConvertUp helps implement apis.Convertible +func (source *TrafficTarget) ConvertUp(ctx context.Context, sink *v1.TrafficTarget) error { + *sink = source.TrafficTarget + switch { + case source.Tag != "" && source.DeprecatedName != "": + if apis.IsInSpec(ctx) { + return apis.ErrMultipleOneOf("name", "tag") + } + case source.DeprecatedName != "": + sink.Tag = source.DeprecatedName + } + return nil +} + +// ConvertUp helps implement apis.Convertible +func (source *RouteStatus) ConvertUp(ctx context.Context, sink *v1.RouteStatus) { + source.Status.ConvertTo(ctx, &sink.Status) + + source.RouteStatusFields.ConvertUp(ctx, &sink.RouteStatusFields) +} + +// ConvertUp helps implement apis.Convertible +func (source *RouteStatusFields) ConvertUp(ctx context.Context, sink *v1.RouteStatusFields) { + if source.URL != nil { + sink.URL = source.URL.DeepCopy() + } + + if source.Address != nil { + if sink.Address == nil { + sink.Address = &duckv1.Addressable{} + } + source.Address.ConvertUp(ctx, sink.Address) + } + + sink.Traffic = make([]v1.TrafficTarget, len(source.Traffic)) + for i := range source.Traffic { + source.Traffic[i].ConvertUp(ctx, &sink.Traffic[i]) + } +} + +// ConvertDown implements apis.Convertible +func (sink *Route) ConvertDown(ctx context.Context, obj apis.Convertible) error { + switch source := obj.(type) { + case *v1beta1.Route: + sink.ObjectMeta = source.ObjectMeta + sink.Spec.ConvertDown(ctx, source.Spec) + sink.Status.ConvertDown(ctx, source.Status) + return nil + default: + return fmt.Errorf("unknown version, got: %T", source) + } +} + +// ConvertDown helps implement apis.Convertible +func (sink *RouteSpec) ConvertDown(ctx context.Context, source v1.RouteSpec) { + sink.Traffic = make([]TrafficTarget, len(source.Traffic)) + for i := range source.Traffic { + sink.Traffic[i].ConvertDown(ctx, source.Traffic[i]) + } +} + +// ConvertDown helps implement apis.Convertible +func (sink *TrafficTarget) ConvertDown(ctx context.Context, source v1.TrafficTarget) { + sink.TrafficTarget = source +} + +// ConvertDown helps implement apis.Convertible +func (sink *RouteStatus) ConvertDown(ctx context.Context, source v1.RouteStatus) { + source.Status.ConvertTo(ctx, &sink.Status) + + sink.RouteStatusFields.ConvertDown(ctx, source.RouteStatusFields) +} + +// ConvertDown helps implement apis.Convertible +func (sink *RouteStatusFields) ConvertDown(ctx context.Context, source v1.RouteStatusFields) { + if source.URL != nil { + sink.URL = source.URL.DeepCopy() + } + + if source.Address != nil { + if sink.Address == nil { + sink.Address = &duckv1alpha1.Addressable{} + } + sink.Address.ConvertDown(ctx, source.Address) + } + + sink.Traffic = make([]TrafficTarget, len(source.Traffic)) + for i := range source.Traffic { + sink.Traffic[i].ConvertDown(ctx, source.Traffic[i]) + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_defaults.go new file mode 100644 index 00000000000..fab2d8ce496 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_defaults.go @@ -0,0 +1,62 @@ +/* +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 v1alpha1 + +import ( + "context" + + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" + "knative.dev/serving/pkg/apis/serving" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +func (r *Route) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) + if r.GetOwnerReferences() == nil { + if apis.IsInUpdate(ctx) { + serving.SetUserInfo(ctx, apis.GetBaseline(ctx).(*Route).Spec, r.Spec, r) + } else { + serving.SetUserInfo(ctx, nil, r.Spec, r) + } + } + +} + +func (rs *RouteSpec) SetDefaults(ctx context.Context) { + if v1.IsUpgradeViaDefaulting(ctx) { + v := v1.RouteSpec{} + if rs.ConvertUp(ctx, &v) == nil { + alpha := RouteSpec{} + alpha.ConvertDown(ctx, v) + *rs = alpha + } + } + + if len(rs.Traffic) == 0 && v1.HasDefaultConfigurationName(ctx) { + rs.Traffic = []TrafficTarget{{ + TrafficTarget: v1.TrafficTarget{ + Percent: ptr.Int64(100), + LatestRevision: ptr.Bool(true), + }, + }} + } + + for i := range rs.Traffic { + rs.Traffic[i].SetDefaults(ctx) + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go new file mode 100644 index 00000000000..401e18791f7 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_lifecycle.go @@ -0,0 +1,175 @@ +/* +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 ( + "fmt" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/serving/pkg/apis/networking/v1alpha1" +) + +var routeCondSet = apis.NewLivingConditionSet( + RouteConditionAllTrafficAssigned, + RouteConditionIngressReady, +) + +func (r *Route) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Route") +} + +func (rs *RouteStatus) IsReady() bool { + return routeCondSet.Manage(rs).IsHappy() +} + +func (rs *RouteStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return routeCondSet.Manage(rs).GetCondition(t) +} + +func (rs *RouteStatus) InitializeConditions() { + routeCondSet.Manage(rs).InitializeConditions() +} + +// // MarkResourceNotConvertible adds a Warning-severity condition to the resource noting that +// // it cannot be converted to a higher version. +// func (rs *RouteStatus) MarkResourceNotConvertible(err *CannotConvertError) { +// routeCondSet.Manage(rs).SetCondition(apis.Condition{ +// Type: ConditionTypeConvertible, +// Status: corev1.ConditionFalse, +// Severity: apis.ConditionSeverityWarning, +// Reason: err.Field, +// Message: err.Message, +// }) +// } + +// MarkServiceNotOwned changes the IngressReady status to be false with the reason being that +// there is a pre-existing placeholder service with the name we wanted to use. +func (rs *RouteStatus) MarkServiceNotOwned(name string) { + routeCondSet.Manage(rs).MarkFalse(RouteConditionIngressReady, "NotOwned", + fmt.Sprintf("There is an existing placeholder Service %q that we do not own.", name)) +} + +// MarkIngressNotConfigured changes the IngressReady condition to be unknown to reflect +// that the Ingress does not yet have a Status +func (rs *RouteStatus) MarkIngressNotConfigured() { + routeCondSet.Manage(rs).MarkUnknown(RouteConditionIngressReady, + "IngressNotConfigured", "Ingress has not yet been reconciled.") +} + +func (rs *RouteStatus) MarkTrafficAssigned() { + routeCondSet.Manage(rs).MarkTrue(RouteConditionAllTrafficAssigned) +} + +func (rs *RouteStatus) MarkUnknownTrafficError(msg string) { + routeCondSet.Manage(rs).MarkUnknown(RouteConditionAllTrafficAssigned, "Unknown", msg) +} + +func (rs *RouteStatus) MarkConfigurationNotReady(name string) { + routeCondSet.Manage(rs).MarkUnknown(RouteConditionAllTrafficAssigned, + "RevisionMissing", + "Configuration %q is waiting for a Revision to become ready.", name) +} + +func (rs *RouteStatus) MarkConfigurationFailed(name string) { + routeCondSet.Manage(rs).MarkFalse(RouteConditionAllTrafficAssigned, + "RevisionMissing", + "Configuration %q does not have any ready Revision.", name) +} + +func (rs *RouteStatus) MarkRevisionNotReady(name string) { + routeCondSet.Manage(rs).MarkUnknown(RouteConditionAllTrafficAssigned, + "RevisionMissing", + "Revision %q is not yet ready.", name) +} + +func (rs *RouteStatus) MarkRevisionFailed(name string) { + routeCondSet.Manage(rs).MarkFalse(RouteConditionAllTrafficAssigned, + "RevisionMissing", + "Revision %q failed to become ready.", name) +} + +func (rs *RouteStatus) MarkMissingTrafficTarget(kind, name string) { + routeCondSet.Manage(rs).MarkFalse(RouteConditionAllTrafficAssigned, + kind+"Missing", + "%s %q referenced in traffic not found.", kind, name) +} + +func (rs *RouteStatus) MarkCertificateProvisionFailed(name string) { + routeCondSet.Manage(rs).SetCondition(apis.Condition{ + Type: RouteConditionCertificateProvisioned, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityWarning, + Reason: "CertificateProvisionFailed", + Message: fmt.Sprintf("Certificate %s fails to be provisioned.", name), + }) +} + +func (rs *RouteStatus) MarkCertificateReady(name string) { + routeCondSet.Manage(rs).SetCondition(apis.Condition{ + Type: RouteConditionCertificateProvisioned, + Status: corev1.ConditionTrue, + Severity: apis.ConditionSeverityWarning, + Reason: "CertificateReady", + Message: fmt.Sprintf("Certificate %s is successfully provisioned", name), + }) +} + +func (rs *RouteStatus) MarkCertificateNotReady(name string) { + routeCondSet.Manage(rs).SetCondition(apis.Condition{ + Type: RouteConditionCertificateProvisioned, + Status: corev1.ConditionUnknown, + Severity: apis.ConditionSeverityWarning, + Reason: "CertificateNotReady", + Message: fmt.Sprintf("Certificate %s is not ready.", name), + }) +} + +func (rs *RouteStatus) MarkCertificateNotOwned(name string) { + routeCondSet.Manage(rs).SetCondition(apis.Condition{ + Type: RouteConditionCertificateProvisioned, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityWarning, + Reason: "CertificateNotOwned", + Message: fmt.Sprintf("There is an existing certificate %s that we don't own.", name), + }) +} + +// PropagateIngressStatus update RouteConditionIngressReady condition +// in RouteStatus according to IngressStatus. +func (rs *RouteStatus) PropagateIngressStatus(cs v1alpha1.IngressStatus) { + cc := cs.GetCondition(v1alpha1.IngressConditionReady) + if cc == nil { + rs.MarkIngressNotConfigured() + return + } + switch { + case cc.Status == corev1.ConditionUnknown: + routeCondSet.Manage(rs).MarkUnknown(RouteConditionIngressReady, cc.Reason, cc.Message) + case cc.Status == corev1.ConditionTrue: + routeCondSet.Manage(rs).MarkTrue(RouteConditionIngressReady) + case cc.Status == corev1.ConditionFalse: + routeCondSet.Manage(rs).MarkFalse(RouteConditionIngressReady, cc.Reason, cc.Message) + } +} + +func (rs *RouteStatus) duck() *duckv1.Status { + return &rs.Status +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_types.go new file mode 100644 index 00000000000..da51e92a828 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_types.go @@ -0,0 +1,163 @@ +/* +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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/kmeta" + + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Route is responsible for configuring ingress over a collection of Revisions. +// Some of the Revisions a Route distributes traffic over may be specified by +// referencing the Configuration responsible for creating them; in these cases +// the Route is additionally responsible for monitoring the Configuration for +// "latest ready" revision changes, and smoothly rolling out latest revisions. +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#route +type Route struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Route (from the client). + // +optional + Spec RouteSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Route (from the controller). + // +optional + Status RouteStatus `json:"status,omitempty"` +} + +// Verify that Route adheres to the appropriate interfaces. +var ( + // Check that Route may be validated and defaulted. + _ apis.Validatable = (*Route)(nil) + _ apis.Defaultable = (*Route)(nil) + + // Check that Route can be converted to higher versions. + _ apis.Convertible = (*Route)(nil) + + // Check that we can create OwnerReferences to a Route. + _ kmeta.OwnerRefable = (*Route)(nil) +) + +// TrafficTarget holds a single entry of the routing table for a Route. +type TrafficTarget struct { + // Name is optionally used to expose a dedicated hostname for referencing this + // target exclusively. It has the form: {name}.${route.status.domain} + // +optional + DeprecatedName string `json:"name,omitempty"` + + // We inherit most of our fields by inlining the v1 type. + // Ultimately all non-v1 fields will be deprecated. + v1.TrafficTarget `json:",inline"` +} + +// RouteSpec holds the desired state of the Route (from the client). +type RouteSpec struct { + // DeprecatedGeneration was used prior in Kubernetes versions <1.11 + // when metadata.generation was not being incremented by the api server + // + // This property will be dropped in future Knative releases and should + // not be used - use metadata.generation + // + // Tracking issue: https://github.com/knative/serving/issues/643 + // + // +optional + DeprecatedGeneration int64 `json:"generation,omitempty"` + + // Traffic specifies how to distribute traffic over a collection of Knative Serving Revisions and Configurations. + // +optional + Traffic []TrafficTarget `json:"traffic,omitempty"` +} + +const ( + // RouteConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + RouteConditionReady = apis.ConditionReady + + // RouteConditionAllTrafficAssigned is set to False when the + // service is not configured properly or has no available + // backends ready to receive traffic. + RouteConditionAllTrafficAssigned apis.ConditionType = "AllTrafficAssigned" + + // RouteConditionIngressReady is set to False when the + // Ingress fails to become Ready. + RouteConditionIngressReady apis.ConditionType = "IngressReady" + + // RouteConditionCertificateProvisioned is set to False when the + // Knative Certificates fail to be provisioned for the Route. + RouteConditionCertificateProvisioned apis.ConditionType = "CertificateProvisioned" +) + +// RouteStatusFields holds all of the non-duckv1.Status status fields of a Route. +// These are defined outline so that we can also inline them into Service, and more easily +// copy them. +type RouteStatusFields struct { + // URL holds the url that will distribute traffic over the provided traffic targets. + // It generally has the form http[s]://{route-name}.{route-namespace}.{cluster-level-suffix} + // +optional + URL *apis.URL `json:"url,omitempty"` + + // DeprecatedDomain holds the top-level domain that will distribute traffic over the provided targets. + // It generally has the form {route-name}.{route-namespace}.{cluster-level-suffix} + // +optional + DeprecatedDomain string `json:"domain,omitempty"` + + // DeprecatedDomainInternal holds the top-level domain that will distribute traffic over the provided + // targets from inside the cluster. It generally has the form + // {route-name}.{route-namespace}.svc.{cluster-domain-name} + // DEPRECATED: Use Address instead. + // +optional + DeprecatedDomainInternal string `json:"domainInternal,omitempty"` + + // Address holds the information needed for a Route to be the target of an event. + // +optional + Address *duckv1alpha1.Addressable `json:"address,omitempty"` + + // Traffic holds the configured traffic distribution. + // These entries will always contain RevisionName references. + // When ConfigurationName appears in the spec, this will hold the + // LatestReadyRevisionName that we last observed. + // +optional + Traffic []TrafficTarget `json:"traffic,omitempty"` +} + +// RouteStatus communicates the observed state of the Route (from the controller). +type RouteStatus struct { + duckv1.Status `json:",inline"` + + RouteStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RouteList is a list of Route resources +type RouteList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Route `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_validation.go new file mode 100644 index 00000000000..025457b7e32 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/route_validation.go @@ -0,0 +1,107 @@ +/* +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 v1alpha1 + +import ( + "context" + "fmt" + + "k8s.io/apimachinery/pkg/api/equality" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +func (r *Route) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).ViaField("metadata") + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Route) + // Don't validate annotations(creator and lastModifier) when route owned by service + // validate only when route created independently. + if r.OwnerReferences == nil { + errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, r.Spec, original.GetAnnotations(), + r.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations")) + } + } + return errs +} + +func (rs *RouteSpec) Validate(ctx context.Context) *apis.FieldError { + if equality.Semantic.DeepEqual(rs, &RouteSpec{}) { + return apis.ErrMissingField(apis.CurrentField) + } + + errs := apis.CheckDeprecated(ctx, rs) + + type diagnostic struct { + index int + field string + } + // Track the targets of named TrafficTarget entries (to detect duplicates). + trafficMap := make(map[string]diagnostic) + + percentSum := int64(0) + for i, tt := range rs.Traffic { + // Delegate to the v1 validation. + errs = errs.Also(tt.TrafficTarget.Validate(ctx).ViaFieldIndex("traffic", i)) + + if tt.Percent != nil { + percentSum += *tt.Percent + } + + if tt.DeprecatedName != "" && tt.Tag != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "tag"). + ViaFieldIndex("traffic", i)) + } else if tt.DeprecatedName == "" && tt.Tag == "" { + // No Name field, so skip the uniqueness check. + continue + } + + errs = errs.Also(apis.CheckDeprecated(ctx, tt).ViaFieldIndex("traffic", i)) + + name := tt.DeprecatedName + field := "name" + if name == "" { + name = tt.Tag + field = "tag" + } + + if d, ok := trafficMap[name]; !ok { + // No entry exists, so add ours + trafficMap[name] = diagnostic{i, field} + } else { + // We want only single definition of the route, even if it points + // to the same config or revision. + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Multiple definitions for %q", name), + Paths: []string{ + fmt.Sprintf("traffic[%d].%s", d.index, d.field), + fmt.Sprintf("traffic[%d].%s", i, field), + }, + }) + } + } + + if percentSum != 100 { + errs = errs.Also(&apis.FieldError{ + Message: fmt.Sprintf("Traffic targets sum to %d, want 100", percentSum), + Paths: []string{"traffic"}, + }) + } + return errs +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_conversion.go new file mode 100644 index 00000000000..c4a799a18ee --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_conversion.go @@ -0,0 +1,157 @@ +/* +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" + + "knative.dev/pkg/apis" + "knative.dev/pkg/ptr" + v1 "knative.dev/serving/pkg/apis/serving/v1" + "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// ConvertUp implements apis.Convertible +func (source *Service) ConvertUp(ctx context.Context, obj apis.Convertible) error { + switch sink := obj.(type) { + case *v1beta1.Service: + sink.ObjectMeta = source.ObjectMeta + if err := source.Spec.ConvertUp(ctx, &sink.Spec); err != nil { + return err + } + return source.Status.ConvertUp(ctx, &sink.Status) + case *v1.Service: + sink.ObjectMeta = source.ObjectMeta + if err := source.Spec.ConvertUp(ctx, &sink.Spec); err != nil { + return err + } + return source.Status.ConvertUp(ctx, &sink.Status) + default: + return fmt.Errorf("unknown version, got: %T", sink) + } +} + +// ConvertUp helps implement apis.Convertible +func (source *ServiceSpec) ConvertUp(ctx context.Context, sink *v1.ServiceSpec) error { + switch { + case source.DeprecatedRunLatest != nil: + sink.RouteSpec = v1.RouteSpec{ + Traffic: []v1.TrafficTarget{{ + Percent: ptr.Int64(100), + LatestRevision: ptr.Bool(true), + }}, + } + return source.DeprecatedRunLatest.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) + + case source.DeprecatedRelease != nil: + if len(source.DeprecatedRelease.Revisions) == 2 { + sink.RouteSpec = v1.RouteSpec{ + Traffic: []v1.TrafficTarget{{ + RevisionName: source.DeprecatedRelease.Revisions[0], + Percent: ptr.Int64(int64(100 - source.DeprecatedRelease.RolloutPercent)), + Tag: "current", + }, { + RevisionName: source.DeprecatedRelease.Revisions[1], + Percent: ptr.Int64(int64(source.DeprecatedRelease.RolloutPercent)), + Tag: "candidate", + }, { + Percent: nil, + Tag: "latest", + LatestRevision: ptr.Bool(true), + }}, + } + } else { + sink.RouteSpec = v1.RouteSpec{ + Traffic: []v1.TrafficTarget{{ + RevisionName: source.DeprecatedRelease.Revisions[0], + Percent: ptr.Int64(100), + Tag: "current", + }, { + Percent: nil, + Tag: "latest", + LatestRevision: ptr.Bool(true), + }}, + } + } + for i, tt := range sink.RouteSpec.Traffic { + if tt.RevisionName == "@latest" { + sink.RouteSpec.Traffic[i].RevisionName = "" + sink.RouteSpec.Traffic[i].LatestRevision = ptr.Bool(true) + } + } + return source.DeprecatedRelease.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) + + case source.DeprecatedPinned != nil: + sink.RouteSpec = v1.RouteSpec{ + Traffic: []v1.TrafficTarget{{ + RevisionName: source.DeprecatedPinned.RevisionName, + Percent: ptr.Int64(100), + }}, + } + return source.DeprecatedPinned.Configuration.ConvertUp(ctx, &sink.ConfigurationSpec) + + case source.DeprecatedManual != nil: + return ConvertErrorf("manual", "manual mode cannot be migrated forward.") + + default: + source.RouteSpec.ConvertUp(ctx, &sink.RouteSpec) + return source.ConfigurationSpec.ConvertUp(ctx, &sink.ConfigurationSpec) + } +} + +// ConvertUp helps implement apis.Convertible +func (source *ServiceStatus) ConvertUp(ctx context.Context, sink *v1.ServiceStatus) error { + source.Status.ConvertTo(ctx, &sink.Status) + + source.RouteStatusFields.ConvertUp(ctx, &sink.RouteStatusFields) + return source.ConfigurationStatusFields.ConvertUp(ctx, &sink.ConfigurationStatusFields) +} + +// ConvertDown implements apis.Convertible +func (sink *Service) ConvertDown(ctx context.Context, obj apis.Convertible) error { + switch source := obj.(type) { + case *v1beta1.Service: + sink.ObjectMeta = source.ObjectMeta + if err := sink.Spec.ConvertDown(ctx, source.Spec); err != nil { + return err + } + return sink.Status.ConvertDown(ctx, source.Status) + case *v1.Service: + sink.ObjectMeta = source.ObjectMeta + if err := sink.Spec.ConvertDown(ctx, source.Spec); err != nil { + return err + } + return sink.Status.ConvertDown(ctx, source.Status) + default: + return fmt.Errorf("unknown version, got: %T", source) + } +} + +// ConvertDown helps implement apis.Convertible +func (sink *ServiceSpec) ConvertDown(ctx context.Context, source v1.ServiceSpec) error { + sink.RouteSpec.ConvertDown(ctx, source.RouteSpec) + return sink.ConfigurationSpec.ConvertDown(ctx, source.ConfigurationSpec) +} + +// ConvertDown helps implement apis.Convertible +func (sink *ServiceStatus) ConvertDown(ctx context.Context, source v1.ServiceStatus) error { + source.Status.ConvertTo(ctx, &sink.Status) + + sink.RouteStatusFields.ConvertDown(ctx, source.RouteStatusFields) + return sink.ConfigurationStatusFields.ConvertDown(ctx, source.ConfigurationStatusFields) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_defaults.go new file mode 100644 index 00000000000..8e7b77c1554 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_defaults.go @@ -0,0 +1,60 @@ +/* +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 v1alpha1 + +import ( + "context" + + "knative.dev/pkg/apis" + + "knative.dev/serving/pkg/apis/serving" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +func (s *Service) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, s.ObjectMeta) + s.Spec.SetDefaults(apis.WithinSpec(ctx)) + if apis.IsInUpdate(ctx) { + serving.SetUserInfo(ctx, apis.GetBaseline(ctx).(*Service).Spec, s.Spec, s) + } else { + serving.SetUserInfo(ctx, nil, s.Spec, s) + } +} + +func (ss *ServiceSpec) SetDefaults(ctx context.Context) { + if v1.IsUpgradeViaDefaulting(ctx) { + v := v1.ServiceSpec{} + if ss.ConvertUp(ctx, &v) == nil { + alpha := ServiceSpec{} + if alpha.ConvertDown(ctx, v) == nil { + *ss = alpha + } + } + } + + if ss.DeprecatedRunLatest != nil { + ss.DeprecatedRunLatest.Configuration.SetDefaults(ctx) + } else if ss.DeprecatedPinned != nil { + ss.DeprecatedPinned.Configuration.SetDefaults(ctx) + } else if ss.DeprecatedRelease != nil { + ss.DeprecatedRelease.Configuration.SetDefaults(ctx) + } else if ss.DeprecatedManual != nil { + } else { + ss.ConfigurationSpec.SetDefaults(ctx) + ss.RouteSpec.SetDefaults(v1.WithDefaultConfigurationName(ctx)) + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go new file mode 100644 index 00000000000..168b5fb4cc8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_lifecycle.go @@ -0,0 +1,161 @@ +/* +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 ( + "fmt" + + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +var serviceCondSet = apis.NewLivingConditionSet( + ServiceConditionConfigurationsReady, + ServiceConditionRoutesReady, +) + +// GetGroupVersionKind returns the GetGroupVersionKind. +func (s *Service) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Service") +} + +// IsReady returns if the service is ready to serve the requested configuration. +func (ss *ServiceStatus) IsReady() bool { + return serviceCondSet.Manage(ss).IsHappy() +} + +// GetCondition returns the condition by name. +func (ss *ServiceStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return serviceCondSet.Manage(ss).GetCondition(t) +} + +// InitializeConditions sets the initial values to the conditions. +func (ss *ServiceStatus) InitializeConditions() { + serviceCondSet.Manage(ss).InitializeConditions() +} + +// MarkResourceNotConvertible adds a Warning-severity condition to the resource noting that +// it cannot be converted to a higher version. +func (ss *ServiceStatus) MarkResourceNotConvertible(err *CannotConvertError) { + serviceCondSet.Manage(ss).SetCondition(apis.Condition{ + Type: ConditionTypeConvertible, + Status: corev1.ConditionFalse, + Severity: apis.ConditionSeverityWarning, + Reason: err.Field, + Message: err.Message, + }) +} + +// MarkConfigurationNotOwned surfaces a failure via the ConfigurationsReady +// status noting that the Configuration with the name we want has already +// been created and we do not own it. +func (ss *ServiceStatus) MarkConfigurationNotOwned(name string) { + serviceCondSet.Manage(ss).MarkFalse(ServiceConditionConfigurationsReady, "NotOwned", + fmt.Sprintf("There is an existing Configuration %q that we do not own.", name)) +} + +// MarkRouteNotOwned surfaces a failure via the RoutesReady status noting that the Route +// with the name we want has already been created and we do not own it. +func (ss *ServiceStatus) MarkRouteNotOwned(name string) { + serviceCondSet.Manage(ss).MarkFalse(ServiceConditionRoutesReady, "NotOwned", + fmt.Sprintf("There is an existing Route %q that we do not own.", name)) +} + +// MarkConfigurationNotReconciled notes that the Configuration controller has not yet +// caught up to the desired changes we have specified. +func (ss *ServiceStatus) MarkConfigurationNotReconciled() { + serviceCondSet.Manage(ss).MarkUnknown(ServiceConditionConfigurationsReady, + "OutOfDate", "The Configuration is still working to reflect the latest desired specification.") +} + +// PropagateConfigurationStatus takes the Configuration status and applies its values +// to the Service status. +func (ss *ServiceStatus) PropagateConfigurationStatus(cs *ConfigurationStatus) { + ss.ConfigurationStatusFields = cs.ConfigurationStatusFields + + cc := cs.GetCondition(ConfigurationConditionReady) + if cc == nil { + return + } + switch { + case cc.Status == corev1.ConditionUnknown: + serviceCondSet.Manage(ss).MarkUnknown(ServiceConditionConfigurationsReady, cc.Reason, cc.Message) + case cc.Status == corev1.ConditionTrue: + serviceCondSet.Manage(ss).MarkTrue(ServiceConditionConfigurationsReady) + case cc.Status == corev1.ConditionFalse: + serviceCondSet.Manage(ss).MarkFalse(ServiceConditionConfigurationsReady, cc.Reason, cc.Message) + } +} + +// MarkRevisionNameTaken notes that the Route has not been programmed because the revision name is taken by a +// conflicting revision definition. +func (ss *ServiceStatus) MarkRevisionNameTaken(name string) { + serviceCondSet.Manage(ss).MarkFalse(ServiceConditionRoutesReady, "RevisionNameTaken", + "The revision name %q is taken by a conflicting Revision, so traffic will not be migrated", name) +} + +const ( + trafficNotMigratedReason = "TrafficNotMigrated" + trafficNotMigratedMessage = "Traffic is not yet migrated to the latest revision." + + // LatestTrafficTarget is the named constant of the `latest` traffic target. + LatestTrafficTarget = "latest" + + // CurrentTrafficTarget is the named constnat of the `current` traffic target. + CurrentTrafficTarget = "current" + + // CandidateTrafficTarget is the named constnat of the `candidate` traffic target. + CandidateTrafficTarget = "candidate" +) + +// MarkRouteNotYetReady marks the service `RouteReady` condition to the `Unknown` state. +// See: #2430, for details. +func (ss *ServiceStatus) MarkRouteNotYetReady() { + serviceCondSet.Manage(ss).MarkUnknown(ServiceConditionRoutesReady, trafficNotMigratedReason, trafficNotMigratedMessage) +} + +// MarkRouteNotReconciled notes that the Route controller has not yet +// caught up to the desired changes we have specified. +func (ss *ServiceStatus) MarkRouteNotReconciled() { + serviceCondSet.Manage(ss).MarkUnknown(ServiceConditionRoutesReady, + "OutOfDate", "The Route is still working to reflect the latest desired specification.") +} + +// PropagateRouteStatus propagates route's status to the service's status. +func (ss *ServiceStatus) PropagateRouteStatus(rs *RouteStatus) { + ss.RouteStatusFields = rs.RouteStatusFields + + rc := rs.GetCondition(RouteConditionReady) + if rc == nil { + return + } + switch { + case rc.Status == corev1.ConditionUnknown: + serviceCondSet.Manage(ss).MarkUnknown(ServiceConditionRoutesReady, rc.Reason, rc.Message) + case rc.Status == corev1.ConditionTrue: + serviceCondSet.Manage(ss).MarkTrue(ServiceConditionRoutesReady) + case rc.Status == corev1.ConditionFalse: + serviceCondSet.Manage(ss).MarkFalse(ServiceConditionRoutesReady, rc.Reason, rc.Message) + } +} + +func (ss *ServiceStatus) duck() *duckv1.Status { + return &ss.Status +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_types.go new file mode 100644 index 00000000000..16580a386f1 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_types.go @@ -0,0 +1,194 @@ +/* +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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "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 + +// Service acts as a top-level container that manages a set of Routes and +// Configurations which implement a network service. Service exists to provide a +// singular abstraction which can be access controlled, reasoned about, and +// which encapsulates software lifecycle decisions such as rollout policy and +// team resource ownership. Service acts only as an orchestrator of the +// underlying Routes and Configurations (much as a kubernetes Deployment +// orchestrates ReplicaSets), and its usage is optional but recommended. +// +// The Service's controller will track the statuses of its owned Configuration +// and Route, reflecting their statuses and conditions as its own. +// +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#service +type Service struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + // +optional + Spec ServiceSpec `json:"spec,omitempty"` + // +optional + Status ServiceStatus `json:"status,omitempty"` +} + +// Verify that Service adheres to the appropriate interfaces. +var ( + // Check that Service may be validated and defaulted. + _ apis.Validatable = (*Service)(nil) + _ apis.Defaultable = (*Service)(nil) + + // Check that Route can be converted to higher versions. + _ apis.Convertible = (*Service)(nil) + + // Check that we can create OwnerReferences to a Service. + _ kmeta.OwnerRefable = (*Service)(nil) +) + +// ServiceSpec represents the configuration for the Service object. Exactly one +// of its members (other than Generation) must be specified. Services can either +// track the latest ready revision of a configuration or be pinned to a specific +// revision. +type ServiceSpec struct { + // DeprecatedGeneration was used prior in Kubernetes versions <1.11 + // when metadata.generation was not being incremented by the api server + // + // This property will be dropped in future Knative releases and should + // not be used - use metadata.generation + // + // Tracking issue: https://github.com/knative/serving/issues/643 + // + // +optional + DeprecatedGeneration int64 `json:"generation,omitempty"` + + // DeprecatedRunLatest defines a simple Service. It will automatically + // configure a route that keeps the latest ready revision + // from the supplied configuration running. + // +optional + DeprecatedRunLatest *RunLatestType `json:"runLatest,omitempty"` + + // DeprecatedPinned is DEPRECATED in favor of ReleaseType + // +optional + DeprecatedPinned *PinnedType `json:"pinned,omitempty"` + + // DeprecatedManual mode enables users to start managing the underlying Route and Configuration + // resources directly. This advanced usage is intended as a path for users to graduate + // from the limited capabilities of Service to the full power of Route. + // +optional + DeprecatedManual *ManualType `json:"manual,omitempty"` + + // Release enables gradual promotion of new revisions by allowing traffic + // to be split between two revisions. This type replaces the deprecated Pinned type. + // +optional + DeprecatedRelease *ReleaseType `json:"release,omitempty"` + + // We are moving to a shape where the Configuration and Route specifications + // are inlined into the Service, which gives them compatible shapes. We are + // staging this change here as a path to this in v1beta1, which drops the + // "mode" based specifications above. Ultimately all non-v1beta1 fields will + // be deprecated, and then dropped in v1beta1. + ConfigurationSpec `json:",inline"` + RouteSpec `json:",inline"` +} + +// ManualType contains the options for configuring a manual service. See ServiceSpec for +// more details. +type ManualType struct { + // DeprecatedManual type does not contain a configuration as this type provides the + // user complete control over the configuration and route. +} + +// ReleaseType contains the options for slowly releasing revisions. See ServiceSpec for +// more details. +type ReleaseType struct { + // Revisions is an ordered list of 1 or 2 revisions. The first will + // have a TrafficTarget with a name of "current" and the second will have + // a name of "candidate". + // +optional + Revisions []string `json:"revisions,omitempty"` + + // RolloutPercent is the percent of traffic that should be sent to the "candidate" + // revision. Valid values are between 0 and 99 inclusive. + // +optional + RolloutPercent int `json:"rolloutPercent,omitempty"` + + // The configuration for this service. All revisions from this service must + // come from a single configuration. + // +optional + Configuration ConfigurationSpec `json:"configuration,omitempty"` +} + +// ReleaseLatestRevisionKeyword is a shortcut for usage in the `release` mode +// to refer to the latest created revision. +// See #2819 for details. +const ReleaseLatestRevisionKeyword = "@latest" + +// RunLatestType contains the options for always having a route to the latest configuration. See +// ServiceSpec for more details. +type RunLatestType struct { + // The configuration for this service. + // +optional + Configuration ConfigurationSpec `json:"configuration,omitempty"` +} + +// PinnedType is DEPRECATED. ReleaseType should be used instead. To get the behavior of PinnedType set +// ReleaseType.Revisions to []string{PinnedType.RevisionName} and ReleaseType.RolloutPercent to 0. +type PinnedType struct { + // The revision name to pin this service to until changed + // to a different service type. + // +optional + RevisionName string `json:"revisionName,omitempty"` + + // The configuration for this service. + // +optional + Configuration ConfigurationSpec `json:"configuration,omitempty"` +} + +// ConditionType represents a Service condition value +const ( + // ServiceConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + ServiceConditionReady = apis.ConditionReady + // ServiceConditionRoutesReady is set when the service's underlying + // routes have reported readiness. + ServiceConditionRoutesReady apis.ConditionType = "RoutesReady" + // ServiceConditionConfigurationsReady is set when the service's underlying + // configurations have reported readiness. + ServiceConditionConfigurationsReady apis.ConditionType = "ConfigurationsReady" +) + +// ServiceStatus represents the Status stanza of the Service resource. +type ServiceStatus struct { + duckv1.Status `json:",inline"` + + RouteStatusFields `json:",inline"` + + ConfigurationStatusFields `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ServiceList is a list of Service resources +type ServiceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Service `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_validation.go new file mode 100644 index 00000000000..5798ab249bf --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/service_validation.go @@ -0,0 +1,183 @@ +/* +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 v1alpha1 + +import ( + "context" + "fmt" + + "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/util/validation" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" + + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// Validate validates the fields belonging to Service +func (s *Service) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(s.GetObjectMeta()).ViaField("metadata")) + ctx = apis.WithinParent(ctx, s.ObjectMeta) + errs = errs.Also(s.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Service) + errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, s.Spec, original.GetAnnotations(), + s.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations")) + field, currentConfig := s.Spec.getConfigurationSpec() + _, originalConfig := original.Spec.getConfigurationSpec() + + if currentConfig != nil && originalConfig != nil { + templateField := "template" + if currentConfig.GetTemplate() == currentConfig.DeprecatedRevisionTemplate { + templateField = "revisionTemplate" + } + err := currentConfig.GetTemplate().VerifyNameChange(ctx, + originalConfig.GetTemplate()) + errs = errs.Also(err.ViaField("spec", field, "configuration", templateField)) + } + } + + return errs +} + +func (ss *ServiceSpec) getConfigurationSpec() (string, *ConfigurationSpec) { + switch { + case ss.DeprecatedRunLatest != nil: + return "runLatest", &ss.DeprecatedRunLatest.Configuration + case ss.DeprecatedRelease != nil: + return "release", &ss.DeprecatedRelease.Configuration + case ss.DeprecatedPinned != nil: + return "pinned", &ss.DeprecatedPinned.Configuration + default: + return "", &ss.ConfigurationSpec + } +} + +// Validate validates the fields belonging to ServiceSpec recursively +func (ss *ServiceSpec) Validate(ctx context.Context) *apis.FieldError { + // We would do this semantic DeepEqual, but the spec is comprised + // entirely of a oneof, the validation for which produces a clearer + // error message. + // if equality.Semantic.DeepEqual(ss, &ServiceSpec{}) { + // return apis.ErrMissingField(currentField) + // } + + errs := apis.CheckDeprecated(ctx, ss) + + set := []string{} + + if ss.DeprecatedRunLatest != nil { + set = append(set, "runLatest") + errs = errs.Also(ss.DeprecatedRunLatest.Validate(ctx).ViaField("runLatest")) + } + if ss.DeprecatedRelease != nil { + set = append(set, "release") + errs = errs.Also(ss.DeprecatedRelease.Validate(ctx).ViaField("release")) + } + if ss.DeprecatedManual != nil { + set = append(set, "manual") + errs = errs.Also(apis.ErrDisallowedFields("manual")) + } + if ss.DeprecatedPinned != nil { + set = append(set, "pinned") + errs = errs.Also(ss.DeprecatedPinned.Validate(ctx).ViaField("pinned")) + } + + // Before checking ConfigurationSpec, check RouteSpec. + if len(set) > 0 && len(ss.RouteSpec.Traffic) > 0 { + errs = errs.Also(apis.ErrMultipleOneOf( + append([]string{"traffic"}, set...)...)) + } + + if !equality.Semantic.DeepEqual(ss.ConfigurationSpec, ConfigurationSpec{}) { + set = append(set, "template") + + // Disallow the use of deprecated fields within our inlined + // Configuration and Route specs. + ctx = apis.DisallowDeprecated(ctx) + + errs = errs.Also(ss.ConfigurationSpec.Validate(ctx)) + errs = errs.Also(ss.RouteSpec.Validate( + // Within the context of Service, the RouteSpec has a default + // configurationName. + v1.WithDefaultConfigurationName(ctx))) + } + + if len(set) > 1 { + errs = errs.Also(apis.ErrMultipleOneOf(set...)) + } else if len(set) == 0 { + errs = errs.Also(apis.ErrMissingOneOf("runLatest", "release", "pinned", "template")) + } + return errs +} + +// Validate validates the fields belonging to PinnedType +func (pt *PinnedType) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + if pt.RevisionName == "" { + errs = apis.ErrMissingField("revisionName") + } + return errs.Also(pt.Configuration.Validate(ctx).ViaField("configuration")) +} + +// Validate validates the fields belonging to RunLatestType +func (rlt *RunLatestType) Validate(ctx context.Context) *apis.FieldError { + return rlt.Configuration.Validate(ctx).ViaField("configuration") +} + +// Validate validates the fields belonging to ReleaseType +func (rt *ReleaseType) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + numRevisions := len(rt.Revisions) + if numRevisions == 0 { + errs = errs.Also(apis.ErrMissingField("revisions")) + } + if numRevisions > 2 { + errs = errs.Also(apis.ErrOutOfBoundsValue(numRevisions, 1, 2, "revisions")) + } + for i, r := range rt.Revisions { + // Skip over the last revision special keyword. + if r == ReleaseLatestRevisionKeyword { + continue + } + if msgs := validation.IsDNS1035Label(r); len(msgs) > 0 { + errs = errs.Also(apis.ErrInvalidArrayValue( + fmt.Sprintf("not a DNS 1035 label: %v", msgs), + "revisions", i)) + } + } + + if numRevisions < 2 && rt.RolloutPercent != 0 { + errs = errs.Also(apis.ErrGeneric("may not set rolloutPercent for a single revision", "rolloutPercent")) + } + + if rt.RolloutPercent < 0 || rt.RolloutPercent > 99 { + errs = errs.Also(apis.ErrOutOfBoundsValue( + rt.RolloutPercent, 0, 99, + "rolloutPercent")) + } + + return errs.Also(rt.Configuration.Validate(ctx).ViaField("configuration")) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..8d347d821b6 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,635 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 ( + v1 "k8s.io/api/core/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + apis "knative.dev/pkg/apis" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CannotConvertError) DeepCopyInto(out *CannotConvertError) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CannotConvertError. +func (in *CannotConvertError) DeepCopy() *CannotConvertError { + if in == nil { + return nil + } + out := new(CannotConvertError) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Configuration) DeepCopyInto(out *Configuration) { + *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 Configuration. +func (in *Configuration) DeepCopy() *Configuration { + if in == nil { + return nil + } + out := new(Configuration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Configuration) 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 *ConfigurationList) DeepCopyInto(out *ConfigurationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Configuration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationList. +func (in *ConfigurationList) DeepCopy() *ConfigurationList { + if in == nil { + return nil + } + out := new(ConfigurationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ConfigurationList) 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 *ConfigurationSpec) DeepCopyInto(out *ConfigurationSpec) { + *out = *in + if in.DeprecatedBuild != nil { + in, out := &in.DeprecatedBuild, &out.DeprecatedBuild + *out = new(runtime.RawExtension) + (*in).DeepCopyInto(*out) + } + if in.DeprecatedRevisionTemplate != nil { + in, out := &in.DeprecatedRevisionTemplate, &out.DeprecatedRevisionTemplate + *out = new(RevisionTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.Template != nil { + in, out := &in.Template, &out.Template + *out = new(RevisionTemplateSpec) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationSpec. +func (in *ConfigurationSpec) DeepCopy() *ConfigurationSpec { + if in == nil { + return nil + } + out := new(ConfigurationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationStatus) DeepCopyInto(out *ConfigurationStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + out.ConfigurationStatusFields = in.ConfigurationStatusFields + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationStatus. +func (in *ConfigurationStatus) DeepCopy() *ConfigurationStatus { + if in == nil { + return nil + } + out := new(ConfigurationStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ConfigurationStatusFields) DeepCopyInto(out *ConfigurationStatusFields) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationStatusFields. +func (in *ConfigurationStatusFields) DeepCopy() *ConfigurationStatusFields { + if in == nil { + return nil + } + out := new(ConfigurationStatusFields) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ManualType) DeepCopyInto(out *ManualType) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManualType. +func (in *ManualType) DeepCopy() *ManualType { + if in == nil { + return nil + } + out := new(ManualType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PinnedType) DeepCopyInto(out *PinnedType) { + *out = *in + in.Configuration.DeepCopyInto(&out.Configuration) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PinnedType. +func (in *PinnedType) DeepCopy() *PinnedType { + if in == nil { + return nil + } + out := new(PinnedType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ReleaseType) DeepCopyInto(out *ReleaseType) { + *out = *in + if in.Revisions != nil { + in, out := &in.Revisions, &out.Revisions + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.Configuration.DeepCopyInto(&out.Configuration) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReleaseType. +func (in *ReleaseType) DeepCopy() *ReleaseType { + if in == nil { + return nil + } + out := new(ReleaseType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Revision) DeepCopyInto(out *Revision) { + *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 Revision. +func (in *Revision) DeepCopy() *Revision { + if in == nil { + return nil + } + out := new(Revision) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Revision) 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 *RevisionList) DeepCopyInto(out *RevisionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Revision, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionList. +func (in *RevisionList) DeepCopy() *RevisionList { + if in == nil { + return nil + } + out := new(RevisionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RevisionList) 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 *RevisionSpec) DeepCopyInto(out *RevisionSpec) { + *out = *in + in.RevisionSpec.DeepCopyInto(&out.RevisionSpec) + if in.DeprecatedBuildRef != nil { + in, out := &in.DeprecatedBuildRef, &out.DeprecatedBuildRef + *out = new(v1.ObjectReference) + **out = **in + } + if in.DeprecatedContainer != nil { + in, out := &in.DeprecatedContainer, &out.DeprecatedContainer + *out = new(v1.Container) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionSpec. +func (in *RevisionSpec) DeepCopy() *RevisionSpec { + if in == nil { + return nil + } + out := new(RevisionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionStatus) DeepCopyInto(out *RevisionStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionStatus. +func (in *RevisionStatus) DeepCopy() *RevisionStatus { + if in == nil { + return nil + } + out := new(RevisionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RevisionTemplateSpec) DeepCopyInto(out *RevisionTemplateSpec) { + *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 RevisionTemplateSpec. +func (in *RevisionTemplateSpec) DeepCopy() *RevisionTemplateSpec { + if in == nil { + return nil + } + out := new(RevisionTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Route) DeepCopyInto(out *Route) { + *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 Route. +func (in *Route) DeepCopy() *Route { + if in == nil { + return nil + } + out := new(Route) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Route) 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 *RouteList) DeepCopyInto(out *RouteList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Route, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteList. +func (in *RouteList) DeepCopy() *RouteList { + if in == nil { + return nil + } + out := new(RouteList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RouteList) 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 *RouteSpec) DeepCopyInto(out *RouteSpec) { + *out = *in + if in.Traffic != nil { + in, out := &in.Traffic, &out.Traffic + *out = make([]TrafficTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteSpec. +func (in *RouteSpec) DeepCopy() *RouteSpec { + if in == nil { + return nil + } + out := new(RouteSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteStatus) DeepCopyInto(out *RouteStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatus. +func (in *RouteStatus) DeepCopy() *RouteStatus { + if in == nil { + return nil + } + out := new(RouteStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RouteStatusFields) DeepCopyInto(out *RouteStatusFields) { + *out = *in + if in.URL != nil { + in, out := &in.URL, &out.URL + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + if in.Address != nil { + in, out := &in.Address, &out.Address + *out = new(duckv1alpha1.Addressable) + (*in).DeepCopyInto(*out) + } + if in.Traffic != nil { + in, out := &in.Traffic, &out.Traffic + *out = make([]TrafficTarget, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteStatusFields. +func (in *RouteStatusFields) DeepCopy() *RouteStatusFields { + if in == nil { + return nil + } + out := new(RouteStatusFields) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RunLatestType) DeepCopyInto(out *RunLatestType) { + *out = *in + in.Configuration.DeepCopyInto(&out.Configuration) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RunLatestType. +func (in *RunLatestType) DeepCopy() *RunLatestType { + if in == nil { + return nil + } + out := new(RunLatestType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Service) DeepCopyInto(out *Service) { + *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 Service. +func (in *Service) DeepCopy() *Service { + if in == nil { + return nil + } + out := new(Service) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Service) 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 *ServiceList) DeepCopyInto(out *ServiceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Service, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceList. +func (in *ServiceList) DeepCopy() *ServiceList { + if in == nil { + return nil + } + out := new(ServiceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServiceList) 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 *ServiceSpec) DeepCopyInto(out *ServiceSpec) { + *out = *in + if in.DeprecatedRunLatest != nil { + in, out := &in.DeprecatedRunLatest, &out.DeprecatedRunLatest + *out = new(RunLatestType) + (*in).DeepCopyInto(*out) + } + if in.DeprecatedPinned != nil { + in, out := &in.DeprecatedPinned, &out.DeprecatedPinned + *out = new(PinnedType) + (*in).DeepCopyInto(*out) + } + if in.DeprecatedManual != nil { + in, out := &in.DeprecatedManual, &out.DeprecatedManual + *out = new(ManualType) + **out = **in + } + if in.DeprecatedRelease != nil { + in, out := &in.DeprecatedRelease, &out.DeprecatedRelease + *out = new(ReleaseType) + (*in).DeepCopyInto(*out) + } + in.ConfigurationSpec.DeepCopyInto(&out.ConfigurationSpec) + in.RouteSpec.DeepCopyInto(&out.RouteSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceSpec. +func (in *ServiceSpec) DeepCopy() *ServiceSpec { + if in == nil { + return nil + } + out := new(ServiceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceStatus) DeepCopyInto(out *ServiceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + in.RouteStatusFields.DeepCopyInto(&out.RouteStatusFields) + out.ConfigurationStatusFields = in.ConfigurationStatusFields + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceStatus. +func (in *ServiceStatus) DeepCopy() *ServiceStatus { + if in == nil { + return nil + } + out := new(ServiceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TrafficTarget) DeepCopyInto(out *TrafficTarget) { + *out = *in + in.TrafficTarget.DeepCopyInto(&out.TrafficTarget) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TrafficTarget. +func (in *TrafficTarget) DeepCopy() *TrafficTarget { + if in == nil { + return nil + } + out := new(TrafficTarget) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_conversion.go new file mode 100644 index 00000000000..ede69e83f23 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_conversion.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 v1beta1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Configuration) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Configuration) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_defaults.go new file mode 100644 index 00000000000..eb48e8a79ce --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_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 v1beta1 + +import ( + "context" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +// SetDefaults implements apis.Defaultable +func (c *Configuration) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, c.ObjectMeta) + c.Spec.SetDefaults(apis.WithinSpec(ctx)) + if c.GetOwnerReferences() == nil { + if apis.IsInUpdate(ctx) { + serving.SetUserInfo(ctx, apis.GetBaseline(ctx).(*Configuration).Spec, c.Spec, c) + } else { + serving.SetUserInfo(ctx, nil, c.Spec, c) + } + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go new file mode 100644 index 00000000000..b2b1297b82b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_lifecycle.go @@ -0,0 +1,24 @@ +/* +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 v1beta1 + +import "k8s.io/apimachinery/pkg/runtime/schema" + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Configuration) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Configuration") +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_types.go new file mode 100644 index 00000000000..fbc18a92c53 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_types.go @@ -0,0 +1,73 @@ +/* +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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + "knative.dev/pkg/kmeta" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Configuration represents the "floating HEAD" of a linear history of Revisions. +// Users create new Revisions by updating the Configuration's spec. +// The "latest created" revision's name is available under status, as is the +// "latest ready" revision's name. +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#configuration +type Configuration struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec v1.ConfigurationSpec `json:"spec,omitempty"` + + // +optional + Status v1.ConfigurationStatus `json:"status,omitempty"` +} + +// Verify that Configuration adheres to the appropriate interfaces. +var ( + // Check that Configuration may be validated and defaulted. + _ apis.Validatable = (*Configuration)(nil) + _ apis.Defaultable = (*Configuration)(nil) + + // Check that Configuration can be converted to higher versions. + _ apis.Convertible = (*Configuration)(nil) + + // Check that we can create OwnerReferences to a Configuration. + _ kmeta.OwnerRefable = (*Configuration)(nil) +) + +const ( + // ConfigurationConditionReady is set when the configuration's latest + // underlying revision has reported readiness. + ConfigurationConditionReady = apis.ConditionReady +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ConfigurationList is a list of Configuration resources +type ConfigurationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Configuration `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_validation.go new file mode 100644 index 00000000000..f4df84744c3 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/configuration_validation.go @@ -0,0 +1,83 @@ +/* +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 v1beta1 + +import ( + "context" + "strings" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" + "knative.dev/serving/pkg/reconciler/route/config" +) + +// Validate makes sure that Configuration is properly configured. +func (c *Configuration) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(c.GetObjectMeta()).Also( + c.validateLabels().ViaField("labels")).ViaField("metadata")) + ctx = apis.WithinParent(ctx, c.ObjectMeta) + errs = errs.Also(c.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + errs = errs.Also(c.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Configuration) + // Don't validate annotations(creator and lastModifier) when configuration owned by service + // validate only when configuration created independently. + if c.OwnerReferences == nil { + errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, c.Spec, original.GetAnnotations(), + c.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations")) + } + err := c.Spec.Template.VerifyNameChange(ctx, original.Spec.Template) + errs = errs.Also(err.ViaField("spec.template")) + } + + return errs +} + +// validateLabels function validates configuration labels +func (c *Configuration) validateLabels() (errs *apis.FieldError) { + for key, val := range c.GetLabels() { + switch { + case key == config.VisibilityLabelKey: + errs = errs.Also(serving.ValidateClusterVisibilityLabel(val)) + case key == serving.RouteLabelKey: + case key == serving.ServiceLabelKey: + errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", c.GetOwnerReferences())) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return +} + +// verifyLabelOwnerRef function verifies the owner references of resource with label key has val value. +func verifyLabelOwnerRef(val, label, resource string, ownerRefs []metav1.OwnerReference) (errs *apis.FieldError) { + for _, ref := range ownerRefs { + if ref.Kind == resource && val == ref.Name { + return + } + } + return errs.Also(apis.ErrMissingField(label)) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/doc.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/doc.go new file mode 100644 index 00000000000..1aad21df515 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/doc.go @@ -0,0 +1,23 @@ +/* +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. +*/ + +// Api versions allow the api contract for a resource to be changed while keeping +// backward compatibility by support multiple concurrent versions +// of the same resource + +// +k8s:deepcopy-gen=package +// +groupName=serving.knative.dev +package v1beta1 diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/register.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/register.go new file mode 100644 index 00000000000..1e8d182282a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/register.go @@ -0,0 +1,59 @@ +/* +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 v1beta1 + +import ( + "knative.dev/serving/pkg/apis/serving" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: serving.GroupName, Version: "v1beta1"} + +// 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 { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Revision{}, + &RevisionList{}, + &Configuration{}, + &ConfigurationList{}, + &Route{}, + &RouteList{}, + &Service{}, + &ServiceList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_conversion.go new file mode 100644 index 00000000000..388cef7410f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_conversion.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 v1beta1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Revision) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Revision) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_defaults.go new file mode 100644 index 00000000000..4a00953945c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_defaults.go @@ -0,0 +1,26 @@ +/* +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 v1beta1 + +import ( + "context" +) + +// SetDefaults implements apis.Defaultable +func (r *Revision) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(ctx) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go new file mode 100644 index 00000000000..f737dbaf578 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_lifecycle.go @@ -0,0 +1,31 @@ +/* +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 v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" +) + +const ( + // DefaultUserPort is the system default port value exposed on the user-container. + DefaultUserPort = 8080 +) + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Revision) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Revision") +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_types.go new file mode 100644 index 00000000000..fcaa9fbf47e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_types.go @@ -0,0 +1,73 @@ +/* +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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/pkg/apis" + "knative.dev/pkg/kmeta" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Revision is an immutable snapshot of code and configuration. A revision +// references a container image. Revisions are created by updates to a +// Configuration. +// +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#revision +type Revision struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec v1.RevisionSpec `json:"spec,omitempty"` + + // +optional + Status v1.RevisionStatus `json:"status,omitempty"` +} + +// Verify that Revision adheres to the appropriate interfaces. +var ( + // Check that Revision can be validated, can be defaulted, and has immutable fields. + _ apis.Validatable = (*Revision)(nil) + _ apis.Defaultable = (*Revision)(nil) + + // Check that Revision can be converted to higher versions. + _ apis.Convertible = (*Revision)(nil) + + // Check that we can create OwnerReferences to a Revision. + _ kmeta.OwnerRefable = (*Revision)(nil) +) + +const ( + // RevisionConditionReady is set when the revision is starting to materialize + // runtime resources, and becomes true when those resources are ready. + RevisionConditionReady = apis.ConditionReady +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RevisionList is a list of Revision resources +type RevisionList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Revision `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_validation.go new file mode 100644 index 00000000000..43fe2f6f266 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/revision_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 v1beta1 + +import ( + "context" + "strings" + + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" + "knative.dev/serving/pkg/apis/serving" +) + +// Validate ensures Revision is properly configured. +func (r *Revision) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).Also( + r.ValidateLabels().ViaField("labels")).ViaField("metadata") + errs = errs.Also(r.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Revision) + if diff, err := kmp.ShortDiff(original.Spec, r.Spec); err != nil { + return &apis.FieldError{ + Message: "Failed to diff Revision", + Paths: []string{"spec"}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: diff, + } + } + } else { + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + return errs +} + +// ValidateLabels function validates service labels +func (r *Revision) ValidateLabels() (errs *apis.FieldError) { + for key, val := range r.GetLabels() { + switch { + case key == serving.RouteLabelKey || key == serving.ServiceLabelKey || key == serving.ConfigurationGenerationLabelKey: + case key == serving.ConfigurationLabelKey: + errs = errs.Also(verifyLabelOwnerRef(val, serving.ConfigurationLabelKey, "Configuration", r.GetOwnerReferences())) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, "")) + } + } + return +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_conversion.go new file mode 100644 index 00000000000..3fa1bb1f480 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_conversion.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 v1beta1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Route) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Route) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_defaults.go new file mode 100644 index 00000000000..115c2903c2c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_defaults.go @@ -0,0 +1,36 @@ +/* +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 v1beta1 + +import ( + "context" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +// SetDefaults implements apis.Defaultable +func (r *Route) SetDefaults(ctx context.Context) { + r.Spec.SetDefaults(apis.WithinSpec(ctx)) + if r.GetOwnerReferences() == nil { + if apis.IsInUpdate(ctx) { + serving.SetUserInfo(ctx, apis.GetBaseline(ctx).(*Route).Spec, r.Spec, r) + } else { + serving.SetUserInfo(ctx, nil, r.Spec, r) + } + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_lifecycle.go new file mode 100644 index 00000000000..f4b93117da8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_lifecycle.go @@ -0,0 +1,24 @@ +/* +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 v1beta1 + +import "k8s.io/apimachinery/pkg/runtime/schema" + +// GetGroupVersionKind returns the GroupVersionKind. +func (r *Route) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Route") +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_types.go new file mode 100644 index 00000000000..f98d1fc590c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_types.go @@ -0,0 +1,77 @@ +/* +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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "knative.dev/pkg/apis" + "knative.dev/pkg/kmeta" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Route is responsible for configuring ingress over a collection of Revisions. +// Some of the Revisions a Route distributes traffic over may be specified by +// referencing the Configuration responsible for creating them; in these cases +// the Route is additionally responsible for monitoring the Configuration for +// "latest ready revision" changes, and smoothly rolling out latest revisions. +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#route +type Route struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec holds the desired state of the Route (from the client). + // +optional + Spec v1.RouteSpec `json:"spec,omitempty"` + + // Status communicates the observed state of the Route (from the controller). + // +optional + Status v1.RouteStatus `json:"status,omitempty"` +} + +// Verify that Route adheres to the appropriate interfaces. +var ( + // Check that Route may be validated and defaulted. + _ apis.Validatable = (*Route)(nil) + _ apis.Defaultable = (*Route)(nil) + + // Check that Route can be converted to higher versions. + _ apis.Convertible = (*Route)(nil) + + // Check that we can create OwnerReferences to a Route. + _ kmeta.OwnerRefable = (*Route)(nil) +) + +const ( + // RouteConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + RouteConditionReady = apis.ConditionReady +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RouteList is a list of Route resources +type RouteList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Route `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_validation.go new file mode 100644 index 00000000000..d2ccf00372d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/route_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 v1beta1 + +import ( + "context" + "strings" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" + "knative.dev/serving/pkg/reconciler/route/config" +) + +// Validate makes sure that Route is properly configured. +func (r *Route) Validate(ctx context.Context) *apis.FieldError { + errs := serving.ValidateObjectMetadata(r.GetObjectMeta()).Also( + r.validateLabels().ViaField("labels")).ViaField("metadata") + errs = errs.Also(r.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + errs = errs.Also(r.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Route) + // Don't validate annotations(creator and lastModifier) when route owned by service + // validate only when route created independently. + if r.OwnerReferences == nil { + errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, r.Spec, original.GetAnnotations(), + r.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations")) + } + } + return errs +} + +// validateLabels function validates route labels. +func (r *Route) validateLabels() (errs *apis.FieldError) { + for key, val := range r.GetLabels() { + switch { + case key == config.VisibilityLabelKey: + errs = errs.Also(serving.ValidateClusterVisibilityLabel(val)) + case key == serving.ServiceLabelKey: + errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", r.GetOwnerReferences())) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_conversion.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_conversion.go new file mode 100644 index 00000000000..ca7fdb08181 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_conversion.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 v1beta1 + +import ( + "context" + "fmt" + + "knative.dev/pkg/apis" +) + +// ConvertUp implements apis.Convertible +func (source *Service) ConvertUp(ctx context.Context, sink apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", sink) +} + +// ConvertDown implements apis.Convertible +func (sink *Service) ConvertDown(ctx context.Context, source apis.Convertible) error { + return fmt.Errorf("v1beta1 is the highest known version, got: %T", source) +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_defaults.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_defaults.go new file mode 100644 index 00000000000..906b875d48b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_defaults.go @@ -0,0 +1,35 @@ +/* +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 v1beta1 + +import ( + "context" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" +) + +// SetDefaults implements apis.Defaultable +func (s *Service) SetDefaults(ctx context.Context) { + ctx = apis.WithinParent(ctx, s.ObjectMeta) + s.Spec.SetDefaults(apis.WithinSpec(ctx)) + if apis.IsInUpdate(ctx) { + serving.SetUserInfo(ctx, apis.GetBaseline(ctx).(*Service).Spec, s.Spec, s) + } else { + serving.SetUserInfo(ctx, nil, s.Spec, s) + } +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_lifecycle.go new file mode 100644 index 00000000000..ad59308fcd0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_lifecycle.go @@ -0,0 +1,24 @@ +/* +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 v1beta1 + +import "k8s.io/apimachinery/pkg/runtime/schema" + +// GetGroupVersionKind returns the GroupVersionKind. +func (s *Service) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Service") +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_types.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_types.go new file mode 100644 index 00000000000..3c224273ee7 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_types.go @@ -0,0 +1,82 @@ +/* +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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "knative.dev/pkg/apis" + "knative.dev/pkg/kmeta" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// Service acts as a top-level container that manages a Route and Configuration +// which implement a network service. Service exists to provide a singular +// abstraction which can be access controlled, reasoned about, and which +// encapsulates software lifecycle decisions such as rollout policy and +// team resource ownership. Service acts only as an orchestrator of the +// underlying Routes and Configurations (much as a kubernetes Deployment +// orchestrates ReplicaSets), and its usage is optional but recommended. +// +// The Service's controller will track the statuses of its owned Configuration +// and Route, reflecting their statuses and conditions as its own. +// +// See also: https://github.com/knative/serving/blob/master/docs/spec/overview.md#service +type Service struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +optional + Spec v1.ServiceSpec `json:"spec,omitempty"` + + // +optional + Status v1.ServiceStatus `json:"status,omitempty"` +} + +// Verify that Service adheres to the appropriate interfaces. +var ( + // Check that Service may be validated and defaulted. + _ apis.Validatable = (*Service)(nil) + _ apis.Defaultable = (*Service)(nil) + + // Check that Service can be converted to higher versions. + _ apis.Convertible = (*Service)(nil) + + // Check that we can create OwnerReferences to a Service. + _ kmeta.OwnerRefable = (*Service)(nil) +) + +// ConditionType represents a Service condition value +const ( + // ServiceConditionReady is set when the service is configured + // and has available backends ready to receive traffic. + ServiceConditionReady = apis.ConditionReady +) + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ServiceList is a list of Service resources +type ServiceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Service `json:"items"` +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_validation.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_validation.go new file mode 100644 index 00000000000..6daced418ca --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/service_validation.go @@ -0,0 +1,65 @@ +/* +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 v1beta1 + +import ( + "context" + "strings" + + "knative.dev/pkg/apis" + "knative.dev/serving/pkg/apis/serving" + "knative.dev/serving/pkg/reconciler/route/config" +) + +// Validate makes sure that Service is properly configured. +func (s *Service) Validate(ctx context.Context) (errs *apis.FieldError) { + // If we are in a status sub resource update, the metadata and spec cannot change. + // So, to avoid rejecting controller status updates due to validations that may + // have changed (i.e. due to config-defaults changes), we elide the metadata and + // spec validation. + if !apis.IsInStatusUpdate(ctx) { + errs = errs.Also(serving.ValidateObjectMetadata(s.GetObjectMeta()).Also( + s.validateLabels().ViaField("labels")).ViaField("metadata")) + ctx = apis.WithinParent(ctx, s.ObjectMeta) + errs = errs.Also(s.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) + } + + errs = errs.Also(s.Status.Validate(apis.WithinStatus(ctx)).ViaField("status")) + + if apis.IsInUpdate(ctx) { + original := apis.GetBaseline(ctx).(*Service) + errs = errs.Also(apis.ValidateCreatorAndModifier(original.Spec, s.Spec, original.GetAnnotations(), + s.GetAnnotations(), serving.GroupName).ViaField("metadata.annotations")) + err := s.Spec.ConfigurationSpec.Template.VerifyNameChange(ctx, + original.Spec.ConfigurationSpec.Template) + errs = errs.Also(err.ViaField("spec.template")) + } + return errs +} + +// validateLabels function validates service labels +func (s *Service) validateLabels() (errs *apis.FieldError) { + for key, val := range s.GetLabels() { + switch { + case key == config.VisibilityLabelKey: + errs = errs.Also(serving.ValidateClusterVisibilityLabel(val)) + case strings.HasPrefix(key, serving.GroupNamePrefix): + errs = errs.Also(apis.ErrInvalidKeyName(key, apis.CurrentField)) + } + } + return +} diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..0c9d27d139c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,269 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 v1beta1 + +import ( + 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 *Configuration) DeepCopyInto(out *Configuration) { + *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 Configuration. +func (in *Configuration) DeepCopy() *Configuration { + if in == nil { + return nil + } + out := new(Configuration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Configuration) 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 *ConfigurationList) DeepCopyInto(out *ConfigurationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Configuration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigurationList. +func (in *ConfigurationList) DeepCopy() *ConfigurationList { + if in == nil { + return nil + } + out := new(ConfigurationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ConfigurationList) 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 *Revision) DeepCopyInto(out *Revision) { + *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 Revision. +func (in *Revision) DeepCopy() *Revision { + if in == nil { + return nil + } + out := new(Revision) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Revision) 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 *RevisionList) DeepCopyInto(out *RevisionList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Revision, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RevisionList. +func (in *RevisionList) DeepCopy() *RevisionList { + if in == nil { + return nil + } + out := new(RevisionList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RevisionList) 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 *Route) DeepCopyInto(out *Route) { + *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 Route. +func (in *Route) DeepCopy() *Route { + if in == nil { + return nil + } + out := new(Route) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Route) 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 *RouteList) DeepCopyInto(out *RouteList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Route, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteList. +func (in *RouteList) DeepCopy() *RouteList { + if in == nil { + return nil + } + out := new(RouteList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *RouteList) 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 *Service) DeepCopyInto(out *Service) { + *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 Service. +func (in *Service) DeepCopy() *Service { + if in == nil { + return nil + } + out := new(Service) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Service) 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 *ServiceList) DeepCopyInto(out *ServiceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Service, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceList. +func (in *ServiceList) DeepCopy() *ServiceList { + if in == nil { + return nil + } + out := new(ServiceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ServiceList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} diff --git a/vendor/knative.dev/serving/pkg/autoscaler/testdata/config-autoscaler.yaml b/vendor/knative.dev/serving/pkg/autoscaler/testdata/config-autoscaler.yaml new file mode 120000 index 00000000000..a57d715c10e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/autoscaler/testdata/config-autoscaler.yaml @@ -0,0 +1 @@ +../../../config/core/configmaps/autoscaler.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/clientset.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/clientset.go new file mode 100644 index 00000000000..6c637a6c0cd --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/clientset.go @@ -0,0 +1,153 @@ +/* +Copyright 2020 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 versioned + +import ( + "fmt" + + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" + autoscalingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" + networkingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1" + servingv1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1" + servingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" + servingv1beta1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface + NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface + ServingV1alpha1() servingv1alpha1.ServingV1alpha1Interface + ServingV1beta1() servingv1beta1.ServingV1beta1Interface + ServingV1() servingv1.ServingV1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + autoscalingV1alpha1 *autoscalingv1alpha1.AutoscalingV1alpha1Client + networkingV1alpha1 *networkingv1alpha1.NetworkingV1alpha1Client + servingV1alpha1 *servingv1alpha1.ServingV1alpha1Client + servingV1beta1 *servingv1beta1.ServingV1beta1Client + servingV1 *servingv1.ServingV1Client +} + +// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client +func (c *Clientset) AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return c.autoscalingV1alpha1 +} + +// NetworkingV1alpha1 retrieves the NetworkingV1alpha1Client +func (c *Clientset) NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface { + return c.networkingV1alpha1 +} + +// ServingV1alpha1 retrieves the ServingV1alpha1Client +func (c *Clientset) ServingV1alpha1() servingv1alpha1.ServingV1alpha1Interface { + return c.servingV1alpha1 +} + +// ServingV1beta1 retrieves the ServingV1beta1Client +func (c *Clientset) ServingV1beta1() servingv1beta1.ServingV1beta1Interface { + return c.servingV1beta1 +} + +// ServingV1 retrieves the ServingV1Client +func (c *Clientset) ServingV1() servingv1.ServingV1Interface { + return c.servingV1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("Burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.autoscalingV1alpha1, err = autoscalingv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.networkingV1alpha1, err = networkingv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.servingV1alpha1, err = servingv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.servingV1beta1, err = servingv1beta1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + cs.servingV1, err = servingv1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + var cs Clientset + cs.autoscalingV1alpha1 = autoscalingv1alpha1.NewForConfigOrDie(c) + cs.networkingV1alpha1 = networkingv1alpha1.NewForConfigOrDie(c) + cs.servingV1alpha1 = servingv1alpha1.NewForConfigOrDie(c) + cs.servingV1beta1 = servingv1beta1.NewForConfigOrDie(c) + cs.servingV1 = servingv1.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.autoscalingV1alpha1 = autoscalingv1alpha1.New(c) + cs.networkingV1alpha1 = networkingv1alpha1.New(c) + cs.servingV1alpha1 = servingv1alpha1.New(c) + cs.servingV1beta1 = servingv1beta1.New(c) + cs.servingV1 = servingv1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/doc.go new file mode 100644 index 00000000000..e48c2aa4460 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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. + +// This package has the automatically generated clientset. +package versioned diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/clientset_generated.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 00000000000..9a071bf4f17 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,110 @@ +/* +Copyright 2020 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 ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" + clientset "knative.dev/serving/pkg/client/clientset/versioned" + autoscalingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" + fakeautoscalingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake" + networkingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1" + fakenetworkingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake" + servingv1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1" + fakeservingv1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake" + servingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" + fakeservingv1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake" + servingv1beta1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1" + fakeservingv1beta1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var _ clientset.Interface = &Clientset{} + +// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client +func (c *Clientset) AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return &fakeautoscalingv1alpha1.FakeAutoscalingV1alpha1{Fake: &c.Fake} +} + +// NetworkingV1alpha1 retrieves the NetworkingV1alpha1Client +func (c *Clientset) NetworkingV1alpha1() networkingv1alpha1.NetworkingV1alpha1Interface { + return &fakenetworkingv1alpha1.FakeNetworkingV1alpha1{Fake: &c.Fake} +} + +// ServingV1alpha1 retrieves the ServingV1alpha1Client +func (c *Clientset) ServingV1alpha1() servingv1alpha1.ServingV1alpha1Interface { + return &fakeservingv1alpha1.FakeServingV1alpha1{Fake: &c.Fake} +} + +// ServingV1beta1 retrieves the ServingV1beta1Client +func (c *Clientset) ServingV1beta1() servingv1beta1.ServingV1beta1Interface { + return &fakeservingv1beta1.FakeServingV1beta1{Fake: &c.Fake} +} + +// ServingV1 retrieves the ServingV1Client +func (c *Clientset) ServingV1() servingv1.ServingV1Interface { + return &fakeservingv1.FakeServingV1{Fake: &c.Fake} +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/doc.go new file mode 100644 index 00000000000..2c4903250c4 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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. + +// This package has the automatically generated fake clientset. +package fake diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/register.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/register.go new file mode 100644 index 00000000000..c00c329ed3d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/fake/register.go @@ -0,0 +1,64 @@ +/* +Copyright 2020 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" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + autoscalingv1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1" + networkingv1alpha1 "knative.dev/serving/pkg/apis/networking/v1alpha1" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" + servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) +var parameterCodec = runtime.NewParameterCodec(scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + autoscalingv1alpha1.AddToScheme, + networkingv1alpha1.AddToScheme, + servingv1alpha1.AddToScheme, + servingv1beta1.AddToScheme, + servingv1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/scheme/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/scheme/doc.go new file mode 100644 index 00000000000..7acc2dcf252 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/scheme/register.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/scheme/register.go new file mode 100644 index 00000000000..d35b6c429d0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/scheme/register.go @@ -0,0 +1,64 @@ +/* +Copyright 2020 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 scheme + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + autoscalingv1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1" + networkingv1alpha1 "knative.dev/serving/pkg/apis/networking/v1alpha1" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" + servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + autoscalingv1alpha1.AddToScheme, + networkingv1alpha1.AddToScheme, + servingv1alpha1.AddToScheme, + servingv1beta1.AddToScheme, + servingv1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go new file mode 100644 index 00000000000..03344f58c1f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 ( + rest "k8s.io/client-go/rest" + v1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1" + "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +type AutoscalingV1alpha1Interface interface { + RESTClient() rest.Interface + MetricsGetter + PodAutoscalersGetter +} + +// AutoscalingV1alpha1Client is used to interact with features provided by the autoscaling.internal.knative.dev group. +type AutoscalingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *AutoscalingV1alpha1Client) Metrics(namespace string) MetricInterface { + return newMetrics(c, namespace) +} + +func (c *AutoscalingV1alpha1Client) PodAutoscalers(namespace string) PodAutoscalerInterface { + return newPodAutoscalers(c, namespace) +} + +// NewForConfig creates a new AutoscalingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*AutoscalingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &AutoscalingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new AutoscalingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AutoscalingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AutoscalingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *AutoscalingV1alpha1Client { + return &AutoscalingV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AutoscalingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go new file mode 100644 index 00000000000..41e872fe9a9 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go new file mode 100644 index 00000000000..c7f6e65cab8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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 has the automatically generated clients. +package fake diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go new file mode 100644 index 00000000000..1a172fd0c05 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go @@ -0,0 +1,44 @@ +/* +Copyright 2020 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" +) + +type FakeAutoscalingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeAutoscalingV1alpha1) Metrics(namespace string) v1alpha1.MetricInterface { + return &FakeMetrics{c, namespace} +} + +func (c *FakeAutoscalingV1alpha1) PodAutoscalers(namespace string) v1alpha1.PodAutoscalerInterface { + return &FakePodAutoscalers{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAutoscalingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_metric.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_metric.go new file mode 100644 index 00000000000..41497c9f24f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_metric.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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/serving/pkg/apis/autoscaling/v1alpha1" +) + +// FakeMetrics implements MetricInterface +type FakeMetrics struct { + Fake *FakeAutoscalingV1alpha1 + ns string +} + +var metricsResource = schema.GroupVersionResource{Group: "autoscaling.internal.knative.dev", Version: "v1alpha1", Resource: "metrics"} + +var metricsKind = schema.GroupVersionKind{Group: "autoscaling.internal.knative.dev", Version: "v1alpha1", Kind: "Metric"} + +// Get takes name of the metric, and returns the corresponding metric object, and an error if there is any. +func (c *FakeMetrics) Get(name string, options v1.GetOptions) (result *v1alpha1.Metric, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(metricsResource, c.ns, name), &v1alpha1.Metric{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Metric), err +} + +// List takes label and field selectors, and returns the list of Metrics that match those selectors. +func (c *FakeMetrics) List(opts v1.ListOptions) (result *v1alpha1.MetricList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(metricsResource, metricsKind, c.ns, opts), &v1alpha1.MetricList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.MetricList{ListMeta: obj.(*v1alpha1.MetricList).ListMeta} + for _, item := range obj.(*v1alpha1.MetricList).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 metrics. +func (c *FakeMetrics) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(metricsResource, c.ns, opts)) + +} + +// Create takes the representation of a metric and creates it. Returns the server's representation of the metric, and an error, if there is any. +func (c *FakeMetrics) Create(metric *v1alpha1.Metric) (result *v1alpha1.Metric, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(metricsResource, c.ns, metric), &v1alpha1.Metric{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Metric), err +} + +// Update takes the representation of a metric and updates it. Returns the server's representation of the metric, and an error, if there is any. +func (c *FakeMetrics) Update(metric *v1alpha1.Metric) (result *v1alpha1.Metric, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(metricsResource, c.ns, metric), &v1alpha1.Metric{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Metric), 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 *FakeMetrics) UpdateStatus(metric *v1alpha1.Metric) (*v1alpha1.Metric, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(metricsResource, "status", c.ns, metric), &v1alpha1.Metric{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Metric), err +} + +// Delete takes name of the metric and deletes it. Returns an error if one occurs. +func (c *FakeMetrics) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(metricsResource, c.ns, name), &v1alpha1.Metric{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeMetrics) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(metricsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.MetricList{}) + return err +} + +// Patch applies the patch and returns the patched metric. +func (c *FakeMetrics) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Metric, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(metricsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Metric{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Metric), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_podautoscaler.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_podautoscaler.go new file mode 100644 index 00000000000..8f79c262b96 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_podautoscaler.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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/serving/pkg/apis/autoscaling/v1alpha1" +) + +// FakePodAutoscalers implements PodAutoscalerInterface +type FakePodAutoscalers struct { + Fake *FakeAutoscalingV1alpha1 + ns string +} + +var podautoscalersResource = schema.GroupVersionResource{Group: "autoscaling.internal.knative.dev", Version: "v1alpha1", Resource: "podautoscalers"} + +var podautoscalersKind = schema.GroupVersionKind{Group: "autoscaling.internal.knative.dev", Version: "v1alpha1", Kind: "PodAutoscaler"} + +// Get takes name of the podAutoscaler, and returns the corresponding podAutoscaler object, and an error if there is any. +func (c *FakePodAutoscalers) Get(name string, options v1.GetOptions) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(podautoscalersResource, c.ns, name), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// List takes label and field selectors, and returns the list of PodAutoscalers that match those selectors. +func (c *FakePodAutoscalers) List(opts v1.ListOptions) (result *v1alpha1.PodAutoscalerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(podautoscalersResource, podautoscalersKind, c.ns, opts), &v1alpha1.PodAutoscalerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.PodAutoscalerList{ListMeta: obj.(*v1alpha1.PodAutoscalerList).ListMeta} + for _, item := range obj.(*v1alpha1.PodAutoscalerList).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 podAutoscalers. +func (c *FakePodAutoscalers) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(podautoscalersResource, c.ns, opts)) + +} + +// Create takes the representation of a podAutoscaler and creates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *FakePodAutoscalers) Create(podAutoscaler *v1alpha1.PodAutoscaler) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(podautoscalersResource, c.ns, podAutoscaler), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// Update takes the representation of a podAutoscaler and updates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *FakePodAutoscalers) Update(podAutoscaler *v1alpha1.PodAutoscaler) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(podautoscalersResource, c.ns, podAutoscaler), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), 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 *FakePodAutoscalers) UpdateStatus(podAutoscaler *v1alpha1.PodAutoscaler) (*v1alpha1.PodAutoscaler, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(podautoscalersResource, "status", c.ns, podAutoscaler), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} + +// Delete takes name of the podAutoscaler and deletes it. Returns an error if one occurs. +func (c *FakePodAutoscalers) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(podautoscalersResource, c.ns, name), &v1alpha1.PodAutoscaler{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakePodAutoscalers) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(podautoscalersResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.PodAutoscalerList{}) + return err +} + +// Patch applies the patch and returns the patched podAutoscaler. +func (c *FakePodAutoscalers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodAutoscaler, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(podautoscalersResource, c.ns, name, pt, data, subresources...), &v1alpha1.PodAutoscaler{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.PodAutoscaler), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go new file mode 100644 index 00000000000..a9b63f8e07a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2020 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 + +type MetricExpansion interface{} + +type PodAutoscalerExpansion interface{} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/metric.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/metric.go new file mode 100644 index 00000000000..5441e307eec --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/metric.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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/serving/pkg/apis/autoscaling/v1alpha1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// MetricsGetter has a method to return a MetricInterface. +// A group's client should implement this interface. +type MetricsGetter interface { + Metrics(namespace string) MetricInterface +} + +// MetricInterface has methods to work with Metric resources. +type MetricInterface interface { + Create(*v1alpha1.Metric) (*v1alpha1.Metric, error) + Update(*v1alpha1.Metric) (*v1alpha1.Metric, error) + UpdateStatus(*v1alpha1.Metric) (*v1alpha1.Metric, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Metric, error) + List(opts v1.ListOptions) (*v1alpha1.MetricList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Metric, err error) + MetricExpansion +} + +// metrics implements MetricInterface +type metrics struct { + client rest.Interface + ns string +} + +// newMetrics returns a Metrics +func newMetrics(c *AutoscalingV1alpha1Client, namespace string) *metrics { + return &metrics{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the metric, and returns the corresponding metric object, and an error if there is any. +func (c *metrics) Get(name string, options v1.GetOptions) (result *v1alpha1.Metric, err error) { + result = &v1alpha1.Metric{} + err = c.client.Get(). + Namespace(c.ns). + Resource("metrics"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Metrics that match those selectors. +func (c *metrics) List(opts v1.ListOptions) (result *v1alpha1.MetricList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.MetricList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("metrics"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested metrics. +func (c *metrics) 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("metrics"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a metric and creates it. Returns the server's representation of the metric, and an error, if there is any. +func (c *metrics) Create(metric *v1alpha1.Metric) (result *v1alpha1.Metric, err error) { + result = &v1alpha1.Metric{} + err = c.client.Post(). + Namespace(c.ns). + Resource("metrics"). + Body(metric). + Do(). + Into(result) + return +} + +// Update takes the representation of a metric and updates it. Returns the server's representation of the metric, and an error, if there is any. +func (c *metrics) Update(metric *v1alpha1.Metric) (result *v1alpha1.Metric, err error) { + result = &v1alpha1.Metric{} + err = c.client.Put(). + Namespace(c.ns). + Resource("metrics"). + Name(metric.Name). + Body(metric). + 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 *metrics) UpdateStatus(metric *v1alpha1.Metric) (result *v1alpha1.Metric, err error) { + result = &v1alpha1.Metric{} + err = c.client.Put(). + Namespace(c.ns). + Resource("metrics"). + Name(metric.Name). + SubResource("status"). + Body(metric). + Do(). + Into(result) + return +} + +// Delete takes name of the metric and deletes it. Returns an error if one occurs. +func (c *metrics) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("metrics"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *metrics) 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("metrics"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched metric. +func (c *metrics) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Metric, err error) { + result = &v1alpha1.Metric{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("metrics"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go new file mode 100644 index 00000000000..64fcbe21379 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/podautoscaler.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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/serving/pkg/apis/autoscaling/v1alpha1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// PodAutoscalersGetter has a method to return a PodAutoscalerInterface. +// A group's client should implement this interface. +type PodAutoscalersGetter interface { + PodAutoscalers(namespace string) PodAutoscalerInterface +} + +// PodAutoscalerInterface has methods to work with PodAutoscaler resources. +type PodAutoscalerInterface interface { + Create(*v1alpha1.PodAutoscaler) (*v1alpha1.PodAutoscaler, error) + Update(*v1alpha1.PodAutoscaler) (*v1alpha1.PodAutoscaler, error) + UpdateStatus(*v1alpha1.PodAutoscaler) (*v1alpha1.PodAutoscaler, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.PodAutoscaler, error) + List(opts v1.ListOptions) (*v1alpha1.PodAutoscalerList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodAutoscaler, err error) + PodAutoscalerExpansion +} + +// podAutoscalers implements PodAutoscalerInterface +type podAutoscalers struct { + client rest.Interface + ns string +} + +// newPodAutoscalers returns a PodAutoscalers +func newPodAutoscalers(c *AutoscalingV1alpha1Client, namespace string) *podAutoscalers { + return &podAutoscalers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the podAutoscaler, and returns the corresponding podAutoscaler object, and an error if there is any. +func (c *podAutoscalers) Get(name string, options v1.GetOptions) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of PodAutoscalers that match those selectors. +func (c *podAutoscalers) List(opts v1.ListOptions) (result *v1alpha1.PodAutoscalerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.PodAutoscalerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("podautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested podAutoscalers. +func (c *podAutoscalers) 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("podautoscalers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a podAutoscaler and creates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *podAutoscalers) Create(podAutoscaler *v1alpha1.PodAutoscaler) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Post(). + Namespace(c.ns). + Resource("podautoscalers"). + Body(podAutoscaler). + Do(). + Into(result) + return +} + +// Update takes the representation of a podAutoscaler and updates it. Returns the server's representation of the podAutoscaler, and an error, if there is any. +func (c *podAutoscalers) Update(podAutoscaler *v1alpha1.PodAutoscaler) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Put(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(podAutoscaler.Name). + Body(podAutoscaler). + 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 *podAutoscalers) UpdateStatus(podAutoscaler *v1alpha1.PodAutoscaler) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Put(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(podAutoscaler.Name). + SubResource("status"). + Body(podAutoscaler). + Do(). + Into(result) + return +} + +// Delete takes name of the podAutoscaler and deletes it. Returns an error if one occurs. +func (c *podAutoscalers) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("podautoscalers"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *podAutoscalers) 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("podautoscalers"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched podAutoscaler. +func (c *podAutoscalers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.PodAutoscaler, err error) { + result = &v1alpha1.PodAutoscaler{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("podautoscalers"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/certificate.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/certificate.go new file mode 100644 index 00000000000..a75c439c562 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/certificate.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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/serving/pkg/apis/networking/v1alpha1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// CertificatesGetter has a method to return a CertificateInterface. +// A group's client should implement this interface. +type CertificatesGetter interface { + Certificates(namespace string) CertificateInterface +} + +// CertificateInterface has methods to work with Certificate resources. +type CertificateInterface interface { + Create(*v1alpha1.Certificate) (*v1alpha1.Certificate, error) + Update(*v1alpha1.Certificate) (*v1alpha1.Certificate, error) + UpdateStatus(*v1alpha1.Certificate) (*v1alpha1.Certificate, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Certificate, error) + List(opts v1.ListOptions) (*v1alpha1.CertificateList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Certificate, err error) + CertificateExpansion +} + +// certificates implements CertificateInterface +type certificates struct { + client rest.Interface + ns string +} + +// newCertificates returns a Certificates +func newCertificates(c *NetworkingV1alpha1Client, namespace string) *certificates { + return &certificates{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the certificate, and returns the corresponding certificate object, and an error if there is any. +func (c *certificates) Get(name string, options v1.GetOptions) (result *v1alpha1.Certificate, err error) { + result = &v1alpha1.Certificate{} + err = c.client.Get(). + Namespace(c.ns). + Resource("certificates"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Certificates that match those selectors. +func (c *certificates) List(opts v1.ListOptions) (result *v1alpha1.CertificateList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.CertificateList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("certificates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested certificates. +func (c *certificates) 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("certificates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a certificate and creates it. Returns the server's representation of the certificate, and an error, if there is any. +func (c *certificates) Create(certificate *v1alpha1.Certificate) (result *v1alpha1.Certificate, err error) { + result = &v1alpha1.Certificate{} + err = c.client.Post(). + Namespace(c.ns). + Resource("certificates"). + Body(certificate). + Do(). + Into(result) + return +} + +// Update takes the representation of a certificate and updates it. Returns the server's representation of the certificate, and an error, if there is any. +func (c *certificates) Update(certificate *v1alpha1.Certificate) (result *v1alpha1.Certificate, err error) { + result = &v1alpha1.Certificate{} + err = c.client.Put(). + Namespace(c.ns). + Resource("certificates"). + Name(certificate.Name). + Body(certificate). + 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 *certificates) UpdateStatus(certificate *v1alpha1.Certificate) (result *v1alpha1.Certificate, err error) { + result = &v1alpha1.Certificate{} + err = c.client.Put(). + Namespace(c.ns). + Resource("certificates"). + Name(certificate.Name). + SubResource("status"). + Body(certificate). + Do(). + Into(result) + return +} + +// Delete takes name of the certificate and deletes it. Returns an error if one occurs. +func (c *certificates) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("certificates"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *certificates) 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("certificates"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched certificate. +func (c *certificates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Certificate, err error) { + result = &v1alpha1.Certificate{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("certificates"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go new file mode 100644 index 00000000000..41e872fe9a9 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/doc.go new file mode 100644 index 00000000000..c7f6e65cab8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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 has the automatically generated clients. +package fake diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_certificate.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_certificate.go new file mode 100644 index 00000000000..b216a354c99 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_certificate.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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/serving/pkg/apis/networking/v1alpha1" +) + +// FakeCertificates implements CertificateInterface +type FakeCertificates struct { + Fake *FakeNetworkingV1alpha1 + ns string +} + +var certificatesResource = schema.GroupVersionResource{Group: "networking.internal.knative.dev", Version: "v1alpha1", Resource: "certificates"} + +var certificatesKind = schema.GroupVersionKind{Group: "networking.internal.knative.dev", Version: "v1alpha1", Kind: "Certificate"} + +// Get takes name of the certificate, and returns the corresponding certificate object, and an error if there is any. +func (c *FakeCertificates) Get(name string, options v1.GetOptions) (result *v1alpha1.Certificate, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(certificatesResource, c.ns, name), &v1alpha1.Certificate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Certificate), err +} + +// List takes label and field selectors, and returns the list of Certificates that match those selectors. +func (c *FakeCertificates) List(opts v1.ListOptions) (result *v1alpha1.CertificateList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(certificatesResource, certificatesKind, c.ns, opts), &v1alpha1.CertificateList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.CertificateList{ListMeta: obj.(*v1alpha1.CertificateList).ListMeta} + for _, item := range obj.(*v1alpha1.CertificateList).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 certificates. +func (c *FakeCertificates) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(certificatesResource, c.ns, opts)) + +} + +// Create takes the representation of a certificate and creates it. Returns the server's representation of the certificate, and an error, if there is any. +func (c *FakeCertificates) Create(certificate *v1alpha1.Certificate) (result *v1alpha1.Certificate, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(certificatesResource, c.ns, certificate), &v1alpha1.Certificate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Certificate), err +} + +// Update takes the representation of a certificate and updates it. Returns the server's representation of the certificate, and an error, if there is any. +func (c *FakeCertificates) Update(certificate *v1alpha1.Certificate) (result *v1alpha1.Certificate, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(certificatesResource, c.ns, certificate), &v1alpha1.Certificate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Certificate), 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 *FakeCertificates) UpdateStatus(certificate *v1alpha1.Certificate) (*v1alpha1.Certificate, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(certificatesResource, "status", c.ns, certificate), &v1alpha1.Certificate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Certificate), err +} + +// Delete takes name of the certificate and deletes it. Returns an error if one occurs. +func (c *FakeCertificates) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(certificatesResource, c.ns, name), &v1alpha1.Certificate{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeCertificates) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(certificatesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.CertificateList{}) + return err +} + +// Patch applies the patch and returns the patched certificate. +func (c *FakeCertificates) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Certificate, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(certificatesResource, c.ns, name, pt, data, subresources...), &v1alpha1.Certificate{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Certificate), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_ingress.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_ingress.go new file mode 100644 index 00000000000..dd20595fc3b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_ingress.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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/serving/pkg/apis/networking/v1alpha1" +) + +// FakeIngresses implements IngressInterface +type FakeIngresses struct { + Fake *FakeNetworkingV1alpha1 + ns string +} + +var ingressesResource = schema.GroupVersionResource{Group: "networking.internal.knative.dev", Version: "v1alpha1", Resource: "ingresses"} + +var ingressesKind = schema.GroupVersionKind{Group: "networking.internal.knative.dev", Version: "v1alpha1", Kind: "Ingress"} + +// Get takes name of the ingress, and returns the corresponding ingress object, and an error if there is any. +func (c *FakeIngresses) Get(name string, options v1.GetOptions) (result *v1alpha1.Ingress, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(ingressesResource, c.ns, name), &v1alpha1.Ingress{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Ingress), err +} + +// List takes label and field selectors, and returns the list of Ingresses that match those selectors. +func (c *FakeIngresses) List(opts v1.ListOptions) (result *v1alpha1.IngressList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(ingressesResource, ingressesKind, c.ns, opts), &v1alpha1.IngressList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.IngressList{ListMeta: obj.(*v1alpha1.IngressList).ListMeta} + for _, item := range obj.(*v1alpha1.IngressList).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 ingresses. +func (c *FakeIngresses) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(ingressesResource, c.ns, opts)) + +} + +// Create takes the representation of a ingress and creates it. Returns the server's representation of the ingress, and an error, if there is any. +func (c *FakeIngresses) Create(ingress *v1alpha1.Ingress) (result *v1alpha1.Ingress, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(ingressesResource, c.ns, ingress), &v1alpha1.Ingress{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Ingress), err +} + +// Update takes the representation of a ingress and updates it. Returns the server's representation of the ingress, and an error, if there is any. +func (c *FakeIngresses) Update(ingress *v1alpha1.Ingress) (result *v1alpha1.Ingress, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(ingressesResource, c.ns, ingress), &v1alpha1.Ingress{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Ingress), 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 *FakeIngresses) UpdateStatus(ingress *v1alpha1.Ingress) (*v1alpha1.Ingress, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(ingressesResource, "status", c.ns, ingress), &v1alpha1.Ingress{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Ingress), err +} + +// Delete takes name of the ingress and deletes it. Returns an error if one occurs. +func (c *FakeIngresses) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(ingressesResource, c.ns, name), &v1alpha1.Ingress{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeIngresses) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(ingressesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.IngressList{}) + return err +} + +// Patch applies the patch and returns the patched ingress. +func (c *FakeIngresses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Ingress, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(ingressesResource, c.ns, name, pt, data, subresources...), &v1alpha1.Ingress{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Ingress), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go new file mode 100644 index 00000000000..439ee16a55a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_networking_client.go @@ -0,0 +1,48 @@ +/* +Copyright 2020 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1" +) + +type FakeNetworkingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeNetworkingV1alpha1) Certificates(namespace string) v1alpha1.CertificateInterface { + return &FakeCertificates{c, namespace} +} + +func (c *FakeNetworkingV1alpha1) Ingresses(namespace string) v1alpha1.IngressInterface { + return &FakeIngresses{c, namespace} +} + +func (c *FakeNetworkingV1alpha1) ServerlessServices(namespace string) v1alpha1.ServerlessServiceInterface { + return &FakeServerlessServices{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeNetworkingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_serverlessservice.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_serverlessservice.go new file mode 100644 index 00000000000..92a9fc106e6 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/fake/fake_serverlessservice.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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/serving/pkg/apis/networking/v1alpha1" +) + +// FakeServerlessServices implements ServerlessServiceInterface +type FakeServerlessServices struct { + Fake *FakeNetworkingV1alpha1 + ns string +} + +var serverlessservicesResource = schema.GroupVersionResource{Group: "networking.internal.knative.dev", Version: "v1alpha1", Resource: "serverlessservices"} + +var serverlessservicesKind = schema.GroupVersionKind{Group: "networking.internal.knative.dev", Version: "v1alpha1", Kind: "ServerlessService"} + +// Get takes name of the serverlessService, and returns the corresponding serverlessService object, and an error if there is any. +func (c *FakeServerlessServices) Get(name string, options v1.GetOptions) (result *v1alpha1.ServerlessService, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(serverlessservicesResource, c.ns, name), &v1alpha1.ServerlessService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ServerlessService), err +} + +// List takes label and field selectors, and returns the list of ServerlessServices that match those selectors. +func (c *FakeServerlessServices) List(opts v1.ListOptions) (result *v1alpha1.ServerlessServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(serverlessservicesResource, serverlessservicesKind, c.ns, opts), &v1alpha1.ServerlessServiceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ServerlessServiceList{ListMeta: obj.(*v1alpha1.ServerlessServiceList).ListMeta} + for _, item := range obj.(*v1alpha1.ServerlessServiceList).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 serverlessServices. +func (c *FakeServerlessServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(serverlessservicesResource, c.ns, opts)) + +} + +// Create takes the representation of a serverlessService and creates it. Returns the server's representation of the serverlessService, and an error, if there is any. +func (c *FakeServerlessServices) Create(serverlessService *v1alpha1.ServerlessService) (result *v1alpha1.ServerlessService, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(serverlessservicesResource, c.ns, serverlessService), &v1alpha1.ServerlessService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ServerlessService), err +} + +// Update takes the representation of a serverlessService and updates it. Returns the server's representation of the serverlessService, and an error, if there is any. +func (c *FakeServerlessServices) Update(serverlessService *v1alpha1.ServerlessService) (result *v1alpha1.ServerlessService, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(serverlessservicesResource, c.ns, serverlessService), &v1alpha1.ServerlessService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ServerlessService), 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 *FakeServerlessServices) UpdateStatus(serverlessService *v1alpha1.ServerlessService) (*v1alpha1.ServerlessService, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(serverlessservicesResource, "status", c.ns, serverlessService), &v1alpha1.ServerlessService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ServerlessService), err +} + +// Delete takes name of the serverlessService and deletes it. Returns an error if one occurs. +func (c *FakeServerlessServices) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(serverlessservicesResource, c.ns, name), &v1alpha1.ServerlessService{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeServerlessServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(serverlessservicesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ServerlessServiceList{}) + return err +} + +// Patch applies the patch and returns the patched serverlessService. +func (c *FakeServerlessServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ServerlessService, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(serverlessservicesResource, c.ns, name, pt, data, subresources...), &v1alpha1.ServerlessService{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.ServerlessService), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go new file mode 100644 index 00000000000..de5c9dac5b8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/generated_expansion.go @@ -0,0 +1,25 @@ +/* +Copyright 2020 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 + +type CertificateExpansion interface{} + +type IngressExpansion interface{} + +type ServerlessServiceExpansion interface{} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/ingress.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/ingress.go new file mode 100644 index 00000000000..1610ffc7e43 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/ingress.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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/serving/pkg/apis/networking/v1alpha1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// IngressesGetter has a method to return a IngressInterface. +// A group's client should implement this interface. +type IngressesGetter interface { + Ingresses(namespace string) IngressInterface +} + +// IngressInterface has methods to work with Ingress resources. +type IngressInterface interface { + Create(*v1alpha1.Ingress) (*v1alpha1.Ingress, error) + Update(*v1alpha1.Ingress) (*v1alpha1.Ingress, error) + UpdateStatus(*v1alpha1.Ingress) (*v1alpha1.Ingress, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Ingress, error) + List(opts v1.ListOptions) (*v1alpha1.IngressList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Ingress, err error) + IngressExpansion +} + +// ingresses implements IngressInterface +type ingresses struct { + client rest.Interface + ns string +} + +// newIngresses returns a Ingresses +func newIngresses(c *NetworkingV1alpha1Client, namespace string) *ingresses { + return &ingresses{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the ingress, and returns the corresponding ingress object, and an error if there is any. +func (c *ingresses) Get(name string, options v1.GetOptions) (result *v1alpha1.Ingress, err error) { + result = &v1alpha1.Ingress{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ingresses"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Ingresses that match those selectors. +func (c *ingresses) List(opts v1.ListOptions) (result *v1alpha1.IngressList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.IngressList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("ingresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested ingresses. +func (c *ingresses) 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("ingresses"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a ingress and creates it. Returns the server's representation of the ingress, and an error, if there is any. +func (c *ingresses) Create(ingress *v1alpha1.Ingress) (result *v1alpha1.Ingress, err error) { + result = &v1alpha1.Ingress{} + err = c.client.Post(). + Namespace(c.ns). + Resource("ingresses"). + Body(ingress). + Do(). + Into(result) + return +} + +// Update takes the representation of a ingress and updates it. Returns the server's representation of the ingress, and an error, if there is any. +func (c *ingresses) Update(ingress *v1alpha1.Ingress) (result *v1alpha1.Ingress, err error) { + result = &v1alpha1.Ingress{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ingresses"). + Name(ingress.Name). + Body(ingress). + 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 *ingresses) UpdateStatus(ingress *v1alpha1.Ingress) (result *v1alpha1.Ingress, err error) { + result = &v1alpha1.Ingress{} + err = c.client.Put(). + Namespace(c.ns). + Resource("ingresses"). + Name(ingress.Name). + SubResource("status"). + Body(ingress). + Do(). + Into(result) + return +} + +// Delete takes name of the ingress and deletes it. Returns an error if one occurs. +func (c *ingresses) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("ingresses"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *ingresses) 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("ingresses"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched ingress. +func (c *ingresses) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Ingress, err error) { + result = &v1alpha1.Ingress{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("ingresses"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go new file mode 100644 index 00000000000..fc7fd0617b8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/networking_client.go @@ -0,0 +1,99 @@ +/* +Copyright 2020 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 ( + rest "k8s.io/client-go/rest" + v1alpha1 "knative.dev/serving/pkg/apis/networking/v1alpha1" + "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +type NetworkingV1alpha1Interface interface { + RESTClient() rest.Interface + CertificatesGetter + IngressesGetter + ServerlessServicesGetter +} + +// NetworkingV1alpha1Client is used to interact with features provided by the networking.internal.knative.dev group. +type NetworkingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *NetworkingV1alpha1Client) Certificates(namespace string) CertificateInterface { + return newCertificates(c, namespace) +} + +func (c *NetworkingV1alpha1Client) Ingresses(namespace string) IngressInterface { + return newIngresses(c, namespace) +} + +func (c *NetworkingV1alpha1Client) ServerlessServices(namespace string) ServerlessServiceInterface { + return newServerlessServices(c, namespace) +} + +// NewForConfig creates a new NetworkingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*NetworkingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &NetworkingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new NetworkingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *NetworkingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new NetworkingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *NetworkingV1alpha1Client { + return &NetworkingV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *NetworkingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/serverlessservice.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/serverlessservice.go new file mode 100644 index 00000000000..7fbd71d4e86 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/networking/v1alpha1/serverlessservice.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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/serving/pkg/apis/networking/v1alpha1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// ServerlessServicesGetter has a method to return a ServerlessServiceInterface. +// A group's client should implement this interface. +type ServerlessServicesGetter interface { + ServerlessServices(namespace string) ServerlessServiceInterface +} + +// ServerlessServiceInterface has methods to work with ServerlessService resources. +type ServerlessServiceInterface interface { + Create(*v1alpha1.ServerlessService) (*v1alpha1.ServerlessService, error) + Update(*v1alpha1.ServerlessService) (*v1alpha1.ServerlessService, error) + UpdateStatus(*v1alpha1.ServerlessService) (*v1alpha1.ServerlessService, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.ServerlessService, error) + List(opts v1.ListOptions) (*v1alpha1.ServerlessServiceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ServerlessService, err error) + ServerlessServiceExpansion +} + +// serverlessServices implements ServerlessServiceInterface +type serverlessServices struct { + client rest.Interface + ns string +} + +// newServerlessServices returns a ServerlessServices +func newServerlessServices(c *NetworkingV1alpha1Client, namespace string) *serverlessServices { + return &serverlessServices{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the serverlessService, and returns the corresponding serverlessService object, and an error if there is any. +func (c *serverlessServices) Get(name string, options v1.GetOptions) (result *v1alpha1.ServerlessService, err error) { + result = &v1alpha1.ServerlessService{} + err = c.client.Get(). + Namespace(c.ns). + Resource("serverlessservices"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ServerlessServices that match those selectors. +func (c *serverlessServices) List(opts v1.ListOptions) (result *v1alpha1.ServerlessServiceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ServerlessServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("serverlessservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested serverlessServices. +func (c *serverlessServices) 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("serverlessservices"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a serverlessService and creates it. Returns the server's representation of the serverlessService, and an error, if there is any. +func (c *serverlessServices) Create(serverlessService *v1alpha1.ServerlessService) (result *v1alpha1.ServerlessService, err error) { + result = &v1alpha1.ServerlessService{} + err = c.client.Post(). + Namespace(c.ns). + Resource("serverlessservices"). + Body(serverlessService). + Do(). + Into(result) + return +} + +// Update takes the representation of a serverlessService and updates it. Returns the server's representation of the serverlessService, and an error, if there is any. +func (c *serverlessServices) Update(serverlessService *v1alpha1.ServerlessService) (result *v1alpha1.ServerlessService, err error) { + result = &v1alpha1.ServerlessService{} + err = c.client.Put(). + Namespace(c.ns). + Resource("serverlessservices"). + Name(serverlessService.Name). + Body(serverlessService). + 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 *serverlessServices) UpdateStatus(serverlessService *v1alpha1.ServerlessService) (result *v1alpha1.ServerlessService, err error) { + result = &v1alpha1.ServerlessService{} + err = c.client.Put(). + Namespace(c.ns). + Resource("serverlessservices"). + Name(serverlessService.Name). + SubResource("status"). + Body(serverlessService). + Do(). + Into(result) + return +} + +// Delete takes name of the serverlessService and deletes it. Returns an error if one occurs. +func (c *serverlessServices) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("serverlessservices"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *serverlessServices) 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("serverlessservices"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched serverlessService. +func (c *serverlessServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ServerlessService, err error) { + result = &v1alpha1.ServerlessService{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("serverlessservices"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/configuration.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/configuration.go new file mode 100644 index 00000000000..2bff52a806e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/configuration.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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 v1 + +import ( + "time" + + metav1 "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" + v1 "knative.dev/serving/pkg/apis/serving/v1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// ConfigurationsGetter has a method to return a ConfigurationInterface. +// A group's client should implement this interface. +type ConfigurationsGetter interface { + Configurations(namespace string) ConfigurationInterface +} + +// ConfigurationInterface has methods to work with Configuration resources. +type ConfigurationInterface interface { + Create(*v1.Configuration) (*v1.Configuration, error) + Update(*v1.Configuration) (*v1.Configuration, error) + UpdateStatus(*v1.Configuration) (*v1.Configuration, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.Configuration, error) + List(opts metav1.ListOptions) (*v1.ConfigurationList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Configuration, err error) + ConfigurationExpansion +} + +// configurations implements ConfigurationInterface +type configurations struct { + client rest.Interface + ns string +} + +// newConfigurations returns a Configurations +func newConfigurations(c *ServingV1Client, namespace string) *configurations { + return &configurations{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the configuration, and returns the corresponding configuration object, and an error if there is any. +func (c *configurations) Get(name string, options metav1.GetOptions) (result *v1.Configuration, err error) { + result = &v1.Configuration{} + err = c.client.Get(). + Namespace(c.ns). + Resource("configurations"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Configurations that match those selectors. +func (c *configurations) List(opts metav1.ListOptions) (result *v1.ConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ConfigurationList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("configurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested configurations. +func (c *configurations) Watch(opts metav1.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("configurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a configuration and creates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *configurations) Create(configuration *v1.Configuration) (result *v1.Configuration, err error) { + result = &v1.Configuration{} + err = c.client.Post(). + Namespace(c.ns). + Resource("configurations"). + Body(configuration). + Do(). + Into(result) + return +} + +// Update takes the representation of a configuration and updates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *configurations) Update(configuration *v1.Configuration) (result *v1.Configuration, err error) { + result = &v1.Configuration{} + err = c.client.Put(). + Namespace(c.ns). + Resource("configurations"). + Name(configuration.Name). + Body(configuration). + 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 *configurations) UpdateStatus(configuration *v1.Configuration) (result *v1.Configuration, err error) { + result = &v1.Configuration{} + err = c.client.Put(). + Namespace(c.ns). + Resource("configurations"). + Name(configuration.Name). + SubResource("status"). + Body(configuration). + Do(). + Into(result) + return +} + +// Delete takes name of the configuration and deletes it. Returns an error if one occurs. +func (c *configurations) Delete(name string, options *metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("configurations"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *configurations) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.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("configurations"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched configuration. +func (c *configurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Configuration, err error) { + result = &v1.Configuration{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("configurations"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/doc.go new file mode 100644 index 00000000000..5b83bd1f41a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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. + +// This package has the automatically generated typed clients. +package v1 diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/doc.go new file mode 100644 index 00000000000..c7f6e65cab8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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 has the automatically generated clients. +package fake diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_configuration.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_configuration.go new file mode 100644 index 00000000000..7a556551558 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_configuration.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// FakeConfigurations implements ConfigurationInterface +type FakeConfigurations struct { + Fake *FakeServingV1 + ns string +} + +var configurationsResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1", Resource: "configurations"} + +var configurationsKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1", Kind: "Configuration"} + +// Get takes name of the configuration, and returns the corresponding configuration object, and an error if there is any. +func (c *FakeConfigurations) Get(name string, options v1.GetOptions) (result *servingv1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(configurationsResource, c.ns, name), &servingv1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Configuration), err +} + +// List takes label and field selectors, and returns the list of Configurations that match those selectors. +func (c *FakeConfigurations) List(opts v1.ListOptions) (result *servingv1.ConfigurationList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(configurationsResource, configurationsKind, c.ns, opts), &servingv1.ConfigurationList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &servingv1.ConfigurationList{ListMeta: obj.(*servingv1.ConfigurationList).ListMeta} + for _, item := range obj.(*servingv1.ConfigurationList).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 configurations. +func (c *FakeConfigurations) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(configurationsResource, c.ns, opts)) + +} + +// Create takes the representation of a configuration and creates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *FakeConfigurations) Create(configuration *servingv1.Configuration) (result *servingv1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(configurationsResource, c.ns, configuration), &servingv1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Configuration), err +} + +// Update takes the representation of a configuration and updates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *FakeConfigurations) Update(configuration *servingv1.Configuration) (result *servingv1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(configurationsResource, c.ns, configuration), &servingv1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Configuration), 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 *FakeConfigurations) UpdateStatus(configuration *servingv1.Configuration) (*servingv1.Configuration, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(configurationsResource, "status", c.ns, configuration), &servingv1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Configuration), err +} + +// Delete takes name of the configuration and deletes it. Returns an error if one occurs. +func (c *FakeConfigurations) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(configurationsResource, c.ns, name), &servingv1.Configuration{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeConfigurations) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(configurationsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &servingv1.ConfigurationList{}) + return err +} + +// Patch applies the patch and returns the patched configuration. +func (c *FakeConfigurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *servingv1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(configurationsResource, c.ns, name, pt, data, subresources...), &servingv1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Configuration), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_revision.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_revision.go new file mode 100644 index 00000000000..2d57ce7b5a1 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_revision.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// FakeRevisions implements RevisionInterface +type FakeRevisions struct { + Fake *FakeServingV1 + ns string +} + +var revisionsResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1", Resource: "revisions"} + +var revisionsKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1", Kind: "Revision"} + +// Get takes name of the revision, and returns the corresponding revision object, and an error if there is any. +func (c *FakeRevisions) Get(name string, options v1.GetOptions) (result *servingv1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(revisionsResource, c.ns, name), &servingv1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Revision), err +} + +// List takes label and field selectors, and returns the list of Revisions that match those selectors. +func (c *FakeRevisions) List(opts v1.ListOptions) (result *servingv1.RevisionList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(revisionsResource, revisionsKind, c.ns, opts), &servingv1.RevisionList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &servingv1.RevisionList{ListMeta: obj.(*servingv1.RevisionList).ListMeta} + for _, item := range obj.(*servingv1.RevisionList).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 revisions. +func (c *FakeRevisions) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(revisionsResource, c.ns, opts)) + +} + +// Create takes the representation of a revision and creates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *FakeRevisions) Create(revision *servingv1.Revision) (result *servingv1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(revisionsResource, c.ns, revision), &servingv1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Revision), err +} + +// Update takes the representation of a revision and updates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *FakeRevisions) Update(revision *servingv1.Revision) (result *servingv1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(revisionsResource, c.ns, revision), &servingv1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Revision), 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 *FakeRevisions) UpdateStatus(revision *servingv1.Revision) (*servingv1.Revision, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(revisionsResource, "status", c.ns, revision), &servingv1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Revision), err +} + +// Delete takes name of the revision and deletes it. Returns an error if one occurs. +func (c *FakeRevisions) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(revisionsResource, c.ns, name), &servingv1.Revision{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRevisions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(revisionsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &servingv1.RevisionList{}) + return err +} + +// Patch applies the patch and returns the patched revision. +func (c *FakeRevisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *servingv1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(revisionsResource, c.ns, name, pt, data, subresources...), &servingv1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Revision), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_route.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_route.go new file mode 100644 index 00000000000..00692ab9873 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_route.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// FakeRoutes implements RouteInterface +type FakeRoutes struct { + Fake *FakeServingV1 + ns string +} + +var routesResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1", Resource: "routes"} + +var routesKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1", Kind: "Route"} + +// Get takes name of the route, and returns the corresponding route object, and an error if there is any. +func (c *FakeRoutes) Get(name string, options v1.GetOptions) (result *servingv1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(routesResource, c.ns, name), &servingv1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Route), err +} + +// List takes label and field selectors, and returns the list of Routes that match those selectors. +func (c *FakeRoutes) List(opts v1.ListOptions) (result *servingv1.RouteList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(routesResource, routesKind, c.ns, opts), &servingv1.RouteList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &servingv1.RouteList{ListMeta: obj.(*servingv1.RouteList).ListMeta} + for _, item := range obj.(*servingv1.RouteList).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 routes. +func (c *FakeRoutes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(routesResource, c.ns, opts)) + +} + +// Create takes the representation of a route and creates it. Returns the server's representation of the route, and an error, if there is any. +func (c *FakeRoutes) Create(route *servingv1.Route) (result *servingv1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(routesResource, c.ns, route), &servingv1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Route), err +} + +// Update takes the representation of a route and updates it. Returns the server's representation of the route, and an error, if there is any. +func (c *FakeRoutes) Update(route *servingv1.Route) (result *servingv1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(routesResource, c.ns, route), &servingv1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Route), 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 *FakeRoutes) UpdateStatus(route *servingv1.Route) (*servingv1.Route, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(routesResource, "status", c.ns, route), &servingv1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Route), err +} + +// Delete takes name of the route and deletes it. Returns an error if one occurs. +func (c *FakeRoutes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(routesResource, c.ns, name), &servingv1.Route{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRoutes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(routesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &servingv1.RouteList{}) + return err +} + +// Patch applies the patch and returns the patched route. +func (c *FakeRoutes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *servingv1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(routesResource, c.ns, name, pt, data, subresources...), &servingv1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Route), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_service.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_service.go new file mode 100644 index 00000000000..f9f335e2824 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_service.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// FakeServices implements ServiceInterface +type FakeServices struct { + Fake *FakeServingV1 + ns string +} + +var servicesResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1", Resource: "services"} + +var servicesKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1", Kind: "Service"} + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *FakeServices) Get(name string, options v1.GetOptions) (result *servingv1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(servicesResource, c.ns, name), &servingv1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Service), err +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *FakeServices) List(opts v1.ListOptions) (result *servingv1.ServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(servicesResource, servicesKind, c.ns, opts), &servingv1.ServiceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &servingv1.ServiceList{ListMeta: obj.(*servingv1.ServiceList).ListMeta} + for _, item := range obj.(*servingv1.ServiceList).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 services. +func (c *FakeServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(servicesResource, c.ns, opts)) + +} + +// Create takes the representation of a service and creates it. Returns the server's representation of the service, and an error, if there is any. +func (c *FakeServices) Create(service *servingv1.Service) (result *servingv1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(servicesResource, c.ns, service), &servingv1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Service), err +} + +// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any. +func (c *FakeServices) Update(service *servingv1.Service) (result *servingv1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(servicesResource, c.ns, service), &servingv1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Service), 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 *FakeServices) UpdateStatus(service *servingv1.Service) (*servingv1.Service, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(servicesResource, "status", c.ns, service), &servingv1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Service), err +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *FakeServices) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(servicesResource, c.ns, name), &servingv1.Service{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(servicesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &servingv1.ServiceList{}) + return err +} + +// Patch applies the patch and returns the patched service. +func (c *FakeServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *servingv1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, name, pt, data, subresources...), &servingv1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*servingv1.Service), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_serving_client.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_serving_client.go new file mode 100644 index 00000000000..617587c4c2b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/fake/fake_serving_client.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1" +) + +type FakeServingV1 struct { + *testing.Fake +} + +func (c *FakeServingV1) Configurations(namespace string) v1.ConfigurationInterface { + return &FakeConfigurations{c, namespace} +} + +func (c *FakeServingV1) Revisions(namespace string) v1.RevisionInterface { + return &FakeRevisions{c, namespace} +} + +func (c *FakeServingV1) Routes(namespace string) v1.RouteInterface { + return &FakeRoutes{c, namespace} +} + +func (c *FakeServingV1) Services(namespace string) v1.ServiceInterface { + return &FakeServices{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeServingV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/generated_expansion.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/generated_expansion.go new file mode 100644 index 00000000000..4c0460b13c8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2020 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 v1 + +type ConfigurationExpansion interface{} + +type RevisionExpansion interface{} + +type RouteExpansion interface{} + +type ServiceExpansion interface{} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/revision.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/revision.go new file mode 100644 index 00000000000..e6d5120437c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/revision.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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 v1 + +import ( + "time" + + metav1 "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" + v1 "knative.dev/serving/pkg/apis/serving/v1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// RevisionsGetter has a method to return a RevisionInterface. +// A group's client should implement this interface. +type RevisionsGetter interface { + Revisions(namespace string) RevisionInterface +} + +// RevisionInterface has methods to work with Revision resources. +type RevisionInterface interface { + Create(*v1.Revision) (*v1.Revision, error) + Update(*v1.Revision) (*v1.Revision, error) + UpdateStatus(*v1.Revision) (*v1.Revision, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.Revision, error) + List(opts metav1.ListOptions) (*v1.RevisionList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Revision, err error) + RevisionExpansion +} + +// revisions implements RevisionInterface +type revisions struct { + client rest.Interface + ns string +} + +// newRevisions returns a Revisions +func newRevisions(c *ServingV1Client, namespace string) *revisions { + return &revisions{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the revision, and returns the corresponding revision object, and an error if there is any. +func (c *revisions) Get(name string, options metav1.GetOptions) (result *v1.Revision, err error) { + result = &v1.Revision{} + err = c.client.Get(). + Namespace(c.ns). + Resource("revisions"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Revisions that match those selectors. +func (c *revisions) List(opts metav1.ListOptions) (result *v1.RevisionList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.RevisionList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("revisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested revisions. +func (c *revisions) Watch(opts metav1.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("revisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a revision and creates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *revisions) Create(revision *v1.Revision) (result *v1.Revision, err error) { + result = &v1.Revision{} + err = c.client.Post(). + Namespace(c.ns). + Resource("revisions"). + Body(revision). + Do(). + Into(result) + return +} + +// Update takes the representation of a revision and updates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *revisions) Update(revision *v1.Revision) (result *v1.Revision, err error) { + result = &v1.Revision{} + err = c.client.Put(). + Namespace(c.ns). + Resource("revisions"). + Name(revision.Name). + Body(revision). + 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 *revisions) UpdateStatus(revision *v1.Revision) (result *v1.Revision, err error) { + result = &v1.Revision{} + err = c.client.Put(). + Namespace(c.ns). + Resource("revisions"). + Name(revision.Name). + SubResource("status"). + Body(revision). + Do(). + Into(result) + return +} + +// Delete takes name of the revision and deletes it. Returns an error if one occurs. +func (c *revisions) Delete(name string, options *metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("revisions"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *revisions) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.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("revisions"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched revision. +func (c *revisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Revision, err error) { + result = &v1.Revision{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("revisions"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/route.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/route.go new file mode 100644 index 00000000000..b3105f3a958 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/route.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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 v1 + +import ( + "time" + + metav1 "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" + v1 "knative.dev/serving/pkg/apis/serving/v1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// RoutesGetter has a method to return a RouteInterface. +// A group's client should implement this interface. +type RoutesGetter interface { + Routes(namespace string) RouteInterface +} + +// RouteInterface has methods to work with Route resources. +type RouteInterface interface { + Create(*v1.Route) (*v1.Route, error) + Update(*v1.Route) (*v1.Route, error) + UpdateStatus(*v1.Route) (*v1.Route, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.Route, error) + List(opts metav1.ListOptions) (*v1.RouteList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Route, err error) + RouteExpansion +} + +// routes implements RouteInterface +type routes struct { + client rest.Interface + ns string +} + +// newRoutes returns a Routes +func newRoutes(c *ServingV1Client, namespace string) *routes { + return &routes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the route, and returns the corresponding route object, and an error if there is any. +func (c *routes) Get(name string, options metav1.GetOptions) (result *v1.Route, err error) { + result = &v1.Route{} + err = c.client.Get(). + Namespace(c.ns). + Resource("routes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Routes that match those selectors. +func (c *routes) List(opts metav1.ListOptions) (result *v1.RouteList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.RouteList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("routes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested routes. +func (c *routes) Watch(opts metav1.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("routes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a route and creates it. Returns the server's representation of the route, and an error, if there is any. +func (c *routes) Create(route *v1.Route) (result *v1.Route, err error) { + result = &v1.Route{} + err = c.client.Post(). + Namespace(c.ns). + Resource("routes"). + Body(route). + Do(). + Into(result) + return +} + +// Update takes the representation of a route and updates it. Returns the server's representation of the route, and an error, if there is any. +func (c *routes) Update(route *v1.Route) (result *v1.Route, err error) { + result = &v1.Route{} + err = c.client.Put(). + Namespace(c.ns). + Resource("routes"). + Name(route.Name). + Body(route). + 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 *routes) UpdateStatus(route *v1.Route) (result *v1.Route, err error) { + result = &v1.Route{} + err = c.client.Put(). + Namespace(c.ns). + Resource("routes"). + Name(route.Name). + SubResource("status"). + Body(route). + Do(). + Into(result) + return +} + +// Delete takes name of the route and deletes it. Returns an error if one occurs. +func (c *routes) Delete(name string, options *metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("routes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *routes) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.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("routes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched route. +func (c *routes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Route, err error) { + result = &v1.Route{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("routes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/service.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/service.go new file mode 100644 index 00000000000..a2148ae0121 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/service.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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 v1 + +import ( + "time" + + metav1 "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" + v1 "knative.dev/serving/pkg/apis/serving/v1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// ServicesGetter has a method to return a ServiceInterface. +// A group's client should implement this interface. +type ServicesGetter interface { + Services(namespace string) ServiceInterface +} + +// ServiceInterface has methods to work with Service resources. +type ServiceInterface interface { + Create(*v1.Service) (*v1.Service, error) + Update(*v1.Service) (*v1.Service, error) + UpdateStatus(*v1.Service) (*v1.Service, error) + Delete(name string, options *metav1.DeleteOptions) error + DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error + Get(name string, options metav1.GetOptions) (*v1.Service, error) + List(opts metav1.ListOptions) (*v1.ServiceList, error) + Watch(opts metav1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Service, err error) + ServiceExpansion +} + +// services implements ServiceInterface +type services struct { + client rest.Interface + ns string +} + +// newServices returns a Services +func newServices(c *ServingV1Client, namespace string) *services { + return &services{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *services) Get(name string, options metav1.GetOptions) (result *v1.Service, err error) { + result = &v1.Service{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *services) List(opts metav1.ListOptions) (result *v1.ServiceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.ServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested services. +func (c *services) Watch(opts metav1.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("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a service and creates it. Returns the server's representation of the service, and an error, if there is any. +func (c *services) Create(service *v1.Service) (result *v1.Service, err error) { + result = &v1.Service{} + err = c.client.Post(). + Namespace(c.ns). + Resource("services"). + Body(service). + Do(). + Into(result) + return +} + +// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any. +func (c *services) Update(service *v1.Service) (result *v1.Service, err error) { + result = &v1.Service{} + err = c.client.Put(). + Namespace(c.ns). + Resource("services"). + Name(service.Name). + Body(service). + 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 *services) UpdateStatus(service *v1.Service) (result *v1.Service, err error) { + result = &v1.Service{} + err = c.client.Put(). + Namespace(c.ns). + Resource("services"). + Name(service.Name). + SubResource("status"). + Body(service). + Do(). + Into(result) + return +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *services) Delete(name string, options *metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("services"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *services) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.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("services"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched service. +func (c *services) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1.Service, err error) { + result = &v1.Service{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("services"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/serving_client.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/serving_client.go new file mode 100644 index 00000000000..25925ba2d05 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1/serving_client.go @@ -0,0 +1,104 @@ +/* +Copyright 2020 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 v1 + +import ( + rest "k8s.io/client-go/rest" + v1 "knative.dev/serving/pkg/apis/serving/v1" + "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +type ServingV1Interface interface { + RESTClient() rest.Interface + ConfigurationsGetter + RevisionsGetter + RoutesGetter + ServicesGetter +} + +// ServingV1Client is used to interact with features provided by the serving.knative.dev group. +type ServingV1Client struct { + restClient rest.Interface +} + +func (c *ServingV1Client) Configurations(namespace string) ConfigurationInterface { + return newConfigurations(c, namespace) +} + +func (c *ServingV1Client) Revisions(namespace string) RevisionInterface { + return newRevisions(c, namespace) +} + +func (c *ServingV1Client) Routes(namespace string) RouteInterface { + return newRoutes(c, namespace) +} + +func (c *ServingV1Client) Services(namespace string) ServiceInterface { + return newServices(c, namespace) +} + +// NewForConfig creates a new ServingV1Client for the given config. +func NewForConfig(c *rest.Config) (*ServingV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &ServingV1Client{client}, nil +} + +// NewForConfigOrDie creates a new ServingV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ServingV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ServingV1Client for the given RESTClient. +func New(c rest.Interface) *ServingV1Client { + return &ServingV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ServingV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/configuration.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/configuration.go new file mode 100644 index 00000000000..1d583fdbaf4 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/configuration.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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/serving/pkg/apis/serving/v1alpha1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// ConfigurationsGetter has a method to return a ConfigurationInterface. +// A group's client should implement this interface. +type ConfigurationsGetter interface { + Configurations(namespace string) ConfigurationInterface +} + +// ConfigurationInterface has methods to work with Configuration resources. +type ConfigurationInterface interface { + Create(*v1alpha1.Configuration) (*v1alpha1.Configuration, error) + Update(*v1alpha1.Configuration) (*v1alpha1.Configuration, error) + UpdateStatus(*v1alpha1.Configuration) (*v1alpha1.Configuration, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Configuration, error) + List(opts v1.ListOptions) (*v1alpha1.ConfigurationList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Configuration, err error) + ConfigurationExpansion +} + +// configurations implements ConfigurationInterface +type configurations struct { + client rest.Interface + ns string +} + +// newConfigurations returns a Configurations +func newConfigurations(c *ServingV1alpha1Client, namespace string) *configurations { + return &configurations{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the configuration, and returns the corresponding configuration object, and an error if there is any. +func (c *configurations) Get(name string, options v1.GetOptions) (result *v1alpha1.Configuration, err error) { + result = &v1alpha1.Configuration{} + err = c.client.Get(). + Namespace(c.ns). + Resource("configurations"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Configurations that match those selectors. +func (c *configurations) List(opts v1.ListOptions) (result *v1alpha1.ConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ConfigurationList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("configurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested configurations. +func (c *configurations) 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("configurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a configuration and creates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *configurations) Create(configuration *v1alpha1.Configuration) (result *v1alpha1.Configuration, err error) { + result = &v1alpha1.Configuration{} + err = c.client.Post(). + Namespace(c.ns). + Resource("configurations"). + Body(configuration). + Do(). + Into(result) + return +} + +// Update takes the representation of a configuration and updates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *configurations) Update(configuration *v1alpha1.Configuration) (result *v1alpha1.Configuration, err error) { + result = &v1alpha1.Configuration{} + err = c.client.Put(). + Namespace(c.ns). + Resource("configurations"). + Name(configuration.Name). + Body(configuration). + 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 *configurations) UpdateStatus(configuration *v1alpha1.Configuration) (result *v1alpha1.Configuration, err error) { + result = &v1alpha1.Configuration{} + err = c.client.Put(). + Namespace(c.ns). + Resource("configurations"). + Name(configuration.Name). + SubResource("status"). + Body(configuration). + Do(). + Into(result) + return +} + +// Delete takes name of the configuration and deletes it. Returns an error if one occurs. +func (c *configurations) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("configurations"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *configurations) 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("configurations"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched configuration. +func (c *configurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Configuration, err error) { + result = &v1alpha1.Configuration{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("configurations"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/doc.go new file mode 100644 index 00000000000..41e872fe9a9 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/doc.go new file mode 100644 index 00000000000..c7f6e65cab8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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 has the automatically generated clients. +package fake diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_configuration.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_configuration.go new file mode 100644 index 00000000000..670989b3f5e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_configuration.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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/serving/pkg/apis/serving/v1alpha1" +) + +// FakeConfigurations implements ConfigurationInterface +type FakeConfigurations struct { + Fake *FakeServingV1alpha1 + ns string +} + +var configurationsResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1alpha1", Resource: "configurations"} + +var configurationsKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1alpha1", Kind: "Configuration"} + +// Get takes name of the configuration, and returns the corresponding configuration object, and an error if there is any. +func (c *FakeConfigurations) Get(name string, options v1.GetOptions) (result *v1alpha1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(configurationsResource, c.ns, name), &v1alpha1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Configuration), err +} + +// List takes label and field selectors, and returns the list of Configurations that match those selectors. +func (c *FakeConfigurations) List(opts v1.ListOptions) (result *v1alpha1.ConfigurationList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(configurationsResource, configurationsKind, c.ns, opts), &v1alpha1.ConfigurationList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ConfigurationList{ListMeta: obj.(*v1alpha1.ConfigurationList).ListMeta} + for _, item := range obj.(*v1alpha1.ConfigurationList).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 configurations. +func (c *FakeConfigurations) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(configurationsResource, c.ns, opts)) + +} + +// Create takes the representation of a configuration and creates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *FakeConfigurations) Create(configuration *v1alpha1.Configuration) (result *v1alpha1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(configurationsResource, c.ns, configuration), &v1alpha1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Configuration), err +} + +// Update takes the representation of a configuration and updates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *FakeConfigurations) Update(configuration *v1alpha1.Configuration) (result *v1alpha1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(configurationsResource, c.ns, configuration), &v1alpha1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Configuration), 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 *FakeConfigurations) UpdateStatus(configuration *v1alpha1.Configuration) (*v1alpha1.Configuration, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(configurationsResource, "status", c.ns, configuration), &v1alpha1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Configuration), err +} + +// Delete takes name of the configuration and deletes it. Returns an error if one occurs. +func (c *FakeConfigurations) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(configurationsResource, c.ns, name), &v1alpha1.Configuration{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeConfigurations) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(configurationsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ConfigurationList{}) + return err +} + +// Patch applies the patch and returns the patched configuration. +func (c *FakeConfigurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(configurationsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Configuration), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_revision.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_revision.go new file mode 100644 index 00000000000..113ab1aab9e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_revision.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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/serving/pkg/apis/serving/v1alpha1" +) + +// FakeRevisions implements RevisionInterface +type FakeRevisions struct { + Fake *FakeServingV1alpha1 + ns string +} + +var revisionsResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1alpha1", Resource: "revisions"} + +var revisionsKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1alpha1", Kind: "Revision"} + +// Get takes name of the revision, and returns the corresponding revision object, and an error if there is any. +func (c *FakeRevisions) Get(name string, options v1.GetOptions) (result *v1alpha1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(revisionsResource, c.ns, name), &v1alpha1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Revision), err +} + +// List takes label and field selectors, and returns the list of Revisions that match those selectors. +func (c *FakeRevisions) List(opts v1.ListOptions) (result *v1alpha1.RevisionList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(revisionsResource, revisionsKind, c.ns, opts), &v1alpha1.RevisionList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.RevisionList{ListMeta: obj.(*v1alpha1.RevisionList).ListMeta} + for _, item := range obj.(*v1alpha1.RevisionList).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 revisions. +func (c *FakeRevisions) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(revisionsResource, c.ns, opts)) + +} + +// Create takes the representation of a revision and creates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *FakeRevisions) Create(revision *v1alpha1.Revision) (result *v1alpha1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(revisionsResource, c.ns, revision), &v1alpha1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Revision), err +} + +// Update takes the representation of a revision and updates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *FakeRevisions) Update(revision *v1alpha1.Revision) (result *v1alpha1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(revisionsResource, c.ns, revision), &v1alpha1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Revision), 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 *FakeRevisions) UpdateStatus(revision *v1alpha1.Revision) (*v1alpha1.Revision, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(revisionsResource, "status", c.ns, revision), &v1alpha1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Revision), err +} + +// Delete takes name of the revision and deletes it. Returns an error if one occurs. +func (c *FakeRevisions) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(revisionsResource, c.ns, name), &v1alpha1.Revision{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRevisions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(revisionsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.RevisionList{}) + return err +} + +// Patch applies the patch and returns the patched revision. +func (c *FakeRevisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(revisionsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Revision), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_route.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_route.go new file mode 100644 index 00000000000..a972e90cf42 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_route.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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/serving/pkg/apis/serving/v1alpha1" +) + +// FakeRoutes implements RouteInterface +type FakeRoutes struct { + Fake *FakeServingV1alpha1 + ns string +} + +var routesResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1alpha1", Resource: "routes"} + +var routesKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1alpha1", Kind: "Route"} + +// Get takes name of the route, and returns the corresponding route object, and an error if there is any. +func (c *FakeRoutes) Get(name string, options v1.GetOptions) (result *v1alpha1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(routesResource, c.ns, name), &v1alpha1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Route), err +} + +// List takes label and field selectors, and returns the list of Routes that match those selectors. +func (c *FakeRoutes) List(opts v1.ListOptions) (result *v1alpha1.RouteList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(routesResource, routesKind, c.ns, opts), &v1alpha1.RouteList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.RouteList{ListMeta: obj.(*v1alpha1.RouteList).ListMeta} + for _, item := range obj.(*v1alpha1.RouteList).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 routes. +func (c *FakeRoutes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(routesResource, c.ns, opts)) + +} + +// Create takes the representation of a route and creates it. Returns the server's representation of the route, and an error, if there is any. +func (c *FakeRoutes) Create(route *v1alpha1.Route) (result *v1alpha1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(routesResource, c.ns, route), &v1alpha1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Route), err +} + +// Update takes the representation of a route and updates it. Returns the server's representation of the route, and an error, if there is any. +func (c *FakeRoutes) Update(route *v1alpha1.Route) (result *v1alpha1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(routesResource, c.ns, route), &v1alpha1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Route), 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 *FakeRoutes) UpdateStatus(route *v1alpha1.Route) (*v1alpha1.Route, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(routesResource, "status", c.ns, route), &v1alpha1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Route), err +} + +// Delete takes name of the route and deletes it. Returns an error if one occurs. +func (c *FakeRoutes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(routesResource, c.ns, name), &v1alpha1.Route{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRoutes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(routesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.RouteList{}) + return err +} + +// Patch applies the patch and returns the patched route. +func (c *FakeRoutes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(routesResource, c.ns, name, pt, data, subresources...), &v1alpha1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Route), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_service.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_service.go new file mode 100644 index 00000000000..c319e904d81 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_service.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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/serving/pkg/apis/serving/v1alpha1" +) + +// FakeServices implements ServiceInterface +type FakeServices struct { + Fake *FakeServingV1alpha1 + ns string +} + +var servicesResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1alpha1", Resource: "services"} + +var servicesKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1alpha1", Kind: "Service"} + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *FakeServices) Get(name string, options v1.GetOptions) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(servicesResource, c.ns, name), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *FakeServices) List(opts v1.ListOptions) (result *v1alpha1.ServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(servicesResource, servicesKind, c.ns, opts), &v1alpha1.ServiceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.ServiceList{ListMeta: obj.(*v1alpha1.ServiceList).ListMeta} + for _, item := range obj.(*v1alpha1.ServiceList).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 services. +func (c *FakeServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(servicesResource, c.ns, opts)) + +} + +// Create takes the representation of a service and creates it. Returns the server's representation of the service, and an error, if there is any. +func (c *FakeServices) Create(service *v1alpha1.Service) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(servicesResource, c.ns, service), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any. +func (c *FakeServices) Update(service *v1alpha1.Service) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(servicesResource, c.ns, service), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), 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 *FakeServices) UpdateStatus(service *v1alpha1.Service) (*v1alpha1.Service, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(servicesResource, "status", c.ns, service), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *FakeServices) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(servicesResource, c.ns, name), &v1alpha1.Service{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(servicesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.ServiceList{}) + return err +} + +// Patch applies the patch and returns the patched service. +func (c *FakeServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, name, pt, data, subresources...), &v1alpha1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Service), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_serving_client.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_serving_client.go new file mode 100644 index 00000000000..dfe37782ed5 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/fake/fake_serving_client.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1alpha1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" +) + +type FakeServingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeServingV1alpha1) Configurations(namespace string) v1alpha1.ConfigurationInterface { + return &FakeConfigurations{c, namespace} +} + +func (c *FakeServingV1alpha1) Revisions(namespace string) v1alpha1.RevisionInterface { + return &FakeRevisions{c, namespace} +} + +func (c *FakeServingV1alpha1) Routes(namespace string) v1alpha1.RouteInterface { + return &FakeRoutes{c, namespace} +} + +func (c *FakeServingV1alpha1) Services(namespace string) v1alpha1.ServiceInterface { + return &FakeServices{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeServingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.go new file mode 100644 index 00000000000..1e9bae5365d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2020 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 + +type ConfigurationExpansion interface{} + +type RevisionExpansion interface{} + +type RouteExpansion interface{} + +type ServiceExpansion interface{} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/revision.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/revision.go new file mode 100644 index 00000000000..efac4f465ab --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/revision.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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/serving/pkg/apis/serving/v1alpha1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// RevisionsGetter has a method to return a RevisionInterface. +// A group's client should implement this interface. +type RevisionsGetter interface { + Revisions(namespace string) RevisionInterface +} + +// RevisionInterface has methods to work with Revision resources. +type RevisionInterface interface { + Create(*v1alpha1.Revision) (*v1alpha1.Revision, error) + Update(*v1alpha1.Revision) (*v1alpha1.Revision, error) + UpdateStatus(*v1alpha1.Revision) (*v1alpha1.Revision, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Revision, error) + List(opts v1.ListOptions) (*v1alpha1.RevisionList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Revision, err error) + RevisionExpansion +} + +// revisions implements RevisionInterface +type revisions struct { + client rest.Interface + ns string +} + +// newRevisions returns a Revisions +func newRevisions(c *ServingV1alpha1Client, namespace string) *revisions { + return &revisions{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the revision, and returns the corresponding revision object, and an error if there is any. +func (c *revisions) Get(name string, options v1.GetOptions) (result *v1alpha1.Revision, err error) { + result = &v1alpha1.Revision{} + err = c.client.Get(). + Namespace(c.ns). + Resource("revisions"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Revisions that match those selectors. +func (c *revisions) List(opts v1.ListOptions) (result *v1alpha1.RevisionList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.RevisionList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("revisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested revisions. +func (c *revisions) 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("revisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a revision and creates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *revisions) Create(revision *v1alpha1.Revision) (result *v1alpha1.Revision, err error) { + result = &v1alpha1.Revision{} + err = c.client.Post(). + Namespace(c.ns). + Resource("revisions"). + Body(revision). + Do(). + Into(result) + return +} + +// Update takes the representation of a revision and updates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *revisions) Update(revision *v1alpha1.Revision) (result *v1alpha1.Revision, err error) { + result = &v1alpha1.Revision{} + err = c.client.Put(). + Namespace(c.ns). + Resource("revisions"). + Name(revision.Name). + Body(revision). + 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 *revisions) UpdateStatus(revision *v1alpha1.Revision) (result *v1alpha1.Revision, err error) { + result = &v1alpha1.Revision{} + err = c.client.Put(). + Namespace(c.ns). + Resource("revisions"). + Name(revision.Name). + SubResource("status"). + Body(revision). + Do(). + Into(result) + return +} + +// Delete takes name of the revision and deletes it. Returns an error if one occurs. +func (c *revisions) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("revisions"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *revisions) 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("revisions"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched revision. +func (c *revisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Revision, err error) { + result = &v1alpha1.Revision{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("revisions"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/route.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/route.go new file mode 100644 index 00000000000..82e9d2373b9 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/route.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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/serving/pkg/apis/serving/v1alpha1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// RoutesGetter has a method to return a RouteInterface. +// A group's client should implement this interface. +type RoutesGetter interface { + Routes(namespace string) RouteInterface +} + +// RouteInterface has methods to work with Route resources. +type RouteInterface interface { + Create(*v1alpha1.Route) (*v1alpha1.Route, error) + Update(*v1alpha1.Route) (*v1alpha1.Route, error) + UpdateStatus(*v1alpha1.Route) (*v1alpha1.Route, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Route, error) + List(opts v1.ListOptions) (*v1alpha1.RouteList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Route, err error) + RouteExpansion +} + +// routes implements RouteInterface +type routes struct { + client rest.Interface + ns string +} + +// newRoutes returns a Routes +func newRoutes(c *ServingV1alpha1Client, namespace string) *routes { + return &routes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the route, and returns the corresponding route object, and an error if there is any. +func (c *routes) Get(name string, options v1.GetOptions) (result *v1alpha1.Route, err error) { + result = &v1alpha1.Route{} + err = c.client.Get(). + Namespace(c.ns). + Resource("routes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Routes that match those selectors. +func (c *routes) List(opts v1.ListOptions) (result *v1alpha1.RouteList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.RouteList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("routes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested routes. +func (c *routes) 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("routes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a route and creates it. Returns the server's representation of the route, and an error, if there is any. +func (c *routes) Create(route *v1alpha1.Route) (result *v1alpha1.Route, err error) { + result = &v1alpha1.Route{} + err = c.client.Post(). + Namespace(c.ns). + Resource("routes"). + Body(route). + Do(). + Into(result) + return +} + +// Update takes the representation of a route and updates it. Returns the server's representation of the route, and an error, if there is any. +func (c *routes) Update(route *v1alpha1.Route) (result *v1alpha1.Route, err error) { + result = &v1alpha1.Route{} + err = c.client.Put(). + Namespace(c.ns). + Resource("routes"). + Name(route.Name). + Body(route). + 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 *routes) UpdateStatus(route *v1alpha1.Route) (result *v1alpha1.Route, err error) { + result = &v1alpha1.Route{} + err = c.client.Put(). + Namespace(c.ns). + Resource("routes"). + Name(route.Name). + SubResource("status"). + Body(route). + Do(). + Into(result) + return +} + +// Delete takes name of the route and deletes it. Returns an error if one occurs. +func (c *routes) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("routes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *routes) 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("routes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched route. +func (c *routes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Route, err error) { + result = &v1alpha1.Route{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("routes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/service.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/service.go new file mode 100644 index 00000000000..a5b669ab382 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/service.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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/serving/pkg/apis/serving/v1alpha1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// ServicesGetter has a method to return a ServiceInterface. +// A group's client should implement this interface. +type ServicesGetter interface { + Services(namespace string) ServiceInterface +} + +// ServiceInterface has methods to work with Service resources. +type ServiceInterface interface { + Create(*v1alpha1.Service) (*v1alpha1.Service, error) + Update(*v1alpha1.Service) (*v1alpha1.Service, error) + UpdateStatus(*v1alpha1.Service) (*v1alpha1.Service, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Service, error) + List(opts v1.ListOptions) (*v1alpha1.ServiceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Service, err error) + ServiceExpansion +} + +// services implements ServiceInterface +type services struct { + client rest.Interface + ns string +} + +// newServices returns a Services +func newServices(c *ServingV1alpha1Client, namespace string) *services { + return &services{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *services) Get(name string, options v1.GetOptions) (result *v1alpha1.Service, err error) { + result = &v1alpha1.Service{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *services) List(opts v1.ListOptions) (result *v1alpha1.ServiceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.ServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested services. +func (c *services) 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("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a service and creates it. Returns the server's representation of the service, and an error, if there is any. +func (c *services) Create(service *v1alpha1.Service) (result *v1alpha1.Service, err error) { + result = &v1alpha1.Service{} + err = c.client.Post(). + Namespace(c.ns). + Resource("services"). + Body(service). + Do(). + Into(result) + return +} + +// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any. +func (c *services) Update(service *v1alpha1.Service) (result *v1alpha1.Service, err error) { + result = &v1alpha1.Service{} + err = c.client.Put(). + Namespace(c.ns). + Resource("services"). + Name(service.Name). + Body(service). + 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 *services) UpdateStatus(service *v1alpha1.Service) (result *v1alpha1.Service, err error) { + result = &v1alpha1.Service{} + err = c.client.Put(). + Namespace(c.ns). + Resource("services"). + Name(service.Name). + SubResource("status"). + Body(service). + Do(). + Into(result) + return +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *services) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("services"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *services) 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("services"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched service. +func (c *services) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Service, err error) { + result = &v1alpha1.Service{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("services"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/serving_client.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/serving_client.go new file mode 100644 index 00000000000..e6ade911beb --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1/serving_client.go @@ -0,0 +1,104 @@ +/* +Copyright 2020 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 ( + rest "k8s.io/client-go/rest" + v1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" + "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +type ServingV1alpha1Interface interface { + RESTClient() rest.Interface + ConfigurationsGetter + RevisionsGetter + RoutesGetter + ServicesGetter +} + +// ServingV1alpha1Client is used to interact with features provided by the serving.knative.dev group. +type ServingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *ServingV1alpha1Client) Configurations(namespace string) ConfigurationInterface { + return newConfigurations(c, namespace) +} + +func (c *ServingV1alpha1Client) Revisions(namespace string) RevisionInterface { + return newRevisions(c, namespace) +} + +func (c *ServingV1alpha1Client) Routes(namespace string) RouteInterface { + return newRoutes(c, namespace) +} + +func (c *ServingV1alpha1Client) Services(namespace string) ServiceInterface { + return newServices(c, namespace) +} + +// NewForConfig creates a new ServingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*ServingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &ServingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new ServingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ServingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ServingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *ServingV1alpha1Client { + return &ServingV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ServingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/configuration.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/configuration.go new file mode 100644 index 00000000000..abc50b8a1be --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/configuration.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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 v1beta1 + +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" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// ConfigurationsGetter has a method to return a ConfigurationInterface. +// A group's client should implement this interface. +type ConfigurationsGetter interface { + Configurations(namespace string) ConfigurationInterface +} + +// ConfigurationInterface has methods to work with Configuration resources. +type ConfigurationInterface interface { + Create(*v1beta1.Configuration) (*v1beta1.Configuration, error) + Update(*v1beta1.Configuration) (*v1beta1.Configuration, error) + UpdateStatus(*v1beta1.Configuration) (*v1beta1.Configuration, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Configuration, error) + List(opts v1.ListOptions) (*v1beta1.ConfigurationList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Configuration, err error) + ConfigurationExpansion +} + +// configurations implements ConfigurationInterface +type configurations struct { + client rest.Interface + ns string +} + +// newConfigurations returns a Configurations +func newConfigurations(c *ServingV1beta1Client, namespace string) *configurations { + return &configurations{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the configuration, and returns the corresponding configuration object, and an error if there is any. +func (c *configurations) Get(name string, options v1.GetOptions) (result *v1beta1.Configuration, err error) { + result = &v1beta1.Configuration{} + err = c.client.Get(). + Namespace(c.ns). + Resource("configurations"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Configurations that match those selectors. +func (c *configurations) List(opts v1.ListOptions) (result *v1beta1.ConfigurationList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ConfigurationList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("configurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested configurations. +func (c *configurations) 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("configurations"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a configuration and creates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *configurations) Create(configuration *v1beta1.Configuration) (result *v1beta1.Configuration, err error) { + result = &v1beta1.Configuration{} + err = c.client.Post(). + Namespace(c.ns). + Resource("configurations"). + Body(configuration). + Do(). + Into(result) + return +} + +// Update takes the representation of a configuration and updates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *configurations) Update(configuration *v1beta1.Configuration) (result *v1beta1.Configuration, err error) { + result = &v1beta1.Configuration{} + err = c.client.Put(). + Namespace(c.ns). + Resource("configurations"). + Name(configuration.Name). + Body(configuration). + 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 *configurations) UpdateStatus(configuration *v1beta1.Configuration) (result *v1beta1.Configuration, err error) { + result = &v1beta1.Configuration{} + err = c.client.Put(). + Namespace(c.ns). + Resource("configurations"). + Name(configuration.Name). + SubResource("status"). + Body(configuration). + Do(). + Into(result) + return +} + +// Delete takes name of the configuration and deletes it. Returns an error if one occurs. +func (c *configurations) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("configurations"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *configurations) 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("configurations"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched configuration. +func (c *configurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Configuration, err error) { + result = &v1beta1.Configuration{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("configurations"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/doc.go new file mode 100644 index 00000000000..b641cb37309 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/doc.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/doc.go new file mode 100644 index 00000000000..c7f6e65cab8 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2020 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 has the automatically generated clients. +package fake diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_configuration.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_configuration.go new file mode 100644 index 00000000000..c0aa1d25100 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_configuration.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// FakeConfigurations implements ConfigurationInterface +type FakeConfigurations struct { + Fake *FakeServingV1beta1 + ns string +} + +var configurationsResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1beta1", Resource: "configurations"} + +var configurationsKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1beta1", Kind: "Configuration"} + +// Get takes name of the configuration, and returns the corresponding configuration object, and an error if there is any. +func (c *FakeConfigurations) Get(name string, options v1.GetOptions) (result *v1beta1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(configurationsResource, c.ns, name), &v1beta1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Configuration), err +} + +// List takes label and field selectors, and returns the list of Configurations that match those selectors. +func (c *FakeConfigurations) List(opts v1.ListOptions) (result *v1beta1.ConfigurationList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(configurationsResource, configurationsKind, c.ns, opts), &v1beta1.ConfigurationList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.ConfigurationList{ListMeta: obj.(*v1beta1.ConfigurationList).ListMeta} + for _, item := range obj.(*v1beta1.ConfigurationList).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 configurations. +func (c *FakeConfigurations) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(configurationsResource, c.ns, opts)) + +} + +// Create takes the representation of a configuration and creates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *FakeConfigurations) Create(configuration *v1beta1.Configuration) (result *v1beta1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(configurationsResource, c.ns, configuration), &v1beta1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Configuration), err +} + +// Update takes the representation of a configuration and updates it. Returns the server's representation of the configuration, and an error, if there is any. +func (c *FakeConfigurations) Update(configuration *v1beta1.Configuration) (result *v1beta1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(configurationsResource, c.ns, configuration), &v1beta1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Configuration), 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 *FakeConfigurations) UpdateStatus(configuration *v1beta1.Configuration) (*v1beta1.Configuration, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(configurationsResource, "status", c.ns, configuration), &v1beta1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Configuration), err +} + +// Delete takes name of the configuration and deletes it. Returns an error if one occurs. +func (c *FakeConfigurations) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(configurationsResource, c.ns, name), &v1beta1.Configuration{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeConfigurations) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(configurationsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.ConfigurationList{}) + return err +} + +// Patch applies the patch and returns the patched configuration. +func (c *FakeConfigurations) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Configuration, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(configurationsResource, c.ns, name, pt, data, subresources...), &v1beta1.Configuration{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Configuration), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_revision.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_revision.go new file mode 100644 index 00000000000..4025c075940 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_revision.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// FakeRevisions implements RevisionInterface +type FakeRevisions struct { + Fake *FakeServingV1beta1 + ns string +} + +var revisionsResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1beta1", Resource: "revisions"} + +var revisionsKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1beta1", Kind: "Revision"} + +// Get takes name of the revision, and returns the corresponding revision object, and an error if there is any. +func (c *FakeRevisions) Get(name string, options v1.GetOptions) (result *v1beta1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(revisionsResource, c.ns, name), &v1beta1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Revision), err +} + +// List takes label and field selectors, and returns the list of Revisions that match those selectors. +func (c *FakeRevisions) List(opts v1.ListOptions) (result *v1beta1.RevisionList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(revisionsResource, revisionsKind, c.ns, opts), &v1beta1.RevisionList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.RevisionList{ListMeta: obj.(*v1beta1.RevisionList).ListMeta} + for _, item := range obj.(*v1beta1.RevisionList).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 revisions. +func (c *FakeRevisions) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(revisionsResource, c.ns, opts)) + +} + +// Create takes the representation of a revision and creates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *FakeRevisions) Create(revision *v1beta1.Revision) (result *v1beta1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(revisionsResource, c.ns, revision), &v1beta1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Revision), err +} + +// Update takes the representation of a revision and updates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *FakeRevisions) Update(revision *v1beta1.Revision) (result *v1beta1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(revisionsResource, c.ns, revision), &v1beta1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Revision), 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 *FakeRevisions) UpdateStatus(revision *v1beta1.Revision) (*v1beta1.Revision, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(revisionsResource, "status", c.ns, revision), &v1beta1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Revision), err +} + +// Delete takes name of the revision and deletes it. Returns an error if one occurs. +func (c *FakeRevisions) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(revisionsResource, c.ns, name), &v1beta1.Revision{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRevisions) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(revisionsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.RevisionList{}) + return err +} + +// Patch applies the patch and returns the patched revision. +func (c *FakeRevisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Revision, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(revisionsResource, c.ns, name, pt, data, subresources...), &v1beta1.Revision{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Revision), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_route.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_route.go new file mode 100644 index 00000000000..4bb9dc913d7 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_route.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// FakeRoutes implements RouteInterface +type FakeRoutes struct { + Fake *FakeServingV1beta1 + ns string +} + +var routesResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1beta1", Resource: "routes"} + +var routesKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1beta1", Kind: "Route"} + +// Get takes name of the route, and returns the corresponding route object, and an error if there is any. +func (c *FakeRoutes) Get(name string, options v1.GetOptions) (result *v1beta1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(routesResource, c.ns, name), &v1beta1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Route), err +} + +// List takes label and field selectors, and returns the list of Routes that match those selectors. +func (c *FakeRoutes) List(opts v1.ListOptions) (result *v1beta1.RouteList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(routesResource, routesKind, c.ns, opts), &v1beta1.RouteList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.RouteList{ListMeta: obj.(*v1beta1.RouteList).ListMeta} + for _, item := range obj.(*v1beta1.RouteList).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 routes. +func (c *FakeRoutes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(routesResource, c.ns, opts)) + +} + +// Create takes the representation of a route and creates it. Returns the server's representation of the route, and an error, if there is any. +func (c *FakeRoutes) Create(route *v1beta1.Route) (result *v1beta1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(routesResource, c.ns, route), &v1beta1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Route), err +} + +// Update takes the representation of a route and updates it. Returns the server's representation of the route, and an error, if there is any. +func (c *FakeRoutes) Update(route *v1beta1.Route) (result *v1beta1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(routesResource, c.ns, route), &v1beta1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Route), 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 *FakeRoutes) UpdateStatus(route *v1beta1.Route) (*v1beta1.Route, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(routesResource, "status", c.ns, route), &v1beta1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Route), err +} + +// Delete takes name of the route and deletes it. Returns an error if one occurs. +func (c *FakeRoutes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(routesResource, c.ns, name), &v1beta1.Route{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeRoutes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(routesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.RouteList{}) + return err +} + +// Patch applies the patch and returns the patched route. +func (c *FakeRoutes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Route, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(routesResource, c.ns, name, pt, data, subresources...), &v1beta1.Route{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Route), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_service.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_service.go new file mode 100644 index 00000000000..593f70c17a3 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_service.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// FakeServices implements ServiceInterface +type FakeServices struct { + Fake *FakeServingV1beta1 + ns string +} + +var servicesResource = schema.GroupVersionResource{Group: "serving.knative.dev", Version: "v1beta1", Resource: "services"} + +var servicesKind = schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1beta1", Kind: "Service"} + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *FakeServices) Get(name string, options v1.GetOptions) (result *v1beta1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(servicesResource, c.ns, name), &v1beta1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Service), err +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *FakeServices) List(opts v1.ListOptions) (result *v1beta1.ServiceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(servicesResource, servicesKind, c.ns, opts), &v1beta1.ServiceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.ServiceList{ListMeta: obj.(*v1beta1.ServiceList).ListMeta} + for _, item := range obj.(*v1beta1.ServiceList).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 services. +func (c *FakeServices) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(servicesResource, c.ns, opts)) + +} + +// Create takes the representation of a service and creates it. Returns the server's representation of the service, and an error, if there is any. +func (c *FakeServices) Create(service *v1beta1.Service) (result *v1beta1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(servicesResource, c.ns, service), &v1beta1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Service), err +} + +// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any. +func (c *FakeServices) Update(service *v1beta1.Service) (result *v1beta1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(servicesResource, c.ns, service), &v1beta1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Service), 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 *FakeServices) UpdateStatus(service *v1beta1.Service) (*v1beta1.Service, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(servicesResource, "status", c.ns, service), &v1beta1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Service), err +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *FakeServices) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(servicesResource, c.ns, name), &v1beta1.Service{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeServices) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(servicesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.ServiceList{}) + return err +} + +// Patch applies the patch and returns the patched service. +func (c *FakeServices) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Service, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(servicesResource, c.ns, name, pt, data, subresources...), &v1beta1.Service{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Service), err +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_serving_client.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_serving_client.go new file mode 100644 index 00000000000..74b96703974 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/fake/fake_serving_client.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1beta1 "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1" +) + +type FakeServingV1beta1 struct { + *testing.Fake +} + +func (c *FakeServingV1beta1) Configurations(namespace string) v1beta1.ConfigurationInterface { + return &FakeConfigurations{c, namespace} +} + +func (c *FakeServingV1beta1) Revisions(namespace string) v1beta1.RevisionInterface { + return &FakeRevisions{c, namespace} +} + +func (c *FakeServingV1beta1) Routes(namespace string) v1beta1.RouteInterface { + return &FakeRoutes{c, namespace} +} + +func (c *FakeServingV1beta1) Services(namespace string) v1beta1.ServiceInterface { + return &FakeServices{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeServingV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/generated_expansion.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/generated_expansion.go new file mode 100644 index 00000000000..b7a7ae310c0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/generated_expansion.go @@ -0,0 +1,27 @@ +/* +Copyright 2020 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 v1beta1 + +type ConfigurationExpansion interface{} + +type RevisionExpansion interface{} + +type RouteExpansion interface{} + +type ServiceExpansion interface{} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/revision.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/revision.go new file mode 100644 index 00000000000..a8ca29f396e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/revision.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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 v1beta1 + +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" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// RevisionsGetter has a method to return a RevisionInterface. +// A group's client should implement this interface. +type RevisionsGetter interface { + Revisions(namespace string) RevisionInterface +} + +// RevisionInterface has methods to work with Revision resources. +type RevisionInterface interface { + Create(*v1beta1.Revision) (*v1beta1.Revision, error) + Update(*v1beta1.Revision) (*v1beta1.Revision, error) + UpdateStatus(*v1beta1.Revision) (*v1beta1.Revision, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Revision, error) + List(opts v1.ListOptions) (*v1beta1.RevisionList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Revision, err error) + RevisionExpansion +} + +// revisions implements RevisionInterface +type revisions struct { + client rest.Interface + ns string +} + +// newRevisions returns a Revisions +func newRevisions(c *ServingV1beta1Client, namespace string) *revisions { + return &revisions{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the revision, and returns the corresponding revision object, and an error if there is any. +func (c *revisions) Get(name string, options v1.GetOptions) (result *v1beta1.Revision, err error) { + result = &v1beta1.Revision{} + err = c.client.Get(). + Namespace(c.ns). + Resource("revisions"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Revisions that match those selectors. +func (c *revisions) List(opts v1.ListOptions) (result *v1beta1.RevisionList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.RevisionList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("revisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested revisions. +func (c *revisions) 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("revisions"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a revision and creates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *revisions) Create(revision *v1beta1.Revision) (result *v1beta1.Revision, err error) { + result = &v1beta1.Revision{} + err = c.client.Post(). + Namespace(c.ns). + Resource("revisions"). + Body(revision). + Do(). + Into(result) + return +} + +// Update takes the representation of a revision and updates it. Returns the server's representation of the revision, and an error, if there is any. +func (c *revisions) Update(revision *v1beta1.Revision) (result *v1beta1.Revision, err error) { + result = &v1beta1.Revision{} + err = c.client.Put(). + Namespace(c.ns). + Resource("revisions"). + Name(revision.Name). + Body(revision). + 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 *revisions) UpdateStatus(revision *v1beta1.Revision) (result *v1beta1.Revision, err error) { + result = &v1beta1.Revision{} + err = c.client.Put(). + Namespace(c.ns). + Resource("revisions"). + Name(revision.Name). + SubResource("status"). + Body(revision). + Do(). + Into(result) + return +} + +// Delete takes name of the revision and deletes it. Returns an error if one occurs. +func (c *revisions) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("revisions"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *revisions) 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("revisions"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched revision. +func (c *revisions) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Revision, err error) { + result = &v1beta1.Revision{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("revisions"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/route.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/route.go new file mode 100644 index 00000000000..b893abcf270 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/route.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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 v1beta1 + +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" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// RoutesGetter has a method to return a RouteInterface. +// A group's client should implement this interface. +type RoutesGetter interface { + Routes(namespace string) RouteInterface +} + +// RouteInterface has methods to work with Route resources. +type RouteInterface interface { + Create(*v1beta1.Route) (*v1beta1.Route, error) + Update(*v1beta1.Route) (*v1beta1.Route, error) + UpdateStatus(*v1beta1.Route) (*v1beta1.Route, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Route, error) + List(opts v1.ListOptions) (*v1beta1.RouteList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Route, err error) + RouteExpansion +} + +// routes implements RouteInterface +type routes struct { + client rest.Interface + ns string +} + +// newRoutes returns a Routes +func newRoutes(c *ServingV1beta1Client, namespace string) *routes { + return &routes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the route, and returns the corresponding route object, and an error if there is any. +func (c *routes) Get(name string, options v1.GetOptions) (result *v1beta1.Route, err error) { + result = &v1beta1.Route{} + err = c.client.Get(). + Namespace(c.ns). + Resource("routes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Routes that match those selectors. +func (c *routes) List(opts v1.ListOptions) (result *v1beta1.RouteList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.RouteList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("routes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested routes. +func (c *routes) 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("routes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a route and creates it. Returns the server's representation of the route, and an error, if there is any. +func (c *routes) Create(route *v1beta1.Route) (result *v1beta1.Route, err error) { + result = &v1beta1.Route{} + err = c.client.Post(). + Namespace(c.ns). + Resource("routes"). + Body(route). + Do(). + Into(result) + return +} + +// Update takes the representation of a route and updates it. Returns the server's representation of the route, and an error, if there is any. +func (c *routes) Update(route *v1beta1.Route) (result *v1beta1.Route, err error) { + result = &v1beta1.Route{} + err = c.client.Put(). + Namespace(c.ns). + Resource("routes"). + Name(route.Name). + Body(route). + 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 *routes) UpdateStatus(route *v1beta1.Route) (result *v1beta1.Route, err error) { + result = &v1beta1.Route{} + err = c.client.Put(). + Namespace(c.ns). + Resource("routes"). + Name(route.Name). + SubResource("status"). + Body(route). + Do(). + Into(result) + return +} + +// Delete takes name of the route and deletes it. Returns an error if one occurs. +func (c *routes) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("routes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *routes) 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("routes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched route. +func (c *routes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Route, err error) { + result = &v1beta1.Route{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("routes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/service.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/service.go new file mode 100644 index 00000000000..12985f2c771 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/service.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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 v1beta1 + +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" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" + scheme "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +// ServicesGetter has a method to return a ServiceInterface. +// A group's client should implement this interface. +type ServicesGetter interface { + Services(namespace string) ServiceInterface +} + +// ServiceInterface has methods to work with Service resources. +type ServiceInterface interface { + Create(*v1beta1.Service) (*v1beta1.Service, error) + Update(*v1beta1.Service) (*v1beta1.Service, error) + UpdateStatus(*v1beta1.Service) (*v1beta1.Service, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Service, error) + List(opts v1.ListOptions) (*v1beta1.ServiceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Service, err error) + ServiceExpansion +} + +// services implements ServiceInterface +type services struct { + client rest.Interface + ns string +} + +// newServices returns a Services +func newServices(c *ServingV1beta1Client, namespace string) *services { + return &services{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the service, and returns the corresponding service object, and an error if there is any. +func (c *services) Get(name string, options v1.GetOptions) (result *v1beta1.Service, err error) { + result = &v1beta1.Service{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Services that match those selectors. +func (c *services) List(opts v1.ListOptions) (result *v1beta1.ServiceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ServiceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested services. +func (c *services) 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("services"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a service and creates it. Returns the server's representation of the service, and an error, if there is any. +func (c *services) Create(service *v1beta1.Service) (result *v1beta1.Service, err error) { + result = &v1beta1.Service{} + err = c.client.Post(). + Namespace(c.ns). + Resource("services"). + Body(service). + Do(). + Into(result) + return +} + +// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any. +func (c *services) Update(service *v1beta1.Service) (result *v1beta1.Service, err error) { + result = &v1beta1.Service{} + err = c.client.Put(). + Namespace(c.ns). + Resource("services"). + Name(service.Name). + Body(service). + 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 *services) UpdateStatus(service *v1beta1.Service) (result *v1beta1.Service, err error) { + result = &v1beta1.Service{} + err = c.client.Put(). + Namespace(c.ns). + Resource("services"). + Name(service.Name). + SubResource("status"). + Body(service). + Do(). + Into(result) + return +} + +// Delete takes name of the service and deletes it. Returns an error if one occurs. +func (c *services) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("services"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *services) 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("services"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched service. +func (c *services) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Service, err error) { + result = &v1beta1.Service{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("services"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/serving_client.go b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/serving_client.go new file mode 100644 index 00000000000..235b1739148 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1beta1/serving_client.go @@ -0,0 +1,104 @@ +/* +Copyright 2020 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 v1beta1 + +import ( + rest "k8s.io/client-go/rest" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" + "knative.dev/serving/pkg/client/clientset/versioned/scheme" +) + +type ServingV1beta1Interface interface { + RESTClient() rest.Interface + ConfigurationsGetter + RevisionsGetter + RoutesGetter + ServicesGetter +} + +// ServingV1beta1Client is used to interact with features provided by the serving.knative.dev group. +type ServingV1beta1Client struct { + restClient rest.Interface +} + +func (c *ServingV1beta1Client) Configurations(namespace string) ConfigurationInterface { + return newConfigurations(c, namespace) +} + +func (c *ServingV1beta1Client) Revisions(namespace string) RevisionInterface { + return newRevisions(c, namespace) +} + +func (c *ServingV1beta1Client) Routes(namespace string) RouteInterface { + return newRoutes(c, namespace) +} + +func (c *ServingV1beta1Client) Services(namespace string) ServiceInterface { + return newServices(c, namespace) +} + +// NewForConfig creates a new ServingV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*ServingV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &ServingV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new ServingV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *ServingV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new ServingV1beta1Client for the given RESTClient. +func New(c rest.Interface) *ServingV1beta1Client { + return &ServingV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *ServingV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/interface.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/interface.go new file mode 100644 index 00000000000..a21a2a0bde0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package autoscaling + +import ( + v1alpha1 "knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go new file mode 100644 index 00000000000..fa410aa8d3d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Metrics returns a MetricInformer. + Metrics() MetricInformer + // PodAutoscalers returns a PodAutoscalerInformer. + PodAutoscalers() PodAutoscalerInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Metrics returns a MetricInformer. +func (v *version) Metrics() MetricInformer { + return &metricInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// PodAutoscalers returns a PodAutoscalerInformer. +func (v *version) PodAutoscalers() PodAutoscalerInformer { + return &podAutoscalerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/metric.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/metric.go new file mode 100644 index 00000000000..5a5a8f45151 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/metric.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + autoscalingv1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1" +) + +// MetricInformer provides access to a shared informer and lister for +// Metrics. +type MetricInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.MetricLister +} + +type metricInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewMetricInformer constructs a new informer for Metric type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewMetricInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredMetricInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredMetricInformer constructs a new informer for Metric type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredMetricInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha1().Metrics(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha1().Metrics(namespace).Watch(options) + }, + }, + &autoscalingv1alpha1.Metric{}, + resyncPeriod, + indexers, + ) +} + +func (f *metricInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredMetricInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *metricInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&autoscalingv1alpha1.Metric{}, f.defaultInformer) +} + +func (f *metricInformer) Lister() v1alpha1.MetricLister { + return v1alpha1.NewMetricLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/podautoscaler.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/podautoscaler.go new file mode 100644 index 00000000000..eb872c4f55a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/autoscaling/v1alpha1/podautoscaler.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + autoscalingv1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1" +) + +// PodAutoscalerInformer provides access to a shared informer and lister for +// PodAutoscalers. +type PodAutoscalerInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.PodAutoscalerLister +} + +type podAutoscalerInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewPodAutoscalerInformer constructs a new informer for PodAutoscaler type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewPodAutoscalerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredPodAutoscalerInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredPodAutoscalerInformer constructs a new informer for PodAutoscaler type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredPodAutoscalerInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha1().PodAutoscalers(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.AutoscalingV1alpha1().PodAutoscalers(namespace).Watch(options) + }, + }, + &autoscalingv1alpha1.PodAutoscaler{}, + resyncPeriod, + indexers, + ) +} + +func (f *podAutoscalerInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredPodAutoscalerInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *podAutoscalerInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&autoscalingv1alpha1.PodAutoscaler{}, f.defaultInformer) +} + +func (f *podAutoscalerInformer) Lister() v1alpha1.PodAutoscalerLister { + return v1alpha1.NewPodAutoscalerLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/factory.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/factory.go new file mode 100644 index 00000000000..1d42b4c3e7c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/factory.go @@ -0,0 +1,192 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + autoscaling "knative.dev/serving/pkg/client/informers/externalversions/autoscaling" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + networking "knative.dev/serving/pkg/client/informers/externalversions/networking" + serving "knative.dev/serving/pkg/client/informers/externalversions/serving" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// WaitForCacheSync waits for all started informers' cache were synced. +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Autoscaling() autoscaling.Interface + Networking() networking.Interface + Serving() serving.Interface +} + +func (f *sharedInformerFactory) Autoscaling() autoscaling.Interface { + return autoscaling.New(f, f.namespace, f.tweakListOptions) +} + +func (f *sharedInformerFactory) Networking() networking.Interface { + return networking.New(f, f.namespace, f.tweakListOptions) +} + +func (f *sharedInformerFactory) Serving() serving.Interface { + return serving.New(f, f.namespace, f.tweakListOptions) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/generic.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/generic.go new file mode 100644 index 00000000000..00313b24f5e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/generic.go @@ -0,0 +1,106 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package externalversions + +import ( + "fmt" + + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" + v1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1" + networkingv1alpha1 "knative.dev/serving/pkg/apis/networking/v1alpha1" + v1 "knative.dev/serving/pkg/apis/serving/v1" + servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=autoscaling.internal.knative.dev, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("metrics"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha1().Metrics().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("podautoscalers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha1().PodAutoscalers().Informer()}, nil + + // Group=networking.internal.knative.dev, Version=v1alpha1 + case networkingv1alpha1.SchemeGroupVersion.WithResource("certificates"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().Certificates().Informer()}, nil + case networkingv1alpha1.SchemeGroupVersion.WithResource("ingresses"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().Ingresses().Informer()}, nil + case networkingv1alpha1.SchemeGroupVersion.WithResource("serverlessservices"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Networking().V1alpha1().ServerlessServices().Informer()}, nil + + // Group=serving.knative.dev, Version=v1 + case v1.SchemeGroupVersion.WithResource("configurations"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1().Configurations().Informer()}, nil + case v1.SchemeGroupVersion.WithResource("revisions"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1().Revisions().Informer()}, nil + case v1.SchemeGroupVersion.WithResource("routes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1().Routes().Informer()}, nil + case v1.SchemeGroupVersion.WithResource("services"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1().Services().Informer()}, nil + + // Group=serving.knative.dev, Version=v1alpha1 + case servingv1alpha1.SchemeGroupVersion.WithResource("configurations"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1alpha1().Configurations().Informer()}, nil + case servingv1alpha1.SchemeGroupVersion.WithResource("revisions"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1alpha1().Revisions().Informer()}, nil + case servingv1alpha1.SchemeGroupVersion.WithResource("routes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1alpha1().Routes().Informer()}, nil + case servingv1alpha1.SchemeGroupVersion.WithResource("services"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1alpha1().Services().Informer()}, nil + + // Group=serving.knative.dev, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("configurations"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1beta1().Configurations().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("revisions"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1beta1().Revisions().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("routes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1beta1().Routes().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("services"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Serving().V1beta1().Services().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 00000000000..94e406ae772 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" + versioned "knative.dev/serving/pkg/client/clientset/versioned" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/interface.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/interface.go new file mode 100644 index 00000000000..1a234e1c133 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package networking + +import ( + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/certificate.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/certificate.go new file mode 100644 index 00000000000..b53730e218a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/certificate.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + networkingv1alpha1 "knative.dev/serving/pkg/apis/networking/v1alpha1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "knative.dev/serving/pkg/client/listers/networking/v1alpha1" +) + +// CertificateInformer provides access to a shared informer and lister for +// Certificates. +type CertificateInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.CertificateLister +} + +type certificateInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewCertificateInformer constructs a new informer for Certificate type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewCertificateInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredCertificateInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredCertificateInformer constructs a new informer for Certificate type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredCertificateInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().Certificates(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().Certificates(namespace).Watch(options) + }, + }, + &networkingv1alpha1.Certificate{}, + resyncPeriod, + indexers, + ) +} + +func (f *certificateInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredCertificateInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *certificateInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&networkingv1alpha1.Certificate{}, f.defaultInformer) +} + +func (f *certificateInformer) Lister() v1alpha1.CertificateLister { + return v1alpha1.NewCertificateLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/ingress.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/ingress.go new file mode 100644 index 00000000000..a43875dfb5d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/ingress.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + networkingv1alpha1 "knative.dev/serving/pkg/apis/networking/v1alpha1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "knative.dev/serving/pkg/client/listers/networking/v1alpha1" +) + +// IngressInformer provides access to a shared informer and lister for +// Ingresses. +type IngressInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.IngressLister +} + +type ingressInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewIngressInformer constructs a new informer for Ingress type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewIngressInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredIngressInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredIngressInformer constructs a new informer for Ingress type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredIngressInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().Ingresses(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().Ingresses(namespace).Watch(options) + }, + }, + &networkingv1alpha1.Ingress{}, + resyncPeriod, + indexers, + ) +} + +func (f *ingressInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredIngressInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *ingressInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&networkingv1alpha1.Ingress{}, f.defaultInformer) +} + +func (f *ingressInformer) Lister() v1alpha1.IngressLister { + return v1alpha1.NewIngressLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/interface.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/interface.go new file mode 100644 index 00000000000..55d1bf1b573 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/interface.go @@ -0,0 +1,59 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Certificates returns a CertificateInformer. + Certificates() CertificateInformer + // Ingresses returns a IngressInformer. + Ingresses() IngressInformer + // ServerlessServices returns a ServerlessServiceInformer. + ServerlessServices() ServerlessServiceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Certificates returns a CertificateInformer. +func (v *version) Certificates() CertificateInformer { + return &certificateInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Ingresses returns a IngressInformer. +func (v *version) Ingresses() IngressInformer { + return &ingressInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// ServerlessServices returns a ServerlessServiceInformer. +func (v *version) ServerlessServices() ServerlessServiceInformer { + return &serverlessServiceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/serverlessservice.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/serverlessservice.go new file mode 100644 index 00000000000..e346aca70b6 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/networking/v1alpha1/serverlessservice.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + networkingv1alpha1 "knative.dev/serving/pkg/apis/networking/v1alpha1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "knative.dev/serving/pkg/client/listers/networking/v1alpha1" +) + +// ServerlessServiceInformer provides access to a shared informer and lister for +// ServerlessServices. +type ServerlessServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ServerlessServiceLister +} + +type serverlessServiceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewServerlessServiceInformer constructs a new informer for ServerlessService type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewServerlessServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredServerlessServiceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredServerlessServiceInformer constructs a new informer for ServerlessService type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredServerlessServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().ServerlessServices(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.NetworkingV1alpha1().ServerlessServices(namespace).Watch(options) + }, + }, + &networkingv1alpha1.ServerlessService{}, + resyncPeriod, + indexers, + ) +} + +func (f *serverlessServiceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredServerlessServiceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *serverlessServiceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&networkingv1alpha1.ServerlessService{}, f.defaultInformer) +} + +func (f *serverlessServiceInformer) Lister() v1alpha1.ServerlessServiceLister { + return v1alpha1.NewServerlessServiceLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/interface.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/interface.go new file mode 100644 index 00000000000..be69bb69dd2 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/interface.go @@ -0,0 +1,62 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package serving + +import ( + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1 "knative.dev/serving/pkg/client/informers/externalversions/serving/v1" + v1alpha1 "knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1" + v1beta1 "knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} + +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +} + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/configuration.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/configuration.go new file mode 100644 index 00000000000..6e5b5e5e32e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/configuration.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1 + +import ( + time "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1 "knative.dev/serving/pkg/client/listers/serving/v1" +) + +// ConfigurationInformer provides access to a shared informer and lister for +// Configurations. +type ConfigurationInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.ConfigurationLister +} + +type configurationInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewConfigurationInformer constructs a new informer for Configuration type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredConfigurationInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredConfigurationInformer constructs a new informer for Configuration type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1().Configurations(namespace).List(options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1().Configurations(namespace).Watch(options) + }, + }, + &servingv1.Configuration{}, + resyncPeriod, + indexers, + ) +} + +func (f *configurationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredConfigurationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *configurationInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1.Configuration{}, f.defaultInformer) +} + +func (f *configurationInformer) Lister() v1.ConfigurationLister { + return v1.NewConfigurationLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/interface.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/interface.go new file mode 100644 index 00000000000..d1a44d3186a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/interface.go @@ -0,0 +1,66 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1 + +import ( + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Configurations returns a ConfigurationInformer. + Configurations() ConfigurationInformer + // Revisions returns a RevisionInformer. + Revisions() RevisionInformer + // Routes returns a RouteInformer. + Routes() RouteInformer + // Services returns a ServiceInformer. + Services() ServiceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Configurations returns a ConfigurationInformer. +func (v *version) Configurations() ConfigurationInformer { + return &configurationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Revisions returns a RevisionInformer. +func (v *version) Revisions() RevisionInformer { + return &revisionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Routes returns a RouteInformer. +func (v *version) Routes() RouteInformer { + return &routeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Services returns a ServiceInformer. +func (v *version) Services() ServiceInformer { + return &serviceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/revision.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/revision.go new file mode 100644 index 00000000000..759a0093274 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/revision.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1 + +import ( + time "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1 "knative.dev/serving/pkg/client/listers/serving/v1" +) + +// RevisionInformer provides access to a shared informer and lister for +// Revisions. +type RevisionInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.RevisionLister +} + +type revisionInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRevisionInformer constructs a new informer for Revision type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRevisionInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRevisionInformer constructs a new informer for Revision type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1().Revisions(namespace).List(options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1().Revisions(namespace).Watch(options) + }, + }, + &servingv1.Revision{}, + resyncPeriod, + indexers, + ) +} + +func (f *revisionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRevisionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *revisionInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1.Revision{}, f.defaultInformer) +} + +func (f *revisionInformer) Lister() v1.RevisionLister { + return v1.NewRevisionLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/route.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/route.go new file mode 100644 index 00000000000..dd94268445b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/route.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1 + +import ( + time "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1 "knative.dev/serving/pkg/client/listers/serving/v1" +) + +// RouteInformer provides access to a shared informer and lister for +// Routes. +type RouteInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.RouteLister +} + +type routeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRouteInformer constructs a new informer for Route type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRouteInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRouteInformer constructs a new informer for Route type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1().Routes(namespace).List(options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1().Routes(namespace).Watch(options) + }, + }, + &servingv1.Route{}, + resyncPeriod, + indexers, + ) +} + +func (f *routeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRouteInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *routeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1.Route{}, f.defaultInformer) +} + +func (f *routeInformer) Lister() v1.RouteLister { + return v1.NewRouteLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/service.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/service.go new file mode 100644 index 00000000000..2f17a4fc920 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1/service.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1 + +import ( + time "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1 "knative.dev/serving/pkg/client/listers/serving/v1" +) + +// ServiceInformer provides access to a shared informer and lister for +// Services. +type ServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.ServiceLister +} + +type serviceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1().Services(namespace).List(options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1().Services(namespace).Watch(options) + }, + }, + &servingv1.Service{}, + resyncPeriod, + indexers, + ) +} + +func (f *serviceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *serviceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1.Service{}, f.defaultInformer) +} + +func (f *serviceInformer) Lister() v1.ServiceLister { + return v1.NewServiceLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/configuration.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/configuration.go new file mode 100644 index 00000000000..a7f4b47e254 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/configuration.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "knative.dev/serving/pkg/client/listers/serving/v1alpha1" +) + +// ConfigurationInformer provides access to a shared informer and lister for +// Configurations. +type ConfigurationInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ConfigurationLister +} + +type configurationInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewConfigurationInformer constructs a new informer for Configuration type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredConfigurationInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredConfigurationInformer constructs a new informer for Configuration type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Configurations(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Configurations(namespace).Watch(options) + }, + }, + &servingv1alpha1.Configuration{}, + resyncPeriod, + indexers, + ) +} + +func (f *configurationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredConfigurationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *configurationInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1alpha1.Configuration{}, f.defaultInformer) +} + +func (f *configurationInformer) Lister() v1alpha1.ConfigurationLister { + return v1alpha1.NewConfigurationLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/interface.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/interface.go new file mode 100644 index 00000000000..7b49153ba85 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/interface.go @@ -0,0 +1,66 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Configurations returns a ConfigurationInformer. + Configurations() ConfigurationInformer + // Revisions returns a RevisionInformer. + Revisions() RevisionInformer + // Routes returns a RouteInformer. + Routes() RouteInformer + // Services returns a ServiceInformer. + Services() ServiceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Configurations returns a ConfigurationInformer. +func (v *version) Configurations() ConfigurationInformer { + return &configurationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Revisions returns a RevisionInformer. +func (v *version) Revisions() RevisionInformer { + return &revisionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Routes returns a RouteInformer. +func (v *version) Routes() RouteInformer { + return &routeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Services returns a ServiceInformer. +func (v *version) Services() ServiceInformer { + return &serviceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/revision.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/revision.go new file mode 100644 index 00000000000..3fccf1d3b6d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/revision.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "knative.dev/serving/pkg/client/listers/serving/v1alpha1" +) + +// RevisionInformer provides access to a shared informer and lister for +// Revisions. +type RevisionInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.RevisionLister +} + +type revisionInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRevisionInformer constructs a new informer for Revision type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRevisionInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRevisionInformer constructs a new informer for Revision type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Revisions(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Revisions(namespace).Watch(options) + }, + }, + &servingv1alpha1.Revision{}, + resyncPeriod, + indexers, + ) +} + +func (f *revisionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRevisionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *revisionInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1alpha1.Revision{}, f.defaultInformer) +} + +func (f *revisionInformer) Lister() v1alpha1.RevisionLister { + return v1alpha1.NewRevisionLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/route.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/route.go new file mode 100644 index 00000000000..79db675ef08 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/route.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "knative.dev/serving/pkg/client/listers/serving/v1alpha1" +) + +// RouteInformer provides access to a shared informer and lister for +// Routes. +type RouteInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.RouteLister +} + +type routeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRouteInformer constructs a new informer for Route type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRouteInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRouteInformer constructs a new informer for Route type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Routes(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Routes(namespace).Watch(options) + }, + }, + &servingv1alpha1.Route{}, + resyncPeriod, + indexers, + ) +} + +func (f *routeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRouteInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *routeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1alpha1.Route{}, f.defaultInformer) +} + +func (f *routeInformer) Lister() v1alpha1.RouteLister { + return v1alpha1.NewRouteLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/service.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/service.go new file mode 100644 index 00000000000..1b141a6f3f0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1alpha1/service.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1alpha1 "knative.dev/serving/pkg/client/listers/serving/v1alpha1" +) + +// ServiceInformer provides access to a shared informer and lister for +// Services. +type ServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.ServiceLister +} + +type serviceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Services(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1alpha1().Services(namespace).Watch(options) + }, + }, + &servingv1alpha1.Service{}, + resyncPeriod, + indexers, + ) +} + +func (f *serviceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *serviceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1alpha1.Service{}, f.defaultInformer) +} + +func (f *serviceInformer) Lister() v1alpha1.ServiceLister { + return v1alpha1.NewServiceLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/configuration.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/configuration.go new file mode 100644 index 00000000000..338b8d014c1 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/configuration.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "knative.dev/serving/pkg/client/listers/serving/v1beta1" +) + +// ConfigurationInformer provides access to a shared informer and lister for +// Configurations. +type ConfigurationInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.ConfigurationLister +} + +type configurationInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewConfigurationInformer constructs a new informer for Configuration type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredConfigurationInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredConfigurationInformer constructs a new informer for Configuration type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredConfigurationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Configurations(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Configurations(namespace).Watch(options) + }, + }, + &servingv1beta1.Configuration{}, + resyncPeriod, + indexers, + ) +} + +func (f *configurationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredConfigurationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *configurationInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1beta1.Configuration{}, f.defaultInformer) +} + +func (f *configurationInformer) Lister() v1beta1.ConfigurationLister { + return v1beta1.NewConfigurationLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/interface.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/interface.go new file mode 100644 index 00000000000..6e9290d1e2b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/interface.go @@ -0,0 +1,66 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Configurations returns a ConfigurationInformer. + Configurations() ConfigurationInformer + // Revisions returns a RevisionInformer. + Revisions() RevisionInformer + // Routes returns a RouteInformer. + Routes() RouteInformer + // Services returns a ServiceInformer. + Services() ServiceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Configurations returns a ConfigurationInformer. +func (v *version) Configurations() ConfigurationInformer { + return &configurationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Revisions returns a RevisionInformer. +func (v *version) Revisions() RevisionInformer { + return &revisionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Routes returns a RouteInformer. +func (v *version) Routes() RouteInformer { + return &routeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Services returns a ServiceInformer. +func (v *version) Services() ServiceInformer { + return &serviceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/revision.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/revision.go new file mode 100644 index 00000000000..1d44246d0c0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/revision.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "knative.dev/serving/pkg/client/listers/serving/v1beta1" +) + +// RevisionInformer provides access to a shared informer and lister for +// Revisions. +type RevisionInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.RevisionLister +} + +type revisionInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRevisionInformer constructs a new informer for Revision type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRevisionInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRevisionInformer constructs a new informer for Revision type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredRevisionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Revisions(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Revisions(namespace).Watch(options) + }, + }, + &servingv1beta1.Revision{}, + resyncPeriod, + indexers, + ) +} + +func (f *revisionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRevisionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *revisionInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1beta1.Revision{}, f.defaultInformer) +} + +func (f *revisionInformer) Lister() v1beta1.RevisionLister { + return v1beta1.NewRevisionLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/route.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/route.go new file mode 100644 index 00000000000..3d22f848f52 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/route.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "knative.dev/serving/pkg/client/listers/serving/v1beta1" +) + +// RouteInformer provides access to a shared informer and lister for +// Routes. +type RouteInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.RouteLister +} + +type routeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewRouteInformer constructs a new informer for Route type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredRouteInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredRouteInformer constructs a new informer for Route type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredRouteInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Routes(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Routes(namespace).Watch(options) + }, + }, + &servingv1beta1.Route{}, + resyncPeriod, + indexers, + ) +} + +func (f *routeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredRouteInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *routeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1beta1.Route{}, f.defaultInformer) +} + +func (f *routeInformer) Lister() v1beta1.RouteLister { + return v1beta1.NewRouteLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/service.go b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/service.go new file mode 100644 index 00000000000..e06575d1efb --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/informers/externalversions/serving/v1beta1/service.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + servingv1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" + versioned "knative.dev/serving/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/serving/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "knative.dev/serving/pkg/client/listers/serving/v1beta1" +) + +// ServiceInformer provides access to a shared informer and lister for +// Services. +type ServiceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.ServiceLister +} + +type serviceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredServiceInformer constructs a new informer for Service type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredServiceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Services(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.ServingV1beta1().Services(namespace).Watch(options) + }, + }, + &servingv1beta1.Service{}, + resyncPeriod, + indexers, + ) +} + +func (f *serviceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredServiceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *serviceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&servingv1beta1.Service{}, f.defaultInformer) +} + +func (f *serviceInformer) Lister() v1beta1.ServiceLister { + return v1beta1.NewServiceLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/serving/pkg/client/injection/client/client.go b/vendor/knative.dev/serving/pkg/client/injection/client/client.go new file mode 100644 index 00000000000..1c49fa91a6f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/injection/client/client.go @@ -0,0 +1,49 @@ +/* +Copyright 2020 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 injection-gen. DO NOT EDIT. + +package client + +import ( + "context" + + rest "k8s.io/client-go/rest" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" + versioned "knative.dev/serving/pkg/client/clientset/versioned" +) + +func init() { + injection.Default.RegisterClient(withClient) +} + +// Key is used as the key for associating information with a context.Context. +type Key struct{} + +func withClient(ctx context.Context, cfg *rest.Config) context.Context { + return context.WithValue(ctx, Key{}, versioned.NewForConfigOrDie(cfg)) +} + +// Get extracts the versioned.Interface client from the context. +func Get(ctx context.Context) versioned.Interface { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch knative.dev/serving/pkg/client/clientset/versioned.Interface from context.") + } + return untyped.(versioned.Interface) +} diff --git a/vendor/knative.dev/serving/pkg/client/injection/client/fake/fake.go b/vendor/knative.dev/serving/pkg/client/injection/client/fake/fake.go new file mode 100644 index 00000000000..582e58d23c6 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/injection/client/fake/fake.go @@ -0,0 +1,54 @@ +/* +Copyright 2020 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 injection-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/rest" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" + fake "knative.dev/serving/pkg/client/clientset/versioned/fake" + client "knative.dev/serving/pkg/client/injection/client" +) + +func init() { + injection.Fake.RegisterClient(withClient) +} + +func withClient(ctx context.Context, cfg *rest.Config) context.Context { + ctx, _ = With(ctx) + return ctx +} + +func With(ctx context.Context, objects ...runtime.Object) (context.Context, *fake.Clientset) { + cs := fake.NewSimpleClientset(objects...) + return context.WithValue(ctx, client.Key{}, cs), cs +} + +// Get extracts the Kubernetes client from the context. +func Get(ctx context.Context) *fake.Clientset { + untyped := ctx.Value(client.Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch knative.dev/serving/pkg/client/clientset/versioned/fake.Clientset from context.") + } + return untyped.(*fake.Clientset) +} diff --git a/vendor/knative.dev/serving/pkg/client/injection/informers/factory/factory.go b/vendor/knative.dev/serving/pkg/client/injection/informers/factory/factory.go new file mode 100644 index 00000000000..ba5f57b48e6 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/injection/informers/factory/factory.go @@ -0,0 +1,56 @@ +/* +Copyright 2020 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 injection-gen. DO NOT EDIT. + +package factory + +import ( + "context" + + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" + externalversions "knative.dev/serving/pkg/client/informers/externalversions" + client "knative.dev/serving/pkg/client/injection/client" +) + +func init() { + injection.Default.RegisterInformerFactory(withInformerFactory) +} + +// Key is used as the key for associating information with a context.Context. +type Key struct{} + +func withInformerFactory(ctx context.Context) context.Context { + c := client.Get(ctx) + opts := make([]externalversions.SharedInformerOption, 0, 1) + if injection.HasNamespaceScope(ctx) { + opts = append(opts, externalversions.WithNamespace(injection.GetNamespaceScope(ctx))) + } + return context.WithValue(ctx, Key{}, + externalversions.NewSharedInformerFactoryWithOptions(c, controller.GetResyncPeriod(ctx), opts...)) +} + +// Get extracts the InformerFactory from the context. +func Get(ctx context.Context) externalversions.SharedInformerFactory { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch knative.dev/serving/pkg/client/informers/externalversions.SharedInformerFactory from context.") + } + return untyped.(externalversions.SharedInformerFactory) +} diff --git a/vendor/knative.dev/serving/pkg/client/injection/informers/factory/fake/fake.go b/vendor/knative.dev/serving/pkg/client/injection/informers/factory/fake/fake.go new file mode 100644 index 00000000000..e984ede5735 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/injection/informers/factory/fake/fake.go @@ -0,0 +1,45 @@ +/* +Copyright 2020 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 injection-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + externalversions "knative.dev/serving/pkg/client/informers/externalversions" + fake "knative.dev/serving/pkg/client/injection/client/fake" + factory "knative.dev/serving/pkg/client/injection/informers/factory" +) + +var Get = factory.Get + +func init() { + injection.Fake.RegisterInformerFactory(withInformerFactory) +} + +func withInformerFactory(ctx context.Context) context.Context { + c := fake.Get(ctx) + opts := make([]externalversions.SharedInformerOption, 0, 1) + if injection.HasNamespaceScope(ctx) { + opts = append(opts, externalversions.WithNamespace(injection.GetNamespaceScope(ctx))) + } + return context.WithValue(ctx, factory.Key{}, + externalversions.NewSharedInformerFactoryWithOptions(c, controller.GetResyncPeriod(ctx), opts...)) +} diff --git a/vendor/knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake/fake.go b/vendor/knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake/fake.go new file mode 100644 index 00000000000..e41017317e0 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake/fake.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 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 injection-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + fake "knative.dev/serving/pkg/client/injection/informers/factory/fake" + service "knative.dev/serving/pkg/client/injection/informers/serving/v1/service" +) + +var Get = service.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Serving().V1().Services() + return context.WithValue(ctx, service.Key{}, inf), inf.Informer() +} diff --git a/vendor/knative.dev/serving/pkg/client/injection/informers/serving/v1/service/service.go b/vendor/knative.dev/serving/pkg/client/injection/informers/serving/v1/service/service.go new file mode 100644 index 00000000000..1b721733671 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/injection/informers/serving/v1/service/service.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 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 injection-gen. DO NOT EDIT. + +package service + +import ( + "context" + + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" + v1 "knative.dev/serving/pkg/client/informers/externalversions/serving/v1" + factory "knative.dev/serving/pkg/client/injection/informers/factory" +) + +func init() { + injection.Default.RegisterInformer(withInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct{} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := factory.Get(ctx) + inf := f.Serving().V1().Services() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1.ServiceInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch knative.dev/serving/pkg/client/informers/externalversions/serving/v1.ServiceInformer from context.") + } + return untyped.(v1.ServiceInformer) +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go b/vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go new file mode 100644 index 00000000000..58fd37c078c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go @@ -0,0 +1,35 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +// MetricListerExpansion allows custom methods to be added to +// MetricLister. +type MetricListerExpansion interface{} + +// MetricNamespaceListerExpansion allows custom methods to be added to +// MetricNamespaceLister. +type MetricNamespaceListerExpansion interface{} + +// PodAutoscalerListerExpansion allows custom methods to be added to +// PodAutoscalerLister. +type PodAutoscalerListerExpansion interface{} + +// PodAutoscalerNamespaceListerExpansion allows custom methods to be added to +// PodAutoscalerNamespaceLister. +type PodAutoscalerNamespaceListerExpansion interface{} diff --git a/vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/metric.go b/vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/metric.go new file mode 100644 index 00000000000..192ec63b936 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/metric.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1" +) + +// MetricLister helps list Metrics. +type MetricLister interface { + // List lists all Metrics in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Metric, err error) + // Metrics returns an object that can list and get Metrics. + Metrics(namespace string) MetricNamespaceLister + MetricListerExpansion +} + +// metricLister implements the MetricLister interface. +type metricLister struct { + indexer cache.Indexer +} + +// NewMetricLister returns a new MetricLister. +func NewMetricLister(indexer cache.Indexer) MetricLister { + return &metricLister{indexer: indexer} +} + +// List lists all Metrics in the indexer. +func (s *metricLister) List(selector labels.Selector) (ret []*v1alpha1.Metric, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Metric)) + }) + return ret, err +} + +// Metrics returns an object that can list and get Metrics. +func (s *metricLister) Metrics(namespace string) MetricNamespaceLister { + return metricNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// MetricNamespaceLister helps list and get Metrics. +type MetricNamespaceLister interface { + // List lists all Metrics in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Metric, err error) + // Get retrieves the Metric from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Metric, error) + MetricNamespaceListerExpansion +} + +// metricNamespaceLister implements the MetricNamespaceLister +// interface. +type metricNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Metrics in the indexer for a given namespace. +func (s metricNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Metric, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Metric)) + }) + return ret, err +} + +// Get retrieves the Metric from the indexer for a given namespace and name. +func (s metricNamespaceLister) Get(name string) (*v1alpha1.Metric, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("metric"), name) + } + return obj.(*v1alpha1.Metric), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/podautoscaler.go b/vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/podautoscaler.go new file mode 100644 index 00000000000..f9cdc394486 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/autoscaling/v1alpha1/podautoscaler.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "knative.dev/serving/pkg/apis/autoscaling/v1alpha1" +) + +// PodAutoscalerLister helps list PodAutoscalers. +type PodAutoscalerLister interface { + // List lists all PodAutoscalers in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) + // PodAutoscalers returns an object that can list and get PodAutoscalers. + PodAutoscalers(namespace string) PodAutoscalerNamespaceLister + PodAutoscalerListerExpansion +} + +// podAutoscalerLister implements the PodAutoscalerLister interface. +type podAutoscalerLister struct { + indexer cache.Indexer +} + +// NewPodAutoscalerLister returns a new PodAutoscalerLister. +func NewPodAutoscalerLister(indexer cache.Indexer) PodAutoscalerLister { + return &podAutoscalerLister{indexer: indexer} +} + +// List lists all PodAutoscalers in the indexer. +func (s *podAutoscalerLister) List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PodAutoscaler)) + }) + return ret, err +} + +// PodAutoscalers returns an object that can list and get PodAutoscalers. +func (s *podAutoscalerLister) PodAutoscalers(namespace string) PodAutoscalerNamespaceLister { + return podAutoscalerNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// PodAutoscalerNamespaceLister helps list and get PodAutoscalers. +type PodAutoscalerNamespaceLister interface { + // List lists all PodAutoscalers in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) + // Get retrieves the PodAutoscaler from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.PodAutoscaler, error) + PodAutoscalerNamespaceListerExpansion +} + +// podAutoscalerNamespaceLister implements the PodAutoscalerNamespaceLister +// interface. +type podAutoscalerNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all PodAutoscalers in the indexer for a given namespace. +func (s podAutoscalerNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.PodAutoscaler, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.PodAutoscaler)) + }) + return ret, err +} + +// Get retrieves the PodAutoscaler from the indexer for a given namespace and name. +func (s podAutoscalerNamespaceLister) Get(name string) (*v1alpha1.PodAutoscaler, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("podautoscaler"), name) + } + return obj.(*v1alpha1.PodAutoscaler), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/certificate.go b/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/certificate.go new file mode 100644 index 00000000000..81c7473c17b --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/certificate.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "knative.dev/serving/pkg/apis/networking/v1alpha1" +) + +// CertificateLister helps list Certificates. +type CertificateLister interface { + // List lists all Certificates in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Certificate, err error) + // Certificates returns an object that can list and get Certificates. + Certificates(namespace string) CertificateNamespaceLister + CertificateListerExpansion +} + +// certificateLister implements the CertificateLister interface. +type certificateLister struct { + indexer cache.Indexer +} + +// NewCertificateLister returns a new CertificateLister. +func NewCertificateLister(indexer cache.Indexer) CertificateLister { + return &certificateLister{indexer: indexer} +} + +// List lists all Certificates in the indexer. +func (s *certificateLister) List(selector labels.Selector) (ret []*v1alpha1.Certificate, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Certificate)) + }) + return ret, err +} + +// Certificates returns an object that can list and get Certificates. +func (s *certificateLister) Certificates(namespace string) CertificateNamespaceLister { + return certificateNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// CertificateNamespaceLister helps list and get Certificates. +type CertificateNamespaceLister interface { + // List lists all Certificates in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Certificate, err error) + // Get retrieves the Certificate from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Certificate, error) + CertificateNamespaceListerExpansion +} + +// certificateNamespaceLister implements the CertificateNamespaceLister +// interface. +type certificateNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Certificates in the indexer for a given namespace. +func (s certificateNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Certificate, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Certificate)) + }) + return ret, err +} + +// Get retrieves the Certificate from the indexer for a given namespace and name. +func (s certificateNamespaceLister) Get(name string) (*v1alpha1.Certificate, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("certificate"), name) + } + return obj.(*v1alpha1.Certificate), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/expansion_generated.go b/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/expansion_generated.go new file mode 100644 index 00000000000..a31fdafdcff --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/expansion_generated.go @@ -0,0 +1,43 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +// CertificateListerExpansion allows custom methods to be added to +// CertificateLister. +type CertificateListerExpansion interface{} + +// CertificateNamespaceListerExpansion allows custom methods to be added to +// CertificateNamespaceLister. +type CertificateNamespaceListerExpansion interface{} + +// IngressListerExpansion allows custom methods to be added to +// IngressLister. +type IngressListerExpansion interface{} + +// IngressNamespaceListerExpansion allows custom methods to be added to +// IngressNamespaceLister. +type IngressNamespaceListerExpansion interface{} + +// ServerlessServiceListerExpansion allows custom methods to be added to +// ServerlessServiceLister. +type ServerlessServiceListerExpansion interface{} + +// ServerlessServiceNamespaceListerExpansion allows custom methods to be added to +// ServerlessServiceNamespaceLister. +type ServerlessServiceNamespaceListerExpansion interface{} diff --git a/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/ingress.go b/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/ingress.go new file mode 100644 index 00000000000..14efa3e9593 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/ingress.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "knative.dev/serving/pkg/apis/networking/v1alpha1" +) + +// IngressLister helps list Ingresses. +type IngressLister interface { + // List lists all Ingresses in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Ingress, err error) + // Ingresses returns an object that can list and get Ingresses. + Ingresses(namespace string) IngressNamespaceLister + IngressListerExpansion +} + +// ingressLister implements the IngressLister interface. +type ingressLister struct { + indexer cache.Indexer +} + +// NewIngressLister returns a new IngressLister. +func NewIngressLister(indexer cache.Indexer) IngressLister { + return &ingressLister{indexer: indexer} +} + +// List lists all Ingresses in the indexer. +func (s *ingressLister) List(selector labels.Selector) (ret []*v1alpha1.Ingress, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Ingress)) + }) + return ret, err +} + +// Ingresses returns an object that can list and get Ingresses. +func (s *ingressLister) Ingresses(namespace string) IngressNamespaceLister { + return ingressNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// IngressNamespaceLister helps list and get Ingresses. +type IngressNamespaceLister interface { + // List lists all Ingresses in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Ingress, err error) + // Get retrieves the Ingress from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Ingress, error) + IngressNamespaceListerExpansion +} + +// ingressNamespaceLister implements the IngressNamespaceLister +// interface. +type ingressNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Ingresses in the indexer for a given namespace. +func (s ingressNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Ingress, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Ingress)) + }) + return ret, err +} + +// Get retrieves the Ingress from the indexer for a given namespace and name. +func (s ingressNamespaceLister) Get(name string) (*v1alpha1.Ingress, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("ingress"), name) + } + return obj.(*v1alpha1.Ingress), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/serverlessservice.go b/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/serverlessservice.go new file mode 100644 index 00000000000..f6d3fcd9f07 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/networking/v1alpha1/serverlessservice.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "knative.dev/serving/pkg/apis/networking/v1alpha1" +) + +// ServerlessServiceLister helps list ServerlessServices. +type ServerlessServiceLister interface { + // List lists all ServerlessServices in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.ServerlessService, err error) + // ServerlessServices returns an object that can list and get ServerlessServices. + ServerlessServices(namespace string) ServerlessServiceNamespaceLister + ServerlessServiceListerExpansion +} + +// serverlessServiceLister implements the ServerlessServiceLister interface. +type serverlessServiceLister struct { + indexer cache.Indexer +} + +// NewServerlessServiceLister returns a new ServerlessServiceLister. +func NewServerlessServiceLister(indexer cache.Indexer) ServerlessServiceLister { + return &serverlessServiceLister{indexer: indexer} +} + +// List lists all ServerlessServices in the indexer. +func (s *serverlessServiceLister) List(selector labels.Selector) (ret []*v1alpha1.ServerlessService, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ServerlessService)) + }) + return ret, err +} + +// ServerlessServices returns an object that can list and get ServerlessServices. +func (s *serverlessServiceLister) ServerlessServices(namespace string) ServerlessServiceNamespaceLister { + return serverlessServiceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ServerlessServiceNamespaceLister helps list and get ServerlessServices. +type ServerlessServiceNamespaceLister interface { + // List lists all ServerlessServices in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.ServerlessService, err error) + // Get retrieves the ServerlessService from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.ServerlessService, error) + ServerlessServiceNamespaceListerExpansion +} + +// serverlessServiceNamespaceLister implements the ServerlessServiceNamespaceLister +// interface. +type serverlessServiceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ServerlessServices in the indexer for a given namespace. +func (s serverlessServiceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ServerlessService, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.ServerlessService)) + }) + return ret, err +} + +// Get retrieves the ServerlessService from the indexer for a given namespace and name. +func (s serverlessServiceNamespaceLister) Get(name string) (*v1alpha1.ServerlessService, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("serverlessservice"), name) + } + return obj.(*v1alpha1.ServerlessService), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1/configuration.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1/configuration.go new file mode 100644 index 00000000000..94c3f336416 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1/configuration.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// ConfigurationLister helps list Configurations. +type ConfigurationLister interface { + // List lists all Configurations in the indexer. + List(selector labels.Selector) (ret []*v1.Configuration, err error) + // Configurations returns an object that can list and get Configurations. + Configurations(namespace string) ConfigurationNamespaceLister + ConfigurationListerExpansion +} + +// configurationLister implements the ConfigurationLister interface. +type configurationLister struct { + indexer cache.Indexer +} + +// NewConfigurationLister returns a new ConfigurationLister. +func NewConfigurationLister(indexer cache.Indexer) ConfigurationLister { + return &configurationLister{indexer: indexer} +} + +// List lists all Configurations in the indexer. +func (s *configurationLister) List(selector labels.Selector) (ret []*v1.Configuration, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Configuration)) + }) + return ret, err +} + +// Configurations returns an object that can list and get Configurations. +func (s *configurationLister) Configurations(namespace string) ConfigurationNamespaceLister { + return configurationNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ConfigurationNamespaceLister helps list and get Configurations. +type ConfigurationNamespaceLister interface { + // List lists all Configurations in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.Configuration, err error) + // Get retrieves the Configuration from the indexer for a given namespace and name. + Get(name string) (*v1.Configuration, error) + ConfigurationNamespaceListerExpansion +} + +// configurationNamespaceLister implements the ConfigurationNamespaceLister +// interface. +type configurationNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Configurations in the indexer for a given namespace. +func (s configurationNamespaceLister) List(selector labels.Selector) (ret []*v1.Configuration, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Configuration)) + }) + return ret, err +} + +// Get retrieves the Configuration from the indexer for a given namespace and name. +func (s configurationNamespaceLister) Get(name string) (*v1.Configuration, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("configuration"), name) + } + return obj.(*v1.Configuration), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1/expansion_generated.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1/expansion_generated.go new file mode 100644 index 00000000000..091768b12db --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1/expansion_generated.go @@ -0,0 +1,51 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1 + +// ConfigurationListerExpansion allows custom methods to be added to +// ConfigurationLister. +type ConfigurationListerExpansion interface{} + +// ConfigurationNamespaceListerExpansion allows custom methods to be added to +// ConfigurationNamespaceLister. +type ConfigurationNamespaceListerExpansion interface{} + +// RevisionListerExpansion allows custom methods to be added to +// RevisionLister. +type RevisionListerExpansion interface{} + +// RevisionNamespaceListerExpansion allows custom methods to be added to +// RevisionNamespaceLister. +type RevisionNamespaceListerExpansion interface{} + +// RouteListerExpansion allows custom methods to be added to +// RouteLister. +type RouteListerExpansion interface{} + +// RouteNamespaceListerExpansion allows custom methods to be added to +// RouteNamespaceLister. +type RouteNamespaceListerExpansion interface{} + +// ServiceListerExpansion allows custom methods to be added to +// ServiceLister. +type ServiceListerExpansion interface{} + +// ServiceNamespaceListerExpansion allows custom methods to be added to +// ServiceNamespaceLister. +type ServiceNamespaceListerExpansion interface{} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1/revision.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1/revision.go new file mode 100644 index 00000000000..f53c58db1b1 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1/revision.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// RevisionLister helps list Revisions. +type RevisionLister interface { + // List lists all Revisions in the indexer. + List(selector labels.Selector) (ret []*v1.Revision, err error) + // Revisions returns an object that can list and get Revisions. + Revisions(namespace string) RevisionNamespaceLister + RevisionListerExpansion +} + +// revisionLister implements the RevisionLister interface. +type revisionLister struct { + indexer cache.Indexer +} + +// NewRevisionLister returns a new RevisionLister. +func NewRevisionLister(indexer cache.Indexer) RevisionLister { + return &revisionLister{indexer: indexer} +} + +// List lists all Revisions in the indexer. +func (s *revisionLister) List(selector labels.Selector) (ret []*v1.Revision, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Revision)) + }) + return ret, err +} + +// Revisions returns an object that can list and get Revisions. +func (s *revisionLister) Revisions(namespace string) RevisionNamespaceLister { + return revisionNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RevisionNamespaceLister helps list and get Revisions. +type RevisionNamespaceLister interface { + // List lists all Revisions in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.Revision, err error) + // Get retrieves the Revision from the indexer for a given namespace and name. + Get(name string) (*v1.Revision, error) + RevisionNamespaceListerExpansion +} + +// revisionNamespaceLister implements the RevisionNamespaceLister +// interface. +type revisionNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Revisions in the indexer for a given namespace. +func (s revisionNamespaceLister) List(selector labels.Selector) (ret []*v1.Revision, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Revision)) + }) + return ret, err +} + +// Get retrieves the Revision from the indexer for a given namespace and name. +func (s revisionNamespaceLister) Get(name string) (*v1.Revision, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("revision"), name) + } + return obj.(*v1.Revision), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1/route.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1/route.go new file mode 100644 index 00000000000..02e6374fb56 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1/route.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// RouteLister helps list Routes. +type RouteLister interface { + // List lists all Routes in the indexer. + List(selector labels.Selector) (ret []*v1.Route, err error) + // Routes returns an object that can list and get Routes. + Routes(namespace string) RouteNamespaceLister + RouteListerExpansion +} + +// routeLister implements the RouteLister interface. +type routeLister struct { + indexer cache.Indexer +} + +// NewRouteLister returns a new RouteLister. +func NewRouteLister(indexer cache.Indexer) RouteLister { + return &routeLister{indexer: indexer} +} + +// List lists all Routes in the indexer. +func (s *routeLister) List(selector labels.Selector) (ret []*v1.Route, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Route)) + }) + return ret, err +} + +// Routes returns an object that can list and get Routes. +func (s *routeLister) Routes(namespace string) RouteNamespaceLister { + return routeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RouteNamespaceLister helps list and get Routes. +type RouteNamespaceLister interface { + // List lists all Routes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.Route, err error) + // Get retrieves the Route from the indexer for a given namespace and name. + Get(name string) (*v1.Route, error) + RouteNamespaceListerExpansion +} + +// routeNamespaceLister implements the RouteNamespaceLister +// interface. +type routeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Routes in the indexer for a given namespace. +func (s routeNamespaceLister) List(selector labels.Selector) (ret []*v1.Route, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Route)) + }) + return ret, err +} + +// Get retrieves the Route from the indexer for a given namespace and name. +func (s routeNamespaceLister) Get(name string) (*v1.Route, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("route"), name) + } + return obj.(*v1.Route), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1/service.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1/service.go new file mode 100644 index 00000000000..5ba9b86c19e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1/service.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1 "knative.dev/serving/pkg/apis/serving/v1" +) + +// ServiceLister helps list Services. +type ServiceLister interface { + // List lists all Services in the indexer. + List(selector labels.Selector) (ret []*v1.Service, err error) + // Services returns an object that can list and get Services. + Services(namespace string) ServiceNamespaceLister + ServiceListerExpansion +} + +// serviceLister implements the ServiceLister interface. +type serviceLister struct { + indexer cache.Indexer +} + +// NewServiceLister returns a new ServiceLister. +func NewServiceLister(indexer cache.Indexer) ServiceLister { + return &serviceLister{indexer: indexer} +} + +// List lists all Services in the indexer. +func (s *serviceLister) List(selector labels.Selector) (ret []*v1.Service, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Service)) + }) + return ret, err +} + +// Services returns an object that can list and get Services. +func (s *serviceLister) Services(namespace string) ServiceNamespaceLister { + return serviceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ServiceNamespaceLister helps list and get Services. +type ServiceNamespaceLister interface { + // List lists all Services in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1.Service, err error) + // Get retrieves the Service from the indexer for a given namespace and name. + Get(name string) (*v1.Service, error) + ServiceNamespaceListerExpansion +} + +// serviceNamespaceLister implements the ServiceNamespaceLister +// interface. +type serviceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Services in the indexer for a given namespace. +func (s serviceNamespaceLister) List(selector labels.Selector) (ret []*v1.Service, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.Service)) + }) + return ret, err +} + +// Get retrieves the Service from the indexer for a given namespace and name. +func (s serviceNamespaceLister) Get(name string) (*v1.Service, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("service"), name) + } + return obj.(*v1.Service), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/configuration.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/configuration.go new file mode 100644 index 00000000000..0b3e4d65e63 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/configuration.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" +) + +// ConfigurationLister helps list Configurations. +type ConfigurationLister interface { + // List lists all Configurations in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Configuration, err error) + // Configurations returns an object that can list and get Configurations. + Configurations(namespace string) ConfigurationNamespaceLister + ConfigurationListerExpansion +} + +// configurationLister implements the ConfigurationLister interface. +type configurationLister struct { + indexer cache.Indexer +} + +// NewConfigurationLister returns a new ConfigurationLister. +func NewConfigurationLister(indexer cache.Indexer) ConfigurationLister { + return &configurationLister{indexer: indexer} +} + +// List lists all Configurations in the indexer. +func (s *configurationLister) List(selector labels.Selector) (ret []*v1alpha1.Configuration, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Configuration)) + }) + return ret, err +} + +// Configurations returns an object that can list and get Configurations. +func (s *configurationLister) Configurations(namespace string) ConfigurationNamespaceLister { + return configurationNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ConfigurationNamespaceLister helps list and get Configurations. +type ConfigurationNamespaceLister interface { + // List lists all Configurations in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Configuration, err error) + // Get retrieves the Configuration from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Configuration, error) + ConfigurationNamespaceListerExpansion +} + +// configurationNamespaceLister implements the ConfigurationNamespaceLister +// interface. +type configurationNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Configurations in the indexer for a given namespace. +func (s configurationNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Configuration, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Configuration)) + }) + return ret, err +} + +// Get retrieves the Configuration from the indexer for a given namespace and name. +func (s configurationNamespaceLister) Get(name string) (*v1alpha1.Configuration, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("configuration"), name) + } + return obj.(*v1alpha1.Configuration), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/expansion_generated.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/expansion_generated.go new file mode 100644 index 00000000000..cc9c0e1aa67 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/expansion_generated.go @@ -0,0 +1,51 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +// ConfigurationListerExpansion allows custom methods to be added to +// ConfigurationLister. +type ConfigurationListerExpansion interface{} + +// ConfigurationNamespaceListerExpansion allows custom methods to be added to +// ConfigurationNamespaceLister. +type ConfigurationNamespaceListerExpansion interface{} + +// RevisionListerExpansion allows custom methods to be added to +// RevisionLister. +type RevisionListerExpansion interface{} + +// RevisionNamespaceListerExpansion allows custom methods to be added to +// RevisionNamespaceLister. +type RevisionNamespaceListerExpansion interface{} + +// RouteListerExpansion allows custom methods to be added to +// RouteLister. +type RouteListerExpansion interface{} + +// RouteNamespaceListerExpansion allows custom methods to be added to +// RouteNamespaceLister. +type RouteNamespaceListerExpansion interface{} + +// ServiceListerExpansion allows custom methods to be added to +// ServiceLister. +type ServiceListerExpansion interface{} + +// ServiceNamespaceListerExpansion allows custom methods to be added to +// ServiceNamespaceLister. +type ServiceNamespaceListerExpansion interface{} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/revision.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/revision.go new file mode 100644 index 00000000000..508c59df23e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/revision.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" +) + +// RevisionLister helps list Revisions. +type RevisionLister interface { + // List lists all Revisions in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Revision, err error) + // Revisions returns an object that can list and get Revisions. + Revisions(namespace string) RevisionNamespaceLister + RevisionListerExpansion +} + +// revisionLister implements the RevisionLister interface. +type revisionLister struct { + indexer cache.Indexer +} + +// NewRevisionLister returns a new RevisionLister. +func NewRevisionLister(indexer cache.Indexer) RevisionLister { + return &revisionLister{indexer: indexer} +} + +// List lists all Revisions in the indexer. +func (s *revisionLister) List(selector labels.Selector) (ret []*v1alpha1.Revision, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Revision)) + }) + return ret, err +} + +// Revisions returns an object that can list and get Revisions. +func (s *revisionLister) Revisions(namespace string) RevisionNamespaceLister { + return revisionNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RevisionNamespaceLister helps list and get Revisions. +type RevisionNamespaceLister interface { + // List lists all Revisions in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Revision, err error) + // Get retrieves the Revision from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Revision, error) + RevisionNamespaceListerExpansion +} + +// revisionNamespaceLister implements the RevisionNamespaceLister +// interface. +type revisionNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Revisions in the indexer for a given namespace. +func (s revisionNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Revision, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Revision)) + }) + return ret, err +} + +// Get retrieves the Revision from the indexer for a given namespace and name. +func (s revisionNamespaceLister) Get(name string) (*v1alpha1.Revision, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("revision"), name) + } + return obj.(*v1alpha1.Revision), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/route.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/route.go new file mode 100644 index 00000000000..aee2b9f4a54 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/route.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" +) + +// RouteLister helps list Routes. +type RouteLister interface { + // List lists all Routes in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Route, err error) + // Routes returns an object that can list and get Routes. + Routes(namespace string) RouteNamespaceLister + RouteListerExpansion +} + +// routeLister implements the RouteLister interface. +type routeLister struct { + indexer cache.Indexer +} + +// NewRouteLister returns a new RouteLister. +func NewRouteLister(indexer cache.Indexer) RouteLister { + return &routeLister{indexer: indexer} +} + +// List lists all Routes in the indexer. +func (s *routeLister) List(selector labels.Selector) (ret []*v1alpha1.Route, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Route)) + }) + return ret, err +} + +// Routes returns an object that can list and get Routes. +func (s *routeLister) Routes(namespace string) RouteNamespaceLister { + return routeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RouteNamespaceLister helps list and get Routes. +type RouteNamespaceLister interface { + // List lists all Routes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Route, err error) + // Get retrieves the Route from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Route, error) + RouteNamespaceListerExpansion +} + +// routeNamespaceLister implements the RouteNamespaceLister +// interface. +type routeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Routes in the indexer for a given namespace. +func (s routeNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Route, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Route)) + }) + return ret, err +} + +// Get retrieves the Route from the indexer for a given namespace and name. +func (s routeNamespaceLister) Get(name string) (*v1alpha1.Route, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("route"), name) + } + return obj.(*v1alpha1.Route), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/service.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/service.go new file mode 100644 index 00000000000..798d2b27579 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1alpha1/service.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" +) + +// ServiceLister helps list Services. +type ServiceLister interface { + // List lists all Services in the indexer. + List(selector labels.Selector) (ret []*v1alpha1.Service, err error) + // Services returns an object that can list and get Services. + Services(namespace string) ServiceNamespaceLister + ServiceListerExpansion +} + +// serviceLister implements the ServiceLister interface. +type serviceLister struct { + indexer cache.Indexer +} + +// NewServiceLister returns a new ServiceLister. +func NewServiceLister(indexer cache.Indexer) ServiceLister { + return &serviceLister{indexer: indexer} +} + +// List lists all Services in the indexer. +func (s *serviceLister) List(selector labels.Selector) (ret []*v1alpha1.Service, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Service)) + }) + return ret, err +} + +// Services returns an object that can list and get Services. +func (s *serviceLister) Services(namespace string) ServiceNamespaceLister { + return serviceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ServiceNamespaceLister helps list and get Services. +type ServiceNamespaceLister interface { + // List lists all Services in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha1.Service, err error) + // Get retrieves the Service from the indexer for a given namespace and name. + Get(name string) (*v1alpha1.Service, error) + ServiceNamespaceListerExpansion +} + +// serviceNamespaceLister implements the ServiceNamespaceLister +// interface. +type serviceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Services in the indexer for a given namespace. +func (s serviceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Service, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha1.Service)) + }) + return ret, err +} + +// Get retrieves the Service from the indexer for a given namespace and name. +func (s serviceNamespaceLister) Get(name string) (*v1alpha1.Service, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha1.Resource("service"), name) + } + return obj.(*v1alpha1.Service), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/configuration.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/configuration.go new file mode 100644 index 00000000000..5ccceff0280 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/configuration.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// ConfigurationLister helps list Configurations. +type ConfigurationLister interface { + // List lists all Configurations in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Configuration, err error) + // Configurations returns an object that can list and get Configurations. + Configurations(namespace string) ConfigurationNamespaceLister + ConfigurationListerExpansion +} + +// configurationLister implements the ConfigurationLister interface. +type configurationLister struct { + indexer cache.Indexer +} + +// NewConfigurationLister returns a new ConfigurationLister. +func NewConfigurationLister(indexer cache.Indexer) ConfigurationLister { + return &configurationLister{indexer: indexer} +} + +// List lists all Configurations in the indexer. +func (s *configurationLister) List(selector labels.Selector) (ret []*v1beta1.Configuration, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Configuration)) + }) + return ret, err +} + +// Configurations returns an object that can list and get Configurations. +func (s *configurationLister) Configurations(namespace string) ConfigurationNamespaceLister { + return configurationNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ConfigurationNamespaceLister helps list and get Configurations. +type ConfigurationNamespaceLister interface { + // List lists all Configurations in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.Configuration, err error) + // Get retrieves the Configuration from the indexer for a given namespace and name. + Get(name string) (*v1beta1.Configuration, error) + ConfigurationNamespaceListerExpansion +} + +// configurationNamespaceLister implements the ConfigurationNamespaceLister +// interface. +type configurationNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Configurations in the indexer for a given namespace. +func (s configurationNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Configuration, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Configuration)) + }) + return ret, err +} + +// Get retrieves the Configuration from the indexer for a given namespace and name. +func (s configurationNamespaceLister) Get(name string) (*v1beta1.Configuration, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("configuration"), name) + } + return obj.(*v1beta1.Configuration), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/expansion_generated.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/expansion_generated.go new file mode 100644 index 00000000000..ad73dc85dee --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/expansion_generated.go @@ -0,0 +1,51 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1beta1 + +// ConfigurationListerExpansion allows custom methods to be added to +// ConfigurationLister. +type ConfigurationListerExpansion interface{} + +// ConfigurationNamespaceListerExpansion allows custom methods to be added to +// ConfigurationNamespaceLister. +type ConfigurationNamespaceListerExpansion interface{} + +// RevisionListerExpansion allows custom methods to be added to +// RevisionLister. +type RevisionListerExpansion interface{} + +// RevisionNamespaceListerExpansion allows custom methods to be added to +// RevisionNamespaceLister. +type RevisionNamespaceListerExpansion interface{} + +// RouteListerExpansion allows custom methods to be added to +// RouteLister. +type RouteListerExpansion interface{} + +// RouteNamespaceListerExpansion allows custom methods to be added to +// RouteNamespaceLister. +type RouteNamespaceListerExpansion interface{} + +// ServiceListerExpansion allows custom methods to be added to +// ServiceLister. +type ServiceListerExpansion interface{} + +// ServiceNamespaceListerExpansion allows custom methods to be added to +// ServiceNamespaceLister. +type ServiceNamespaceListerExpansion interface{} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/revision.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/revision.go new file mode 100644 index 00000000000..a74c986f561 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/revision.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// RevisionLister helps list Revisions. +type RevisionLister interface { + // List lists all Revisions in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Revision, err error) + // Revisions returns an object that can list and get Revisions. + Revisions(namespace string) RevisionNamespaceLister + RevisionListerExpansion +} + +// revisionLister implements the RevisionLister interface. +type revisionLister struct { + indexer cache.Indexer +} + +// NewRevisionLister returns a new RevisionLister. +func NewRevisionLister(indexer cache.Indexer) RevisionLister { + return &revisionLister{indexer: indexer} +} + +// List lists all Revisions in the indexer. +func (s *revisionLister) List(selector labels.Selector) (ret []*v1beta1.Revision, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Revision)) + }) + return ret, err +} + +// Revisions returns an object that can list and get Revisions. +func (s *revisionLister) Revisions(namespace string) RevisionNamespaceLister { + return revisionNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RevisionNamespaceLister helps list and get Revisions. +type RevisionNamespaceLister interface { + // List lists all Revisions in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.Revision, err error) + // Get retrieves the Revision from the indexer for a given namespace and name. + Get(name string) (*v1beta1.Revision, error) + RevisionNamespaceListerExpansion +} + +// revisionNamespaceLister implements the RevisionNamespaceLister +// interface. +type revisionNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Revisions in the indexer for a given namespace. +func (s revisionNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Revision, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Revision)) + }) + return ret, err +} + +// Get retrieves the Revision from the indexer for a given namespace and name. +func (s revisionNamespaceLister) Get(name string) (*v1beta1.Revision, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("revision"), name) + } + return obj.(*v1beta1.Revision), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/route.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/route.go new file mode 100644 index 00000000000..d965d0b2cd7 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/route.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// RouteLister helps list Routes. +type RouteLister interface { + // List lists all Routes in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Route, err error) + // Routes returns an object that can list and get Routes. + Routes(namespace string) RouteNamespaceLister + RouteListerExpansion +} + +// routeLister implements the RouteLister interface. +type routeLister struct { + indexer cache.Indexer +} + +// NewRouteLister returns a new RouteLister. +func NewRouteLister(indexer cache.Indexer) RouteLister { + return &routeLister{indexer: indexer} +} + +// List lists all Routes in the indexer. +func (s *routeLister) List(selector labels.Selector) (ret []*v1beta1.Route, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Route)) + }) + return ret, err +} + +// Routes returns an object that can list and get Routes. +func (s *routeLister) Routes(namespace string) RouteNamespaceLister { + return routeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// RouteNamespaceLister helps list and get Routes. +type RouteNamespaceLister interface { + // List lists all Routes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.Route, err error) + // Get retrieves the Route from the indexer for a given namespace and name. + Get(name string) (*v1beta1.Route, error) + RouteNamespaceListerExpansion +} + +// routeNamespaceLister implements the RouteNamespaceLister +// interface. +type routeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Routes in the indexer for a given namespace. +func (s routeNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Route, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Route)) + }) + return ret, err +} + +// Get retrieves the Route from the indexer for a given namespace and name. +func (s routeNamespaceLister) Get(name string) (*v1beta1.Route, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("route"), name) + } + return obj.(*v1beta1.Route), nil +} diff --git a/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/service.go b/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/service.go new file mode 100644 index 00000000000..3fd62721c99 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/client/listers/serving/v1beta1/service.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta1 "knative.dev/serving/pkg/apis/serving/v1beta1" +) + +// ServiceLister helps list Services. +type ServiceLister interface { + // List lists all Services in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Service, err error) + // Services returns an object that can list and get Services. + Services(namespace string) ServiceNamespaceLister + ServiceListerExpansion +} + +// serviceLister implements the ServiceLister interface. +type serviceLister struct { + indexer cache.Indexer +} + +// NewServiceLister returns a new ServiceLister. +func NewServiceLister(indexer cache.Indexer) ServiceLister { + return &serviceLister{indexer: indexer} +} + +// List lists all Services in the indexer. +func (s *serviceLister) List(selector labels.Selector) (ret []*v1beta1.Service, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Service)) + }) + return ret, err +} + +// Services returns an object that can list and get Services. +func (s *serviceLister) Services(namespace string) ServiceNamespaceLister { + return serviceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ServiceNamespaceLister helps list and get Services. +type ServiceNamespaceLister interface { + // List lists all Services in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.Service, err error) + // Get retrieves the Service from the indexer for a given namespace and name. + Get(name string) (*v1beta1.Service, error) + ServiceNamespaceListerExpansion +} + +// serviceNamespaceLister implements the ServiceNamespaceLister +// interface. +type serviceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Services in the indexer for a given namespace. +func (s serviceNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Service, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Service)) + }) + return ret, err +} + +// Get retrieves the Service from the indexer for a given namespace and name. +func (s serviceNamespaceLister) Get(name string) (*v1beta1.Service, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("service"), name) + } + return obj.(*v1beta1.Service), nil +} diff --git a/vendor/knative.dev/serving/pkg/deployment/testdata/config-deployment.yaml b/vendor/knative.dev/serving/pkg/deployment/testdata/config-deployment.yaml new file mode 120000 index 00000000000..10ba19c1482 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/deployment/testdata/config-deployment.yaml @@ -0,0 +1 @@ +../../../config/core/configmaps/deployment.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/gc/config.go b/vendor/knative.dev/serving/pkg/gc/config.go new file mode 100644 index 00000000000..25c2d638440 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/gc/config.go @@ -0,0 +1,95 @@ +/* +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 + + https://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 gc + +import ( + "context" + "fmt" + "strconv" + "time" + + corev1 "k8s.io/api/core/v1" + "knative.dev/pkg/controller" + "knative.dev/pkg/logging" +) + +const ( + ConfigName = "config-gc" +) + +type Config struct { + // Delay duration after a revision create before considering it for GC + StaleRevisionCreateDelay time.Duration + // Timeout since a revision lastPinned before it should be GC'd + // This must be longer than the controller resync period + StaleRevisionTimeout time.Duration + // Minimum number of generations of revisions to keep before considering for GC + StaleRevisionMinimumGenerations int64 + // Minimum staleness duration before updating lastPinned + StaleRevisionLastpinnedDebounce time.Duration +} + +func NewConfigFromConfigMapFunc(ctx context.Context) func(configMap *corev1.ConfigMap) (*Config, error) { + logger := logging.FromContext(ctx) + minRevisionTimeout := controller.GetResyncPeriod(ctx) + return func(configMap *corev1.ConfigMap) (*Config, error) { + c := Config{} + + for _, dur := range []struct { + key string + field *time.Duration + defaultValue time.Duration + }{{ + key: "stale-revision-create-delay", + field: &c.StaleRevisionCreateDelay, + defaultValue: 48 * time.Hour, + }, { + key: "stale-revision-timeout", + field: &c.StaleRevisionTimeout, + defaultValue: 15 * time.Hour, + }, { + key: "stale-revision-lastpinned-debounce", + field: &c.StaleRevisionLastpinnedDebounce, + defaultValue: 5 * time.Hour, + }} { + if raw, ok := configMap.Data[dur.key]; !ok { + *dur.field = dur.defaultValue + } else if val, err := time.ParseDuration(raw); err != nil { + return nil, err + } else { + *dur.field = val + } + } + + if raw, ok := configMap.Data["stale-revision-minimum-generations"]; !ok { + c.StaleRevisionMinimumGenerations = 20 + } else if val, err := strconv.ParseInt(raw, 10 /*base*/, 64 /*bit count*/); err != nil { + return nil, err + } else if val < 0 { + return nil, fmt.Errorf("stale-revision-minimum-generations must be non-negative, was: %d", val) + } else { + c.StaleRevisionMinimumGenerations = val + } + + if c.StaleRevisionTimeout-c.StaleRevisionLastpinnedDebounce < minRevisionTimeout { + logger.Warnf("Got revision timeout of %v, minimum supported value is %v", c.StaleRevisionTimeout, minRevisionTimeout+c.StaleRevisionLastpinnedDebounce) + c.StaleRevisionTimeout = minRevisionTimeout + c.StaleRevisionLastpinnedDebounce + return &c, nil + } + return &c, nil + } +} diff --git a/vendor/knative.dev/serving/pkg/gc/doc.go b/vendor/knative.dev/serving/pkg/gc/doc.go new file mode 100644 index 00000000000..fb89ba37350 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/gc/doc.go @@ -0,0 +1,20 @@ +/* +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 gc holds the typed objects that define the schemas for +// assorted ConfigMap objects on which the Route controller depends. +package gc diff --git a/vendor/knative.dev/serving/pkg/gc/testdata/config-gc.yaml b/vendor/knative.dev/serving/pkg/gc/testdata/config-gc.yaml new file mode 120000 index 00000000000..0fc14e43b54 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/gc/testdata/config-gc.yaml @@ -0,0 +1 @@ +../../../config/core/configmaps/gc.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/gc/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/gc/zz_generated.deepcopy.go new file mode 100644 index 00000000000..9a3151e1204 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/gc/zz_generated.deepcopy.go @@ -0,0 +1,37 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 gc + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Config) DeepCopyInto(out *Config) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config. +func (in *Config) DeepCopy() *Config { + if in == nil { + return nil + } + out := new(Config) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/serving/pkg/logging/testdata/config-logging.yaml b/vendor/knative.dev/serving/pkg/logging/testdata/config-logging.yaml new file mode 120000 index 00000000000..affd1b5f81a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/logging/testdata/config-logging.yaml @@ -0,0 +1 @@ +../../../config/core/configmaps/logging.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/logging/testdata/test-config-logging.yaml b/vendor/knative.dev/serving/pkg/logging/testdata/test-config-logging.yaml new file mode 120000 index 00000000000..761fc5070b2 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/logging/testdata/test-config-logging.yaml @@ -0,0 +1 @@ +../../../test/config/config-logging.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/metrics/testdata/config-observability.yaml b/vendor/knative.dev/serving/pkg/metrics/testdata/config-observability.yaml new file mode 120000 index 00000000000..5bf896ec8cf --- /dev/null +++ b/vendor/knative.dev/serving/pkg/metrics/testdata/config-observability.yaml @@ -0,0 +1 @@ +../../../config/core/configmaps/observability.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/network/bufferpool.go b/vendor/knative.dev/serving/pkg/network/bufferpool.go new file mode 100644 index 00000000000..d571fb1181f --- /dev/null +++ b/vendor/knative.dev/serving/pkg/network/bufferpool.go @@ -0,0 +1,55 @@ +/* +Copyright 2020 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 + + https://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 network + +import ( + "net/http/httputil" + "sync" +) + +// bufferPool implements the BufferPool interface to be used in +// httputil.ReverseProxy. It stores pointers to to slices to +// further avoid allocations, see https://staticcheck.io/docs/checks#SA6002. +type bufferPool struct { + pool *sync.Pool +} + +// NewBufferPool creates a new BytePool. This is only safe to use in the context +// of a httputil.ReverseProxy, as the buffers returned via Put are not cleaned +// explicitly. +func NewBufferPool() httputil.BufferPool { + return &bufferPool{ + pool: &sync.Pool{}, + } +} + +// Get gets a []byte from the bufferPool, or creates a new one if none are +// available in the pool. +func (b *bufferPool) Get() []byte { + buf := b.pool.Get() + if buf == nil { + // Use the default buffer size as defined in the ReverseProxy itself. + return make([]byte, 32*1024) + } + + return *buf.(*[]byte) +} + +// Put returns the given Buffer to the bufferPool. +func (b *bufferPool) Put(buffer []byte) { + b.pool.Put(&buffer) +} diff --git a/vendor/knative.dev/serving/pkg/network/doc.go b/vendor/knative.dev/serving/pkg/network/doc.go new file mode 100644 index 00000000000..71c061a60c9 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/network/doc.go @@ -0,0 +1,20 @@ +/* +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 network holds the typed objects that define the schemas for +// configuring the knative/serving networking layer. +package network diff --git a/vendor/knative.dev/serving/pkg/network/network.go b/vendor/knative.dev/serving/pkg/network/network.go new file mode 100644 index 00000000000..c620b81bb8e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/network/network.go @@ -0,0 +1,406 @@ +/* +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 + + https://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 network + +import ( + "bytes" + "errors" + "fmt" + "io/ioutil" + "net" + "net/http" + "net/url" + "strings" + "text/template" + + corev1 "k8s.io/api/core/v1" +) + +const ( + // ProbeHeaderName is the name of a header that can be added to + // requests to probe the knative networking layer. Requests + // with this header will not be passed to the user container or + // included in request metrics. + ProbeHeaderName = "K-Network-Probe" + + // ProxyHeaderName is the name of an internal header that activator + // uses to mark requests going through it. + ProxyHeaderName = "K-Proxy-Request" + + // HashHeaderName is the name of an internal header that Ingress controller + // uses to find out which version of the networking config is deployed. + HashHeaderName = "K-Network-Hash" + + // OriginalHostHeader is used to avoid Istio host based routing rules + // in Activator. + // The header contains the original Host value that can be rewritten + // at the Queue proxy level back to be a host header. + OriginalHostHeader = "K-Original-Host" + + // ConfigName is the name of the configmap containing all + // customizations for networking features. + ConfigName = "config-network" + + // IstioOutboundIPRangesKey is the name of the configuration entry + // that specifies Istio outbound ip ranges. + IstioOutboundIPRangesKey = "istio.sidecar.includeOutboundIPRanges" + + // DeprecatedDefaultIngressClassKey Please use DefaultIngressClassKey instead. + DeprecatedDefaultIngressClassKey = "clusteringress.class" + + // DefaultIngressClassKey is the name of the configuration entry + // that specifies the default Ingress. + DefaultIngressClassKey = "ingress.class" + + // DefaultCertificateClassKey is the name of the configuration entry + // that specifies the default Certificate. + DefaultCertificateClassKey = "certificate.class" + + // IstioIngressClassName value for specifying knative's Istio + // Ingress reconciler. + IstioIngressClassName = "istio.ingress.networking.knative.dev" + + // CertManagerCertificateClassName value for specifying Knative's Cert-Manager + // Certificate reconciler. + CertManagerCertificateClassName = "cert-manager.certificate.networking.internal.knative.dev" + + // DomainTemplateKey is the name of the configuration entry that + // specifies the golang template string to use to construct the + // Knative service's DNS name. + DomainTemplateKey = "domainTemplate" + + // TagTemplateKey is the name of the configuration entry that + // specifies the golang template string to use to construct the + // hostname for a Route's tag. + TagTemplateKey = "tagTemplate" + + // Since K8s 1.8, prober requests have + // User-Agent = "kube-probe/{major-version}.{minor-version}". + KubeProbeUAPrefix = "kube-probe/" + + // Istio with mTLS rewrites probes, but their probes pass a different + // user-agent. So we augment the probes with this header. + KubeletProbeHeaderName = "K-Kubelet-Probe" + + // DefaultDomainTemplate is the default golang template to use when + // constructing the Knative Route's Domain(host) + DefaultDomainTemplate = "{{.Name}}.{{.Namespace}}.{{.Domain}}" + + // DefaultTagTemplate is the default golang template to use when + // constructing the Knative Route's tag names. + DefaultTagTemplate = "{{.Tag}}-{{.Name}}" + + // AutoTLSKey is the name of the configuration entry + // that specifies enabling auto-TLS or not. + AutoTLSKey = "autoTLS" + + // HTTPProtocolKey is the name of the configuration entry that + // specifies the HTTP endpoint behavior of Knative ingress. + HTTPProtocolKey = "httpProtocol" + + // UserAgentKey is the constant for header "User-Agent". + UserAgentKey = "User-Agent" + + // ActivatorUserAgent is the user-agent header value set in probe requests sent + // from activator. + ActivatorUserAgent = "Knative-Activator-Probe" + + // QueueProxyUserAgent is the user-agent header value set in probe requests sent + // from queue-proxy. + QueueProxyUserAgent = "Knative-Queue-Proxy-Probe" +) + +// DomainTemplateValues are the available properties people can choose from +// in their Route's "DomainTemplate" golang template sting. +// We could add more over time - e.g. RevisionName if we thought that +// might be of interest to people. +type DomainTemplateValues struct { + Name string + Namespace string + Domain string + Annotations map[string]string +} + +// TagTemplateValues are the available properties people can choose from +// in their Route's "TagTemplate" golang template sting. +type TagTemplateValues struct { + Name string + Tag string +} + +// Config contains the networking configuration defined in the +// network config map. +type Config struct { + // IstioOutboundIPRange specifies the IP ranges to intercept + // by Istio sidecar. + IstioOutboundIPRanges string + + // DefaultIngressClass specifies the default Ingress class. + DefaultIngressClass string + + // DomainTemplate is the golang text template to use to generate the + // Route's domain (host) for the Service. + DomainTemplate string + + // TagTemplate is the golang text template to use to generate the + // Route's tag hostnames. + TagTemplate string + + // AutoTLS specifies if auto-TLS is enabled or not. + AutoTLS bool + + // HTTPProtocol specifics the behavior of HTTP endpoint of Knative + // ingress. + HTTPProtocol HTTPProtocol + + // DefaultCertificateClass specifies the default Certificate class. + DefaultCertificateClass string +} + +// HTTPProtocol indicates a type of HTTP endpoint behavior +// that Knative ingress could take. +type HTTPProtocol string + +const ( + // HTTPEnabled represents HTTP proocol is enabled in Knative ingress. + HTTPEnabled HTTPProtocol = "enabled" + + // HTTPDisabled represents HTTP protocol is disabled in Knative ingress. + HTTPDisabled HTTPProtocol = "disabled" + + // HTTPRedirected represents HTTP connection is redirected to HTTPS in Knative ingress. + HTTPRedirected HTTPProtocol = "redirected" +) + +func validateAndNormalizeOutboundIPRanges(s string) (string, error) { + s = strings.TrimSpace(s) + + // * is a valid value + if s == "*" { + return s, nil + } + + cidrs := strings.Split(s, ",") + var normalized []string + for _, cidr := range cidrs { + cidr = strings.TrimSpace(cidr) + if len(cidr) == 0 { + continue + } + if _, _, err := net.ParseCIDR(cidr); err != nil { + return "", err + } + + normalized = append(normalized, cidr) + } + + return strings.Join(normalized, ","), nil +} + +// NewConfigFromConfigMap creates a Config from the supplied ConfigMap +func NewConfigFromConfigMap(configMap *corev1.ConfigMap) (*Config, error) { + nc := &Config{} + if ipr, ok := configMap.Data[IstioOutboundIPRangesKey]; !ok { + // It is OK for this to be absent, we will elide the annotation. + nc.IstioOutboundIPRanges = "*" + } else if normalizedIpr, err := validateAndNormalizeOutboundIPRanges(ipr); err != nil { + return nil, err + } else { + nc.IstioOutboundIPRanges = normalizedIpr + } + + nc.DefaultIngressClass = IstioIngressClassName + if ingressClass, ok := configMap.Data[DefaultIngressClassKey]; ok { + nc.DefaultIngressClass = ingressClass + } else if ingressClass, ok := configMap.Data[DeprecatedDefaultIngressClassKey]; ok { + nc.DefaultIngressClass = ingressClass + } + + nc.DefaultCertificateClass = CertManagerCertificateClassName + if certClass, ok := configMap.Data[DefaultCertificateClassKey]; ok { + nc.DefaultCertificateClass = certClass + } + + // Blank DomainTemplate makes no sense so use our default + if dt, ok := configMap.Data[DomainTemplateKey]; !ok { + nc.DomainTemplate = DefaultDomainTemplate + } else { + t, err := template.New("domain-template").Parse(dt) + if err != nil { + return nil, err + } + if err := checkDomainTemplate(t); err != nil { + return nil, err + } + + nc.DomainTemplate = dt + } + + // Blank TagTemplate makes no sense so use our default + if tt, ok := configMap.Data[TagTemplateKey]; !ok { + nc.TagTemplate = DefaultTagTemplate + } else { + t, err := template.New("tag-template").Parse(tt) + if err != nil { + return nil, err + } + if err := checkTagTemplate(t); err != nil { + return nil, err + } + + nc.TagTemplate = tt + } + + nc.AutoTLS = strings.EqualFold(configMap.Data[AutoTLSKey], "enabled") + + switch strings.ToLower(configMap.Data[HTTPProtocolKey]) { + case string(HTTPEnabled): + nc.HTTPProtocol = HTTPEnabled + case "": + // If HTTPProtocol is not set in the config-network, we set the default value + // to HTTPEnabled. + nc.HTTPProtocol = HTTPEnabled + case string(HTTPDisabled): + nc.HTTPProtocol = HTTPDisabled + case string(HTTPRedirected): + nc.HTTPProtocol = HTTPRedirected + default: + return nil, fmt.Errorf("httpProtocol %s in config-network ConfigMap is not supported", configMap.Data[HTTPProtocolKey]) + } + return nc, nil +} + +// GetDomainTemplate returns the golang Template from the config map +// or panics (the value is validated during CM validation and at +// this point guaranteed to be parseable). +func (c *Config) GetDomainTemplate() *template.Template { + return template.Must(template.New("domain-template").Parse( + c.DomainTemplate)) +} + +func checkDomainTemplate(t *template.Template) error { + // To a test run of applying the template, and see if the + // result is a valid URL. + data := DomainTemplateValues{ + Name: "foo", + Namespace: "bar", + Domain: "baz.com", + Annotations: nil, + } + buf := bytes.Buffer{} + if err := t.Execute(&buf, data); err != nil { + return err + } + u, err := url.Parse("https://" + buf.String()) + if err != nil { + return err + } + + // TODO(mattmoor): Consider validating things like changing + // Name / Namespace changes the resulting hostname. + if u.Hostname() == "" { + return errors.New("empty hostname") + } + if u.RequestURI() != "/" { + return fmt.Errorf("domain template has url path: %s", u.RequestURI()) + } + + return nil +} + +func (c *Config) GetTagTemplate() *template.Template { + return template.Must(template.New("tag-template").Parse( + c.TagTemplate)) +} + +func checkTagTemplate(t *template.Template) error { + // To a test run of applying the template, and see if we + // produce a result without error. + data := TagTemplateValues{ + Name: "foo", + Tag: "v2", + } + return t.Execute(ioutil.Discard, data) +} + +// IsKubeletProbe returns true if the request is a Kubernetes probe. +func IsKubeletProbe(r *http.Request) bool { + return strings.HasPrefix(r.Header.Get("User-Agent"), KubeProbeUAPrefix) || + r.Header.Get(KubeletProbeHeaderName) != "" +} + +// KnativeProbeHeader returns the value for key ProbeHeaderName in request headers. +func KnativeProbeHeader(r *http.Request) string { + return r.Header.Get(ProbeHeaderName) +} + +// KnativeProxyHeader returns the value for key ProxyHeaderName in request headers. +func KnativeProxyHeader(r *http.Request) string { + return r.Header.Get(ProxyHeaderName) +} + +// IsProbe returns true if the request is a Kubernetes probe or a Knative probe, +// i.e. non-empty ProbeHeaderName header. +func IsProbe(r *http.Request) bool { + return IsKubeletProbe(r) || KnativeProbeHeader(r) != "" +} + +// RewriteHostIn removes the `Host` header from the inbound (server) request +// and replaces it with our custom header. +// This is done to avoid Istio Host based routing, see #3870. +// Queue-Proxy will execute the reverse process. +func RewriteHostIn(r *http.Request) { + h := r.Host + r.Host = "" + r.Header.Del("Host") + // Don't overwrite an existing OriginalHostHeader. + if r.Header.Get(OriginalHostHeader) == "" { + r.Header.Set(OriginalHostHeader, h) + } +} + +// RewriteHostOut undoes the `RewriteHostIn` action. +// RewriteHostOut checks if network.OriginalHostHeader was set and if it was, +// then uses that as the r.Host (which takes priority over Request.Header["Host"]). +// If the request did not have the OriginalHostHeader header set, the request is untouched. +func RewriteHostOut(r *http.Request) { + if ohh := r.Header.Get(OriginalHostHeader); ohh != "" { + r.Host = ohh + r.Header.Del("Host") + r.Header.Del(OriginalHostHeader) + } +} + +// NameForPortNumber finds the name for a given port as defined by a Service. +func NameForPortNumber(svc *corev1.Service, portNumber int32) (string, error) { + for _, port := range svc.Spec.Ports { + if port.Port == portNumber { + return port.Name, nil + } + } + return "", fmt.Errorf("no port with number %d found", portNumber) +} + +// PortNumberForName resolves a given name to a portNumber as defined by an EndpointSubset. +func PortNumberForName(sub corev1.EndpointSubset, portName string) (int32, error) { + for _, subPort := range sub.Ports { + if subPort.Name == portName { + return subPort.Port, nil + } + } + return 0, fmt.Errorf("no port for name %q found", portName) +} diff --git a/vendor/knative.dev/serving/pkg/network/probe_handler.go b/vendor/knative.dev/serving/pkg/network/probe_handler.go new file mode 100644 index 00000000000..be88b574868 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/network/probe_handler.go @@ -0,0 +1,52 @@ +/* +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 network + +import ( + "fmt" + "net/http" +) + +// ProbeHeaderValue is the value used in 'K-Network-Probe' +var ProbeHeaderValue = "probe" + +type handler struct { + next http.Handler +} + +// NewProbeHandler wraps a HTTP handler handling probing requests around the provided HTTP handler +func NewProbeHandler(next http.Handler) http.Handler { + return &handler{next: next} +} + +// ServeHTTP handles probing requests +func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if ph := r.Header.Get(ProbeHeaderName); ph != ProbeHeaderValue { + r.Header.Del(HashHeaderName) + h.next.ServeHTTP(w, r) + return + } + + hh := r.Header.Get(HashHeaderName) + if hh == "" { + http.Error(w, fmt.Sprintf("a probe request must contain a non-empty %q header", HashHeaderName), http.StatusBadRequest) + return + } + + w.Header().Set(HashHeaderName, hh) + w.WriteHeader(200) +} diff --git a/vendor/knative.dev/serving/pkg/network/testdata/config-network.yaml b/vendor/knative.dev/serving/pkg/network/testdata/config-network.yaml new file mode 120000 index 00000000000..eb11ac0e9f1 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/network/testdata/config-network.yaml @@ -0,0 +1 @@ +../../../config/core/configmaps/network.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/network/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/network/zz_generated.deepcopy.go new file mode 100644 index 00000000000..43e67b19315 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/network/zz_generated.deepcopy.go @@ -0,0 +1,76 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 network + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Config) DeepCopyInto(out *Config) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Config. +func (in *Config) DeepCopy() *Config { + if in == nil { + return nil + } + out := new(Config) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DomainTemplateValues) DeepCopyInto(out *DomainTemplateValues) { + *out = *in + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *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 DomainTemplateValues. +func (in *DomainTemplateValues) DeepCopy() *DomainTemplateValues { + if in == nil { + return nil + } + out := new(DomainTemplateValues) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TagTemplateValues) DeepCopyInto(out *TagTemplateValues) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TagTemplateValues. +func (in *TagTemplateValues) DeepCopy() *TagTemplateValues { + if in == nil { + return nil + } + out := new(TagTemplateValues) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/serving/pkg/reconciler/certificate/config/testdata/config-certmanager.yaml b/vendor/knative.dev/serving/pkg/reconciler/certificate/config/testdata/config-certmanager.yaml new file mode 120000 index 00000000000..e1a32211b03 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/certificate/config/testdata/config-certmanager.yaml @@ -0,0 +1 @@ +../../../../../config/cert-manager/config.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/gc/config/testdata/config-gc.yaml b/vendor/knative.dev/serving/pkg/reconciler/gc/config/testdata/config-gc.yaml new file mode 120000 index 00000000000..71c3f7d74d9 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/gc/config/testdata/config-gc.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/gc.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/ingress/config/testdata/config-istio.yaml b/vendor/knative.dev/serving/pkg/reconciler/ingress/config/testdata/config-istio.yaml new file mode 120000 index 00000000000..7f369833657 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/ingress/config/testdata/config-istio.yaml @@ -0,0 +1 @@ +../../../../../config/istio-ingress/config.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/ingress/config/testdata/config-network.yaml b/vendor/knative.dev/serving/pkg/reconciler/ingress/config/testdata/config-network.yaml new file mode 120000 index 00000000000..56cb332a042 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/ingress/config/testdata/config-network.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/network.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-autoscaler.yaml b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-autoscaler.yaml new file mode 120000 index 00000000000..4ed318ac460 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-autoscaler.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/autoscaler.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-defaults.yaml b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-defaults.yaml new file mode 120000 index 00000000000..f10641f859d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-defaults.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/defaults.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-deployment.yaml b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-deployment.yaml new file mode 120000 index 00000000000..fa9039a1c3c --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-deployment.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/deployment.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-logging.yaml b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-logging.yaml new file mode 120000 index 00000000000..a76506aeb2a --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-logging.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/logging.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-network.yaml b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-network.yaml new file mode 120000 index 00000000000..56cb332a042 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-network.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/network.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-observability.yaml b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-observability.yaml new file mode 120000 index 00000000000..78663f4745d --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/revision/config/testdata/config-observability.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/observability.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/route/config/doc.go b/vendor/knative.dev/serving/pkg/reconciler/route/config/doc.go new file mode 100644 index 00000000000..18fe4f381fe --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/route/config/doc.go @@ -0,0 +1,20 @@ +/* +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 config holds the typed objects that define the schemas for +// assorted ConfigMap objects on which the Route controller depends. +package config diff --git a/vendor/knative.dev/serving/pkg/reconciler/route/config/domain.go b/vendor/knative.dev/serving/pkg/reconciler/route/config/domain.go new file mode 100644 index 00000000000..3863a1311f4 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/route/config/domain.go @@ -0,0 +1,122 @@ +/* +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 + + https://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 config + +import ( + "strings" + + "github.com/ghodss/yaml" + corev1 "k8s.io/api/core/v1" + "knative.dev/pkg/configmap" + "knative.dev/pkg/network" +) + +const ( + DomainConfigName = "config-domain" + // VisibilityLabelKey is the label to indicate visibility of Route + // and KServices. It can be an annotation too but since users are + // already using labels for domain, it probably best to keep this + // consistent. + VisibilityLabelKey = "serving.knative.dev/visibility" + // VisibilityClusterLocal is the label value for VisibilityLabelKey + // that will result to the Route/KService getting a cluster local + // domain suffix. + VisibilityClusterLocal = "cluster-local" + // DefaultDomain holds the domain that Route's live under by default + // when no label selector-based options apply. + DefaultDomain = "example.com" +) + +// LabelSelector represents map of {key,value} pairs. A single {key,value} in the +// map is equivalent to a requirement key == value. The requirements are ANDed. +type LabelSelector struct { + Selector map[string]string `json:"selector,omitempty"` +} + +func (s *LabelSelector) specificity() int { + return len(s.Selector) +} + +// Matches returns whether the given labels meet the requirement of the selector. +func (s *LabelSelector) Matches(labels map[string]string) bool { + for label, expectedValue := range s.Selector { + value, ok := labels[label] + if !ok || expectedValue != value { + return false + } + } + return true +} + +// Domain maps domains to routes by matching the domain's +// label selectors to the route's labels. +type Domain struct { + // Domains map from domain to label selector. If a route has + // labels matching a particular selector, it will use the + // corresponding domain. If multiple selectors match, we choose + // the most specific selector. + Domains map[string]*LabelSelector +} + +// NewDomainFromConfigMap creates a Domain from the supplied ConfigMap +func NewDomainFromConfigMap(configMap *corev1.ConfigMap) (*Domain, error) { + c := Domain{Domains: map[string]*LabelSelector{}} + hasDefault := false + for k, v := range configMap.Data { + if k == configmap.ExampleKey { + continue + } + labelSelector := LabelSelector{} + err := yaml.Unmarshal([]byte(v), &labelSelector) + if err != nil { + return nil, err + } + c.Domains[k] = &labelSelector + if len(labelSelector.Selector) == 0 { + hasDefault = true + } + } + if !hasDefault { + c.Domains[DefaultDomain] = &LabelSelector{} + } + return &c, nil +} + +// LookupDomainForLabels returns a domain given a set of labels. +// Since we reject configuration without a default domain, this should +// always return a value. +func (c *Domain) LookupDomainForLabels(labels map[string]string) string { + domain := "" + specificity := -1 + // If we see VisibilityLabelKey sets with VisibilityClusterLocal, that + // will take precedence and the route will get a Cluster's Domain Name. + if labels[VisibilityLabelKey] == VisibilityClusterLocal { + return "svc." + network.GetClusterDomainName() + } + for k, selector := range c.Domains { + // Ignore if selector doesn't match, or decrease the specificity. + if !selector.Matches(labels) || selector.specificity() < specificity { + continue + } + if selector.specificity() > specificity || strings.Compare(k, domain) < 0 { + domain = k + specificity = selector.specificity() + } + } + + return domain +} diff --git a/vendor/knative.dev/serving/pkg/reconciler/route/config/store.go b/vendor/knative.dev/serving/pkg/reconciler/route/config/store.go new file mode 100644 index 00000000000..4867d7e0196 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/route/config/store.go @@ -0,0 +1,91 @@ +/* +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 + + https://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 config + +import ( + "context" + + "knative.dev/pkg/configmap" + "knative.dev/pkg/logging" + "knative.dev/serving/pkg/gc" + "knative.dev/serving/pkg/network" +) + +type cfgKey struct{} + +// +k8s:deepcopy-gen=false +type Config struct { + Domain *Domain + GC *gc.Config + Network *network.Config +} + +func FromContext(ctx context.Context) *Config { + return ctx.Value(cfgKey{}).(*Config) +} + +func ToContext(ctx context.Context, c *Config) context.Context { + return context.WithValue(ctx, cfgKey{}, c) +} + +// Store is based on configmap.UntypedStore and is used to store and watch for +// updates to configuration related to routes (currently only config-domain). +// +// +k8s:deepcopy-gen=false +type Store struct { + *configmap.UntypedStore +} + +// NewStore creates a configmap.UntypedStore based config store. +// +// logger must be non-nil implementation of configmap.Logger (commonly used +// loggers conform) +// +// onAfterStore is a variadic list of callbacks to run +// after the ConfigMap has been processed and stored. +// +// See also: configmap.NewUntypedStore(). +func NewStore(ctx context.Context, onAfterStore ...func(name string, value interface{})) *Store { + logger := logging.FromContext(ctx) + + store := &Store{ + UntypedStore: configmap.NewUntypedStore( + "route", + logger, + configmap.Constructors{ + DomainConfigName: NewDomainFromConfigMap, + gc.ConfigName: gc.NewConfigFromConfigMapFunc(ctx), + network.ConfigName: network.NewConfigFromConfigMap, + }, + onAfterStore..., + ), + } + + return store +} + +func (s *Store) ToContext(ctx context.Context) context.Context { + return ToContext(ctx, s.Load()) +} + +func (s *Store) Load() *Config { + return &Config{ + Domain: s.UntypedLoad(DomainConfigName).(*Domain).DeepCopy(), + GC: s.UntypedLoad(gc.ConfigName).(*gc.Config).DeepCopy(), + Network: s.UntypedLoad(network.ConfigName).(*network.Config).DeepCopy(), + } +} diff --git a/vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-domain.yaml b/vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-domain.yaml new file mode 120000 index 00000000000..39a7f1839ab --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-domain.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/domain.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-gc.yaml b/vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-gc.yaml new file mode 120000 index 00000000000..71c3f7d74d9 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-gc.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/gc.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-network.yaml b/vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-network.yaml new file mode 120000 index 00000000000..56cb332a042 --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/route/config/testdata/config-network.yaml @@ -0,0 +1 @@ +../../../../../config/core/configmaps/network.yaml \ No newline at end of file diff --git a/vendor/knative.dev/serving/pkg/reconciler/route/config/zz_generated.deepcopy.go b/vendor/knative.dev/serving/pkg/reconciler/route/config/zz_generated.deepcopy.go new file mode 100644 index 00000000000..86b30c4995e --- /dev/null +++ b/vendor/knative.dev/serving/pkg/reconciler/route/config/zz_generated.deepcopy.go @@ -0,0 +1,75 @@ +// +build !ignore_autogenerated + +/* +Copyright 2020 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 config + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Domain) DeepCopyInto(out *Domain) { + *out = *in + if in.Domains != nil { + in, out := &in.Domains, &out.Domains + *out = make(map[string]*LabelSelector, len(*in)) + for key, val := range *in { + var outVal *LabelSelector + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = new(LabelSelector) + (*in).DeepCopyInto(*out) + } + (*out)[key] = outVal + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Domain. +func (in *Domain) DeepCopy() *Domain { + if in == nil { + return nil + } + out := new(Domain) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LabelSelector) DeepCopyInto(out *LabelSelector) { + *out = *in + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *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 LabelSelector. +func (in *LabelSelector) DeepCopy() *LabelSelector { + if in == nil { + return nil + } + out := new(LabelSelector) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/HEAD b/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/HEAD new file mode 120000 index 00000000000..a41d326440f --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/HEAD @@ -0,0 +1 @@ +../../../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/dev.config b/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/dev.config new file mode 120000 index 00000000000..ee953f22c05 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/dev.config @@ -0,0 +1 @@ +../../dev.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/prod.config b/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/prod.config new file mode 120000 index 00000000000..c8b39a6de1b --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/prod.config @@ -0,0 +1 @@ +../../prod.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/refs b/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/refs new file mode 120000 index 00000000000..37881f203ff --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/dataplane-probe/continuous/kodata/refs @@ -0,0 +1 @@ +../../../../../../.git/refs/ \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/HEAD b/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/HEAD new file mode 120000 index 00000000000..a41d326440f --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/HEAD @@ -0,0 +1 @@ +../../../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/dev.config b/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/dev.config new file mode 120000 index 00000000000..ee953f22c05 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/dev.config @@ -0,0 +1 @@ +../../dev.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/prod.config b/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/prod.config new file mode 120000 index 00000000000..c8b39a6de1b --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/prod.config @@ -0,0 +1 @@ +../../prod.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/refs b/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/refs new file mode 120000 index 00000000000..37881f203ff --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/deployment-probe/continuous/kodata/refs @@ -0,0 +1 @@ +../../../../../../.git/refs/ \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/HEAD b/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/HEAD new file mode 120000 index 00000000000..a41d326440f --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/HEAD @@ -0,0 +1 @@ +../../../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/dev.config b/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/dev.config new file mode 120000 index 00000000000..ee953f22c05 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/dev.config @@ -0,0 +1 @@ +../../dev.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/prod.config b/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/prod.config new file mode 120000 index 00000000000..c8b39a6de1b --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/prod.config @@ -0,0 +1 @@ +../../prod.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/refs b/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/refs new file mode 120000 index 00000000000..37881f203ff --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/load-test/continuous/kodata/refs @@ -0,0 +1 @@ +../../../../../../.git/refs/ \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/HEAD b/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/HEAD new file mode 120000 index 00000000000..a41d326440f --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/HEAD @@ -0,0 +1 @@ +../../../../../../.git/HEAD \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/dev.config b/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/dev.config new file mode 120000 index 00000000000..ee953f22c05 --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/dev.config @@ -0,0 +1 @@ +../../dev.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/prod.config b/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/prod.config new file mode 120000 index 00000000000..c8b39a6de1b --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/prod.config @@ -0,0 +1 @@ +../../prod.config \ No newline at end of file diff --git a/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/refs b/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/refs new file mode 120000 index 00000000000..37881f203ff --- /dev/null +++ b/vendor/knative.dev/serving/test/performance/benchmarks/scale-from-zero/continuous/kodata/refs @@ -0,0 +1 @@ +../../../../../../.git/refs/ \ No newline at end of file diff --git a/vendor/knative.dev/serving/third_party/config/monitoring/logging/elasticsearch/LICENSE b/vendor/knative.dev/serving/third_party/config/monitoring/logging/elasticsearch/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/vendor/knative.dev/serving/third_party/config/monitoring/logging/elasticsearch/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/kubernetes/LICENSE b/vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/kubernetes/LICENSE new file mode 100644 index 00000000000..8dada3edaf5 --- /dev/null +++ b/vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/kubernetes/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/LICENSE b/vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/LICENSE new file mode 100644 index 00000000000..e06d2081865 --- /dev/null +++ b/vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/NOTICE b/vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/NOTICE new file mode 100644 index 00000000000..e520005cdda --- /dev/null +++ b/vendor/knative.dev/serving/third_party/config/monitoring/metrics/prometheus/prometheus-operator/NOTICE @@ -0,0 +1,5 @@ +CoreOS Project +Copyright 2015 CoreOS, Inc + +This product includes software developed at CoreOS, Inc. +(http://www.coreos.com/). diff --git a/vendor/knative.dev/serving/third_party/istio-1.3-latest b/vendor/knative.dev/serving/third_party/istio-1.3-latest new file mode 120000 index 00000000000..04be51b7bcd --- /dev/null +++ b/vendor/knative.dev/serving/third_party/istio-1.3-latest @@ -0,0 +1 @@ +istio-1.3.6 \ No newline at end of file diff --git a/vendor/knative.dev/serving/third_party/istio-1.4-latest b/vendor/knative.dev/serving/third_party/istio-1.4-latest new file mode 120000 index 00000000000..d2c2c177b03 --- /dev/null +++ b/vendor/knative.dev/serving/third_party/istio-1.4-latest @@ -0,0 +1 @@ +istio-1.4.2 \ No newline at end of file From 34479d9d90bdb6eb88f71d9758aa85e38ef8ca71 Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Wed, 22 Jan 2020 19:32:53 +0000 Subject: [PATCH 02/11] use update-dep.sh --- Gopkg.toml | 2 +- vendor/go.opencensus.io/trace/trace.go | 7 ++ vendor/k8s.io/code-generator/Godeps/OWNERS | 4 -- vendor/k8s.io/code-generator/OWNERS | 13 ---- .../code-generator/cmd/client-gen/OWNERS | 10 --- .../code-generator/cmd/go-to-protobuf/OWNERS | 6 -- vendor/knative.dev/pkg/OWNERS | 4 -- vendor/knative.dev/pkg/OWNERS_ALIASES | 67 ------------------- vendor/knative.dev/pkg/apis/OWNERS | 4 -- vendor/knative.dev/pkg/apis/duck/OWNERS | 4 -- vendor/knative.dev/pkg/configmap/OWNERS | 4 -- vendor/knative.dev/pkg/controller/OWNERS | 4 -- vendor/knative.dev/pkg/hack/OWNERS | 10 --- vendor/knative.dev/pkg/injection/OWNERS | 5 -- vendor/knative.dev/pkg/kmeta/OWNERS | 4 -- vendor/knative.dev/pkg/logging/OWNERS | 4 -- vendor/knative.dev/pkg/metrics/OWNERS | 4 -- vendor/knative.dev/pkg/network/OWNERS | 5 -- vendor/knative.dev/pkg/reconciler/OWNERS | 4 -- vendor/knative.dev/pkg/resolver/OWNERS | 5 -- vendor/knative.dev/pkg/source/OWNERS | 4 -- vendor/knative.dev/pkg/test/OWNERS | 10 --- vendor/knative.dev/pkg/testutils/OWNERS | 4 -- vendor/knative.dev/pkg/webhook/OWNERS | 4 -- vendor/knative.dev/pkg/websocket/OWNERS | 4 -- 25 files changed, 8 insertions(+), 188 deletions(-) delete mode 100644 vendor/k8s.io/code-generator/Godeps/OWNERS delete mode 100644 vendor/k8s.io/code-generator/OWNERS delete mode 100644 vendor/k8s.io/code-generator/cmd/client-gen/OWNERS delete mode 100644 vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS delete mode 100644 vendor/knative.dev/pkg/OWNERS delete mode 100644 vendor/knative.dev/pkg/OWNERS_ALIASES delete mode 100644 vendor/knative.dev/pkg/apis/OWNERS delete mode 100644 vendor/knative.dev/pkg/apis/duck/OWNERS delete mode 100644 vendor/knative.dev/pkg/configmap/OWNERS delete mode 100644 vendor/knative.dev/pkg/controller/OWNERS delete mode 100644 vendor/knative.dev/pkg/hack/OWNERS delete mode 100644 vendor/knative.dev/pkg/injection/OWNERS delete mode 100644 vendor/knative.dev/pkg/kmeta/OWNERS delete mode 100644 vendor/knative.dev/pkg/logging/OWNERS delete mode 100644 vendor/knative.dev/pkg/metrics/OWNERS delete mode 100644 vendor/knative.dev/pkg/network/OWNERS delete mode 100644 vendor/knative.dev/pkg/reconciler/OWNERS delete mode 100644 vendor/knative.dev/pkg/resolver/OWNERS delete mode 100644 vendor/knative.dev/pkg/source/OWNERS delete mode 100644 vendor/knative.dev/pkg/test/OWNERS delete mode 100644 vendor/knative.dev/pkg/testutils/OWNERS delete mode 100644 vendor/knative.dev/pkg/webhook/OWNERS delete mode 100644 vendor/knative.dev/pkg/websocket/OWNERS diff --git a/Gopkg.toml b/Gopkg.toml index 1fc78ead538..45344fd1d29 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -124,7 +124,7 @@ required = [ [[constraint]] name = "github.com/tsenart/vegeta" - version = "master" + branch = "master" [[constraint]] name = "contrib.go.opencensus.io/exporter/ocagent" diff --git a/vendor/go.opencensus.io/trace/trace.go b/vendor/go.opencensus.io/trace/trace.go index 3f8977b41b4..2622382a074 100644 --- a/vendor/go.opencensus.io/trace/trace.go +++ b/vendor/go.opencensus.io/trace/trace.go @@ -261,6 +261,13 @@ func startSpanInternal(name string, hasParent bool, parent SpanContext, remotePa return span } +func (s *Span) SetSpanID(spanID SpanID) { + if s.data != nil { + s.data.SpanID = spanID + } + s.spanContext.SpanID = spanID +} + // End ends the span. func (s *Span) End() { if s == nil { diff --git a/vendor/k8s.io/code-generator/Godeps/OWNERS b/vendor/k8s.io/code-generator/Godeps/OWNERS deleted file mode 100644 index 0f5d2f6734e..00000000000 --- a/vendor/k8s.io/code-generator/Godeps/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -approvers: -- dep-approvers diff --git a/vendor/k8s.io/code-generator/OWNERS b/vendor/k8s.io/code-generator/OWNERS deleted file mode 100644 index 6f7abe3edb1..00000000000 --- a/vendor/k8s.io/code-generator/OWNERS +++ /dev/null @@ -1,13 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -approvers: -- lavalamp -- wojtek-t -- sttts -reviewers: -- lavalamp -- wojtek-t -- sttts -labels: -- sig/api-machinery -- area/code-generation diff --git a/vendor/k8s.io/code-generator/cmd/client-gen/OWNERS b/vendor/k8s.io/code-generator/cmd/client-gen/OWNERS deleted file mode 100644 index 62866d0b194..00000000000 --- a/vendor/k8s.io/code-generator/cmd/client-gen/OWNERS +++ /dev/null @@ -1,10 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -approvers: -- lavalamp -- wojtek-t -- caesarxuchao -reviewers: -- lavalamp -- wojtek-t -- caesarxuchao diff --git a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS b/vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS deleted file mode 100644 index 613659162a9..00000000000 --- a/vendor/k8s.io/code-generator/cmd/go-to-protobuf/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -# See the OWNERS docs at https://go.k8s.io/owners - -approvers: -- smarterclayton -reviewers: -- smarterclayton diff --git a/vendor/knative.dev/pkg/OWNERS b/vendor/knative.dev/pkg/OWNERS deleted file mode 100644 index 030df98f78d..00000000000 --- a/vendor/knative.dev/pkg/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- pkg-approvers diff --git a/vendor/knative.dev/pkg/OWNERS_ALIASES b/vendor/knative.dev/pkg/OWNERS_ALIASES deleted file mode 100644 index 7a8145f0240..00000000000 --- a/vendor/knative.dev/pkg/OWNERS_ALIASES +++ /dev/null @@ -1,67 +0,0 @@ -aliases: - pkg-approvers: - - evankanderson - - mattmoor - - vaikas - - apis-approvers: - - mattmoor - - vaikas - - n3wscott - - apis-duck-approvers: - - mattmoor - - vaikas - - configmap-approvers: - - mattmoor - - mdemirhan - - dprotaso - - controller-approvers: - - dgerd - - grantr - - mattmoor - - tcnghia - - vagababov - - kmeta-approvers: - - mattmoor - - dgerd - - vagababov - - logging-approvers: - - mdemirhan - - n3wscott - - yanweiguo - - metrics-approvers: - - mdemirhan - - yanweiguo - - network-approvers: - - markusthoemmes - - tcnghia - - vagababov - - productivity-approvers: - - adrcunha - - chaodaiG - - chizhg - productivity-reviewers: - - adrcunha - - chaodaiG - - coryrc - - chizhg - - steuhs - - yt3liu - - source-approvers: - - n3wscott - - vaikas - - webhook-approvers: - - mattmoor - - grantr - - tcnghia - diff --git a/vendor/knative.dev/pkg/apis/OWNERS b/vendor/knative.dev/pkg/apis/OWNERS deleted file mode 100644 index a25420ebc0d..00000000000 --- a/vendor/knative.dev/pkg/apis/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- apis-approvers diff --git a/vendor/knative.dev/pkg/apis/duck/OWNERS b/vendor/knative.dev/pkg/apis/duck/OWNERS deleted file mode 100644 index ad4d83c51e4..00000000000 --- a/vendor/knative.dev/pkg/apis/duck/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- apis-duck-approvers diff --git a/vendor/knative.dev/pkg/configmap/OWNERS b/vendor/knative.dev/pkg/configmap/OWNERS deleted file mode 100644 index 2480fc6d43f..00000000000 --- a/vendor/knative.dev/pkg/configmap/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- configmap-approvers diff --git a/vendor/knative.dev/pkg/controller/OWNERS b/vendor/knative.dev/pkg/controller/OWNERS deleted file mode 100644 index afa22257a26..00000000000 --- a/vendor/knative.dev/pkg/controller/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- controller-approvers diff --git a/vendor/knative.dev/pkg/hack/OWNERS b/vendor/knative.dev/pkg/hack/OWNERS deleted file mode 100644 index c50adc84930..00000000000 --- a/vendor/knative.dev/pkg/hack/OWNERS +++ /dev/null @@ -1,10 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- productivity-approvers - -reviewers: -- productivity-reviewers - -labels: -- area/test-and-release diff --git a/vendor/knative.dev/pkg/injection/OWNERS b/vendor/knative.dev/pkg/injection/OWNERS deleted file mode 100644 index dda47512a47..00000000000 --- a/vendor/knative.dev/pkg/injection/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- mattmoor -- n3wscott diff --git a/vendor/knative.dev/pkg/kmeta/OWNERS b/vendor/knative.dev/pkg/kmeta/OWNERS deleted file mode 100644 index 29b0d9f2562..00000000000 --- a/vendor/knative.dev/pkg/kmeta/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- kmeta-approvers diff --git a/vendor/knative.dev/pkg/logging/OWNERS b/vendor/knative.dev/pkg/logging/OWNERS deleted file mode 100644 index fa4854ba0a5..00000000000 --- a/vendor/knative.dev/pkg/logging/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- logging-approvers diff --git a/vendor/knative.dev/pkg/metrics/OWNERS b/vendor/knative.dev/pkg/metrics/OWNERS deleted file mode 100644 index 6d3966df44e..00000000000 --- a/vendor/knative.dev/pkg/metrics/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- metrics-approvers diff --git a/vendor/knative.dev/pkg/network/OWNERS b/vendor/knative.dev/pkg/network/OWNERS deleted file mode 100644 index b14ac5308ea..00000000000 --- a/vendor/knative.dev/pkg/network/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- tcnghia -- vagababov diff --git a/vendor/knative.dev/pkg/reconciler/OWNERS b/vendor/knative.dev/pkg/reconciler/OWNERS deleted file mode 100644 index afa22257a26..00000000000 --- a/vendor/knative.dev/pkg/reconciler/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- controller-approvers diff --git a/vendor/knative.dev/pkg/resolver/OWNERS b/vendor/knative.dev/pkg/resolver/OWNERS deleted file mode 100644 index acf2ee2c1cf..00000000000 --- a/vendor/knative.dev/pkg/resolver/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- n3wscott -- vaikas-google diff --git a/vendor/knative.dev/pkg/source/OWNERS b/vendor/knative.dev/pkg/source/OWNERS deleted file mode 100644 index 8d16912160d..00000000000 --- a/vendor/knative.dev/pkg/source/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- source-approvers diff --git a/vendor/knative.dev/pkg/test/OWNERS b/vendor/knative.dev/pkg/test/OWNERS deleted file mode 100644 index c50adc84930..00000000000 --- a/vendor/knative.dev/pkg/test/OWNERS +++ /dev/null @@ -1,10 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- productivity-approvers - -reviewers: -- productivity-reviewers - -labels: -- area/test-and-release diff --git a/vendor/knative.dev/pkg/testutils/OWNERS b/vendor/knative.dev/pkg/testutils/OWNERS deleted file mode 100644 index 46b7acf91e9..00000000000 --- a/vendor/knative.dev/pkg/testutils/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- productivity-approvers diff --git a/vendor/knative.dev/pkg/webhook/OWNERS b/vendor/knative.dev/pkg/webhook/OWNERS deleted file mode 100644 index b87878d94ae..00000000000 --- 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/websocket/OWNERS b/vendor/knative.dev/pkg/websocket/OWNERS deleted file mode 100644 index c3fa6ca63cd..00000000000 --- a/vendor/knative.dev/pkg/websocket/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -# The OWNERS file is used by prow to automatically merge approved PRs. - -approvers: -- network-approvers From f4b470e7e69abb52e503ef5311bbc66874efb2a5 Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Wed, 22 Jan 2020 19:41:29 +0000 Subject: [PATCH 03/11] change to label --- pkg/reconciler/broker/broker_test.go | 20 ++++++++++---------- pkg/reconciler/service_helper.go | 5 ++++- pkg/reconciler/testing/broker.go | 4 ++-- pkg/reconciler/trigger/trigger_test.go | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pkg/reconciler/broker/broker_test.go b/pkg/reconciler/broker/broker_test.go index 7226462cbd9..a2deb02e6b0 100644 --- a/pkg/reconciler/broker/broker_test.go +++ b/pkg/reconciler/broker/broker_test.go @@ -595,7 +595,7 @@ func TestReconcileWithServingService(t *testing.T) { Objects: []runtime.Object{ NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions), createChannel(testNS, triggerChannel, true), }, @@ -614,7 +614,7 @@ func TestReconcileWithServingService(t *testing.T) { WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions, WithTriggerChannelReady(), WithBrokerTriggerChannel(createTriggerChannelRef()), @@ -631,7 +631,7 @@ func TestReconcileWithServingService(t *testing.T) { Objects: []runtime.Object{ NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions), createChannel(testNS, triggerChannel, true), NewServingService(filterServiceName, testNS, filterRevisionName, @@ -648,7 +648,7 @@ func TestReconcileWithServingService(t *testing.T) { WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions, WithTriggerChannelReady(), WithBrokerTriggerChannel(createTriggerChannelRef()), @@ -674,7 +674,7 @@ func TestReconcileWithServingService(t *testing.T) { Objects: []runtime.Object{ NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions), createChannel(testNS, triggerChannel, true), NewServingService(filterServiceName, testNS, filterRevisionName, @@ -701,7 +701,7 @@ func TestReconcileWithServingService(t *testing.T) { WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions, WithTriggerChannelReady(), WithFilterDeploymentAvailable(), @@ -719,7 +719,7 @@ func TestReconcileWithServingService(t *testing.T) { Objects: []runtime.Object{ NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions, WithBrokerGeneration(brokerGeneration), ), @@ -755,7 +755,7 @@ func TestReconcileWithServingService(t *testing.T) { WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions, WithBrokerGeneration(brokerGeneration), WithBrokerStatusObservedGeneration(brokerGeneration), @@ -775,7 +775,7 @@ func TestReconcileWithServingService(t *testing.T) { Objects: []runtime.Object{ NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions), createChannel(testNS, triggerChannel, true), NewServingService(filterServiceName, testNS, filterRevisionName, @@ -798,7 +798,7 @@ func TestReconcileWithServingService(t *testing.T) { WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerAnnotations(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), + WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithBrokerReady, WithBrokerTriggerChannel(createTriggerChannelRef()), WithBrokerAddress(fmt.Sprintf("%s.%s.svc.%s", ingressServiceName, testNS, utils.GetClusterDomainName())), diff --git a/pkg/reconciler/service_helper.go b/pkg/reconciler/service_helper.go index c880f678f30..8183a188b19 100644 --- a/pkg/reconciler/service_helper.go +++ b/pkg/reconciler/service_helper.go @@ -345,10 +345,13 @@ func (h *ServiceHelper) reconcileService(ctx context.Context, svc *corev1.Servic } func (h *ServiceHelper) useServingService(ctx context.Context, owner kmeta.OwnerRefable) (bool, error) { - if v, ok := owner.GetObjectMeta().GetAnnotations()["eventing.knative.dev/serviceFlavor"]; !ok && v != "knative" { + if v, ok := owner.GetObjectMeta().GetLabels()["eventing.knative.dev/serviceFlavor"]; !ok && v != "knative" { return false, nil } + // TODO: changing the label after broker creation is dangerous. + // In the webhook we should make it immutable. + if err := h.APIChecker.Exists(servingv1.SchemeGroupVersion); err != nil { if strings.Contains(err.Error(), "server does not support API version") { return false, err diff --git a/pkg/reconciler/testing/broker.go b/pkg/reconciler/testing/broker.go index ea0e35589f7..15e91c7e3d6 100644 --- a/pkg/reconciler/testing/broker.go +++ b/pkg/reconciler/testing/broker.go @@ -45,9 +45,9 @@ func NewBroker(name, namespace string, o ...BrokerOption) *v1alpha1.Broker { return b } -func WithBrokerAnnotations(annotations map[string]string) BrokerOption { +func WithBrokerLabels(labels map[string]string) BrokerOption { return func(s *v1alpha1.Broker) { - s.Annotations = annotations + s.Labels = labels } } diff --git a/pkg/reconciler/trigger/trigger_test.go b/pkg/reconciler/trigger/trigger_test.go index c17e30e6b5c..7fb9d95859d 100644 --- a/pkg/reconciler/trigger/trigger_test.go +++ b/pkg/reconciler/trigger/trigger_test.go @@ -145,7 +145,7 @@ func TestAllCases(t *testing.T) { func TestAllCasesWithServingServiceBroker(t *testing.T) { b := makeBroker() - b.Annotations = map[string]string{"eventing.knative.dev/serviceFlavor": "knative"} + b.Labels = map[string]string{"eventing.knative.dev/serviceFlavor": "knative"} testAllCases(t, b, makeBrokerFilterServingService()) } From 2c1db0a45ebac33886408f56cedf0320c85ebe72 Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Wed, 22 Jan 2020 19:56:28 +0000 Subject: [PATCH 04/11] some cleanup --- pkg/reconciler/broker/broker.go | 34 ----------------------- pkg/reconciler/testing/serving_service.go | 2 +- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/pkg/reconciler/broker/broker.go b/pkg/reconciler/broker/broker.go index a5ae37fe1f1..a1c8d684f05 100644 --- a/pkg/reconciler/broker/broker.go +++ b/pkg/reconciler/broker/broker.go @@ -222,40 +222,6 @@ func (r *Reconciler) reconcile(ctx context.Context, b *v1alpha1.Broker) error { } b.Status.SetAddress(ingressStatus.URL) - - // filterDeployment, err := r.reconcileFilterDeployment(ctx, b) - // if err != nil { - // logging.FromContext(ctx).Error("Problem reconciling filter Deployment", zap.Error(err)) - // b.Status.MarkFilterFailed("DeploymentFailure", "%v", err) - // return err - // } - // _, err = r.reconcileFilterService(ctx, b) - // if err != nil { - // logging.FromContext(ctx).Error("Problem reconciling filter Service", zap.Error(err)) - // b.Status.MarkFilterFailed("ServiceFailure", "%v", err) - // return err - // } - // b.Status.PropagateFilterDeploymentAvailability(filterDeployment) - - // ingressDeployment, err := r.reconcileIngressDeployment(ctx, b, triggerChan) - // if err != nil { - // logging.FromContext(ctx).Error("Problem reconciling ingress Deployment", zap.Error(err)) - // b.Status.MarkIngressFailed("DeploymentFailure", "%v", err) - // return err - // } - - // svc, err := r.reconcileIngressService(ctx, b) - // if err != nil { - // logging.FromContext(ctx).Error("Problem reconciling ingress Service", zap.Error(err)) - // b.Status.MarkIngressFailed("ServiceFailure", "%v", err) - // return err - // } - // b.Status.PropagateIngressDeploymentAvailability(ingressDeployment) - // b.Status.SetAddress(&apis.URL{ - // Scheme: "http", - // Host: names.ServiceHostName(svc.Name, svc.Namespace), - // }) - return nil } diff --git a/pkg/reconciler/testing/serving_service.go b/pkg/reconciler/testing/serving_service.go index 92149f9763a..c8bd7a6bafd 100644 --- a/pkg/reconciler/testing/serving_service.go +++ b/pkg/reconciler/testing/serving_service.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Knative Authors +Copyright 2020 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. From 4e3d945ad820145c809df4f2c9f863977a7e85ad Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Wed, 22 Jan 2020 19:58:36 +0000 Subject: [PATCH 05/11] more cleanup --- pkg/reconciler/broker/broker.go | 86 --------------------------------- 1 file changed, 86 deletions(-) diff --git a/pkg/reconciler/broker/broker.go b/pkg/reconciler/broker/broker.go index a1c8d684f05..517f7f79e02 100644 --- a/pkg/reconciler/broker/broker.go +++ b/pkg/reconciler/broker/broker.go @@ -274,22 +274,6 @@ func (r *Reconciler) reconcileIngressService(ctx context.Context, b *v1alpha1.Br return r.serviceHelper.ReconcileService(ctx, b, *svcArgs) } -// reconcileFilterDeployment reconciles Broker's 'b' filter deployment. -// func (r *Reconciler) reconcileFilterDeployment(ctx context.Context, b *v1alpha1.Broker) (*v1.Deployment, error) { -// expected := resources.MakeFilterDeployment(&resources.FilterArgs{ -// Broker: b, -// Image: r.filterImage, -// ServiceAccountName: r.filterServiceAccountName, -// }) -// return r.reconcileDeployment(ctx, expected) -// } - -// // reconcileFilterService reconciles Broker's 'b' filter service. -// func (r *Reconciler) reconcileFilterService(ctx context.Context, b *v1alpha1.Broker) (*corev1.Service, error) { -// expected := resources.MakeFilterService(b) -// return r.reconcileService(ctx, expected) -// } - func newTriggerChannel(b *v1alpha1.Broker) (*unstructured.Unstructured, error) { return resources.NewChannel("trigger", b, TriggerChannelLabels(b.Name)) } @@ -350,73 +334,3 @@ func TriggerChannelLabels(brokerName string) map[string]string { "eventing.knative.dev/brokerEverything": "true", } } - -// reconcileDeployment reconciles the K8s Deployment 'd'. -// func (r *Reconciler) reconcileDeployment(ctx context.Context, d *v1.Deployment) (*v1.Deployment, error) { -// current, err := r.deploymentLister.Deployments(d.Namespace).Get(d.Name) -// if apierrs.IsNotFound(err) { -// current, err = r.KubeClientSet.AppsV1().Deployments(d.Namespace).Create(d) -// if err != nil { -// return nil, err -// } -// return current, nil -// } else if err != nil { -// return nil, err -// } - -// if !equality.Semantic.DeepDerivative(d.Spec, current.Spec) { -// // Don't modify the informers copy. -// desired := current.DeepCopy() -// desired.Spec = d.Spec -// current, err = r.KubeClientSet.AppsV1().Deployments(current.Namespace).Update(desired) -// if err != nil { -// return nil, err -// } -// } -// return current, nil -// } - -// // reconcileService reconciles the K8s Service 'svc'. -// func (r *Reconciler) reconcileService(ctx context.Context, svc *corev1.Service) (*corev1.Service, error) { -// current, err := r.serviceLister.Services(svc.Namespace).Get(svc.Name) -// if apierrs.IsNotFound(err) { -// current, err = r.KubeClientSet.CoreV1().Services(svc.Namespace).Create(svc) -// if err != nil { -// return nil, err -// } -// return current, nil -// } else if err != nil { -// return nil, err -// } - -// // spec.clusterIP is immutable and is set on existing services. If we don't set this to the same value, we will -// // encounter an error while updating. -// svc.Spec.ClusterIP = current.Spec.ClusterIP -// if !equality.Semantic.DeepDerivative(svc.Spec, current.Spec) { -// // Don't modify the informers copy. -// desired := current.DeepCopy() -// desired.Spec = svc.Spec -// current, err = r.KubeClientSet.CoreV1().Services(current.Namespace).Update(desired) -// if err != nil { -// return nil, err -// } -// } -// return current, nil -// } - -// reconcileIngressDeploymentCRD reconciles the Ingress Deployment for a CRD backed channel. -// func (r *Reconciler) reconcileIngressDeployment(ctx context.Context, b *v1alpha1.Broker, c *duckv1alpha1.Channelable) (*v1.Deployment, error) { -// expected := resources.MakeIngress(&resources.IngressArgs{ -// Broker: b, -// Image: r.ingressImage, -// ServiceAccountName: r.ingressServiceAccountName, -// ChannelAddress: c.Status.Address.GetURL().Host, -// }) -// return r.reconcileDeployment(ctx, expected) -// } - -// // reconcileIngressService reconciles the Ingress Service. -// func (r *Reconciler) reconcileIngressService(ctx context.Context, b *v1alpha1.Broker) (*corev1.Service, error) { -// expected := resources.MakeIngressService(b) -// return r.reconcileService(ctx, expected) -// } From 23d8c544a09e09e61bdb4409014fe3bf784d997b Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Sat, 25 Jan 2020 00:02:54 +0000 Subject: [PATCH 06/11] hacked informer injection --- Gopkg.lock | 3 +- config/500-controller.yaml | 73 +++- .../serving/informers/v1/emptyable.go | 36 ++ .../serving/informers/v1/service/fake/fake.go | 68 ++++ .../serving/informers/v1/service/service.go | 101 +++++ pkg/reconciler/broker/broker.go | 11 +- pkg/reconciler/broker/broker_test.go | 42 +- pkg/reconciler/broker/controller.go | 40 +- pkg/reconciler/broker/controller_test.go | 18 +- pkg/reconciler/broker/resources/filter.go | 6 +- pkg/reconciler/broker/resources/ingress.go | 6 +- pkg/reconciler/service_helper.go | 363 ------------------ pkg/reconciler/trigger/controller.go | 41 +- pkg/reconciler/trigger/controller_test.go | 13 + pkg/reconciler/trigger/trigger.go | 5 +- pkg/reconciler/trigger/trigger_test.go | 73 ++-- pkg/reconciler/utils/services/base.go | 76 ++++ pkg/reconciler/utils/services/kube/kube.go | 189 +++++++++ .../utils/services/serving/serving.go | 121 ++++++ 19 files changed, 843 insertions(+), 442 deletions(-) mode change 120000 => 100644 config/500-controller.yaml create mode 100644 pkg/client/injection/serving/informers/v1/emptyable.go create mode 100644 pkg/client/injection/serving/informers/v1/service/fake/fake.go create mode 100644 pkg/client/injection/serving/informers/v1/service/service.go delete mode 100644 pkg/reconciler/service_helper.go create mode 100644 pkg/reconciler/utils/services/base.go create mode 100644 pkg/reconciler/utils/services/kube/kube.go create mode 100644 pkg/reconciler/utils/services/serving/serving.go diff --git a/Gopkg.lock b/Gopkg.lock index 352c04aa49b..ef4c3b23ac1 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1654,9 +1654,10 @@ "knative.dev/serving/pkg/apis/serving/v1", "knative.dev/serving/pkg/client/clientset/versioned", "knative.dev/serving/pkg/client/clientset/versioned/fake", + "knative.dev/serving/pkg/client/informers/externalversions/serving/v1", "knative.dev/serving/pkg/client/injection/client", "knative.dev/serving/pkg/client/injection/client/fake", - "knative.dev/serving/pkg/client/injection/informers/serving/v1/service", + "knative.dev/serving/pkg/client/injection/informers/factory", "knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake", "knative.dev/serving/pkg/client/listers/serving/v1", "knative.dev/test-infra/scripts", diff --git a/config/500-controller.yaml b/config/500-controller.yaml deleted file mode 120000 index a3175117ed7..00000000000 --- a/config/500-controller.yaml +++ /dev/null @@ -1 +0,0 @@ -core/deployments/controller.yaml \ No newline at end of file diff --git a/config/500-controller.yaml b/config/500-controller.yaml new file mode 100644 index 00000000000..dc223109564 --- /dev/null +++ b/config/500-controller.yaml @@ -0,0 +1,72 @@ +# 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. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: eventing-controller + namespace: knative-eventing + labels: + eventing.knative.dev/release: devel +spec: + replicas: 1 + selector: + matchLabels: + app: eventing-controller + template: + metadata: + annotations: + sidecar.istio.io/inject: "false" + labels: + app: eventing-controller + eventing.knative.dev/release: devel + spec: + serviceAccountName: eventing-controller + containers: + - name: eventing-controller + terminationMessagePolicy: FallbackToLogsOnError + image: knative.dev/eventing/cmd/controller + env: + - name: SYSTEM_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: CONFIG_LOGGING_NAME + value: config-logging + - name: CONFIG_OBSERVABILITY_NAME + value: config-observability + - name: METRICS_DOMAIN + value: knative.dev/eventing + - name: BROKER_INGRESS_IMAGE + value: knative.dev/eventing/cmd/broker/ingress + - name: BROKER_INGRESS_SERVICE_ACCOUNT + value: eventing-broker-ingress + - name: BROKER_FILTER_IMAGE + value: knative.dev/eventing/cmd/broker/filter + - name: BROKER_FILTER_SERVICE_ACCOUNT + value: eventing-broker-filter + - name: BROKER_IMAGE_PULL_SECRET_NAME + value: + # - name: BROKER_RESOURCE_FLAVOR + # value: knative + ports: + - containerPort: 9090 + name: metrics + volumeMounts: + - name: config-logging + mountPath: /etc/config-logging + volumes: + - name: config-logging + configMap: + name: config-logging diff --git a/pkg/client/injection/serving/informers/v1/emptyable.go b/pkg/client/injection/serving/informers/v1/emptyable.go new file mode 100644 index 00000000000..3cea4d5e360 --- /dev/null +++ b/pkg/client/injection/serving/informers/v1/emptyable.go @@ -0,0 +1,36 @@ +/* +Copyright 2020 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 service + +import v1 "knative.dev/serving/pkg/client/informers/externalversions/serving/v1" + +// EmptyableServiceInformer is an "emptyable" version of v1.ServiceInformer. +type EmptyableServiceInformer interface { + // IsEmpty returns whether the informer is empty. + IsEmpty() bool + + // GetInternal returns the internal v1.ServiceInformer if the informer is not empty. + GetInternal() v1.ServiceInformer + + // Run delegates to v1.ServiceInformer if the informer is not empty. + // Otherwise it does nothing. + Run(<-chan struct{}) + + // HasSynced delegates to v1.ServiceInformer if the informer is not empty. + // Otherwise it always returns true. + HasSynced() bool +} diff --git a/pkg/client/injection/serving/informers/v1/service/fake/fake.go b/pkg/client/injection/serving/informers/v1/service/fake/fake.go new file mode 100644 index 00000000000..232843777ae --- /dev/null +++ b/pkg/client/injection/serving/informers/v1/service/fake/fake.go @@ -0,0 +1,68 @@ +/* +Copyright 2020 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 fake + +import ( + "context" + + informerv1 "knative.dev/eventing/pkg/client/injection/serving/informers/v1" + service "knative.dev/eventing/pkg/client/injection/serving/informers/v1/service" + "knative.dev/pkg/controller" + "knative.dev/pkg/injection" + v1 "knative.dev/serving/pkg/client/informers/externalversions/serving/v1" + fake "knative.dev/serving/pkg/client/injection/informers/factory/fake" +) + +var Get = service.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + var inf informerv1.EmptyableServiceInformer + inf = &emptyableImpl{internal: f.Serving().V1().Services()} + return context.WithValue(ctx, service.Key{}, inf), inf +} + +type emptyableImpl struct { + internal v1.ServiceInformer +} + +func (i *emptyableImpl) IsEmpty() bool { + return (i.internal == nil) +} + +func (i *emptyableImpl) GetInternal() v1.ServiceInformer { + return i.internal +} + +func (i *emptyableImpl) Run(stopCh <-chan struct{}) { + if i.internal != nil { + i.internal.Informer().Run(stopCh) + } else { + <-stopCh + } +} + +func (i *emptyableImpl) HasSynced() bool { + if i.internal != nil { + return i.internal.Informer().HasSynced() + } + return true +} diff --git a/pkg/client/injection/serving/informers/v1/service/service.go b/pkg/client/injection/serving/informers/v1/service/service.go new file mode 100644 index 00000000000..351938579d9 --- /dev/null +++ b/pkg/client/injection/serving/informers/v1/service/service.go @@ -0,0 +1,101 @@ +/* +Copyright 2020 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 service + +import ( + "context" + "strings" + + "k8s.io/client-go/discovery" + + informerv1 "knative.dev/eventing/pkg/client/injection/serving/informers/v1" + kubeclient "knative.dev/pkg/client/injection/kube/client" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + v1 "knative.dev/serving/pkg/client/informers/externalversions/serving/v1" + factory "knative.dev/serving/pkg/client/injection/informers/factory" +) + +func init() { + injection.Default.RegisterInformer(withInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct{} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + kc := kubeclient.Get(ctx) + // Register an empty informer if the serving API is not available. + if err := discovery.ServerSupportsVersion(kc.Discovery(), servingv1.SchemeGroupVersion); err != nil { + if strings.Contains(err.Error(), "server does not support API version") { + var inf informerv1.EmptyableServiceInformer + inf = &emptyableImpl{} + return context.WithValue(ctx, Key{}, inf), inf + } + logging.FromContext(ctx).Panic( + "Failed to check API version", servingv1.SchemeGroupVersion) + } + + f := factory.Get(ctx) + var inf informerv1.EmptyableServiceInformer + inf = &emptyableImpl{internal: f.Serving().V1().Services()} + return context.WithValue(ctx, Key{}, inf), inf +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) informerv1.EmptyableServiceInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch knative.dev/eventing/pkg/serving/EmptyableServiceInformer from context.") + } + return untyped.(informerv1.EmptyableServiceInformer) +} + +var ( + _ controller.Informer = (*emptyableImpl)(nil) + _ informerv1.EmptyableServiceInformer = (*emptyableImpl)(nil) +) + +type emptyableImpl struct { + internal v1.ServiceInformer +} + +func (i *emptyableImpl) IsEmpty() bool { + return (i.internal == nil) +} + +func (i *emptyableImpl) GetInternal() v1.ServiceInformer { + return i.internal +} + +func (i *emptyableImpl) Run(stopCh <-chan struct{}) { + if i.internal != nil { + i.internal.Informer().Run(stopCh) + } else { + <-stopCh + } +} + +func (i *emptyableImpl) HasSynced() bool { + if i.internal != nil { + return i.internal.Informer().HasSynced() + } + return true +} diff --git a/pkg/reconciler/broker/broker.go b/pkg/reconciler/broker/broker.go index 517f7f79e02..3f40f71c8d5 100644 --- a/pkg/reconciler/broker/broker.go +++ b/pkg/reconciler/broker/broker.go @@ -41,6 +41,7 @@ import ( "knative.dev/eventing/pkg/logging" "knative.dev/eventing/pkg/reconciler" "knative.dev/eventing/pkg/reconciler/broker/resources" + "knative.dev/eventing/pkg/reconciler/utils/services" ) const ( @@ -62,7 +63,7 @@ type Reconciler struct { channelableTracker duck.ListableTracker - serviceHelper *reconciler.ServiceHelper + services services.ServiceFlavor ingressImage string ingressServiceAccountName string @@ -255,23 +256,23 @@ func (r *Reconciler) updateStatus(ctx context.Context, desired *v1alpha1.Broker) return b, err } -func (r *Reconciler) reconcileFilterService(ctx context.Context, b *v1alpha1.Broker) (*reconciler.ServiceStatus, error) { +func (r *Reconciler) reconcileFilterService(ctx context.Context, b *v1alpha1.Broker) (*services.Status, error) { svcArgs := resources.MakeFilterServiceArgs(&resources.FilterArgs{ Broker: b, Image: r.filterImage, ServiceAccountName: r.filterServiceAccountName, }) - return r.serviceHelper.ReconcileService(ctx, b, *svcArgs) + return r.services.Reconcile(ctx, b, *svcArgs) } -func (r *Reconciler) reconcileIngressService(ctx context.Context, b *v1alpha1.Broker, c *duckv1alpha1.Channelable) (*reconciler.ServiceStatus, error) { +func (r *Reconciler) reconcileIngressService(ctx context.Context, b *v1alpha1.Broker, c *duckv1alpha1.Channelable) (*services.Status, error) { svcArgs := resources.MakeIngressServiceArgs(&resources.IngressArgs{ Broker: b, Image: r.ingressImage, ServiceAccountName: r.ingressServiceAccountName, ChannelAddress: c.Status.Address.GetURL().Host, }) - return r.serviceHelper.ReconcileService(ctx, b, *svcArgs) + return r.services.Reconcile(ctx, b, *svcArgs) } func newTriggerChannel(b *v1alpha1.Broker) (*unstructured.Unstructured, error) { diff --git a/pkg/reconciler/broker/broker_test.go b/pkg/reconciler/broker/broker_test.go index a2deb02e6b0..90c94e1f485 100644 --- a/pkg/reconciler/broker/broker_test.go +++ b/pkg/reconciler/broker/broker_test.go @@ -39,10 +39,14 @@ import ( "knative.dev/eventing/pkg/reconciler" "knative.dev/eventing/pkg/reconciler/broker/resources" . "knative.dev/eventing/pkg/reconciler/testing" + kubeservice "knative.dev/eventing/pkg/reconciler/utils/services/kube" + servingservice "knative.dev/eventing/pkg/reconciler/utils/services/serving" "knative.dev/eventing/pkg/utils" + kubeclient "knative.dev/pkg/client/injection/kube/client" "knative.dev/pkg/controller" logtesting "knative.dev/pkg/logging/testing" . "knative.dev/pkg/reconciler/testing" + servingclient "knative.dev/serving/pkg/client/injection/client" ) type channelType string @@ -568,13 +572,15 @@ func TestReconcile(t *testing.T) { logger := logtesting.TestLogger(t) table.Test(t, MakeFactory(func(ctx context.Context, listers *Listers, cmw configmap.Watcher) controller.Reconciler { ctx = channelable.WithDuck(ctx) - sh := reconciler.NewServiceHelper( - ctx, listers.GetDeploymentLister(), listers.GetK8sServiceLister(), listers.GetServingServiceLister()) return &Reconciler{ - Base: reconciler.NewBase(ctx, controllerAgentName, cmw), - subscriptionLister: listers.GetSubscriptionLister(), - brokerLister: listers.GetBrokerLister(), - serviceHelper: sh, + Base: reconciler.NewBase(ctx, controllerAgentName, cmw), + subscriptionLister: listers.GetSubscriptionLister(), + brokerLister: listers.GetBrokerLister(), + services: &kubeservice.KubeFlavor{ + KubeClientSet: kubeclient.Get(ctx), + DeploymentLister: listers.GetDeploymentLister(), + ServiceLister: listers.GetK8sServiceLister(), + }, filterImage: filterImage, filterServiceAccountName: filterSA, ingressImage: ingressImage, @@ -595,7 +601,6 @@ func TestReconcileWithServingService(t *testing.T) { Objects: []runtime.Object{ NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions), createChannel(testNS, triggerChannel, true), }, @@ -614,7 +619,6 @@ func TestReconcileWithServingService(t *testing.T) { WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions, WithTriggerChannelReady(), WithBrokerTriggerChannel(createTriggerChannelRef()), @@ -631,7 +635,6 @@ func TestReconcileWithServingService(t *testing.T) { Objects: []runtime.Object{ NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions), createChannel(testNS, triggerChannel, true), NewServingService(filterServiceName, testNS, filterRevisionName, @@ -648,7 +651,6 @@ func TestReconcileWithServingService(t *testing.T) { WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions, WithTriggerChannelReady(), WithBrokerTriggerChannel(createTriggerChannelRef()), @@ -674,7 +676,6 @@ func TestReconcileWithServingService(t *testing.T) { Objects: []runtime.Object{ NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions), createChannel(testNS, triggerChannel, true), NewServingService(filterServiceName, testNS, filterRevisionName, @@ -701,7 +702,6 @@ func TestReconcileWithServingService(t *testing.T) { WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions, WithTriggerChannelReady(), WithFilterDeploymentAvailable(), @@ -719,7 +719,6 @@ func TestReconcileWithServingService(t *testing.T) { Objects: []runtime.Object{ NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions, WithBrokerGeneration(brokerGeneration), ), @@ -755,7 +754,6 @@ func TestReconcileWithServingService(t *testing.T) { WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions, WithBrokerGeneration(brokerGeneration), WithBrokerStatusObservedGeneration(brokerGeneration), @@ -775,7 +773,6 @@ func TestReconcileWithServingService(t *testing.T) { Objects: []runtime.Object{ NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithInitBrokerConditions), createChannel(testNS, triggerChannel, true), NewServingService(filterServiceName, testNS, filterRevisionName, @@ -798,7 +795,6 @@ func TestReconcileWithServingService(t *testing.T) { WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ Object: NewBroker(brokerName, testNS, WithBrokerChannel(channel()), - WithBrokerLabels(map[string]string{"eventing.knative.dev/serviceFlavor": "knative"}), WithBrokerReady, WithBrokerTriggerChannel(createTriggerChannelRef()), WithBrokerAddress(fmt.Sprintf("%s.%s.svc.%s", ingressServiceName, testNS, utils.GetClusterDomainName())), @@ -813,14 +809,14 @@ func TestReconcileWithServingService(t *testing.T) { logger := logtesting.TestLogger(t) table.Test(t, MakeFactory(func(ctx context.Context, listers *Listers, cmw configmap.Watcher) controller.Reconciler { ctx = channelable.WithDuck(ctx) - sh := reconciler.NewServiceHelper( - ctx, listers.GetDeploymentLister(), listers.GetK8sServiceLister(), listers.GetServingServiceLister()) - sh.APIChecker = &fakeAPIChecker{} return &Reconciler{ - Base: reconciler.NewBase(ctx, controllerAgentName, cmw), - subscriptionLister: listers.GetSubscriptionLister(), - brokerLister: listers.GetBrokerLister(), - serviceHelper: sh, + Base: reconciler.NewBase(ctx, controllerAgentName, cmw), + subscriptionLister: listers.GetSubscriptionLister(), + brokerLister: listers.GetBrokerLister(), + services: &servingservice.ServingFlavor{ + ServingClientSet: servingclient.Get(ctx), + ServingLister: listers.GetServingServiceLister(), + }, filterImage: filterImage, filterServiceAccountName: filterSA, ingressImage: ingressImage, diff --git a/pkg/reconciler/broker/controller.go b/pkg/reconciler/broker/controller.go index a52ece05828..9d061f1aeda 100644 --- a/pkg/reconciler/broker/controller.go +++ b/pkg/reconciler/broker/controller.go @@ -26,15 +26,21 @@ import ( "knative.dev/eventing/pkg/apis/eventing/v1alpha1" "knative.dev/eventing/pkg/duck" "knative.dev/eventing/pkg/reconciler" + "knative.dev/eventing/pkg/reconciler/utils/services" "knative.dev/pkg/configmap" "knative.dev/pkg/controller" "knative.dev/eventing/pkg/client/injection/ducks/duck/v1alpha1/channelable" brokerinformer "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/broker" subscriptioninformer "knative.dev/eventing/pkg/client/injection/informers/messaging/v1alpha1/subscription" + servinginformer "knative.dev/eventing/pkg/client/injection/serving/informers/v1/service" + kubeservice "knative.dev/eventing/pkg/reconciler/utils/services/kube" + servingservice "knative.dev/eventing/pkg/reconciler/utils/services/serving" + kubeclient "knative.dev/pkg/client/injection/kube/client" deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment" serviceinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/service" - servinginformer "knative.dev/serving/pkg/client/injection/informers/serving/v1/service" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + servingclient "knative.dev/serving/pkg/client/injection/client" ) const ( @@ -50,6 +56,7 @@ type envConfig struct { IngressServiceAccount string `envconfig:"BROKER_INGRESS_SERVICE_ACCOUNT" required:"true"` FilterImage string `envconfig:"BROKER_FILTER_IMAGE" required:"true"` FilterServiceAccount string `envconfig:"BROKER_FILTER_SERVICE_ACCOUNT" required:"true"` + ResourceFlavor string `envconfig:"BROKER_RESOURCE_FLAVOR"` } // NewController initializes the controller and is called by the generated code @@ -70,6 +77,24 @@ func NewController( serviceInformer := serviceinformer.Get(ctx) servingInformer := servinginformer.Get(ctx) + if env.ResourceFlavor == services.ServingFlavor && servingInformer.IsEmpty() { + log.Fatalf(`BROKER_RESOURCE_FLAVOR is set to %q but %v was not available`, services.ServingFlavor, servingv1.SchemeGroupVersion) + } + + var sf services.ServiceFlavor + if env.ResourceFlavor == services.ServingFlavor { + sf = &servingservice.ServingFlavor{ + ServingClientSet: servingclient.Get(ctx), + ServingLister: servingInformer.GetInternal().Lister(), + } + } else { + sf = &kubeservice.KubeFlavor{ + KubeClientSet: kubeclient.Get(ctx), + DeploymentLister: deploymentInformer.Lister(), + ServiceLister: serviceInformer.Lister(), + } + } + r := &Reconciler{ Base: reconciler.NewBase(ctx, controllerAgentName, cmw), brokerLister: brokerInformer.Lister(), @@ -78,8 +103,7 @@ func NewController( ingressServiceAccountName: env.IngressServiceAccount, filterImage: env.FilterImage, filterServiceAccountName: env.FilterServiceAccount, - serviceHelper: reconciler.NewServiceHelper( - ctx, deploymentInformer.Lister(), serviceInformer.Lister(), servingInformer.Lister()), + services: sf, } impl := controller.NewImpl(r, r.Logger, ReconcilerName) @@ -99,10 +123,12 @@ func NewController( Handler: controller.HandleAll(impl.EnqueueControllerOf), }) - servingInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{ - FilterFunc: controller.Filter(v1alpha1.SchemeGroupVersion.WithKind("Broker")), - Handler: controller.HandleAll(impl.EnqueueControllerOf), - }) + if !servingInformer.IsEmpty() { + servingInformer.GetInternal().Informer().AddEventHandler(cache.FilteringResourceEventHandler{ + FilterFunc: controller.Filter(v1alpha1.SchemeGroupVersion.WithKind("Broker")), + Handler: controller.HandleAll(impl.EnqueueControllerOf), + }) + } return impl } diff --git a/pkg/reconciler/broker/controller_test.go b/pkg/reconciler/broker/controller_test.go index 23205d464da..5530d8a299b 100644 --- a/pkg/reconciler/broker/controller_test.go +++ b/pkg/reconciler/broker/controller_test.go @@ -27,9 +27,9 @@ import ( _ "knative.dev/eventing/pkg/client/injection/ducks/duck/v1alpha1/channelable/fake" _ "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/broker/fake" _ "knative.dev/eventing/pkg/client/injection/informers/messaging/v1alpha1/subscription/fake" + _ "knative.dev/eventing/pkg/client/injection/serving/informers/v1/service/fake" _ "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment/fake" _ "knative.dev/pkg/client/injection/kube/informers/core/v1/service/fake" - _ "knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake" ) func TestNew(t *testing.T) { @@ -46,3 +46,19 @@ func TestNew(t *testing.T) { t.Fatal("Expected NewController to return a non-nil value") } } + +func TestNewWithServing(t *testing.T) { + ctx, _ := SetupFakeContext(t) + + _ = os.Setenv("BROKER_INGRESS_IMAGE", "INGRESS_IMAGE") + _ = os.Setenv("BROKER_INGRESS_SERVICE_ACCOUNT", "INGRESS_SERVICE_ACCOUNT") + _ = os.Setenv("BROKER_FILTER_IMAGE", "FILTER_IMAGE") + _ = os.Setenv("BROKER_FILTER_SERVICE_ACCOUNT", "FILTER_SERVICE_ACCOUNT") + _ = os.Setenv("BROKER_RESOURCE_FLAVOR", "knative") + + c := NewController(ctx, configmap.NewStaticWatcher()) + + if c == nil { + t.Fatal("Expected NewController to return a non-nil value") + } +} diff --git a/pkg/reconciler/broker/resources/filter.go b/pkg/reconciler/broker/resources/filter.go index 4fbe4cedd92..bba32943ada 100644 --- a/pkg/reconciler/broker/resources/filter.go +++ b/pkg/reconciler/broker/resources/filter.go @@ -24,7 +24,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" - "knative.dev/eventing/pkg/reconciler" + "knative.dev/eventing/pkg/reconciler/utils/services" ) const ( @@ -46,8 +46,8 @@ func MakeFilterServiceMeta(b *eventingv1alpha1.Broker) metav1.ObjectMeta { } } -func MakeFilterServiceArgs(args *FilterArgs) *reconciler.ServiceArgs { - return &reconciler.ServiceArgs{ +func MakeFilterServiceArgs(args *FilterArgs) *services.Args { + return &services.Args{ ServiceMeta: MakeFilterServiceMeta(args.Broker), DeployMeta: MakeFilterServiceMeta(args.Broker), PodSpec: corev1.PodSpec{ diff --git a/pkg/reconciler/broker/resources/ingress.go b/pkg/reconciler/broker/resources/ingress.go index 038396b1c24..9b6953380e1 100644 --- a/pkg/reconciler/broker/resources/ingress.go +++ b/pkg/reconciler/broker/resources/ingress.go @@ -24,7 +24,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" - "knative.dev/eventing/pkg/reconciler" + "knative.dev/eventing/pkg/reconciler/utils/services" ) const ( @@ -39,8 +39,8 @@ type IngressArgs struct { ChannelAddress string } -func MakeIngressServiceArgs(args *IngressArgs) *reconciler.ServiceArgs { - return &reconciler.ServiceArgs{ +func MakeIngressServiceArgs(args *IngressArgs) *services.Args { + return &services.Args{ ServiceMeta: metav1.ObjectMeta{ Namespace: args.Broker.Namespace, Name: fmt.Sprintf("%s-broker", args.Broker.Name), diff --git a/pkg/reconciler/service_helper.go b/pkg/reconciler/service_helper.go deleted file mode 100644 index 8183a188b19..00000000000 --- a/pkg/reconciler/service_helper.go +++ /dev/null @@ -1,363 +0,0 @@ -/* -Copyright 2020 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 - - https://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 reconciler - -import ( - "context" - "fmt" - "strings" - - v1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/equality" - apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/client-go/discovery" - "k8s.io/client-go/kubernetes" - appsv1listers "k8s.io/client-go/listers/apps/v1" - corev1listers "k8s.io/client-go/listers/core/v1" - - "knative.dev/eventing/pkg/apis/duck" - "knative.dev/eventing/pkg/reconciler/names" - "knative.dev/pkg/apis" - kubeclient "knative.dev/pkg/client/injection/kube/client" - "knative.dev/pkg/kmeta" - servingcommon "knative.dev/serving/pkg/apis/serving" - servingv1 "knative.dev/serving/pkg/apis/serving/v1" - servingclientset "knative.dev/serving/pkg/client/clientset/versioned" - servingclient "knative.dev/serving/pkg/client/injection/client" - servinglisters "knative.dev/serving/pkg/client/listers/serving/v1" -) - -type ServiceStatus struct { - IsReady bool - URL *apis.URL - Reason string - Message string -} - -type ServiceArgs struct { - ServiceMeta metav1.ObjectMeta - DeployMeta metav1.ObjectMeta - PodSpec corev1.PodSpec -} - -type ServiceHelper struct { - kubeClientSet kubernetes.Interface - servingClientSet servingclientset.Interface - serviceLister corev1listers.ServiceLister - deploymentLister appsv1listers.DeploymentLister - servingLister servinglisters.ServiceLister - APIChecker APIChecker -} - -func NewServiceHelper(ctx context.Context, deploymentLister appsv1listers.DeploymentLister, serviceLister corev1listers.ServiceLister, servingLister servinglisters.ServiceLister) *ServiceHelper { - return &ServiceHelper{ - kubeClientSet: kubeclient.Get(ctx), - servingClientSet: servingclient.Get(ctx), - deploymentLister: deploymentLister, - serviceLister: serviceLister, - servingLister: servingLister, - APIChecker: &apiCheckerImpl{kubeClientSet: kubeclient.Get(ctx)}, - } -} - -type APIChecker interface { - Exists(schema.GroupVersion) error -} - -type apiCheckerImpl struct { - kubeClientSet kubernetes.Interface -} - -func (c *apiCheckerImpl) Exists(s schema.GroupVersion) error { - return discovery.ServerSupportsVersion(c.kubeClientSet.Discovery(), servingv1.SchemeGroupVersion) -} - -func (h *ServiceHelper) ServiceStatus(ctx context.Context, owner kmeta.OwnerRefable, serviceMeta metav1.ObjectMeta) (*ServiceStatus, error) { - useServing, err := h.useServingService(ctx, owner) - if err != nil { - return nil, err - } - - if useServing { - existing, err := h.servingLister.Services(serviceMeta.Namespace).Get(serviceMeta.Name) - if err != nil { - return nil, err - } - return servingServiceStatus(existing), nil - } - - existing, err := h.serviceLister.Services(serviceMeta.Namespace).Get(serviceMeta.Name) - if err != nil { - return nil, err - } - return &ServiceStatus{ - IsReady: true, - URL: &apis.URL{ - Scheme: "http", - Host: names.ServiceHostName(existing.Name, existing.Namespace), - }, - }, nil -} - -func (h *ServiceHelper) ReconcileService(ctx context.Context, owner kmeta.OwnerRefable, args ServiceArgs) (*ServiceStatus, error) { - if err := validateArgs(args); err != nil { - return nil, err - } - - useServing, err := h.useServingService(ctx, owner) - if err != nil { - return nil, err - } - - // Make sure the service metadata has proper owner reference. - args.ServiceMeta.OwnerReferences = append(args.ServiceMeta.OwnerReferences, *kmeta.NewControllerRef(owner)) - - if useServing { - return h.reconcileServingService(ctx, args) - } - - return h.reconcileDeploymentService(ctx, owner, args) -} - -func validateArgs(args ServiceArgs) error { - if !strings.HasPrefix(args.DeployMeta.Name, args.ServiceMeta.Name) { - return fmt.Errorf("service name must be a prefix of deployment name") - } - if err := servingcommon.ValidatePodSpec(args.PodSpec); err != nil { - return err - } - if len(args.PodSpec.Containers[0].Ports) == 0 { - args.PodSpec.Containers[0].Ports = []corev1.ContainerPort{ - { - ContainerPort: 8080, - }, - } - } - return nil -} - -func (h *ServiceHelper) reconcileServingService(ctx context.Context, args ServiceArgs) (*ServiceStatus, error) { - // Serving service requires a strict prefix. - // Add "-rev" to make it strict prefix. - args.DeployMeta.Name = args.DeployMeta.Name + "-rev" - - // Just for testing purpose. - // if args.DeployMeta.Annotations == nil { - // args.DeployMeta.Annotations = make(map[string]string) - // } - // args.DeployMeta.Annotations["autoscaling.knative.dev/minScale"] = "1" - - // Always use cluster local service. - if args.ServiceMeta.Labels == nil { - args.ServiceMeta.Labels = make(map[string]string) - } - args.ServiceMeta.Labels["serving.knative.dev/visibility"] = "cluster-local" - - svc := &servingv1.Service{ - ObjectMeta: args.ServiceMeta, - Spec: servingv1.ServiceSpec{ - ConfigurationSpec: servingv1.ConfigurationSpec{ - Template: servingv1.RevisionTemplateSpec{ - ObjectMeta: args.DeployMeta, - Spec: servingv1.RevisionSpec{ - PodSpec: args.PodSpec, - }, - }, - }, - }, - } - - existing, err := h.servingLister.Services(args.ServiceMeta.Namespace).Get(args.ServiceMeta.Name) - if apierrors.IsNotFound(err) { - existing, err = h.servingClientSet.ServingV1().Services(args.ServiceMeta.Namespace).Create(svc) - if err != nil { - return nil, fmt.Errorf("failed to create serving service: %w", err) - } - return servingServiceStatus(existing), nil - } else if err != nil { - return nil, fmt.Errorf("failed to get existing serving service: %w", err) - } - - if !equality.Semantic.DeepDerivative(svc.Spec, existing.Spec) { - desired := existing.DeepCopy() - desired.Spec = svc.Spec - existing, err = h.servingClientSet.ServingV1().Services(args.ServiceMeta.Namespace).Update(desired) - if err != nil { - return nil, fmt.Errorf("failed to update serving service: %w", err) - } - } - - return servingServiceStatus(existing), nil -} - -func servingServiceStatus(svc *servingv1.Service) *ServiceStatus { - cond := svc.Status.GetCondition(apis.ConditionReady) - ss := &ServiceStatus{ - IsReady: svc.Status.IsReady(), - URL: svc.Status.URL, - } - if cond != nil { - ss.Message = cond.Message - ss.Reason = cond.Reason - } - return ss -} - -func (h *ServiceHelper) reconcileDeploymentService(ctx context.Context, owner kmeta.OwnerRefable, args ServiceArgs) (*ServiceStatus, error) { - // Make sure the deployment metadata has proper owner reference. - args.DeployMeta.OwnerReferences = append(args.DeployMeta.OwnerReferences, *kmeta.NewControllerRef(owner)) - args.PodSpec.Containers[0].Ports[0].Name = "http" - userPort := args.PodSpec.Containers[0].Ports[0].ContainerPort - - if args.PodSpec.Containers[0].LivenessProbe != nil { - if args.PodSpec.Containers[0].LivenessProbe.HTTPGet != nil { - args.PodSpec.Containers[0].LivenessProbe.HTTPGet.Port = intstr.FromInt(int(userPort)) - } - } - if args.PodSpec.Containers[0].ReadinessProbe != nil { - if args.PodSpec.Containers[0].ReadinessProbe.HTTPGet != nil { - args.PodSpec.Containers[0].ReadinessProbe.HTTPGet.Port = intstr.FromInt(int(userPort)) - } - } - - d := &v1.Deployment{ - ObjectMeta: args.DeployMeta, - Spec: v1.DeploymentSpec{ - Selector: &metav1.LabelSelector{ - MatchLabels: args.DeployMeta.Labels, - }, - Template: corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: args.DeployMeta.Labels, - }, - Spec: args.PodSpec, - }, - }, - } - rd, err := h.reconcileDeployment(ctx, d) - if err != nil { - return nil, err - } - - svc := &corev1.Service{ - ObjectMeta: args.ServiceMeta, - Spec: corev1.ServiceSpec{ - Selector: args.DeployMeta.Labels, - Ports: []corev1.ServicePort{ - { - Name: "http", - Port: 80, - TargetPort: intstr.FromInt(int(userPort)), - }, - }, - }, - } - rsvc, err := h.reconcileService(ctx, svc) - if err != nil { - return nil, err - } - - if duck.DeploymentIsAvailable(&rd.Status, true) { - return &ServiceStatus{ - IsReady: true, - URL: &apis.URL{ - Scheme: "http", - Host: names.ServiceHostName(rsvc.Name, rsvc.Namespace), - }, - }, nil - } - - return &ServiceStatus{ - IsReady: false, - Reason: "DeploymentUnavailable", - Message: fmt.Sprintf("The Deployment %q is unavailable", rd.Name), - }, nil -} - -func (h *ServiceHelper) reconcileDeployment(ctx context.Context, d *v1.Deployment) (*v1.Deployment, error) { - existing, err := h.deploymentLister.Deployments(d.Namespace).Get(d.Name) - if apierrors.IsNotFound(err) { - existing, err = h.kubeClientSet.AppsV1().Deployments(d.Namespace).Create(d) - if err != nil { - return nil, fmt.Errorf("failed to create deployment: %w", err) - } - return existing, nil - } else if err != nil { - return nil, fmt.Errorf("failed to get existing deployment: %w", err) - } - - if !equality.Semantic.DeepDerivative(d.Spec, existing.Spec) { - // Don't modify the informers copy. - desired := existing.DeepCopy() - desired.Spec = d.Spec - existing, err = h.kubeClientSet.AppsV1().Deployments(existing.Namespace).Update(desired) - if err != nil { - return nil, fmt.Errorf("failed to update deployment: %w", err) - } - } - return existing, nil -} - -// reconcileService reconciles the K8s Service 'svc'. -func (h *ServiceHelper) reconcileService(ctx context.Context, svc *corev1.Service) (*corev1.Service, error) { - existing, err := h.serviceLister.Services(svc.Namespace).Get(svc.Name) - if apierrors.IsNotFound(err) { - existing, err = h.kubeClientSet.CoreV1().Services(svc.Namespace).Create(svc) - if err != nil { - return nil, fmt.Errorf("failed to create service: %w", err) - } - return existing, nil - } else if err != nil { - return nil, fmt.Errorf("failed to get existing service: %w", err) - } - - // spec.clusterIP is immutable and is set on existing services. If we don't set this to the same value, we will - // encounter an error while updating. - svc.Spec.ClusterIP = existing.Spec.ClusterIP - if !equality.Semantic.DeepDerivative(svc.Spec, existing.Spec) { - // Don't modify the informers copy. - desired := existing.DeepCopy() - desired.Spec = svc.Spec - existing, err = h.kubeClientSet.CoreV1().Services(existing.Namespace).Update(desired) - if err != nil { - return nil, fmt.Errorf("failed to update service: %w", err) - } - } - return existing, nil -} - -func (h *ServiceHelper) useServingService(ctx context.Context, owner kmeta.OwnerRefable) (bool, error) { - if v, ok := owner.GetObjectMeta().GetLabels()["eventing.knative.dev/serviceFlavor"]; !ok && v != "knative" { - return false, nil - } - - // TODO: changing the label after broker creation is dangerous. - // In the webhook we should make it immutable. - - if err := h.APIChecker.Exists(servingv1.SchemeGroupVersion); err != nil { - if strings.Contains(err.Error(), "server does not support API version") { - return false, err - } - return false, fmt.Errorf("failed to check serving API version: %w", err) - } - - return true, nil -} diff --git a/pkg/reconciler/trigger/controller.go b/pkg/reconciler/trigger/controller.go index c7ad5f2de33..72fb73dcad3 100644 --- a/pkg/reconciler/trigger/controller.go +++ b/pkg/reconciler/trigger/controller.go @@ -18,7 +18,10 @@ package trigger import ( "context" + "log" + "github.com/kelseyhightower/envconfig" + "go.uber.org/zap" "k8s.io/client-go/tools/cache" "knative.dev/pkg/client/injection/ducks/duck/v1/conditions" "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/addressable" @@ -31,14 +34,20 @@ import ( "knative.dev/eventing/pkg/apis/eventing/v1alpha1" "knative.dev/eventing/pkg/duck" "knative.dev/eventing/pkg/reconciler" + "knative.dev/eventing/pkg/reconciler/utils/services" "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/broker" "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/trigger" "knative.dev/eventing/pkg/client/injection/informers/messaging/v1alpha1/subscription" + servinginformer "knative.dev/eventing/pkg/client/injection/serving/informers/v1/service" + kubeservice "knative.dev/eventing/pkg/reconciler/utils/services/kube" + servingservice "knative.dev/eventing/pkg/reconciler/utils/services/serving" + kubeclient "knative.dev/pkg/client/injection/kube/client" deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment" serviceinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/service" - servinginformer "knative.dev/serving/pkg/client/injection/informers/serving/v1/service" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + servingclient "knative.dev/serving/pkg/client/injection/client" ) const ( @@ -50,6 +59,10 @@ const ( controllerAgentName = "trigger-controller" ) +type envConfig struct { + ResourceFlavor string `envconfig:"BROKER_RESOURCE_FLAVOR"` +} + // NewController initializes the controller and is called by the generated code. // Registers event handlers to enqueue events. func NewController( @@ -57,6 +70,11 @@ func NewController( cmw configmap.Watcher, ) *controller.Impl { + var env envConfig + if err := envconfig.Process("", &env); err != nil { + log.Fatal("Failed to process env var", zap.Error(err)) + } + triggerInformer := trigger.Get(ctx) subscriptionInformer := subscription.Get(ctx) brokerInformer := broker.Get(ctx) @@ -65,14 +83,31 @@ func NewController( serviceInformer := serviceinformer.Get(ctx) servingInformer := servinginformer.Get(ctx) + if env.ResourceFlavor == services.ServingFlavor && servingInformer.IsEmpty() { + log.Fatalf(`BROKER_RESOURCE_FLAVOR is set to %q but %v was not available`, services.ServingFlavor, servingv1.SchemeGroupVersion) + } + + var sf services.ServiceFlavor + if env.ResourceFlavor == services.ServingFlavor { + sf = &servingservice.ServingFlavor{ + ServingClientSet: servingclient.Get(ctx), + ServingLister: servingInformer.GetInternal().Lister(), + } + } else { + sf = &kubeservice.KubeFlavor{ + KubeClientSet: kubeclient.Get(ctx), + DeploymentLister: deploymentInformer.Lister(), + ServiceLister: serviceInformer.Lister(), + } + } + r := &Reconciler{ Base: reconciler.NewBase(ctx, controllerAgentName, cmw), triggerLister: triggerInformer.Lister(), subscriptionLister: subscriptionInformer.Lister(), brokerLister: brokerInformer.Lister(), namespaceLister: namespaceInformer.Lister(), - serviceHelper: reconciler.NewServiceHelper( - ctx, deploymentInformer.Lister(), serviceInformer.Lister(), servingInformer.Lister()), + services: sf, } impl := controller.NewImpl(r, r.Logger, ReconcilerName) diff --git a/pkg/reconciler/trigger/controller_test.go b/pkg/reconciler/trigger/controller_test.go index 953773a18ba..1d3c9160700 100644 --- a/pkg/reconciler/trigger/controller_test.go +++ b/pkg/reconciler/trigger/controller_test.go @@ -17,6 +17,7 @@ limitations under the License. package trigger import ( + "os" "testing" "knative.dev/pkg/configmap" @@ -34,6 +35,7 @@ import ( _ "knative.dev/pkg/client/injection/kube/informers/core/v1/namespace/fake" _ "knative.dev/pkg/client/injection/kube/informers/core/v1/service/fake" _ "knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake" + _ "knative.dev/eventing/pkg/client/injection/serving/informers/v1/service/fake" ) func TestNew(t *testing.T) { @@ -45,3 +47,14 @@ func TestNew(t *testing.T) { t.Fatal("Expected NewController to return a non-nil value") } } + +func TestNewWithServing(t *testing.T) { + _ = os.Setenv("BROKER_RESOURCE_FLAVOR", "knative") + ctx, _ := SetupFakeContext(t) + + c := NewController(ctx, configmap.NewStaticWatcher()) + + if c == nil { + t.Fatal("Expected NewController to return a non-nil value") + } +} diff --git a/pkg/reconciler/trigger/trigger.go b/pkg/reconciler/trigger/trigger.go index 49907dc443d..c31721071c1 100644 --- a/pkg/reconciler/trigger/trigger.go +++ b/pkg/reconciler/trigger/trigger.go @@ -47,6 +47,7 @@ import ( brokerresources "knative.dev/eventing/pkg/reconciler/broker/resources" "knative.dev/eventing/pkg/reconciler/trigger/path" "knative.dev/eventing/pkg/reconciler/trigger/resources" + "knative.dev/eventing/pkg/reconciler/utils/services" ) const ( @@ -77,7 +78,7 @@ type Reconciler struct { addressableTracker duck.ListableTracker uriResolver *resolver.URIResolver - serviceHelper *reconciler.ServiceHelper + services services.ServiceFlavor } var brokerGVK = v1alpha1.SchemeGroupVersion.WithKind("Broker") @@ -191,7 +192,7 @@ func (r *Reconciler) reconcile(ctx context.Context, t *v1alpha1.Trigger) error { } // Get Broker filter service. - filterSvcStatus, err := r.serviceHelper.ServiceStatus(ctx, b, brokerresources.MakeFilterServiceMeta(b)) + filterSvcStatus, err := r.services.GetStatus(ctx, b, brokerresources.MakeFilterServiceMeta(b)) if err != nil { if apierrs.IsNotFound(err) { logging.FromContext(ctx).Error("can not find Broker's Filter service", zap.Error(err)) diff --git a/pkg/reconciler/trigger/trigger_test.go b/pkg/reconciler/trigger/trigger_test.go index 7fb9d95859d..f3af8f24e9f 100644 --- a/pkg/reconciler/trigger/trigger_test.go +++ b/pkg/reconciler/trigger/trigger_test.go @@ -26,6 +26,7 @@ import ( "knative.dev/pkg/client/injection/ducks/duck/v1/conditions" v1a1addr "knative.dev/pkg/client/injection/ducks/duck/v1alpha1/addressable" v1b1addr "knative.dev/pkg/client/injection/ducks/duck/v1beta1/addressable" + kubeclient "knative.dev/pkg/client/injection/kube/client" "knative.dev/pkg/resolver" corev1 "k8s.io/api/core/v1" @@ -51,11 +52,15 @@ import ( brokerresources "knative.dev/eventing/pkg/reconciler/broker/resources" reconciletesting "knative.dev/eventing/pkg/reconciler/testing" "knative.dev/eventing/pkg/reconciler/trigger/resources" + "knative.dev/eventing/pkg/reconciler/utils/services" + kubeservice "knative.dev/eventing/pkg/reconciler/utils/services/kube" + servingservice "knative.dev/eventing/pkg/reconciler/utils/services/serving" "knative.dev/eventing/pkg/utils" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" servingv1 "knative.dev/serving/pkg/apis/serving/v1" + servingclient "knative.dev/serving/pkg/client/injection/client" . "knative.dev/eventing/pkg/reconciler/testing" . "knative.dev/pkg/reconciler/testing" @@ -140,16 +145,27 @@ func init() { } func TestAllCases(t *testing.T) { - testAllCases(t, makeBroker(), makeBrokerFilterService()) + svcFunc := func(ctx context.Context, listers *Listers) services.ServiceFlavor { + return &kubeservice.KubeFlavor{ + KubeClientSet: kubeclient.Get(ctx), + DeploymentLister: listers.GetDeploymentLister(), + ServiceLister: listers.GetK8sServiceLister(), + } + } + testAllCases(t, makeBrokerFilterService(), svcFunc) } func TestAllCasesWithServingServiceBroker(t *testing.T) { - b := makeBroker() - b.Labels = map[string]string{"eventing.knative.dev/serviceFlavor": "knative"} - testAllCases(t, b, makeBrokerFilterServingService()) + svcFunc := func(ctx context.Context, listers *Listers) services.ServiceFlavor { + return &servingservice.ServingFlavor{ + ServingClientSet: servingclient.Get(ctx), + ServingLister: listers.GetServingServiceLister(), + } + } + testAllCases(t, makeBrokerFilterServingService(), svcFunc) } -func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Object) { +func testAllCases(t *testing.T, brokerFilterSvc runtime.Object, svcFunc func(context.Context, *Listers) services.ServiceFlavor) { triggerKey := testNS + "/" + triggerName table := TableTest{ { @@ -286,7 +302,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Default broker found, with injection annotation enabled", Key: triggerKey, Objects: []runtime.Object{ - makeReadyDefaultBroker(b), + makeReadyDefaultBroker(makeBroker()), reconciletesting.NewTrigger(triggerName, testNS, "default", reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberURI(subscriberURI), @@ -362,7 +378,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "The status of Broker is Unknown", Key: triggerKey, Objects: []runtime.Object{ - makeUnknownStatusBroker(b), + makeUnknownStatusBroker(makeBroker()), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberURI(subscriberURI)), @@ -399,7 +415,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "No Broker Trigger Channel", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBrokerNoTriggerChannel(b), + makeReadyBrokerNoTriggerChannel(makeBroker()), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberURI(subscriberURI), @@ -424,7 +440,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "No Broker Filter Service", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), reconciletesting.WithTriggerSubscriberURI(subscriberURI), @@ -452,7 +468,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Subscription not owned by Trigger", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeIngressSubscriptionNotOwnedByTrigger(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -480,7 +496,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Subscription create fail", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -514,7 +530,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Subscription delete fail", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeDifferentReadySubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -549,7 +565,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Subscription create after delete fail", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeDifferentReadySubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -587,7 +603,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Subscription updated works", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeDifferentReadySubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -623,7 +639,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Subscription Created, not ready", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -655,7 +671,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Trigger has subscriber ref exists", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeSubscriberAddressableAsUnstructured(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -688,7 +704,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Trigger has subscriber ref exists and URI", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeSubscriberAddressableAsUnstructured(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -721,7 +737,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Trigger has subscriber ref exists kubernetes Service", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeSubscriberKubernetesServiceAsUnstructured(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -754,7 +770,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Trigger has subscriber ref doesn't exist", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, reconciletesting.NewTrigger(triggerName, testNS, brokerName, reconciletesting.WithTriggerUID(triggerUID), @@ -780,7 +796,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Subscription not ready, trigger marked not ready", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeFalseStatusSubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -810,7 +826,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Subscription ready, trigger marked ready", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeReadySubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -841,7 +857,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Dependency doesn't exist", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeReadySubscription(), reconciletesting.NewTrigger(triggerName, testNS, brokerName, @@ -873,7 +889,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "The status of Dependency is False", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeReadySubscription(), makeFalseStatusCronJobSource(), @@ -905,7 +921,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "The status of Dependency is Unknown", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeReadySubscription(), makeUnknownStatusCronJobSource(), @@ -938,7 +954,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Dependency generation not equal", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeReadySubscription(), makeGenerationNotEqualCronJobSource(), @@ -970,7 +986,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje Name: "Dependency ready", Key: triggerKey, Objects: []runtime.Object{ - makeReadyBroker(b), + makeReadyBroker(makeBroker()), brokerFilterSvc, makeReadySubscription(), makeReadyCronJobSource(), @@ -1008,9 +1024,6 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje ctx = v1b1addr.WithDuck(ctx) ctx = v1addr.WithDuck(ctx) ctx = conditions.WithDuck(ctx) - sh := reconciler.NewServiceHelper( - ctx, listers.GetDeploymentLister(), listers.GetK8sServiceLister(), listers.GetServingServiceLister()) - sh.APIChecker = &fakeAPIChecker{} return &Reconciler{ Base: reconciler.NewBase(ctx, controllerAgentName, cmw), triggerLister: listers.GetTriggerLister(), @@ -1021,7 +1034,7 @@ func testAllCases(t *testing.T, b *v1alpha1.Broker, brokerFilterSvc runtime.Obje addressableTracker: duck.NewListableTracker(ctx, v1a1addr.Get, func(types.NamespacedName) {}, 0), kresourceTracker: duck.NewListableTracker(ctx, conditions.Get, func(types.NamespacedName) {}, 0), uriResolver: resolver.NewURIResolver(ctx, func(types.NamespacedName) {}), - serviceHelper: sh, + services: svcFunc(ctx, listers), } }, false, diff --git a/pkg/reconciler/utils/services/base.go b/pkg/reconciler/utils/services/base.go new file mode 100644 index 00000000000..bc57f4a14b1 --- /dev/null +++ b/pkg/reconciler/utils/services/base.go @@ -0,0 +1,76 @@ +/* +Copyright 2020 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 services + +import ( + "context" + "fmt" + "strings" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "knative.dev/pkg/apis" + "knative.dev/pkg/kmeta" + servingcommon "knative.dev/serving/pkg/apis/serving" +) + +const ( + // ServingFlavor is the Knative Serving service flavor. + ServingFlavor = "knative" +) + +// Status represents the status of a service. +type Status struct { + IsReady bool + URL *apis.URL + Reason string + Message string +} + +// Args is the arguments to reconcile a service. +type Args struct { + ServiceMeta metav1.ObjectMeta + DeployMeta metav1.ObjectMeta + PodSpec corev1.PodSpec +} + +// ServiceFlavor is the interface to a service implementation. +type ServiceFlavor interface { + // Reconcile reconciles a service. + Reconcile(context.Context, kmeta.OwnerRefable, Args) (*Status, error) + // GetStatus get the status of a service. + GetStatus(context.Context, kmeta.OwnerRefable, metav1.ObjectMeta) (*Status, error) +} + +// ValidateArgs validates the arguments to create a service. +func ValidateArgs(args Args) error { + if !strings.HasPrefix(args.DeployMeta.Name, args.ServiceMeta.Name) { + return fmt.Errorf("service name must be a prefix of deployment name") + } + if err := servingcommon.ValidatePodSpec(args.PodSpec); err != nil { + return err + } + if len(args.PodSpec.Containers[0].Ports) == 0 { + args.PodSpec.Containers[0].Ports = []corev1.ContainerPort{ + { + ContainerPort: 8080, + }, + } + } + return nil +} diff --git a/pkg/reconciler/utils/services/kube/kube.go b/pkg/reconciler/utils/services/kube/kube.go new file mode 100644 index 00000000000..4de834f5c82 --- /dev/null +++ b/pkg/reconciler/utils/services/kube/kube.go @@ -0,0 +1,189 @@ +/* +Copyright 2020 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 kube + +import ( + "context" + "fmt" + + v1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/equality" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/client-go/kubernetes" + appsv1listers "k8s.io/client-go/listers/apps/v1" + corev1listers "k8s.io/client-go/listers/core/v1" + + "knative.dev/eventing/pkg/apis/duck" + "knative.dev/eventing/pkg/reconciler/names" + "knative.dev/eventing/pkg/reconciler/utils/services" + "knative.dev/pkg/apis" + "knative.dev/pkg/kmeta" +) + +type KubeFlavor struct { + KubeClientSet kubernetes.Interface + ServiceLister corev1listers.ServiceLister + DeploymentLister appsv1listers.DeploymentLister +} + +func (k *KubeFlavor) Reconcile(ctx context.Context, owner kmeta.OwnerRefable, args services.Args) (*services.Status, error) { + if err := services.ValidateArgs(args); err != nil { + return nil, err + } + fillDefaults(&args, owner) + + d := &v1.Deployment{ + ObjectMeta: args.DeployMeta, + Spec: v1.DeploymentSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: args.DeployMeta.Labels, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: args.DeployMeta.Labels, + }, + Spec: args.PodSpec, + }, + }, + } + rd, err := k.reconcileDeployment(ctx, d) + if err != nil { + return nil, err + } + + svc := &corev1.Service{ + ObjectMeta: args.ServiceMeta, + Spec: corev1.ServiceSpec{ + Selector: args.DeployMeta.Labels, + Ports: []corev1.ServicePort{ + { + Name: "http", + Port: 80, + TargetPort: intstr.FromInt(int(args.PodSpec.Containers[0].Ports[0].ContainerPort)), + }, + }, + }, + } + rsvc, err := k.reconcileService(ctx, svc) + if err != nil { + return nil, err + } + + if duck.DeploymentIsAvailable(&rd.Status, true) { + return &services.Status{ + IsReady: true, + URL: &apis.URL{ + Scheme: "http", + Host: names.ServiceHostName(rsvc.Name, rsvc.Namespace), + }, + }, nil + } + + return &services.Status{ + IsReady: false, + Reason: "DeploymentUnavailable", + Message: fmt.Sprintf("The Deployment %q is unavailable", rd.Name), + }, nil +} + +func (k *KubeFlavor) GetStatus(ctx context.Context, owner kmeta.OwnerRefable, svcMeta metav1.ObjectMeta) (*services.Status, error) { + existing, err := k.ServiceLister.Services(svcMeta.Namespace).Get(svcMeta.Name) + if err != nil { + return nil, err + } + return &services.Status{ + IsReady: true, + URL: &apis.URL{ + Scheme: "http", + Host: names.ServiceHostName(existing.Name, existing.Namespace), + }, + }, nil +} + +func fillDefaults(args *services.Args, owner kmeta.OwnerRefable) { + // Make sure the service metadata has proper owner reference. + args.ServiceMeta.OwnerReferences = append(args.ServiceMeta.OwnerReferences, *kmeta.NewControllerRef(owner)) + args.DeployMeta.OwnerReferences = append(args.DeployMeta.OwnerReferences, *kmeta.NewControllerRef(owner)) + args.PodSpec.Containers[0].Ports[0].Name = "http" + userPort := args.PodSpec.Containers[0].Ports[0].ContainerPort + + if args.PodSpec.Containers[0].LivenessProbe != nil { + if args.PodSpec.Containers[0].LivenessProbe.HTTPGet != nil { + args.PodSpec.Containers[0].LivenessProbe.HTTPGet.Port = intstr.FromInt(int(userPort)) + } + } + if args.PodSpec.Containers[0].ReadinessProbe != nil { + if args.PodSpec.Containers[0].ReadinessProbe.HTTPGet != nil { + args.PodSpec.Containers[0].ReadinessProbe.HTTPGet.Port = intstr.FromInt(int(userPort)) + } + } +} + +func (k *KubeFlavor) reconcileDeployment(ctx context.Context, d *v1.Deployment) (*v1.Deployment, error) { + existing, err := k.DeploymentLister.Deployments(d.Namespace).Get(d.Name) + if apierrors.IsNotFound(err) { + existing, err = k.KubeClientSet.AppsV1().Deployments(d.Namespace).Create(d) + if err != nil { + return nil, fmt.Errorf("failed to create deployment: %w", err) + } + return existing, nil + } else if err != nil { + return nil, fmt.Errorf("failed to get existing deployment: %w", err) + } + + if !equality.Semantic.DeepDerivative(d.Spec, existing.Spec) { + // Don't modify the informers copy. + desired := existing.DeepCopy() + desired.Spec = d.Spec + existing, err = k.KubeClientSet.AppsV1().Deployments(existing.Namespace).Update(desired) + if err != nil { + return nil, fmt.Errorf("failed to update deployment: %w", err) + } + } + return existing, nil +} + +// reconcileService reconciles the K8s Service 'svc'. +func (k *KubeFlavor) reconcileService(ctx context.Context, svc *corev1.Service) (*corev1.Service, error) { + existing, err := k.ServiceLister.Services(svc.Namespace).Get(svc.Name) + if apierrors.IsNotFound(err) { + existing, err = k.KubeClientSet.CoreV1().Services(svc.Namespace).Create(svc) + if err != nil { + return nil, fmt.Errorf("failed to create service: %w", err) + } + return existing, nil + } else if err != nil { + return nil, fmt.Errorf("failed to get existing service: %w", err) + } + + // spec.clusterIP is immutable and is set on existing services. If we don't set this to the same value, we will + // encounter an error while updating. + svc.Spec.ClusterIP = existing.Spec.ClusterIP + if !equality.Semantic.DeepDerivative(svc.Spec, existing.Spec) { + // Don't modify the informers copy. + desired := existing.DeepCopy() + desired.Spec = svc.Spec + existing, err = k.KubeClientSet.CoreV1().Services(existing.Namespace).Update(desired) + if err != nil { + return nil, fmt.Errorf("failed to update service: %w", err) + } + } + return existing, nil +} diff --git a/pkg/reconciler/utils/services/serving/serving.go b/pkg/reconciler/utils/services/serving/serving.go new file mode 100644 index 00000000000..64ad98ac5c1 --- /dev/null +++ b/pkg/reconciler/utils/services/serving/serving.go @@ -0,0 +1,121 @@ +/* +Copyright 2020 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 serving + +import ( + "context" + "fmt" + + "k8s.io/apimachinery/pkg/api/equality" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/eventing/pkg/reconciler/utils/services" + "knative.dev/pkg/apis" + "knative.dev/pkg/kmeta" + servingv1 "knative.dev/serving/pkg/apis/serving/v1" + servingclientset "knative.dev/serving/pkg/client/clientset/versioned" + servinglisters "knative.dev/serving/pkg/client/listers/serving/v1" +) + +type ServingFlavor struct { + ServingClientSet servingclientset.Interface + ServingLister servinglisters.ServiceLister +} + +func (s *ServingFlavor) Reconcile(ctx context.Context, owner kmeta.OwnerRefable, args services.Args) (*services.Status, error) { + if err := services.ValidateArgs(args); err != nil { + return nil, err + } + fillDefaults(&args, owner) + + svc := &servingv1.Service{ + ObjectMeta: args.ServiceMeta, + Spec: servingv1.ServiceSpec{ + ConfigurationSpec: servingv1.ConfigurationSpec{ + Template: servingv1.RevisionTemplateSpec{ + ObjectMeta: args.DeployMeta, + Spec: servingv1.RevisionSpec{ + PodSpec: args.PodSpec, + }, + }, + }, + }, + } + + existing, err := s.ServingLister.Services(args.ServiceMeta.Namespace).Get(args.ServiceMeta.Name) + if apierrors.IsNotFound(err) { + existing, err = s.ServingClientSet.ServingV1().Services(args.ServiceMeta.Namespace).Create(svc) + if err != nil { + return nil, fmt.Errorf("failed to create serving service: %w", err) + } + return servingServiceStatus(existing), nil + } else if err != nil { + return nil, fmt.Errorf("failed to get existing serving service: %w", err) + } + + if !equality.Semantic.DeepDerivative(svc.Spec, existing.Spec) { + desired := existing.DeepCopy() + desired.Spec = svc.Spec + existing, err = s.ServingClientSet.ServingV1().Services(args.ServiceMeta.Namespace).Update(desired) + if err != nil { + return nil, fmt.Errorf("failed to update serving service: %w", err) + } + } + + return servingServiceStatus(existing), nil +} + +func (s *ServingFlavor) GetStatus(ctx context.Context, owner kmeta.OwnerRefable, svcMeta metav1.ObjectMeta) (*services.Status, error) { + existing, err := s.ServingLister.Services(svcMeta.Namespace).Get(svcMeta.Name) + if err != nil { + return nil, err + } + return servingServiceStatus(existing), nil +} + +func fillDefaults(args *services.Args, owner kmeta.OwnerRefable) { + // Make sure the service metadata has proper owner reference. + args.ServiceMeta.OwnerReferences = append(args.ServiceMeta.OwnerReferences, *kmeta.NewControllerRef(owner)) + // Serving service requires a strict prefix. + // Add "-rev" to make it strict prefix. + args.DeployMeta.Name = args.DeployMeta.Name + "-rev" + + // Just for testing purpose. + // if args.DeployMeta.Annotations == nil { + // args.DeployMeta.Annotations = make(map[string]string) + // } + // args.DeployMeta.Annotations["autoscaling.knative.dev/minScale"] = "1" + + // Always use cluster local service. + if args.ServiceMeta.Labels == nil { + args.ServiceMeta.Labels = make(map[string]string) + } + args.ServiceMeta.Labels["serving.knative.dev/visibility"] = "cluster-local" +} + +func servingServiceStatus(svc *servingv1.Service) *services.Status { + cond := svc.Status.GetCondition(apis.ConditionReady) + ss := &services.Status{ + IsReady: svc.Status.IsReady(), + URL: svc.Status.URL, + } + if cond != nil { + ss.Message = cond.Message + ss.Reason = cond.Reason + } + return ss +} From 44df9b30da7999af15589c0e7d26038457f7e0d6 Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Mon, 27 Jan 2020 06:14:14 +0000 Subject: [PATCH 07/11] workaround the informer issue --- .../serving/informers/v1/emptyable.go | 36 -- .../serving/informers/v1/service/fake/fake.go | 34 +- .../serving/informers/v1/service/service.go | 48 +- pkg/reconciler/broker/broker.go | 15 +- pkg/reconciler/broker/broker_test.go | 8 +- pkg/reconciler/broker/controller.go | 20 +- pkg/reconciler/broker/resources/filter.go | 6 +- pkg/reconciler/broker/resources/ingress.go | 6 +- .../{utils/services => service}/base.go | 19 +- .../{utils/services => service}/kube/kube.go | 52 +- pkg/reconciler/service/kube/kube_test.go | 516 ++++++++++++++++++ .../services => service}/serving/serving.go | 36 +- .../service/serving/serving_test.go | 401 ++++++++++++++ pkg/reconciler/service/testing/owner.go | 32 ++ pkg/reconciler/service/testing/pod.go | 57 ++ pkg/reconciler/testing/deployment.go | 17 + pkg/reconciler/testing/serving_service.go | 6 + pkg/reconciler/trigger/controller.go | 20 +- pkg/reconciler/trigger/trigger.go | 6 +- pkg/reconciler/trigger/trigger_test.go | 18 +- 20 files changed, 1162 insertions(+), 191 deletions(-) delete mode 100644 pkg/client/injection/serving/informers/v1/emptyable.go rename pkg/reconciler/{utils/services => service}/base.go (76%) rename pkg/reconciler/{utils/services => service}/kube/kube.go (74%) create mode 100644 pkg/reconciler/service/kube/kube_test.go rename pkg/reconciler/{utils/services => service}/serving/serving.go (72%) create mode 100644 pkg/reconciler/service/serving/serving_test.go create mode 100644 pkg/reconciler/service/testing/owner.go create mode 100644 pkg/reconciler/service/testing/pod.go diff --git a/pkg/client/injection/serving/informers/v1/emptyable.go b/pkg/client/injection/serving/informers/v1/emptyable.go deleted file mode 100644 index 3cea4d5e360..00000000000 --- a/pkg/client/injection/serving/informers/v1/emptyable.go +++ /dev/null @@ -1,36 +0,0 @@ -/* -Copyright 2020 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 service - -import v1 "knative.dev/serving/pkg/client/informers/externalversions/serving/v1" - -// EmptyableServiceInformer is an "emptyable" version of v1.ServiceInformer. -type EmptyableServiceInformer interface { - // IsEmpty returns whether the informer is empty. - IsEmpty() bool - - // GetInternal returns the internal v1.ServiceInformer if the informer is not empty. - GetInternal() v1.ServiceInformer - - // Run delegates to v1.ServiceInformer if the informer is not empty. - // Otherwise it does nothing. - Run(<-chan struct{}) - - // HasSynced delegates to v1.ServiceInformer if the informer is not empty. - // Otherwise it always returns true. - HasSynced() bool -} diff --git a/pkg/client/injection/serving/informers/v1/service/fake/fake.go b/pkg/client/injection/serving/informers/v1/service/fake/fake.go index 232843777ae..2790623a1cc 100644 --- a/pkg/client/injection/serving/informers/v1/service/fake/fake.go +++ b/pkg/client/injection/serving/informers/v1/service/fake/fake.go @@ -19,11 +19,9 @@ package fake import ( "context" - informerv1 "knative.dev/eventing/pkg/client/injection/serving/informers/v1" - service "knative.dev/eventing/pkg/client/injection/serving/informers/v1/service" + "knative.dev/eventing/pkg/client/injection/serving/informers/v1/service" "knative.dev/pkg/controller" "knative.dev/pkg/injection" - v1 "knative.dev/serving/pkg/client/informers/externalversions/serving/v1" fake "knative.dev/serving/pkg/client/injection/informers/factory/fake" ) @@ -35,34 +33,6 @@ func init() { func withInformer(ctx context.Context) (context.Context, controller.Informer) { f := fake.Get(ctx) - var inf informerv1.EmptyableServiceInformer - inf = &emptyableImpl{internal: f.Serving().V1().Services()} + inf := service.NewEmptyableServiceInformer(f.Serving().V1().Services()) return context.WithValue(ctx, service.Key{}, inf), inf } - -type emptyableImpl struct { - internal v1.ServiceInformer -} - -func (i *emptyableImpl) IsEmpty() bool { - return (i.internal == nil) -} - -func (i *emptyableImpl) GetInternal() v1.ServiceInformer { - return i.internal -} - -func (i *emptyableImpl) Run(stopCh <-chan struct{}) { - if i.internal != nil { - i.internal.Informer().Run(stopCh) - } else { - <-stopCh - } -} - -func (i *emptyableImpl) HasSynced() bool { - if i.internal != nil { - return i.internal.Informer().HasSynced() - } - return true -} diff --git a/pkg/client/injection/serving/informers/v1/service/service.go b/pkg/client/injection/serving/informers/v1/service/service.go index 351938579d9..0c0f806ec60 100644 --- a/pkg/client/injection/serving/informers/v1/service/service.go +++ b/pkg/client/injection/serving/informers/v1/service/service.go @@ -21,8 +21,6 @@ import ( "strings" "k8s.io/client-go/discovery" - - informerv1 "knative.dev/eventing/pkg/client/injection/serving/informers/v1" kubeclient "knative.dev/pkg/client/injection/kube/client" controller "knative.dev/pkg/controller" injection "knative.dev/pkg/injection" @@ -32,6 +30,10 @@ import ( factory "knative.dev/serving/pkg/client/injection/informers/factory" ) +// This package register a serving v1 service informer as an "emptyable" informer. +// An "emptyable" informer delegates a real informer if the serving v1 API exists; +// otherwise it does nothing. +// This allows informer injection without knowing if the API exists in advance. func init() { injection.Default.RegisterInformer(withInformer) } @@ -44,48 +46,52 @@ func withInformer(ctx context.Context) (context.Context, controller.Informer) { // Register an empty informer if the serving API is not available. if err := discovery.ServerSupportsVersion(kc.Discovery(), servingv1.SchemeGroupVersion); err != nil { if strings.Contains(err.Error(), "server does not support API version") { - var inf informerv1.EmptyableServiceInformer - inf = &emptyableImpl{} + inf := &EmptyableServiceInformer{} return context.WithValue(ctx, Key{}, inf), inf } - logging.FromContext(ctx).Panic( - "Failed to check API version", servingv1.SchemeGroupVersion) + logging.FromContext(ctx).Panic("Failed to check API version", servingv1.SchemeGroupVersion) } f := factory.Get(ctx) - var inf informerv1.EmptyableServiceInformer - inf = &emptyableImpl{internal: f.Serving().V1().Services()} + inf := NewEmptyableServiceInformer(f.Serving().V1().Services()) return context.WithValue(ctx, Key{}, inf), inf } // Get extracts the typed informer from the context. -func Get(ctx context.Context) informerv1.EmptyableServiceInformer { +func Get(ctx context.Context) *EmptyableServiceInformer { untyped := ctx.Value(Key{}) if untyped == nil { logging.FromContext(ctx).Panic( - "Unable to fetch knative.dev/eventing/pkg/serving/EmptyableServiceInformer from context.") + "Unable to fetch knative.dev/eventing/pkg/client/injection/serving/informers/v1/service.EmptyableServiceInformer from context.") } - return untyped.(informerv1.EmptyableServiceInformer) + return untyped.(*EmptyableServiceInformer) } -var ( - _ controller.Informer = (*emptyableImpl)(nil) - _ informerv1.EmptyableServiceInformer = (*emptyableImpl)(nil) -) +var _ controller.Informer = (*EmptyableServiceInformer)(nil) -type emptyableImpl struct { +// EmptyableServiceInformer is an "emptyable" version of v1.ServiceInformer. +type EmptyableServiceInformer struct { internal v1.ServiceInformer } -func (i *emptyableImpl) IsEmpty() bool { +// NewEmptyableServiceInformer returns a new EmptyableServiceInformer. +func NewEmptyableServiceInformer(internal v1.ServiceInformer) *EmptyableServiceInformer { + return &EmptyableServiceInformer{internal: internal} +} + +// IsEmpty returns whether the informer is empty. +func (i *EmptyableServiceInformer) IsEmpty() bool { return (i.internal == nil) } -func (i *emptyableImpl) GetInternal() v1.ServiceInformer { +// GetInternal returns the internal v1.ServiceInformer if the informer is not empty. +func (i *EmptyableServiceInformer) GetInternal() v1.ServiceInformer { return i.internal } -func (i *emptyableImpl) Run(stopCh <-chan struct{}) { +// Run delegates to v1.ServiceInformer if the informer is not empty. +// Otherwise it does nothing. +func (i *EmptyableServiceInformer) Run(stopCh <-chan struct{}) { if i.internal != nil { i.internal.Informer().Run(stopCh) } else { @@ -93,7 +99,9 @@ func (i *emptyableImpl) Run(stopCh <-chan struct{}) { } } -func (i *emptyableImpl) HasSynced() bool { +// HasSynced delegates to v1.ServiceInformer if the informer is not empty. +// Otherwise it always returns true. +func (i *EmptyableServiceInformer) HasSynced() bool { if i.internal != nil { return i.internal.Informer().HasSynced() } diff --git a/pkg/reconciler/broker/broker.go b/pkg/reconciler/broker/broker.go index 3f40f71c8d5..b06ded728b5 100644 --- a/pkg/reconciler/broker/broker.go +++ b/pkg/reconciler/broker/broker.go @@ -32,6 +32,7 @@ import ( "k8s.io/client-go/tools/cache" duckapis "knative.dev/pkg/apis/duck" "knative.dev/pkg/controller" + "knative.dev/pkg/kmeta" duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" "knative.dev/eventing/pkg/apis/eventing/v1alpha1" @@ -41,7 +42,7 @@ import ( "knative.dev/eventing/pkg/logging" "knative.dev/eventing/pkg/reconciler" "knative.dev/eventing/pkg/reconciler/broker/resources" - "knative.dev/eventing/pkg/reconciler/utils/services" + "knative.dev/eventing/pkg/reconciler/service" ) const ( @@ -57,14 +58,14 @@ const ( type Reconciler struct { *reconciler.Base + svcReconciler service.Reconciler + // listers index properties about resources brokerLister eventinglisters.BrokerLister subscriptionLister messaginglisters.SubscriptionLister channelableTracker duck.ListableTracker - services services.ServiceFlavor - ingressImage string ingressServiceAccountName string filterImage string @@ -256,23 +257,23 @@ func (r *Reconciler) updateStatus(ctx context.Context, desired *v1alpha1.Broker) return b, err } -func (r *Reconciler) reconcileFilterService(ctx context.Context, b *v1alpha1.Broker) (*services.Status, error) { +func (r *Reconciler) reconcileFilterService(ctx context.Context, b *v1alpha1.Broker) (*service.Status, error) { svcArgs := resources.MakeFilterServiceArgs(&resources.FilterArgs{ Broker: b, Image: r.filterImage, ServiceAccountName: r.filterServiceAccountName, }) - return r.services.Reconcile(ctx, b, *svcArgs) + return r.svcReconciler.Reconcile(ctx, *kmeta.NewControllerRef(b), *svcArgs) } -func (r *Reconciler) reconcileIngressService(ctx context.Context, b *v1alpha1.Broker, c *duckv1alpha1.Channelable) (*services.Status, error) { +func (r *Reconciler) reconcileIngressService(ctx context.Context, b *v1alpha1.Broker, c *duckv1alpha1.Channelable) (*service.Status, error) { svcArgs := resources.MakeIngressServiceArgs(&resources.IngressArgs{ Broker: b, Image: r.ingressImage, ServiceAccountName: r.ingressServiceAccountName, ChannelAddress: c.Status.Address.GetURL().Host, }) - return r.services.Reconcile(ctx, b, *svcArgs) + return r.svcReconciler.Reconcile(ctx, *kmeta.NewControllerRef(b), *svcArgs) } func newTriggerChannel(b *v1alpha1.Broker) (*unstructured.Unstructured, error) { diff --git a/pkg/reconciler/broker/broker_test.go b/pkg/reconciler/broker/broker_test.go index 90c94e1f485..4a1d07c5c2a 100644 --- a/pkg/reconciler/broker/broker_test.go +++ b/pkg/reconciler/broker/broker_test.go @@ -38,9 +38,9 @@ import ( "knative.dev/eventing/pkg/duck" "knative.dev/eventing/pkg/reconciler" "knative.dev/eventing/pkg/reconciler/broker/resources" + kubeservice "knative.dev/eventing/pkg/reconciler/service/kube" + servingservice "knative.dev/eventing/pkg/reconciler/service/serving" . "knative.dev/eventing/pkg/reconciler/testing" - kubeservice "knative.dev/eventing/pkg/reconciler/utils/services/kube" - servingservice "knative.dev/eventing/pkg/reconciler/utils/services/serving" "knative.dev/eventing/pkg/utils" kubeclient "knative.dev/pkg/client/injection/kube/client" "knative.dev/pkg/controller" @@ -576,7 +576,7 @@ func TestReconcile(t *testing.T) { Base: reconciler.NewBase(ctx, controllerAgentName, cmw), subscriptionLister: listers.GetSubscriptionLister(), brokerLister: listers.GetBrokerLister(), - services: &kubeservice.KubeFlavor{ + svcReconciler: &kubeservice.ServiceReconciler{ KubeClientSet: kubeclient.Get(ctx), DeploymentLister: listers.GetDeploymentLister(), ServiceLister: listers.GetK8sServiceLister(), @@ -813,7 +813,7 @@ func TestReconcileWithServingService(t *testing.T) { Base: reconciler.NewBase(ctx, controllerAgentName, cmw), subscriptionLister: listers.GetSubscriptionLister(), brokerLister: listers.GetBrokerLister(), - services: &servingservice.ServingFlavor{ + svcReconciler: &servingservice.ServiceReconciler{ ServingClientSet: servingclient.Get(ctx), ServingLister: listers.GetServingServiceLister(), }, diff --git a/pkg/reconciler/broker/controller.go b/pkg/reconciler/broker/controller.go index 9d061f1aeda..2abea99a7d0 100644 --- a/pkg/reconciler/broker/controller.go +++ b/pkg/reconciler/broker/controller.go @@ -26,7 +26,7 @@ import ( "knative.dev/eventing/pkg/apis/eventing/v1alpha1" "knative.dev/eventing/pkg/duck" "knative.dev/eventing/pkg/reconciler" - "knative.dev/eventing/pkg/reconciler/utils/services" + "knative.dev/eventing/pkg/reconciler/service" "knative.dev/pkg/configmap" "knative.dev/pkg/controller" @@ -34,8 +34,8 @@ import ( brokerinformer "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/broker" subscriptioninformer "knative.dev/eventing/pkg/client/injection/informers/messaging/v1alpha1/subscription" servinginformer "knative.dev/eventing/pkg/client/injection/serving/informers/v1/service" - kubeservice "knative.dev/eventing/pkg/reconciler/utils/services/kube" - servingservice "knative.dev/eventing/pkg/reconciler/utils/services/serving" + kubeservice "knative.dev/eventing/pkg/reconciler/service/kube" + servingservice "knative.dev/eventing/pkg/reconciler/service/serving" kubeclient "knative.dev/pkg/client/injection/kube/client" deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment" serviceinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/service" @@ -77,18 +77,18 @@ func NewController( serviceInformer := serviceinformer.Get(ctx) servingInformer := servinginformer.Get(ctx) - if env.ResourceFlavor == services.ServingFlavor && servingInformer.IsEmpty() { - log.Fatalf(`BROKER_RESOURCE_FLAVOR is set to %q but %v was not available`, services.ServingFlavor, servingv1.SchemeGroupVersion) + if env.ResourceFlavor == service.ServingFlavor && servingInformer.IsEmpty() { + log.Fatalf(`BROKER_RESOURCE_FLAVOR is set to %q but %v was not available`, service.ServingFlavor, servingv1.SchemeGroupVersion) } - var sf services.ServiceFlavor - if env.ResourceFlavor == services.ServingFlavor { - sf = &servingservice.ServingFlavor{ + var svcReconciler service.Reconciler + if env.ResourceFlavor == service.ServingFlavor { + svcReconciler = &servingservice.ServiceReconciler{ ServingClientSet: servingclient.Get(ctx), ServingLister: servingInformer.GetInternal().Lister(), } } else { - sf = &kubeservice.KubeFlavor{ + svcReconciler = &kubeservice.ServiceReconciler{ KubeClientSet: kubeclient.Get(ctx), DeploymentLister: deploymentInformer.Lister(), ServiceLister: serviceInformer.Lister(), @@ -103,7 +103,7 @@ func NewController( ingressServiceAccountName: env.IngressServiceAccount, filterImage: env.FilterImage, filterServiceAccountName: env.FilterServiceAccount, - services: sf, + svcReconciler: svcReconciler, } impl := controller.NewImpl(r, r.Logger, ReconcilerName) diff --git a/pkg/reconciler/broker/resources/filter.go b/pkg/reconciler/broker/resources/filter.go index bba32943ada..0df58226632 100644 --- a/pkg/reconciler/broker/resources/filter.go +++ b/pkg/reconciler/broker/resources/filter.go @@ -24,7 +24,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" - "knative.dev/eventing/pkg/reconciler/utils/services" + "knative.dev/eventing/pkg/reconciler/service" ) const ( @@ -46,8 +46,8 @@ func MakeFilterServiceMeta(b *eventingv1alpha1.Broker) metav1.ObjectMeta { } } -func MakeFilterServiceArgs(args *FilterArgs) *services.Args { - return &services.Args{ +func MakeFilterServiceArgs(args *FilterArgs) *service.Args { + return &service.Args{ ServiceMeta: MakeFilterServiceMeta(args.Broker), DeployMeta: MakeFilterServiceMeta(args.Broker), PodSpec: corev1.PodSpec{ diff --git a/pkg/reconciler/broker/resources/ingress.go b/pkg/reconciler/broker/resources/ingress.go index 9b6953380e1..9090b3706b8 100644 --- a/pkg/reconciler/broker/resources/ingress.go +++ b/pkg/reconciler/broker/resources/ingress.go @@ -24,7 +24,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" - "knative.dev/eventing/pkg/reconciler/utils/services" + "knative.dev/eventing/pkg/reconciler/service" ) const ( @@ -39,8 +39,8 @@ type IngressArgs struct { ChannelAddress string } -func MakeIngressServiceArgs(args *IngressArgs) *services.Args { - return &services.Args{ +func MakeIngressServiceArgs(args *IngressArgs) *service.Args { + return &service.Args{ ServiceMeta: metav1.ObjectMeta{ Namespace: args.Broker.Namespace, Name: fmt.Sprintf("%s-broker", args.Broker.Name), diff --git a/pkg/reconciler/utils/services/base.go b/pkg/reconciler/service/base.go similarity index 76% rename from pkg/reconciler/utils/services/base.go rename to pkg/reconciler/service/base.go index bc57f4a14b1..c634ae2be00 100644 --- a/pkg/reconciler/utils/services/base.go +++ b/pkg/reconciler/service/base.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package services +package service import ( "context" @@ -23,9 +23,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/apis" - "knative.dev/pkg/kmeta" servingcommon "knative.dev/serving/pkg/apis/serving" ) @@ -34,7 +32,7 @@ const ( ServingFlavor = "knative" ) -// Status represents the status of a service. +// Status represents the status of an addressable service. type Status struct { IsReady bool URL *apis.URL @@ -42,26 +40,27 @@ type Status struct { Message string } -// Args is the arguments to reconcile a service. +// Args is the arguments to reconcile an addressable service. type Args struct { ServiceMeta metav1.ObjectMeta DeployMeta metav1.ObjectMeta PodSpec corev1.PodSpec } -// ServiceFlavor is the interface to a service implementation. -type ServiceFlavor interface { +// Reconciler is the interface to reconcile addressable services. +type Reconciler interface { // Reconcile reconciles a service. - Reconcile(context.Context, kmeta.OwnerRefable, Args) (*Status, error) + Reconcile(context.Context, metav1.OwnerReference, Args) (*Status, error) // GetStatus get the status of a service. - GetStatus(context.Context, kmeta.OwnerRefable, metav1.ObjectMeta) (*Status, error) + GetStatus(context.Context, metav1.ObjectMeta) (*Status, error) } -// ValidateArgs validates the arguments to create a service. +// ValidateArgs validates the arguments for a service. func ValidateArgs(args Args) error { if !strings.HasPrefix(args.DeployMeta.Name, args.ServiceMeta.Name) { return fmt.Errorf("service name must be a prefix of deployment name") } + // Use serving's validation since it's more strict. if err := servingcommon.ValidatePodSpec(args.PodSpec); err != nil { return err } diff --git a/pkg/reconciler/utils/services/kube/kube.go b/pkg/reconciler/service/kube/kube.go similarity index 74% rename from pkg/reconciler/utils/services/kube/kube.go rename to pkg/reconciler/service/kube/kube.go index 4de834f5c82..7f21c3cd5a7 100644 --- a/pkg/reconciler/utils/services/kube/kube.go +++ b/pkg/reconciler/service/kube/kube.go @@ -29,22 +29,25 @@ import ( "k8s.io/client-go/kubernetes" appsv1listers "k8s.io/client-go/listers/apps/v1" corev1listers "k8s.io/client-go/listers/core/v1" - "knative.dev/eventing/pkg/apis/duck" "knative.dev/eventing/pkg/reconciler/names" - "knative.dev/eventing/pkg/reconciler/utils/services" + "knative.dev/eventing/pkg/reconciler/service" "knative.dev/pkg/apis" - "knative.dev/pkg/kmeta" ) -type KubeFlavor struct { +// ServiceReconciler reconciles addressable services implemented with +// k8s services and deployments. +type ServiceReconciler struct { KubeClientSet kubernetes.Interface ServiceLister corev1listers.ServiceLister DeploymentLister appsv1listers.DeploymentLister } -func (k *KubeFlavor) Reconcile(ctx context.Context, owner kmeta.OwnerRefable, args services.Args) (*services.Status, error) { - if err := services.ValidateArgs(args); err != nil { +var _ service.Reconciler = (*ServiceReconciler)(nil) + +// Reconcile reconciles an addressable service with k8s service and deployment. +func (r *ServiceReconciler) Reconcile(ctx context.Context, owner metav1.OwnerReference, args service.Args) (*service.Status, error) { + if err := service.ValidateArgs(args); err != nil { return nil, err } fillDefaults(&args, owner) @@ -63,7 +66,7 @@ func (k *KubeFlavor) Reconcile(ctx context.Context, owner kmeta.OwnerRefable, ar }, }, } - rd, err := k.reconcileDeployment(ctx, d) + rd, err := r.reconcileDeployment(ctx, d) if err != nil { return nil, err } @@ -81,13 +84,13 @@ func (k *KubeFlavor) Reconcile(ctx context.Context, owner kmeta.OwnerRefable, ar }, }, } - rsvc, err := k.reconcileService(ctx, svc) + rsvc, err := r.reconcileService(ctx, svc) if err != nil { return nil, err } if duck.DeploymentIsAvailable(&rd.Status, true) { - return &services.Status{ + return &service.Status{ IsReady: true, URL: &apis.URL{ Scheme: "http", @@ -96,19 +99,20 @@ func (k *KubeFlavor) Reconcile(ctx context.Context, owner kmeta.OwnerRefable, ar }, nil } - return &services.Status{ + return &service.Status{ IsReady: false, Reason: "DeploymentUnavailable", Message: fmt.Sprintf("The Deployment %q is unavailable", rd.Name), }, nil } -func (k *KubeFlavor) GetStatus(ctx context.Context, owner kmeta.OwnerRefable, svcMeta metav1.ObjectMeta) (*services.Status, error) { - existing, err := k.ServiceLister.Services(svcMeta.Namespace).Get(svcMeta.Name) +// GetStatus returns the status of a k8s service. +func (r *ServiceReconciler) GetStatus(ctx context.Context, svcMeta metav1.ObjectMeta) (*service.Status, error) { + existing, err := r.ServiceLister.Services(svcMeta.Namespace).Get(svcMeta.Name) if err != nil { return nil, err } - return &services.Status{ + return &service.Status{ IsReady: true, URL: &apis.URL{ Scheme: "http", @@ -117,10 +121,10 @@ func (k *KubeFlavor) GetStatus(ctx context.Context, owner kmeta.OwnerRefable, sv }, nil } -func fillDefaults(args *services.Args, owner kmeta.OwnerRefable) { +func fillDefaults(args *service.Args, owner metav1.OwnerReference) { // Make sure the service metadata has proper owner reference. - args.ServiceMeta.OwnerReferences = append(args.ServiceMeta.OwnerReferences, *kmeta.NewControllerRef(owner)) - args.DeployMeta.OwnerReferences = append(args.DeployMeta.OwnerReferences, *kmeta.NewControllerRef(owner)) + args.ServiceMeta.OwnerReferences = append(args.ServiceMeta.OwnerReferences, owner) + args.DeployMeta.OwnerReferences = append(args.DeployMeta.OwnerReferences, owner) args.PodSpec.Containers[0].Ports[0].Name = "http" userPort := args.PodSpec.Containers[0].Ports[0].ContainerPort @@ -136,10 +140,10 @@ func fillDefaults(args *services.Args, owner kmeta.OwnerRefable) { } } -func (k *KubeFlavor) reconcileDeployment(ctx context.Context, d *v1.Deployment) (*v1.Deployment, error) { - existing, err := k.DeploymentLister.Deployments(d.Namespace).Get(d.Name) +func (r *ServiceReconciler) reconcileDeployment(ctx context.Context, d *v1.Deployment) (*v1.Deployment, error) { + existing, err := r.DeploymentLister.Deployments(d.Namespace).Get(d.Name) if apierrors.IsNotFound(err) { - existing, err = k.KubeClientSet.AppsV1().Deployments(d.Namespace).Create(d) + existing, err = r.KubeClientSet.AppsV1().Deployments(d.Namespace).Create(d) if err != nil { return nil, fmt.Errorf("failed to create deployment: %w", err) } @@ -152,7 +156,7 @@ func (k *KubeFlavor) reconcileDeployment(ctx context.Context, d *v1.Deployment) // Don't modify the informers copy. desired := existing.DeepCopy() desired.Spec = d.Spec - existing, err = k.KubeClientSet.AppsV1().Deployments(existing.Namespace).Update(desired) + existing, err = r.KubeClientSet.AppsV1().Deployments(existing.Namespace).Update(desired) if err != nil { return nil, fmt.Errorf("failed to update deployment: %w", err) } @@ -161,10 +165,10 @@ func (k *KubeFlavor) reconcileDeployment(ctx context.Context, d *v1.Deployment) } // reconcileService reconciles the K8s Service 'svc'. -func (k *KubeFlavor) reconcileService(ctx context.Context, svc *corev1.Service) (*corev1.Service, error) { - existing, err := k.ServiceLister.Services(svc.Namespace).Get(svc.Name) +func (r *ServiceReconciler) reconcileService(ctx context.Context, svc *corev1.Service) (*corev1.Service, error) { + existing, err := r.ServiceLister.Services(svc.Namespace).Get(svc.Name) if apierrors.IsNotFound(err) { - existing, err = k.KubeClientSet.CoreV1().Services(svc.Namespace).Create(svc) + existing, err = r.KubeClientSet.CoreV1().Services(svc.Namespace).Create(svc) if err != nil { return nil, fmt.Errorf("failed to create service: %w", err) } @@ -180,7 +184,7 @@ func (k *KubeFlavor) reconcileService(ctx context.Context, svc *corev1.Service) // Don't modify the informers copy. desired := existing.DeepCopy() desired.Spec = svc.Spec - existing, err = k.KubeClientSet.CoreV1().Services(existing.Namespace).Update(desired) + existing, err = r.KubeClientSet.CoreV1().Services(existing.Namespace).Update(desired) if err != nil { return nil, fmt.Errorf("failed to update service: %w", err) } diff --git a/pkg/reconciler/service/kube/kube_test.go b/pkg/reconciler/service/kube/kube_test.go new file mode 100644 index 00000000000..952b04e0540 --- /dev/null +++ b/pkg/reconciler/service/kube/kube_test.go @@ -0,0 +1,516 @@ +/* +Copyright 2020 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 kube + +import ( + "context" + "strings" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/intstr" + clientgotesting "k8s.io/client-go/testing" + "knative.dev/eventing/pkg/reconciler/service" + "knative.dev/pkg/apis" + fakekubeclient "knative.dev/pkg/client/injection/kube/client/fake" + "knative.dev/pkg/logging" + logtesting "knative.dev/pkg/logging/testing" + + . "knative.dev/eventing/pkg/reconciler/service/testing" + . "knative.dev/eventing/pkg/reconciler/testing" + . "knative.dev/pkg/reconciler/testing" +) + +func TestReconcile(t *testing.T) { + cases := []struct { + name string + objects []runtime.Object + args service.Args + reactors []clientgotesting.ReactionFunc + wantCreates []runtime.Object + wantUpdates []runtime.Object + wantStatus *service.Status + wantErr bool + }{{ + name: "already reconciled do nothing", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc-deploy", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image.example.com", + WithPodContainerPort("", 8000), + ), + }, + objects: []runtime.Object{ + NewDeployment("my-svc-deploy", "my-ns", + WithDeploymentOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithDeploymentLabels(map[string]string{"app": "test"}), + WithDeploymentPodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("http", 8000))), + ), + NewService("my-svc", "my-ns", + WithServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServiceLabels(map[string]string{"app": "test"}), + WithServicePorts([]corev1.ServicePort{{Name: "http", Port: 80, TargetPort: intstr.FromInt(8000)}}), + ), + }, + wantStatus: &service.Status{ + IsReady: true, + URL: &apis.URL{ + Scheme: "http", + Host: "my-svc.my-ns.svc.cluster.local", + }, + }, + }, { + name: "successful create", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc-deploy", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image.example.com", + WithPodContainerPort("", 8000), + ), + }, + wantCreates: []runtime.Object{ + NewDeployment("my-svc-deploy", "my-ns", + WithDeploymentOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithDeploymentLabels(map[string]string{"app": "test"}), + WithDeploymentPodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("http", 8000))), + ), + NewService("my-svc", "my-ns", + WithServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServiceLabels(map[string]string{"app": "test"}), + WithServicePorts([]corev1.ServicePort{{Name: "http", Port: 80, TargetPort: intstr.FromInt(8000)}}), + ), + }, + wantStatus: &service.Status{ + IsReady: true, + URL: &apis.URL{ + Scheme: "http", + Host: "my-svc.my-ns.svc.cluster.local", + }, + }, + }, { + name: "successful update", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc-deploy", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image2.example.com", + WithPodContainerPort("", 8000), + ), + }, + objects: []runtime.Object{ + NewDeployment("my-svc-deploy", "my-ns", + WithDeploymentOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithDeploymentLabels(map[string]string{"app": "test"}), + WithDeploymentPodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("http", 8000))), + ), + NewService("my-svc", "my-ns", + WithServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServiceLabels(map[string]string{"app": "test"}), + WithServicePorts([]corev1.ServicePort{{Name: "http", Port: 80, TargetPort: intstr.FromInt(8000)}}), + ), + }, + wantUpdates: []runtime.Object{ + NewDeployment("my-svc-deploy", "my-ns", + WithDeploymentOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithDeploymentLabels(map[string]string{"app": "test"}), + WithDeploymentPodSpec(MakePodSpec("user-container", "image2.example.com", WithPodContainerPort("http", 8000))), + ), + }, + wantStatus: &service.Status{ + IsReady: true, + URL: &apis.URL{ + Scheme: "http", + Host: "my-svc.my-ns.svc.cluster.local", + }, + }, + }, { + name: "deployment not available", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc-deploy", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image.example.com", + WithPodContainerPort("", 8000), + ), + }, + objects: []runtime.Object{ + NewDeployment("my-svc-deploy", "my-ns", + WithDeploymentOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithDeploymentLabels(map[string]string{"app": "test"}), + WithDeploymentPodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("http", 8000))), + WithDeploymentNotAvailable(), + ), + NewService("my-svc", "my-ns", + WithServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServiceLabels(map[string]string{"app": "test"}), + WithServicePorts([]corev1.ServicePort{{Name: "http", Port: 80, TargetPort: intstr.FromInt(8000)}}), + ), + }, + wantStatus: &service.Status{ + IsReady: false, + Message: `The Deployment "my-svc-deploy" is unavailable`, + Reason: "DeploymentUnavailable", + }, + }, { + name: "create deployment error", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc-deploy", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image.example.com", + WithPodContainerPort("", 8000), + ), + }, + reactors: []clientgotesting.ReactionFunc{ + InduceFailure("create", "deployments"), + }, + wantCreates: []runtime.Object{ + NewDeployment("my-svc-deploy", "my-ns", + WithDeploymentOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithDeploymentLabels(map[string]string{"app": "test"}), + WithDeploymentPodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("http", 8000))), + ), + }, + wantErr: true, + }, { + name: "update deployment error", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc-deploy", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image2.example.com", + WithPodContainerPort("", 8000), + ), + }, + reactors: []clientgotesting.ReactionFunc{ + InduceFailure("update", "deployments"), + }, + objects: []runtime.Object{ + NewDeployment("my-svc-deploy", "my-ns", + WithDeploymentOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithDeploymentLabels(map[string]string{"app": "test"}), + WithDeploymentPodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("http", 8000))), + ), + }, + wantUpdates: []runtime.Object{ + NewDeployment("my-svc-deploy", "my-ns", + WithDeploymentOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithDeploymentLabels(map[string]string{"app": "test"}), + WithDeploymentPodSpec(MakePodSpec("user-container", "image2.example.com", WithPodContainerPort("http", 8000))), + ), + }, + wantErr: true, + }, { + name: "create service error", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc-deploy", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image.example.com", + WithPodContainerPort("", 8000), + ), + }, + reactors: []clientgotesting.ReactionFunc{ + InduceFailure("create", "services"), + }, + objects: []runtime.Object{ + NewDeployment("my-svc-deploy", "my-ns", + WithDeploymentOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithDeploymentLabels(map[string]string{"app": "test"}), + WithDeploymentPodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("http", 8000))), + ), + }, + wantCreates: []runtime.Object{ + NewService("my-svc", "my-ns", + WithServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServiceLabels(map[string]string{"app": "test"}), + WithServicePorts([]corev1.ServicePort{{Name: "http", Port: 80, TargetPort: intstr.FromInt(8000)}}), + ), + }, + wantErr: true, + }, { + name: "update service error", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc-deploy", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image.example.com", + WithPodContainerPort("", 8001), + ), + }, + reactors: []clientgotesting.ReactionFunc{ + InduceFailure("update", "services"), + }, + objects: []runtime.Object{ + NewDeployment("my-svc-deploy", "my-ns", + WithDeploymentOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithDeploymentLabels(map[string]string{"app": "test"}), + WithDeploymentPodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("http", 8001))), + ), + NewService("my-svc", "my-ns", + WithServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServiceLabels(map[string]string{"app": "test"}), + WithServicePorts([]corev1.ServicePort{{Name: "http", Port: 80, TargetPort: intstr.FromInt(8000)}}), + ), + }, + wantUpdates: []runtime.Object{ + NewService("my-svc", "my-ns", + WithServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServiceLabels(map[string]string{"app": "test"}), + WithServicePorts([]corev1.ServicePort{{Name: "http", Port: 80, TargetPort: intstr.FromInt(8001)}}), + ), + }, + wantErr: true, + }} + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + ctx := context.Background() + ctx = logging.WithLogger(ctx, logtesting.TestLogger(t)) + + ls := NewListers(tc.objects) + ctx, kubeClient := fakekubeclient.With(ctx, ls.GetKubeObjects()...) + + for _, reactor := range tc.reactors { + kubeClient.PrependReactor("*", "*", reactor) + } + recorderList := ActionRecorderList{kubeClient} + + svcReconciler := &ServiceReconciler{ + KubeClientSet: kubeClient, + DeploymentLister: ls.GetDeploymentLister(), + ServiceLister: ls.GetServiceLister(), + } + + status, err := svcReconciler.Reconcile(ctx, MakeOwnerReference(), tc.args) + if (err != nil) != tc.wantErr { + t.Error("Service reconcile got err=nil want err") + } + + if diff := cmp.Diff(tc.wantStatus, status, cmpopts.EquateEmpty()); diff != "" { + t.Errorf("Unexpected create (-want, +got): %s", diff) + } + + actions, err := recorderList.ActionsByVerb() + if err != nil { + t.Errorf("Error capturing actions by verb: %q", err) + } + + for i, want := range tc.wantCreates { + if i >= len(actions.Creates) { + t.Errorf("Missing create: %#v", want) + continue + } + got := actions.Creates[i] + obj := got.GetObject() + + if diff := cmp.Diff(want, obj, ignoreLastTransitionTime, safeDeployDiff, cmpopts.EquateEmpty()); diff != "" { + t.Errorf("Unexpected create (-want, +got): %s", diff) + } + } + if got, want := len(actions.Creates), len(tc.wantCreates); got > want { + for _, extra := range actions.Creates[want:] { + t.Errorf("Extra create: %#v", extra.GetObject()) + } + } + + for i, want := range tc.wantUpdates { + if i >= len(actions.Updates) { + t.Errorf("Missing update: %#v", want) + continue + } + got := actions.Updates[i] + obj := got.GetObject() + + if diff := cmp.Diff(want, obj, ignoreLastTransitionTime, safeDeployDiff, cmpopts.EquateEmpty()); diff != "" { + t.Errorf("Unexpected update (-want, +got): %s", diff) + } + } + if got, want := len(actions.Updates), len(tc.wantUpdates); got > want { + for _, extra := range actions.Updates[want:] { + t.Errorf("Extra update: %#v", extra.GetObject()) + } + } + }) + } +} + +func TestGetStatus(t *testing.T) { + cases := []struct { + name string + objects []runtime.Object + reactors []clientgotesting.ReactionFunc + svcMeta metav1.ObjectMeta + wantStatus *service.Status + wantErr bool + }{{ + name: "successfully get status", + objects: []runtime.Object{ + NewService("my-svc", "my-ns", + WithServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServiceLabels(map[string]string{"app": "test"}), + WithServicePorts([]corev1.ServicePort{{Name: "http", Port: 80, TargetPort: intstr.FromInt(8000)}}), + ), + }, + svcMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + wantStatus: &service.Status{ + IsReady: true, + URL: &apis.URL{ + Scheme: "http", + Host: "my-svc.my-ns.svc.cluster.local", + }, + }, + }, { + name: "not found", + svcMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + wantErr: true, + }, { + name: "get service error", + svcMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + reactors: []clientgotesting.ReactionFunc{ + InduceFailure("get", "services"), + }, + wantErr: true, + }} + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + ctx := context.Background() + ctx = logging.WithLogger(ctx, logtesting.TestLogger(t)) + + ls := NewListers(tc.objects) + ctx, kubeClient := fakekubeclient.With(ctx, ls.GetKubeObjects()...) + + for _, reactor := range tc.reactors { + kubeClient.PrependReactor("*", "*", reactor) + } + + svcReconciler := &ServiceReconciler{ + KubeClientSet: kubeClient, + DeploymentLister: ls.GetDeploymentLister(), + ServiceLister: ls.GetServiceLister(), + } + + status, err := svcReconciler.GetStatus(ctx, tc.svcMeta) + if (err != nil) != tc.wantErr { + t.Error("Service reconcile got err=nil want err") + } + if diff := cmp.Diff(tc.wantStatus, status, cmpopts.EquateEmpty()); diff != "" { + t.Errorf("Unexpected create (-want, +got): %s", diff) + } + }) + } +} + +var ( + ignoreLastTransitionTime = cmp.FilterPath(func(p cmp.Path) bool { + return strings.HasSuffix(p.String(), "LastTransitionTime.Inner.Time") + }, cmp.Ignore()) + + safeDeployDiff = cmpopts.IgnoreUnexported(resource.Quantity{}) +) diff --git a/pkg/reconciler/utils/services/serving/serving.go b/pkg/reconciler/service/serving/serving.go similarity index 72% rename from pkg/reconciler/utils/services/serving/serving.go rename to pkg/reconciler/service/serving/serving.go index 64ad98ac5c1..8cef0445b72 100644 --- a/pkg/reconciler/utils/services/serving/serving.go +++ b/pkg/reconciler/service/serving/serving.go @@ -23,21 +23,22 @@ import ( "k8s.io/apimachinery/pkg/api/equality" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/eventing/pkg/reconciler/utils/services" + "knative.dev/eventing/pkg/reconciler/service" "knative.dev/pkg/apis" - "knative.dev/pkg/kmeta" servingv1 "knative.dev/serving/pkg/apis/serving/v1" servingclientset "knative.dev/serving/pkg/client/clientset/versioned" servinglisters "knative.dev/serving/pkg/client/listers/serving/v1" ) -type ServingFlavor struct { +// ServiceReconciler reconciles addressable services with knative serving API. +type ServiceReconciler struct { ServingClientSet servingclientset.Interface ServingLister servinglisters.ServiceLister } -func (s *ServingFlavor) Reconcile(ctx context.Context, owner kmeta.OwnerRefable, args services.Args) (*services.Status, error) { - if err := services.ValidateArgs(args); err != nil { +// Reconcile reconciles a service with knative serving API. +func (r *ServiceReconciler) Reconcile(ctx context.Context, owner metav1.OwnerReference, args service.Args) (*service.Status, error) { + if err := service.ValidateArgs(args); err != nil { return nil, err } fillDefaults(&args, owner) @@ -56,9 +57,9 @@ func (s *ServingFlavor) Reconcile(ctx context.Context, owner kmeta.OwnerRefable, }, } - existing, err := s.ServingLister.Services(args.ServiceMeta.Namespace).Get(args.ServiceMeta.Name) + existing, err := r.ServingLister.Services(args.ServiceMeta.Namespace).Get(args.ServiceMeta.Name) if apierrors.IsNotFound(err) { - existing, err = s.ServingClientSet.ServingV1().Services(args.ServiceMeta.Namespace).Create(svc) + existing, err = r.ServingClientSet.ServingV1().Services(args.ServiceMeta.Namespace).Create(svc) if err != nil { return nil, fmt.Errorf("failed to create serving service: %w", err) } @@ -70,7 +71,7 @@ func (s *ServingFlavor) Reconcile(ctx context.Context, owner kmeta.OwnerRefable, if !equality.Semantic.DeepDerivative(svc.Spec, existing.Spec) { desired := existing.DeepCopy() desired.Spec = svc.Spec - existing, err = s.ServingClientSet.ServingV1().Services(args.ServiceMeta.Namespace).Update(desired) + existing, err = r.ServingClientSet.ServingV1().Services(args.ServiceMeta.Namespace).Update(desired) if err != nil { return nil, fmt.Errorf("failed to update serving service: %w", err) } @@ -79,27 +80,22 @@ func (s *ServingFlavor) Reconcile(ctx context.Context, owner kmeta.OwnerRefable, return servingServiceStatus(existing), nil } -func (s *ServingFlavor) GetStatus(ctx context.Context, owner kmeta.OwnerRefable, svcMeta metav1.ObjectMeta) (*services.Status, error) { - existing, err := s.ServingLister.Services(svcMeta.Namespace).Get(svcMeta.Name) +// GetStatus returns the knative serving service status. +func (r *ServiceReconciler) GetStatus(ctx context.Context, svcMeta metav1.ObjectMeta) (*service.Status, error) { + existing, err := r.ServingLister.Services(svcMeta.Namespace).Get(svcMeta.Name) if err != nil { return nil, err } return servingServiceStatus(existing), nil } -func fillDefaults(args *services.Args, owner kmeta.OwnerRefable) { +func fillDefaults(args *service.Args, owner metav1.OwnerReference) { // Make sure the service metadata has proper owner reference. - args.ServiceMeta.OwnerReferences = append(args.ServiceMeta.OwnerReferences, *kmeta.NewControllerRef(owner)) + args.ServiceMeta.OwnerReferences = append(args.ServiceMeta.OwnerReferences, owner) // Serving service requires a strict prefix. // Add "-rev" to make it strict prefix. args.DeployMeta.Name = args.DeployMeta.Name + "-rev" - // Just for testing purpose. - // if args.DeployMeta.Annotations == nil { - // args.DeployMeta.Annotations = make(map[string]string) - // } - // args.DeployMeta.Annotations["autoscaling.knative.dev/minScale"] = "1" - // Always use cluster local service. if args.ServiceMeta.Labels == nil { args.ServiceMeta.Labels = make(map[string]string) @@ -107,9 +103,9 @@ func fillDefaults(args *services.Args, owner kmeta.OwnerRefable) { args.ServiceMeta.Labels["serving.knative.dev/visibility"] = "cluster-local" } -func servingServiceStatus(svc *servingv1.Service) *services.Status { +func servingServiceStatus(svc *servingv1.Service) *service.Status { cond := svc.Status.GetCondition(apis.ConditionReady) - ss := &services.Status{ + ss := &service.Status{ IsReady: svc.Status.IsReady(), URL: svc.Status.URL, } diff --git a/pkg/reconciler/service/serving/serving_test.go b/pkg/reconciler/service/serving/serving_test.go new file mode 100644 index 00000000000..85e10aaaab8 --- /dev/null +++ b/pkg/reconciler/service/serving/serving_test.go @@ -0,0 +1,401 @@ +/* +Copyright 2020 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 serving + +import ( + "context" + "strings" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + clientgotesting "k8s.io/client-go/testing" + "knative.dev/eventing/pkg/reconciler/service" + "knative.dev/pkg/apis" + "knative.dev/pkg/logging" + logtesting "knative.dev/pkg/logging/testing" + fakeservingclient "knative.dev/serving/pkg/client/injection/client/fake" + + . "knative.dev/eventing/pkg/reconciler/service/testing" + . "knative.dev/eventing/pkg/reconciler/testing" + . "knative.dev/pkg/reconciler/testing" +) + +func TestReconcile(t *testing.T) { + cases := []struct { + name string + objects []runtime.Object + args service.Args + reactors []clientgotesting.ReactionFunc + wantCreates []runtime.Object + wantUpdates []runtime.Object + wantStatus *service.Status + wantErr bool + }{{ + name: "already reconciled do nothing", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image.example.com", + WithPodContainerPort("", 8000), + ), + }, + objects: []runtime.Object{ + NewServingService("my-svc", "my-ns", "my-svc-rev", + WithServingServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServingServiceLabels(map[string]string{"app": "test", "serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(map[string]string{"app": "test"}), + WithServingServicePodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("", 8000))), + WithServingServiceReady(), + ), + }, + wantStatus: &service.Status{ + IsReady: true, + URL: &apis.URL{ + Scheme: "http", + Host: "my-svc.my-ns.svc.cluster.local", + }, + }, + }, { + name: "successful create", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image.example.com", + WithPodContainerPort("", 8000), + ), + }, + wantCreates: []runtime.Object{ + NewServingService("my-svc", "my-ns", "my-svc-rev", + WithServingServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServingServiceLabels(map[string]string{"app": "test", "serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(map[string]string{"app": "test"}), + WithServingServicePodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("", 8000))), + ), + }, + wantStatus: &service.Status{ + IsReady: false, + }, + }, { + name: "successful update", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image2.example.com", + WithPodContainerPort("", 8000), + ), + }, + objects: []runtime.Object{ + NewServingService("my-svc", "my-ns", "my-svc-rev", + WithServingServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServingServiceLabels(map[string]string{"app": "test", "serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(map[string]string{"app": "test"}), + WithServingServicePodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("", 8000))), + ), + }, + wantUpdates: []runtime.Object{ + NewServingService("my-svc", "my-ns", "my-svc-rev", + WithServingServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServingServiceLabels(map[string]string{"app": "test", "serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(map[string]string{"app": "test"}), + WithServingServicePodSpec(MakePodSpec("user-container", "image2.example.com", WithPodContainerPort("", 8000))), + ), + }, + wantStatus: &service.Status{ + IsReady: false, + }, + }, { + name: "successful create", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image.example.com", + WithPodContainerPort("", 8000), + ), + }, + reactors: []clientgotesting.ReactionFunc{ + InduceFailure("create", "services"), + }, + wantCreates: []runtime.Object{ + NewServingService("my-svc", "my-ns", "my-svc-rev", + WithServingServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServingServiceLabels(map[string]string{"app": "test", "serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(map[string]string{"app": "test"}), + WithServingServicePodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("", 8000))), + ), + }, + wantErr: true, + }, { + name: "successful update", + args: service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + DeployMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + PodSpec: MakePodSpec( + "user-container", + "image2.example.com", + WithPodContainerPort("", 8000), + ), + }, + reactors: []clientgotesting.ReactionFunc{ + InduceFailure("update", "services"), + }, + objects: []runtime.Object{ + NewServingService("my-svc", "my-ns", "my-svc-rev", + WithServingServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServingServiceLabels(map[string]string{"app": "test", "serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(map[string]string{"app": "test"}), + WithServingServicePodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("", 8000))), + ), + }, + wantUpdates: []runtime.Object{ + NewServingService("my-svc", "my-ns", "my-svc-rev", + WithServingServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServingServiceLabels(map[string]string{"app": "test", "serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(map[string]string{"app": "test"}), + WithServingServicePodSpec(MakePodSpec("user-container", "image2.example.com", WithPodContainerPort("", 8000))), + ), + }, + wantErr: true, + }} + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + ctx := context.Background() + ctx = logging.WithLogger(ctx, logtesting.TestLogger(t)) + + ls := NewListers(tc.objects) + ctx, servingclient := fakeservingclient.With(ctx, ls.GetServingObjects()...) + + for _, reactor := range tc.reactors { + servingclient.PrependReactor("*", "*", reactor) + } + recorderList := ActionRecorderList{servingclient} + + svcReconciler := &ServiceReconciler{ + ServingClientSet: servingclient, + ServingLister: ls.GetServingServiceLister(), + } + + status, err := svcReconciler.Reconcile(ctx, MakeOwnerReference(), tc.args) + if (err != nil) != tc.wantErr { + t.Error("Service reconcile got err=nil want err") + } + + if diff := cmp.Diff(tc.wantStatus, status, cmpopts.EquateEmpty()); diff != "" { + t.Errorf("Unexpected create (-want, +got): %s", diff) + } + + actions, err := recorderList.ActionsByVerb() + if err != nil { + t.Errorf("Error capturing actions by verb: %q", err) + } + + for i, want := range tc.wantCreates { + if i >= len(actions.Creates) { + t.Errorf("Missing create: %#v", want) + continue + } + got := actions.Creates[i] + obj := got.GetObject() + + if diff := cmp.Diff(want, obj, ignoreLastTransitionTime, safeDeployDiff, cmpopts.EquateEmpty()); diff != "" { + t.Errorf("Unexpected create (-want, +got): %s", diff) + } + } + if got, want := len(actions.Creates), len(tc.wantCreates); got > want { + for _, extra := range actions.Creates[want:] { + t.Errorf("Extra create: %#v", extra.GetObject()) + } + } + + for i, want := range tc.wantUpdates { + if i >= len(actions.Updates) { + t.Errorf("Missing update: %#v", want) + continue + } + got := actions.Updates[i] + obj := got.GetObject() + + if diff := cmp.Diff(want, obj, ignoreLastTransitionTime, safeDeployDiff, cmpopts.EquateEmpty()); diff != "" { + t.Errorf("Unexpected update (-want, +got): %s", diff) + } + } + if got, want := len(actions.Updates), len(tc.wantUpdates); got > want { + for _, extra := range actions.Updates[want:] { + t.Errorf("Extra update: %#v", extra.GetObject()) + } + } + }) + } +} + +func TestGetStatus(t *testing.T) { + cases := []struct { + name string + objects []runtime.Object + reactors []clientgotesting.ReactionFunc + svcMeta metav1.ObjectMeta + wantStatus *service.Status + wantErr bool + }{{ + name: "successfully get ready status", + objects: []runtime.Object{ + NewServingService("my-svc", "my-ns", "my-svc-rev", + WithServingServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServingServiceLabels(map[string]string{"app": "test", "serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(map[string]string{"app": "test"}), + WithServingServicePodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("", 8000))), + WithServingServiceReady(), + ), + }, + svcMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + wantStatus: &service.Status{ + IsReady: true, + URL: &apis.URL{ + Scheme: "http", + Host: "my-svc.my-ns.svc.cluster.local", + }, + }, + }, { + name: "successfully get not ready status", + objects: []runtime.Object{ + NewServingService("my-svc", "my-ns", "my-svc-rev", + WithServingServiceOwnerReferences([]metav1.OwnerReference{MakeOwnerReference()}), + WithServingServiceLabels(map[string]string{"app": "test", "serving.knative.dev/visibility": "cluster-local"}), + WithServingServiceTemplateLabels(map[string]string{"app": "test"}), + WithServingServicePodSpec(MakePodSpec("user-container", "image.example.com", WithPodContainerPort("", 8000))), + ), + }, + svcMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + wantStatus: &service.Status{ + IsReady: false, + }, + }, { + name: "not found", + svcMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + wantErr: true, + }, { + name: "get service error", + svcMeta: metav1.ObjectMeta{ + Name: "my-svc", + Namespace: "my-ns", + Labels: map[string]string{"app": "test"}, + }, + reactors: []clientgotesting.ReactionFunc{ + InduceFailure("get", "services"), + }, + wantErr: true, + }} + + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + ctx := context.Background() + ctx = logging.WithLogger(ctx, logtesting.TestLogger(t)) + + ls := NewListers(tc.objects) + ctx, servingclient := fakeservingclient.With(ctx, ls.GetServingObjects()...) + + for _, reactor := range tc.reactors { + servingclient.PrependReactor("*", "*", reactor) + } + + svcReconciler := &ServiceReconciler{ + ServingClientSet: servingclient, + ServingLister: ls.GetServingServiceLister(), + } + + status, err := svcReconciler.GetStatus(ctx, tc.svcMeta) + if (err != nil) != tc.wantErr { + t.Error("Service reconcile got err=nil want err") + } + if diff := cmp.Diff(tc.wantStatus, status, cmpopts.EquateEmpty()); diff != "" { + t.Errorf("Unexpected create (-want, +got): %s", diff) + } + }) + } +} + +var ( + ignoreLastTransitionTime = cmp.FilterPath(func(p cmp.Path) bool { + return strings.HasSuffix(p.String(), "LastTransitionTime.Inner.Time") + }, cmp.Ignore()) + + safeDeployDiff = cmpopts.IgnoreUnexported(resource.Quantity{}) +) diff --git a/pkg/reconciler/service/testing/owner.go b/pkg/reconciler/service/testing/owner.go new file mode 100644 index 00000000000..d8b0942a9dc --- /dev/null +++ b/pkg/reconciler/service/testing/owner.go @@ -0,0 +1,32 @@ +/* +Copyright 2020 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 testing + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func MakeOwnerReference() metav1.OwnerReference { + trueVal := true + return metav1.OwnerReference{ + APIVersion: "test.example.com/v1", + Kind: "owner", + Name: "owner", + BlockOwnerDeletion: &trueVal, + Controller: &trueVal, + } +} diff --git a/pkg/reconciler/service/testing/pod.go b/pkg/reconciler/service/testing/pod.go new file mode 100644 index 00000000000..fa824dc1bd0 --- /dev/null +++ b/pkg/reconciler/service/testing/pod.go @@ -0,0 +1,57 @@ +/* +Copyright 2020 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 testing + +import ( + corev1 "k8s.io/api/core/v1" +) + +type PodSpecOption func(*corev1.PodSpec) + +func MakePodSpec(name, image string, opts ...PodSpecOption) corev1.PodSpec { + p := &corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: name, + Image: image, + }, + }, + } + + for _, opt := range opts { + opt(p) + } + return *p +} + +func WithPodContainerPort(name string, port int32) PodSpecOption { + return func(p *corev1.PodSpec) { + p.Containers[0].Ports = []corev1.ContainerPort{ + { + Name: name, + ContainerPort: port, + }, + } + } +} + +func WithPodContainerProbes(liveness, readiness *corev1.Probe) PodSpecOption { + return func(p *corev1.PodSpec) { + p.Containers[0].LivenessProbe = liveness + p.Containers[0].ReadinessProbe = readiness + } +} diff --git a/pkg/reconciler/testing/deployment.go b/pkg/reconciler/testing/deployment.go index 8a7e6b46307..e9b984326bb 100644 --- a/pkg/reconciler/testing/deployment.go +++ b/pkg/reconciler/testing/deployment.go @@ -85,6 +85,12 @@ func WithDeploymentContainer(name, image string, liveness *corev1.Probe, readine } } +func WithDeploymentPodSpec(podSpec corev1.PodSpec) DeploymentOption { + return func(d *appsv1.Deployment) { + d.Spec.Template.Spec = podSpec + } +} + // WithDeploymentAvailable marks the Deployment as available. func WithDeploymentAvailable() DeploymentOption { return func(d *appsv1.Deployment) { @@ -96,3 +102,14 @@ func WithDeploymentAvailable() DeploymentOption { } } } + +func WithDeploymentNotAvailable() DeploymentOption { + return func(d *appsv1.Deployment) { + d.Status.Conditions = []appsv1.DeploymentCondition{ + { + Type: appsv1.DeploymentAvailable, + Status: corev1.ConditionFalse, + }, + } + } +} diff --git a/pkg/reconciler/testing/serving_service.go b/pkg/reconciler/testing/serving_service.go index c8bd7a6bafd..6fcdabb2deb 100644 --- a/pkg/reconciler/testing/serving_service.go +++ b/pkg/reconciler/testing/serving_service.go @@ -109,6 +109,12 @@ func WithServingServiceContainer(name, image string, liveness *corev1.Probe, rea } } +func WithServingServicePodSpec(podSpec corev1.PodSpec) ServingServiceOption { + return func(svc *servingv1.Service) { + svc.Spec.Template.Spec.Containers[0] = podSpec.Containers[0] + } +} + func WithServingServiceReady() ServingServiceOption { return func(svc *servingv1.Service) { svc.Status.Conditions = []apis.Condition{ diff --git a/pkg/reconciler/trigger/controller.go b/pkg/reconciler/trigger/controller.go index 72fb73dcad3..8c26008cf59 100644 --- a/pkg/reconciler/trigger/controller.go +++ b/pkg/reconciler/trigger/controller.go @@ -34,15 +34,15 @@ import ( "knative.dev/eventing/pkg/apis/eventing/v1alpha1" "knative.dev/eventing/pkg/duck" "knative.dev/eventing/pkg/reconciler" - "knative.dev/eventing/pkg/reconciler/utils/services" + "knative.dev/eventing/pkg/reconciler/service" "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/broker" "knative.dev/eventing/pkg/client/injection/informers/eventing/v1alpha1/trigger" "knative.dev/eventing/pkg/client/injection/informers/messaging/v1alpha1/subscription" servinginformer "knative.dev/eventing/pkg/client/injection/serving/informers/v1/service" - kubeservice "knative.dev/eventing/pkg/reconciler/utils/services/kube" - servingservice "knative.dev/eventing/pkg/reconciler/utils/services/serving" + kubeservice "knative.dev/eventing/pkg/reconciler/service/kube" + servingservice "knative.dev/eventing/pkg/reconciler/service/serving" kubeclient "knative.dev/pkg/client/injection/kube/client" deploymentinformer "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment" serviceinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/service" @@ -83,18 +83,18 @@ func NewController( serviceInformer := serviceinformer.Get(ctx) servingInformer := servinginformer.Get(ctx) - if env.ResourceFlavor == services.ServingFlavor && servingInformer.IsEmpty() { - log.Fatalf(`BROKER_RESOURCE_FLAVOR is set to %q but %v was not available`, services.ServingFlavor, servingv1.SchemeGroupVersion) + if env.ResourceFlavor == service.ServingFlavor && servingInformer.IsEmpty() { + log.Fatalf(`BROKER_RESOURCE_FLAVOR is set to %q but %v was not available`, service.ServingFlavor, servingv1.SchemeGroupVersion) } - var sf services.ServiceFlavor - if env.ResourceFlavor == services.ServingFlavor { - sf = &servingservice.ServingFlavor{ + var svcReconciler service.Reconciler + if env.ResourceFlavor == service.ServingFlavor { + svcReconciler = &servingservice.ServiceReconciler{ ServingClientSet: servingclient.Get(ctx), ServingLister: servingInformer.GetInternal().Lister(), } } else { - sf = &kubeservice.KubeFlavor{ + svcReconciler = &kubeservice.ServiceReconciler{ KubeClientSet: kubeclient.Get(ctx), DeploymentLister: deploymentInformer.Lister(), ServiceLister: serviceInformer.Lister(), @@ -107,7 +107,7 @@ func NewController( subscriptionLister: subscriptionInformer.Lister(), brokerLister: brokerInformer.Lister(), namespaceLister: namespaceInformer.Lister(), - services: sf, + svcReconciler: svcReconciler, } impl := controller.NewImpl(r, r.Logger, ReconcilerName) diff --git a/pkg/reconciler/trigger/trigger.go b/pkg/reconciler/trigger/trigger.go index c31721071c1..8553b7b29ec 100644 --- a/pkg/reconciler/trigger/trigger.go +++ b/pkg/reconciler/trigger/trigger.go @@ -45,9 +45,9 @@ import ( "knative.dev/eventing/pkg/logging" "knative.dev/eventing/pkg/reconciler" brokerresources "knative.dev/eventing/pkg/reconciler/broker/resources" + "knative.dev/eventing/pkg/reconciler/service" "knative.dev/eventing/pkg/reconciler/trigger/path" "knative.dev/eventing/pkg/reconciler/trigger/resources" - "knative.dev/eventing/pkg/reconciler/utils/services" ) const ( @@ -78,7 +78,7 @@ type Reconciler struct { addressableTracker duck.ListableTracker uriResolver *resolver.URIResolver - services services.ServiceFlavor + svcReconciler service.Reconciler } var brokerGVK = v1alpha1.SchemeGroupVersion.WithKind("Broker") @@ -192,7 +192,7 @@ func (r *Reconciler) reconcile(ctx context.Context, t *v1alpha1.Trigger) error { } // Get Broker filter service. - filterSvcStatus, err := r.services.GetStatus(ctx, b, brokerresources.MakeFilterServiceMeta(b)) + filterSvcStatus, err := r.svcReconciler.GetStatus(ctx, brokerresources.MakeFilterServiceMeta(b)) if err != nil { if apierrs.IsNotFound(err) { logging.FromContext(ctx).Error("can not find Broker's Filter service", zap.Error(err)) diff --git a/pkg/reconciler/trigger/trigger_test.go b/pkg/reconciler/trigger/trigger_test.go index f3af8f24e9f..73fee6acb1d 100644 --- a/pkg/reconciler/trigger/trigger_test.go +++ b/pkg/reconciler/trigger/trigger_test.go @@ -50,11 +50,11 @@ import ( messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" "knative.dev/eventing/pkg/reconciler" brokerresources "knative.dev/eventing/pkg/reconciler/broker/resources" + "knative.dev/eventing/pkg/reconciler/service" + kubeservice "knative.dev/eventing/pkg/reconciler/service/kube" + servingservice "knative.dev/eventing/pkg/reconciler/service/serving" reconciletesting "knative.dev/eventing/pkg/reconciler/testing" "knative.dev/eventing/pkg/reconciler/trigger/resources" - "knative.dev/eventing/pkg/reconciler/utils/services" - kubeservice "knative.dev/eventing/pkg/reconciler/utils/services/kube" - servingservice "knative.dev/eventing/pkg/reconciler/utils/services/serving" "knative.dev/eventing/pkg/utils" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" @@ -145,8 +145,8 @@ func init() { } func TestAllCases(t *testing.T) { - svcFunc := func(ctx context.Context, listers *Listers) services.ServiceFlavor { - return &kubeservice.KubeFlavor{ + svcFunc := func(ctx context.Context, listers *Listers) service.Reconciler { + return &kubeservice.ServiceReconciler{ KubeClientSet: kubeclient.Get(ctx), DeploymentLister: listers.GetDeploymentLister(), ServiceLister: listers.GetK8sServiceLister(), @@ -156,8 +156,8 @@ func TestAllCases(t *testing.T) { } func TestAllCasesWithServingServiceBroker(t *testing.T) { - svcFunc := func(ctx context.Context, listers *Listers) services.ServiceFlavor { - return &servingservice.ServingFlavor{ + svcFunc := func(ctx context.Context, listers *Listers) service.Reconciler { + return &servingservice.ServiceReconciler{ ServingClientSet: servingclient.Get(ctx), ServingLister: listers.GetServingServiceLister(), } @@ -165,7 +165,7 @@ func TestAllCasesWithServingServiceBroker(t *testing.T) { testAllCases(t, makeBrokerFilterServingService(), svcFunc) } -func testAllCases(t *testing.T, brokerFilterSvc runtime.Object, svcFunc func(context.Context, *Listers) services.ServiceFlavor) { +func testAllCases(t *testing.T, brokerFilterSvc runtime.Object, svcFunc func(context.Context, *Listers) service.Reconciler) { triggerKey := testNS + "/" + triggerName table := TableTest{ { @@ -1034,7 +1034,7 @@ func testAllCases(t *testing.T, brokerFilterSvc runtime.Object, svcFunc func(con addressableTracker: duck.NewListableTracker(ctx, v1a1addr.Get, func(types.NamespacedName) {}, 0), kresourceTracker: duck.NewListableTracker(ctx, conditions.Get, func(types.NamespacedName) {}, 0), uriResolver: resolver.NewURIResolver(ctx, func(types.NamespacedName) {}), - services: svcFunc(ctx, listers), + svcReconciler: svcFunc(ctx, listers), } }, false, From 660bb3cfd24d94599e57d4f82501c06fc0987106 Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Mon, 27 Jan 2020 06:45:31 +0000 Subject: [PATCH 08/11] run update-codegen --- Gopkg.lock | 1 + config/500-controller.yaml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Gopkg.lock b/Gopkg.lock index ef4c3b23ac1..994017fa82f 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1658,6 +1658,7 @@ "knative.dev/serving/pkg/client/injection/client", "knative.dev/serving/pkg/client/injection/client/fake", "knative.dev/serving/pkg/client/injection/informers/factory", + "knative.dev/serving/pkg/client/injection/informers/factory/fake", "knative.dev/serving/pkg/client/injection/informers/serving/v1/service/fake", "knative.dev/serving/pkg/client/listers/serving/v1", "knative.dev/test-infra/scripts", diff --git a/config/500-controller.yaml b/config/500-controller.yaml index dc223109564..f4704975c15 100644 --- a/config/500-controller.yaml +++ b/config/500-controller.yaml @@ -58,6 +58,8 @@ spec: value: eventing-broker-filter - name: BROKER_IMAGE_PULL_SECRET_NAME value: + # Uncomment the following to use knative service for + # broker components. # - name: BROKER_RESOURCE_FLAVOR # value: knative ports: From f6d7da1cc9c62fdf62d0fdb0f8654e8035bc0715 Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Mon, 27 Jan 2020 21:40:56 +0000 Subject: [PATCH 09/11] add unit tests for broker resources --- .../broker/resources/filter_test.go | 130 ++++++++++++++++++ .../broker/resources/ingress_test.go | 128 +++++++++++++++++ 2 files changed, 258 insertions(+) create mode 100644 pkg/reconciler/broker/resources/filter_test.go create mode 100644 pkg/reconciler/broker/resources/ingress_test.go diff --git a/pkg/reconciler/broker/resources/filter_test.go b/pkg/reconciler/broker/resources/filter_test.go new file mode 100644 index 00000000000..011e8974a97 --- /dev/null +++ b/pkg/reconciler/broker/resources/filter_test.go @@ -0,0 +1,130 @@ +/* +Copyright 2020 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 resources + +import ( + "os" + "testing" + + "github.com/google/go-cmp/cmp" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + "knative.dev/eventing/pkg/reconciler/service" +) + +func TestMakeFilterServiceArgs(t *testing.T) { + _ = os.Setenv("SYSTEM_NAMESPACE", "my-system-ns") + b := &eventingv1alpha1.Broker{ + ObjectMeta: metav1.ObjectMeta{ + Name: "default", + Namespace: "my-ns", + }, + } + want := &service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Namespace: "my-ns", + Name: "default-broker-filter", + Labels: map[string]string{ + "eventing.knative.dev/broker": "default", + "eventing.knative.dev/brokerRole": "filter", + }, + }, + DeployMeta: metav1.ObjectMeta{ + Namespace: "my-ns", + Name: "default-broker-filter", + Labels: map[string]string{ + "eventing.knative.dev/broker": "default", + "eventing.knative.dev/brokerRole": "filter", + }, + }, + PodSpec: corev1.PodSpec{ + ServiceAccountName: "my-serviceaccount", + Containers: []corev1.Container{ + { + Name: "filter", + Image: "image.example.com/filter", + LivenessProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/healthz", + }, + }, + InitialDelaySeconds: 5, + PeriodSeconds: 2, + FailureThreshold: 3, + TimeoutSeconds: 10, + SuccessThreshold: 1, + }, + ReadinessProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/readyz", + }, + }, + InitialDelaySeconds: 5, + PeriodSeconds: 2, + FailureThreshold: 3, + TimeoutSeconds: 10, + SuccessThreshold: 1, + }, + Env: []corev1.EnvVar{ + { + Name: "SYSTEM_NAMESPACE", + Value: "my-system-ns", + }, + { + Name: "NAMESPACE", + Value: "my-ns", + }, + { + Name: "POD_NAME", + Value: "default-broker-filter", + }, + { + Name: "CONTAINER_NAME", + Value: "filter", + }, + { + Name: "BROKER", + Value: "default", + }, + { + Name: "METRICS_DOMAIN", + Value: "knative.dev/internal/eventing", + }, + }, + Ports: []corev1.ContainerPort{ + { + ContainerPort: 8080, + }, + }, + }, + }, + }, + } + + got := MakeFilterServiceArgs(&FilterArgs{ + Broker: b, + Image: "image.example.com/filter", + ServiceAccountName: "my-serviceaccount", + }) + + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("Unexpected filter service arguments (-want, +got): %s", diff) + } +} diff --git a/pkg/reconciler/broker/resources/ingress_test.go b/pkg/reconciler/broker/resources/ingress_test.go new file mode 100644 index 00000000000..ca6b013a35d --- /dev/null +++ b/pkg/reconciler/broker/resources/ingress_test.go @@ -0,0 +1,128 @@ +/* +Copyright 2020 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 resources + +import ( + "os" + "testing" + + "github.com/google/go-cmp/cmp" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + "knative.dev/eventing/pkg/reconciler/service" +) + +func TestMakeIngressServiceArgs(t *testing.T) { + _ = os.Setenv("SYSTEM_NAMESPACE", "my-system-ns") + b := &eventingv1alpha1.Broker{ + ObjectMeta: metav1.ObjectMeta{ + Name: "default", + Namespace: "my-ns", + }, + } + + want := &service.Args{ + ServiceMeta: metav1.ObjectMeta{ + Namespace: "my-ns", + Name: "default-broker", + Labels: map[string]string{ + "eventing.knative.dev/broker": "default", + "eventing.knative.dev/brokerRole": "ingress", + }, + }, + DeployMeta: metav1.ObjectMeta{ + Namespace: "my-ns", + Name: "default-broker-ingress", + Labels: map[string]string{ + "eventing.knative.dev/broker": "default", + "eventing.knative.dev/brokerRole": "ingress", + }, + }, + PodSpec: corev1.PodSpec{ + ServiceAccountName: "my-serviceaccount", + Containers: []corev1.Container{ + { + Name: "ingress", + Image: "image.example.com/ingress", + LivenessProbe: &corev1.Probe{ + Handler: corev1.Handler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/healthz", + }, + }, + InitialDelaySeconds: 5, + PeriodSeconds: 2, + FailureThreshold: 3, + TimeoutSeconds: 10, + SuccessThreshold: 1, + }, + Env: []corev1.EnvVar{ + { + Name: "SYSTEM_NAMESPACE", + Value: "my-system-ns", + }, + { + Name: "NAMESPACE", + Value: "my-ns", + }, + { + Name: "POD_NAME", + Value: "default-broker-ingress", + }, + { + Name: "CONTAINER_NAME", + Value: "ingress", + }, + { + Name: "FILTER", + Value: "", + }, + { + Name: "CHANNEL", + Value: "chan.example.com", + }, + { + Name: "BROKER", + Value: "default", + }, + { + Name: "METRICS_DOMAIN", + Value: "knative.dev/internal/eventing", + }, + }, + Ports: []corev1.ContainerPort{ + { + ContainerPort: 8080, + }, + }, + }, + }, + }, + } + + got := MakeIngressServiceArgs(&IngressArgs{ + Broker: b, + Image: "image.example.com/ingress", + ServiceAccountName: "my-serviceaccount", + ChannelAddress: "chan.example.com", + }) + + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("Unexpected filter service arguments (-want, +got): %s", diff) + } +} From af885e53f4d669a1218555e4c7d97b5e46c5dade Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Mon, 27 Jan 2020 22:53:22 +0000 Subject: [PATCH 10/11] fix controller yaml symlink --- config/500-controller.yaml | 75 +------------------------ config/core/deployments/controller.yaml | 4 ++ 2 files changed, 5 insertions(+), 74 deletions(-) mode change 100644 => 120000 config/500-controller.yaml diff --git a/config/500-controller.yaml b/config/500-controller.yaml deleted file mode 100644 index f4704975c15..00000000000 --- a/config/500-controller.yaml +++ /dev/null @@ -1,74 +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. - -apiVersion: apps/v1 -kind: Deployment -metadata: - name: eventing-controller - namespace: knative-eventing - labels: - eventing.knative.dev/release: devel -spec: - replicas: 1 - selector: - matchLabels: - app: eventing-controller - template: - metadata: - annotations: - sidecar.istio.io/inject: "false" - labels: - app: eventing-controller - eventing.knative.dev/release: devel - spec: - serviceAccountName: eventing-controller - containers: - - name: eventing-controller - terminationMessagePolicy: FallbackToLogsOnError - image: knative.dev/eventing/cmd/controller - env: - - name: SYSTEM_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: CONFIG_LOGGING_NAME - value: config-logging - - name: CONFIG_OBSERVABILITY_NAME - value: config-observability - - name: METRICS_DOMAIN - value: knative.dev/eventing - - name: BROKER_INGRESS_IMAGE - value: knative.dev/eventing/cmd/broker/ingress - - name: BROKER_INGRESS_SERVICE_ACCOUNT - value: eventing-broker-ingress - - name: BROKER_FILTER_IMAGE - value: knative.dev/eventing/cmd/broker/filter - - name: BROKER_FILTER_SERVICE_ACCOUNT - value: eventing-broker-filter - - name: BROKER_IMAGE_PULL_SECRET_NAME - value: - # Uncomment the following to use knative service for - # broker components. - # - name: BROKER_RESOURCE_FLAVOR - # value: knative - ports: - - containerPort: 9090 - name: metrics - volumeMounts: - - name: config-logging - mountPath: /etc/config-logging - volumes: - - name: config-logging - configMap: - name: config-logging diff --git a/config/500-controller.yaml b/config/500-controller.yaml new file mode 120000 index 00000000000..a3175117ed7 --- /dev/null +++ b/config/500-controller.yaml @@ -0,0 +1 @@ +core/deployments/controller.yaml \ No newline at end of file diff --git a/config/core/deployments/controller.yaml b/config/core/deployments/controller.yaml index ac3c0727e42..2d22ee4566c 100644 --- a/config/core/deployments/controller.yaml +++ b/config/core/deployments/controller.yaml @@ -64,6 +64,10 @@ spec: value: eventing-broker-filter - name: BROKER_IMAGE_PULL_SECRET_NAME value: + # Uncomment the following to use knative service for + # broker components. + # - name: BROKER_RESOURCE_FLAVOR + # value: knative # Legacy CronJobSource - name: CRONJOB_RA_IMAGE value: knative.dev/eventing/cmd/cronjob_receive_adapter From d2763de108fb4a7851a1ff6f87018fa991a98c98 Mon Sep 17 00:00:00 2001 From: Chen Shou Date: Mon, 27 Jan 2020 22:57:26 +0000 Subject: [PATCH 11/11] fix more symlinks --- config/200-controller-clusterrole.yaml | 133 +----------------- .../core/roles/controller-clusterroles.yaml | 7 + 2 files changed, 8 insertions(+), 132 deletions(-) mode change 100644 => 120000 config/200-controller-clusterrole.yaml diff --git a/config/200-controller-clusterrole.yaml b/config/200-controller-clusterrole.yaml deleted file mode 100644 index 0a84d0ec14a..00000000000 --- a/config/200-controller-clusterrole.yaml +++ /dev/null @@ -1,132 +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. - -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: knative-eventing-controller - labels: - eventing.knative.dev/release: devel -rules: - - apiGroups: - - "" - resources: - - "namespaces" - - "secrets" - - "configmaps" - - "services" - - "events" - - "serviceaccounts" - verbs: &everything - - "get" - - "list" - - "create" - - "update" - - "delete" - - "patch" - - "watch" - - # Brokers and the namespace annotation controllers manipulate Deployments. - - apiGroups: - - "apps" - resources: - - "deployments" - verbs: *everything - - # The namespace annotation controller needs to manipulate RoleBindings. - - apiGroups: - - "rbac.authorization.k8s.io" - resources: - - "rolebindings" - verbs: *everything - - - apiGroups: - - serving.knative.dev - resources: - - services - verbs: *everything - - # Our own resources and statuses we care about. - - apiGroups: - - "eventing.knative.dev" - resources: - - "brokers" - - "brokers/status" - - "triggers" - - "triggers/status" - - "eventtypes" - - "eventtypes/status" - verbs: *everything - - # Eventing resources and finalizers we care about. - - apiGroups: - - "eventing.knative.dev" - resources: - - "brokers/finalizers" - - "triggers/finalizers" - verbs: - - "update" - - # Our own resources and statuses we care about. - - apiGroups: - - "messaging.knative.dev" - resources: - - "sequences" - - "sequences/status" - - "channels" - - "channels/status" - - "parallels" - - "parallels/status" - - "subscriptions" - - "subscriptions/status" - verbs: *everything - - # Flow resources and statuses we care about. - - apiGroups: - - "flows.knative.dev" - resources: - - "sequences" - - "sequences/status" - - "parallels" - - "parallels/status" - verbs: *everything - - # Messaging resources and finalizers we care about. - - apiGroups: - - "messaging.knative.dev" - resources: - - "sequences/finalizers" - - "parallels/finalizers" - - "channels/finalizers" - verbs: - - "update" - - # Flows resources and finalizers we care about. - - apiGroups: - - "flows.knative.dev" - resources: - - "sequences/finalizers" - - "parallels/finalizers" - verbs: - - "update" - - # The subscription controller needs to retrieve and watch CustomResourceDefinitions. - - apiGroups: - - "apiextensions.k8s.io" - resources: - - "customresourcedefinitions" - verbs: - - "get" - - "list" - - "watch" diff --git a/config/200-controller-clusterrole.yaml b/config/200-controller-clusterrole.yaml new file mode 120000 index 00000000000..db8a566437d --- /dev/null +++ b/config/200-controller-clusterrole.yaml @@ -0,0 +1 @@ +core/roles/controller-clusterroles.yaml \ No newline at end of file diff --git a/config/core/roles/controller-clusterroles.yaml b/config/core/roles/controller-clusterroles.yaml index a8b3436bbcd..2f5c9aa81cd 100644 --- a/config/core/roles/controller-clusterroles.yaml +++ b/config/core/roles/controller-clusterroles.yaml @@ -51,6 +51,13 @@ rules: - "rolebindings" verbs: *everything + # To make use knative serving API. + - apiGroups: + - serving.knative.dev + resources: + - services + verbs: *everything + # Our own resources and statuses we care about. - apiGroups: - "eventing.knative.dev"