From 15d01edc298743f8a46b6062e98191a471055617 Mon Sep 17 00:00:00 2001 From: Lionel Villard Date: Tue, 27 Apr 2021 10:39:54 -0400 Subject: [PATCH] remove v1alpha1 sources APIs --- cmd/webhook/main.go | 11 +- config/core/resources/apiserversource.yaml | 302 +---------- config/core/resources/sinkbindings.yaml | 6 +- go.sum | 2 - hack/update-codegen.sh | 4 +- .../sources/v1alpha1/apiserver_conversion.go | 162 ------ .../v1alpha1/apiserver_conversion_test.go | 334 ------------ .../sources/v1alpha1/apiserver_defaults.go | 29 - .../v1alpha1/apiserver_defaults_test.go | 28 - .../sources/v1alpha1/apiserver_lifecycle.go | 146 ----- .../v1alpha1/apiserver_lifecycle_test.go | 304 ----------- pkg/apis/sources/v1alpha1/apiserver_types.go | 123 ----- .../sources/v1alpha1/apiserver_types_test.go | 27 - .../sources/v1alpha1/apiserver_validation.go | 56 -- .../v1alpha1/apiserver_validation_test.go | 98 ---- pkg/apis/sources/v1alpha1/doc.go | 20 - pkg/apis/sources/v1alpha1/implements_test.go | 45 -- pkg/apis/sources/v1alpha1/register.go | 55 -- pkg/apis/sources/v1alpha1/register_test.go | 73 --- .../sources/v1alpha1/sinkbinding_context.go | 43 -- .../v1alpha1/sinkbinding_context_test.go | 43 -- .../v1alpha1/sinkbinding_conversion.go | 55 -- .../v1alpha1/sinkbinding_conversion_test.go | 294 ---------- .../sources/v1alpha1/sinkbinding_defaults.go | 34 -- .../v1alpha1/sinkbinding_defaults_test.go | 151 ------ .../sources/v1alpha1/sinkbinding_lifecycle.go | 152 ------ .../v1alpha1/sinkbinding_lifecycle_test.go | 506 ------------------ .../sources/v1alpha1/sinkbinding_types.go | 79 --- .../v1alpha1/sinkbinding_types_test.go | 27 - .../v1alpha1/sinkbinding_validation.go | 38 -- .../v1alpha1/sinkbinding_validation_test.go | 126 ----- .../sources/v1alpha1/zz_generated.deepcopy.go | 258 --------- pkg/client/clientset/versioned/clientset.go | 14 - .../versioned/fake/clientset_generated.go | 7 - .../clientset/versioned/fake/register.go | 2 - .../clientset/versioned/scheme/register.go | 2 - .../typed/sources/v1alpha1/apiserversource.go | 195 ------- .../versioned/typed/sources/v1alpha1/doc.go | 20 - .../typed/sources/v1alpha1/fake/doc.go | 20 - .../v1alpha1/fake/fake_apiserversource.go | 142 ----- .../sources/v1alpha1/fake/fake_sinkbinding.go | 142 ----- .../v1alpha1/fake/fake_sources_client.go | 44 -- .../sources/v1alpha1/generated_expansion.go | 23 - .../typed/sources/v1alpha1/sinkbinding.go | 195 ------- .../typed/sources/v1alpha1/sources_client.go | 94 ---- .../informers/externalversions/generic.go | 7 - .../externalversions/sources/interface.go | 8 - .../sources/v1alpha1/apiserversource.go | 90 ---- .../sources/v1alpha1/interface.go | 52 -- .../sources/v1alpha1/sinkbinding.go | 90 ---- .../apiserversource/apiserversource.go | 52 -- .../v1alpha1/apiserversource/fake/fake.go | 40 -- .../filtered/apiserversource.go | 65 --- .../apiserversource/filtered/fake/fake.go | 52 -- .../sources/v1alpha1/sinkbinding/fake/fake.go | 40 -- .../sinkbinding/filtered/fake/fake.go | 52 -- .../sinkbinding/filtered/sinkbinding.go | 65 --- .../v1alpha1/sinkbinding/sinkbinding.go | 52 -- .../sources/v1alpha1/apiserversource.go | 99 ---- .../sources/v1alpha1/expansion_generated.go | 35 -- .../listers/sources/v1alpha1/sinkbinding.go | 99 ---- pkg/reconciler/testing/listers.go | 10 - pkg/reconciler/testing/v1/sinkbinding.go | 2 +- .../testing/v1alpha1/sinkbinding.go | 63 --- pkg/reconciler/testing/v1beta1/listers.go | 10 - test/e2e/source_sinkbinding_v1alpha1_test.go | 210 -------- test/e2e_flags.go | 4 +- test/lib/creation.go | 18 - 68 files changed, 22 insertions(+), 5724 deletions(-) delete mode 100644 pkg/apis/sources/v1alpha1/apiserver_conversion.go delete mode 100644 pkg/apis/sources/v1alpha1/apiserver_conversion_test.go delete mode 100644 pkg/apis/sources/v1alpha1/apiserver_defaults.go delete mode 100644 pkg/apis/sources/v1alpha1/apiserver_defaults_test.go delete mode 100644 pkg/apis/sources/v1alpha1/apiserver_lifecycle.go delete mode 100644 pkg/apis/sources/v1alpha1/apiserver_lifecycle_test.go delete mode 100644 pkg/apis/sources/v1alpha1/apiserver_types.go delete mode 100644 pkg/apis/sources/v1alpha1/apiserver_types_test.go delete mode 100644 pkg/apis/sources/v1alpha1/apiserver_validation.go delete mode 100644 pkg/apis/sources/v1alpha1/apiserver_validation_test.go delete mode 100644 pkg/apis/sources/v1alpha1/doc.go delete mode 100644 pkg/apis/sources/v1alpha1/implements_test.go delete mode 100644 pkg/apis/sources/v1alpha1/register.go delete mode 100644 pkg/apis/sources/v1alpha1/register_test.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_context.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_context_test.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_conversion.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_defaults.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_defaults_test.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_lifecycle.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_lifecycle_test.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_types.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_types_test.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_validation.go delete mode 100644 pkg/apis/sources/v1alpha1/sinkbinding_validation_test.go delete mode 100644 pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go delete mode 100644 pkg/client/clientset/versioned/typed/sources/v1alpha1/apiserversource.go delete mode 100644 pkg/client/clientset/versioned/typed/sources/v1alpha1/doc.go delete mode 100644 pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/doc.go delete mode 100644 pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_apiserversource.go delete mode 100644 pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go delete mode 100644 pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go delete mode 100644 pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go delete mode 100644 pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go delete mode 100644 pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go delete mode 100644 pkg/client/informers/externalversions/sources/v1alpha1/apiserversource.go delete mode 100644 pkg/client/informers/externalversions/sources/v1alpha1/interface.go delete mode 100644 pkg/client/informers/externalversions/sources/v1alpha1/sinkbinding.go delete mode 100644 pkg/client/injection/informers/sources/v1alpha1/apiserversource/apiserversource.go delete mode 100644 pkg/client/injection/informers/sources/v1alpha1/apiserversource/fake/fake.go delete mode 100644 pkg/client/injection/informers/sources/v1alpha1/apiserversource/filtered/apiserversource.go delete mode 100644 pkg/client/injection/informers/sources/v1alpha1/apiserversource/filtered/fake/fake.go delete mode 100644 pkg/client/injection/informers/sources/v1alpha1/sinkbinding/fake/fake.go delete mode 100644 pkg/client/injection/informers/sources/v1alpha1/sinkbinding/filtered/fake/fake.go delete mode 100644 pkg/client/injection/informers/sources/v1alpha1/sinkbinding/filtered/sinkbinding.go delete mode 100644 pkg/client/injection/informers/sources/v1alpha1/sinkbinding/sinkbinding.go delete mode 100644 pkg/client/listers/sources/v1alpha1/apiserversource.go delete mode 100644 pkg/client/listers/sources/v1alpha1/expansion_generated.go delete mode 100644 pkg/client/listers/sources/v1alpha1/sinkbinding.go delete mode 100644 pkg/reconciler/testing/v1alpha1/sinkbinding.go delete mode 100644 test/e2e/source_sinkbinding_v1alpha1_test.go diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go index f9ff24c4a2d..0b95322a2e1 100644 --- a/cmd/webhook/main.go +++ b/cmd/webhook/main.go @@ -49,7 +49,6 @@ import ( "knative.dev/eventing/pkg/apis/sources" pingdefaultconfig "knative.dev/eventing/pkg/apis/sources/config" sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" sourcesv1beta2 "knative.dev/eventing/pkg/apis/sources/v1beta2" @@ -71,9 +70,6 @@ var ourTypes = map[schema.GroupVersionKind]resourcesemantics.GenericCRD{ messagingv1.SchemeGroupVersion.WithKind("Subscription"): &messagingv1.Subscription{}, // For group sources.knative.dev. - // v1alpha1 - sourcesv1alpha1.SchemeGroupVersion.WithKind("ApiServerSource"): &sourcesv1alpha1.ApiServerSource{}, - sourcesv1alpha1.SchemeGroupVersion.WithKind("SinkBinding"): &sourcesv1alpha1.SinkBinding{}, // v1alpha2 sourcesv1alpha2.SchemeGroupVersion.WithKind("ApiServerSource"): &sourcesv1alpha2.ApiServerSource{}, sourcesv1alpha2.SchemeGroupVersion.WithKind("PingSource"): &sourcesv1alpha2.PingSource{}, @@ -223,7 +219,6 @@ func NewConversionController(ctx context.Context, cmw configmap.Watcher) *contro } var ( - sourcesv1alpha1_ = sourcesv1alpha1.SchemeGroupVersion.Version sourcesv1alpha2_ = sourcesv1alpha2.SchemeGroupVersion.Version sourcesv1beta1_ = sourcesv1beta1.SchemeGroupVersion.Version sourcesv1beta2_ = sourcesv1beta2.SchemeGroupVersion.Version @@ -239,9 +234,8 @@ func NewConversionController(ctx context.Context, cmw configmap.Watcher) *contro // Sources sourcesv1.Kind("ApiServerSource"): { DefinitionName: sources.ApiServerSourceResource.String(), - HubVersion: sourcesv1alpha1_, + HubVersion: sourcesv1alpha2_, Zygotes: map[string]conversion.ConvertibleObject{ - sourcesv1alpha1_: &sourcesv1alpha1.ApiServerSource{}, sourcesv1alpha2_: &sourcesv1alpha2.ApiServerSource{}, sourcesv1beta1_: &sourcesv1beta1.ApiServerSource{}, sourcesv1_: &sourcesv1.ApiServerSource{}, @@ -258,9 +252,8 @@ func NewConversionController(ctx context.Context, cmw configmap.Watcher) *contro }, sourcesv1.Kind("SinkBinding"): { DefinitionName: sources.SinkBindingResource.String(), - HubVersion: sourcesv1alpha1_, + HubVersion: sourcesv1alpha2_, Zygotes: map[string]conversion.ConvertibleObject{ - sourcesv1alpha1_: &sourcesv1alpha1.SinkBinding{}, sourcesv1alpha2_: &sourcesv1alpha2.SinkBinding{}, sourcesv1beta1_: &sourcesv1beta1.SinkBinding{}, sourcesv1_: &sourcesv1.SinkBinding{}, diff --git a/config/core/resources/apiserversource.yaml b/config/core/resources/apiserversource.yaml index c5b4106e20e..72e9466b1d9 100644 --- a/config/core/resources/apiserversource.yaml +++ b/config/core/resources/apiserversource.yaml @@ -37,298 +37,11 @@ spec: group: sources.knative.dev versions: - &version - name: v1alpha1 + name: v1alpha2 served: true storage: false subresources: status: {} - schema: - openAPIV3Schema: - type: object - description: 'ApiServerSource is an event source that brings Kubernetes API server events into Knative.' - properties: - spec: - type: object - description: 'ApiServerSourceSpec defines the desired state of ApiServerSource (from the client).' - properties: - ceOverrides: - description: 'CloudEventOverrides defines overrides to control the - output format and modifications of the event sent to the sink.' - type: object - properties: - extensions: - description: 'Extensions specify what attribute are added or - overridden on the outbound event. Each `Extensions` key-value - pair are set on the event as an attribute extension independently.' - type: object - additionalProperties: - type: string - mode: - description: 'Mode is the mode the receive adapter controller runs - under: Ref or Resource. `Ref` sends only the reference to the - resource. `Resource` send the full resource.' - type: string - owner: - description: 'ResourceOwner is an additional filter to only track resources - that are owned by a specific resource type. If ResourceOwner matches - Resources[n] then Resources[n] is allowed to pass the ResourceOwner - filter.' - type: object - properties: - apiVersion: - description: 'APIVersion - the API version of the resource - to watch.' - type: string - kind: - description: 'Kind of the resource to watch. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - resources: - description: 'Resources is the list of resources to watch' - type: array - items: - type: object - properties: - apiVersion: - description: 'API version of the resource to watch.' - type: string - controller: - description: 'If true, send an event referencing the object - controlling the resource Deprecated: Per-resource - controller flag will no longer be supported in v1alpha2, - please use Spec.Owner as a GKV.' - type: boolean - controllerSelector: - description: 'ControllerSelector restricts this source - to objects with a controlling owner reference of the - specified kind. Only apiVersion and kind are used. - Both are optional. Deprecated: Per-resource owner - refs will no longer be supported in v1alpha2, please - use Spec.Owner as a GKV.' - type: object - properties: - apiVersion: - description: 'API version of the referent.' - type: string - blockOwnerDeletion: - description: 'If true, AND if the owner has the - "foregroundDeletion" finalizer, then the owner - cannot be deleted from the key-value store - until this reference is removed. Defaults - to false. To set this field, a user needs - "delete" permission of the owner, otherwise - 422 (Unprocessable Entity) will be returned.' - type: boolean - controller: - description: 'If true, this reference points to - the managing controller.' - type: boolean - kind: - description: 'Kind of the referent. More info: - https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - name: - description: 'Name of the referent. More info: - http://kubernetes.io/docs/user-guide/identifiers#names' - type: string - uid: - description: 'UID of the referent. More info: - http://kubernetes.io/docs/user-guide/identifiers#uids' - type: string - kind: - description: 'Kind of the resource to watch. More info: - https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - labelSelector: - description: 'LabelSelector restricts this source to objects - with the selected labels More info: http://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors' - type: object - properties: - matchExpressions: - description: 'matchExpressions is a list of label - selector requirements. The requirements are - ANDed.' - type: array - items: - type: object - properties: - key: - description: 'key is the label key - that the selector applies to.' - type: string - operator: - description: 'operator represents a - key''s relationship to a set of - values. Valid operators are In, - NotIn, Exists and DoesNotExist.' - type: string - values: - description: 'values is an array of - string values. If the operator - is In or NotIn, the values array - must be non-empty. If the operator - is Exists or DoesNotExist, the - values array must be empty. This - array is replaced during a strategic - merge patch.' - type: array - items: - type: string - matchLabels: - description: 'matchLabels is a map of {key,value} - pairs. A single {key,value} in the matchLabels - map is equivalent to an element of matchExpressions, - whose key field is "key", the operator is - "In", and the values array contains only "value". - The requirements are ANDed.' - type: object - x-kubernetes-preserve-unknown-fields: true - serviceAccountName: - description: 'ServiceAccountName is the name of the ServiceAccount - to use to run this source.' - type: string - sink: - description: 'Sink is a reference to an object that will resolve to - a domain name to use as the sink.' - type: object - properties: - apiVersion: - type: string - kind: - type: string - name: - type: string - namespace: - type: string - ref: - description: 'Ref points to an Addressable.' - type: object - properties: - apiVersion: - description: 'API version of the referent.' - type: string - fieldPath: - description: 'If referring to a piece of an object - instead of an entire object, this string should - contain a valid JSON/Go field access statement, - such as desiredState.manifest.containers[2]. For - example, if the object reference is to a container - within a pod, this would take on a value like: - "spec.containers{name}" (where "name" refers to - the name of the container that triggered the event) - or if no container name is specified "spec.containers[2]" - (container with index 2 in this pod). This syntax - is chosen only to have some well-defined way of - referencing a part of an object.' - type: string - kind: - description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' - type: string - namespace: - description: 'Namespace of the referent. More info: - https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/' - type: string - resourceVersion: - description: 'Specific resourceVersion to which this - reference is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency' - type: string - uid: - description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids' - type: string - uri: - description: 'URI can be an absolute URL(non-empty scheme and - non-empty host) pointing to the target or a relative URI. - Relative URIs will be resolved using the base URI retrieved - from Ref.' - type: string - status: - type: object - description: 'ApiServerSourceStatus defines the observed state of ApiServerSource (from the controller).' - properties: - annotations: - description: 'Annotations is additional Status fields for the Resource - to save some additional State as well as convey more information - to the user. This is roughly akin to Annotations on any k8s resource, - just the reconciler conveying richer information outwards.' - type: object - x-kubernetes-preserve-unknown-fields: true - ceAttributes: - description: 'CloudEventAttributes are the specific attributes that - the Source uses as part of its CloudEvents.' - type: array - items: - type: object - properties: - source: - description: 'Source is the CloudEvents source attribute.' - type: string - type: - description: Type refers to the CloudEvent type attribute.' - type: string - conditions: - description: 'Conditions the latest available observations of a resource''s - current state.' - type: array - items: - type: object - required: - - type - - status - properties: - lastTransitionTime: - description: 'LastTransitionTime is the last time the condition - transitioned from one status to another. We use VolatileTime - in place of metav1.Time to exclude this from creating - equality.Semantic differences (all other things held - constant).' - type: string - message: - description: 'A human readable message indicating details - about the transition.' - type: string - reason: - description: 'The reason for the condition''s last transition.' - type: string - severity: - description: 'Severity with which to treat failures of - this type of condition. When this is not specified, - it defaults to Error.' - type: string - status: - description: 'Status of the condition, one of True, False, - Unknown.' - type: string - type: - description: 'Type of condition.' - type: string - observedGeneration: - description: 'ObservedGeneration is the "Generation" of the Service - that was last processed by the controller.' - type: integer - format: int64 - sinkUri: - description: 'SinkURI is the current active sink URI that has been - configured for the Source.' - type: string - additionalPrinterColumns: - - name: Sink - type: string - jsonPath: ".status.sinkUri" - - name: Age - type: date - jsonPath: .metadata.creationTimestamp - - name: Ready - type: string - jsonPath: ".status.conditions[?(@.type==\"Ready\")].status" - - name: Reason - type: string - jsonPath: ".status.conditions[?(@.type==\"Ready\")].reason" - - << : *version - name: v1alpha2 - served: true - storage: false schema: openAPIV3Schema: &openAPIV3Schema type: object @@ -535,6 +248,19 @@ spec: description: 'SinkURI is the current active sink URI that has been configured for the Source.' type: string + additionalPrinterColumns: + - name: Sink + type: string + jsonPath: ".status.sinkUri" + - name: Age + type: date + jsonPath: .metadata.creationTimestamp + - name: Ready + type: string + jsonPath: ".status.conditions[?(@.type==\"Ready\")].status" + - name: Reason + type: string + jsonPath: ".status.conditions[?(@.type==\"Ready\")].reason" - <<: *version name: v1beta1 served: true diff --git a/config/core/resources/sinkbindings.yaml b/config/core/resources/sinkbindings.yaml index 0939a3ecb87..2181b0a573a 100644 --- a/config/core/resources/sinkbindings.yaml +++ b/config/core/resources/sinkbindings.yaml @@ -26,7 +26,7 @@ spec: group: sources.knative.dev versions: - &version - name: v1alpha1 + name: v1alpha2 served: true storage: false subresources: @@ -52,10 +52,6 @@ spec: - name: Reason type: string jsonPath: ".status.conditions[?(@.type=='Ready')].reason" - - <<: *version - name: v1alpha2 - served: true - storage: false - <<: *version name: v1beta1 served: true diff --git a/go.sum b/go.sum index e95df0499b4..07b1fd5ca7d 100644 --- a/go.sum +++ b/go.sum @@ -1117,13 +1117,11 @@ k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6 h1:+WnxoVtG8TMiudHBSEtrVL k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H64/qeyjQoUZhGpeFDVdxjTeEVN2o= k8s.io/utils v0.0.0-20200729134348-d5654de09c73 h1:uJmqzgNWG7XyClnU/mLPBWwfKKF1K8Hf8whTseBgJcg= k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -knative.dev/hack v0.0.0-20210325223819-b6ab329907d3 h1:km0Rrh0T9/wA2pivQm1hqSPVwgNgGCHC2WNn3GakZmE= knative.dev/hack v0.0.0-20210325223819-b6ab329907d3/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/hack v0.0.0-20210426064739-88c69cd1eca7 h1:Z5icQ2KNCDSzTcHWMGI3KzdK/BpmgkGYdTX0RRzZul0= knative.dev/hack v0.0.0-20210426064739-88c69cd1eca7/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/hack/schema v0.0.0-20210426064739-88c69cd1eca7 h1:ztK9WrMIOXLvCKDftybJs+AS8gNywgOiJyZEuKSEyBw= knative.dev/hack/schema v0.0.0-20210426064739-88c69cd1eca7/go.mod h1:ffjwmdcrH5vN3mPhO8RrF2KfNnbHeCE2C60A+2cv3U0= -knative.dev/pkg v0.0.0-20210420053235-1afd04993622 h1:wSyDPp/LuOLeDCpvUHgKXqb4DfmCEPelsaYzC0Fojm0= knative.dev/pkg v0.0.0-20210420053235-1afd04993622/go.mod h1:UtcSLHy2XIz5blWoPTA40F87zk4O7erxkCwv+7Tsmws= knative.dev/pkg v0.0.0-20210426180040-cfc1eed82870 h1:22gVDwcYqqZDGJOEBTBCthJH88dyTSLokOWlz1E9GIg= knative.dev/pkg v0.0.0-20210426180040-cfc1eed82870/go.mod h1:UtcSLHy2XIz5blWoPTA40F87zk4O7erxkCwv+7Tsmws= diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index dcdc10462b3..cd1b45899d6 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -38,7 +38,7 @@ group "Kubernetes Codegen" # instead of the $GOPATH directly. For normal projects this can be dropped. ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ knative.dev/eventing/pkg/client knative.dev/eventing/pkg/apis \ - "eventing:v1beta1 eventing:v1 messaging:v1 flows:v1 sources:v1alpha1 sources:v1alpha2 sources:v1beta1 sources:v1beta2 sources:v1" \ + "eventing:v1beta1 eventing:v1 messaging:v1 flows:v1 sources:v1alpha2 sources:v1beta1 sources:v1beta2 sources:v1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # Deep copy config @@ -59,7 +59,7 @@ group "Knative Codegen" # Knative Injection ${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \ knative.dev/eventing/pkg/client knative.dev/eventing/pkg/apis \ - "eventing:v1beta1 eventing:v1 messaging:v1 flows:v1 sources:v1alpha1 sources:v1alpha2 sources:v1beta1 sources:v1beta2 sources:v1 duck:v1beta1 duck:v1" \ + "eventing:v1beta1 eventing:v1 messaging:v1 flows:v1 sources:v1alpha2 sources:v1beta1 sources:v1beta2 sources:v1 duck:v1beta1 duck:v1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt group "Update deps post-codegen" diff --git a/pkg/apis/sources/v1alpha1/apiserver_conversion.go b/pkg/apis/sources/v1alpha1/apiserver_conversion.go deleted file mode 100644 index 619ff14fce9..00000000000 --- a/pkg/apis/sources/v1alpha1/apiserver_conversion.go +++ /dev/null @@ -1,162 +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 v1alpha1 - -import ( - "context" - "reflect" - - "github.com/google/go-cmp/cmp" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - corev1 "k8s.io/api/core/v1" - "knative.dev/eventing/pkg/apis/sources/v1alpha2" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" -) - -// ConvertTo implements apis.Convertible. -// Converts source (from v1alpha1.ApiServerSource) into into a higher version. -func (source *ApiServerSource) ConvertTo(ctx context.Context, obj apis.Convertible) error { - switch sink := obj.(type) { - case *v1alpha2.ApiServerSource: - // Meta - sink.ObjectMeta = source.ObjectMeta - - // Spec - - if len(source.Spec.Resources) > 0 { - sink.Spec.Resources = make([]v1alpha2.APIVersionKindSelector, len(source.Spec.Resources)) - } - for i, v := range source.Spec.Resources { - sink.Spec.Resources[i] = v1alpha2.APIVersionKindSelector{ - APIVersion: v.APIVersion, - Kind: v.Kind, - } - - if !cmp.Equal(v.LabelSelector, metav1.LabelSelector{}) { - sink.Spec.Resources[i].LabelSelector = &metav1.LabelSelector{} - v.LabelSelector.DeepCopyInto(sink.Spec.Resources[i].LabelSelector) - } - } - - switch source.Spec.Mode { - case RefMode: - sink.Spec.EventMode = v1alpha2.ReferenceMode - case ResourceMode: - sink.Spec.EventMode = v1alpha2.ResourceMode - } - - // Optional Spec - - if source.Spec.ResourceOwner != nil { - sink.Spec.ResourceOwner = source.Spec.ResourceOwner - } - - if source.Spec.Sink != nil { - var ref *duckv1.KReference - if source.Spec.Sink.Ref != nil { - ref = &duckv1.KReference{ - Kind: source.Spec.Sink.Ref.Kind, - Namespace: source.Spec.Sink.Ref.Namespace, - Name: source.Spec.Sink.Ref.Name, - APIVersion: source.Spec.Sink.Ref.APIVersion, - } - } - sink.Spec.Sink = duckv1.Destination{ - Ref: ref, - URI: source.Spec.Sink.URI, - } - } - - if source.Spec.CloudEventOverrides != nil { - sink.Spec.CloudEventOverrides = source.Spec.CloudEventOverrides.DeepCopy() - } - - sink.Spec.ServiceAccountName = source.Spec.ServiceAccountName - - // Status - source.Status.SourceStatus.DeepCopyInto(&sink.Status.SourceStatus) - return nil - default: - return apis.ConvertToViaProxy(ctx, source, &v1alpha2.ApiServerSource{}, sink) - } -} - -// ConvertFrom implements apis.Convertible. -// Converts obj from a higher version into v1alpha1.ApiServerSource. -func (sink *ApiServerSource) ConvertFrom(ctx context.Context, obj apis.Convertible) error { - switch source := obj.(type) { - case *v1alpha2.ApiServerSource: - // Meta - sink.ObjectMeta = source.ObjectMeta - - // Spec - - switch source.Spec.EventMode { - case v1alpha2.ReferenceMode: - sink.Spec.Mode = RefMode - case v1alpha2.ResourceMode: - sink.Spec.Mode = ResourceMode - } - - sink.Spec.CloudEventOverrides = source.Spec.CloudEventOverrides - - sink.Spec.Sink = &duckv1beta1.Destination{ - URI: source.Spec.Sink.URI, - } - if source.Spec.Sink.Ref != nil { - sink.Spec.Sink.Ref = &corev1.ObjectReference{ - Kind: source.Spec.Sink.Ref.Kind, - Namespace: source.Spec.Sink.Ref.Namespace, - Name: source.Spec.Sink.Ref.Name, - APIVersion: source.Spec.Sink.Ref.APIVersion, - } - } - if sink.Spec.Sink != nil && reflect.DeepEqual(*sink.Spec.Sink, duckv1beta1.Destination{}) { - sink.Spec.Sink = nil - } - - if len(source.Spec.Resources) > 0 { - sink.Spec.Resources = make([]ApiServerResource, len(source.Spec.Resources)) - } - for i, v := range source.Spec.Resources { - sink.Spec.Resources[i] = ApiServerResource{} - sink.Spec.Resources[i].APIVersion = v.APIVersion - sink.Spec.Resources[i].Kind = v.Kind - if v.LabelSelector != nil { - sink.Spec.Resources[i].LabelSelector = *v.LabelSelector - } - } - - // Spec Optionals - - if source.Spec.ResourceOwner != nil { - sink.Spec.ResourceOwner = source.Spec.ResourceOwner - } - - sink.Spec.ServiceAccountName = source.Spec.ServiceAccountName - - // Status - source.Status.SourceStatus.DeepCopyInto(&sink.Status.SourceStatus) - - return nil - default: - return apis.ConvertFromViaProxy(ctx, source, &v1alpha2.ApiServerSource{}, sink) - } -} diff --git a/pkg/apis/sources/v1alpha1/apiserver_conversion_test.go b/pkg/apis/sources/v1alpha1/apiserver_conversion_test.go deleted file mode 100644 index f059cefac6c..00000000000 --- a/pkg/apis/sources/v1alpha1/apiserver_conversion_test.go +++ /dev/null @@ -1,334 +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 v1alpha1 - -import ( - "context" - "errors" - "reflect" - "testing" - - corev1 "k8s.io/api/core/v1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" - - v1 "knative.dev/eventing/pkg/apis/sources/v1" - "knative.dev/eventing/pkg/apis/sources/v1alpha2" - "knative.dev/eventing/pkg/apis/sources/v1beta1" - - "github.com/google/go-cmp/cmp" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" -) - -// implement apis.Convertible -type testObject struct{} - -func (*testObject) ConvertTo(ctx context.Context, obj apis.Convertible) error { - return errors.New("Won't go") -} - -func (*testObject) ConvertFrom(ctx context.Context, obj apis.Convertible) error { - return errors.New("Won't go") -} - -func TestApiServerSourceConversionBadType(t *testing.T) { - good, bad := &ApiServerSource{}, &testObject{} - - if err := good.ConvertTo(context.Background(), bad); err == nil { - t.Errorf("ConvertTo() = %#v, wanted error", bad) - } - - if err := good.ConvertFrom(context.Background(), bad); err == nil { - t.Errorf("ConvertFrom() = %#v, wanted error", good) - } -} - -func TestApiServerSourceConversionRoundTripUp(t *testing.T) { - // Just one for now, just adding the for loop for ease of future changes. - versions := []apis.Convertible{&v1alpha2.ApiServerSource{}, &v1beta1.ApiServerSource{}, &v1.ApiServerSource{}} - - path := apis.HTTP("") - path.Path = "/path" - sink := duckv1beta1.Destination{ - Ref: &corev1.ObjectReference{ - APIVersion: "Baf", - Kind: "Foo", - Name: "Baz", - Namespace: "Baz", - }, - DeprecatedAPIVersion: "depApi", - DeprecatedKind: "depKind", - DeprecatedName: "depName", - DeprecatedNamespace: "depNamespace", - URI: path, - } - sinkUri := apis.HTTP("example.com") - sinkUri.Path = "path" - - tests := []struct { - name string - in *ApiServerSource - }{{name: "empty", - in: &ApiServerSource{ - ObjectMeta: metav1.ObjectMeta{ - Name: "apiserver-name", - Namespace: "apiserver-ns", - Generation: 17, - }, - Spec: ApiServerSourceSpec{}, - Status: ApiServerSourceStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - }, - }, - }, - }, {name: "simple configuration", - in: &ApiServerSource{ - ObjectMeta: metav1.ObjectMeta{ - Name: "apiserver-name", - Namespace: "apiserver-ns", - Generation: 17, - }, - Spec: ApiServerSourceSpec{ - Resources: []ApiServerResource{{ - APIVersion: "A1", - Kind: "K1", - LabelSelector: metav1.LabelSelector{ - MatchLabels: map[string]string{"A1": "K1"}, - }, - }, { - APIVersion: "A2", - Kind: "K2", - }}, - Sink: &sink, - Mode: "Ref", - }, - Status: ApiServerSourceStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "Unknown", - }}, - }, - SinkURI: sinkUri, - }, - }, - }, - }, {name: "full", - in: &ApiServerSource{ - ObjectMeta: metav1.ObjectMeta{ - Name: "apiserver-name", - Namespace: "apiserver-ns", - Generation: 17, - }, - Spec: ApiServerSourceSpec{ - Resources: []ApiServerResource{{ - APIVersion: "A1", - Kind: "K1", - LabelSelector: metav1.LabelSelector{ - MatchLabels: map[string]string{ - "foo": "bar", - }, - MatchExpressions: []metav1.LabelSelectorRequirement{{ - Key: "aKey", - Operator: metav1.LabelSelectorOpIn, - Values: []string{"the", "house"}, - }}, - }, - ControllerSelector: metav1.OwnerReference{}, - Controller: true, - }, { - APIVersion: "A2", - Kind: "K2", - }}, - ServiceAccountName: "adult", - Sink: &sink, - CloudEventOverrides: &duckv1.CloudEventOverrides{ - Extensions: map[string]string{ - "foo": "bar", - "baz": "baf", - }, - }, - Mode: "Resource", - }, - Status: ApiServerSourceStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - SinkURI: sinkUri, - }, - }, - }, - }} - for _, test := range tests { - for _, version := range versions { - t.Run(test.name, func(t *testing.T) { - ver := version - if err := test.in.ConvertTo(context.Background(), ver); err != nil { - t.Error("ConvertTo() =", err) - } - - got := &ApiServerSource{} - - if err := got.ConvertFrom(context.Background(), ver); err != nil { - t.Error("ConvertFrom() =", err) - } - fixed := fixApiServerSourceDeprecated(test.in) - if diff := cmp.Diff(fixed, got); diff != "" { - t.Error("roundtrip (-want, +got) =", diff) - } - }) - } - } -} - -// This tests round tripping from a higher version -> v1alpha1 and back to the higher version. -func TestApiServerSourceConversionRoundTripDown(t *testing.T) { - path := apis.HTTP("") - path.Path = "/path" - sink := duckv1.Destination{ - Ref: &duckv1.KReference{ - Kind: "Foo", - Namespace: "Bar", - Name: "Baz", - APIVersion: "Baf", - }, - URI: path, - } - sinkUri := apis.HTTP("example.com") - sinkUri.Path = "path" - - ceOverrides := duckv1.CloudEventOverrides{ - Extensions: map[string]string{ - "foo": "bar", - "baz": "baf", - }, - } - - tests := []struct { - name string - in apis.Convertible - }{{name: "empty", - in: &v1.ApiServerSource{ - ObjectMeta: metav1.ObjectMeta{ - Name: "apiserver-name", - Namespace: "apiserver-ns", - Generation: 17, - }, - Spec: v1.ApiServerSourceSpec{}, - Status: v1.ApiServerSourceStatus{}, - }, - }, {name: "simple configuration", - in: &v1.ApiServerSource{ - ObjectMeta: metav1.ObjectMeta{ - Name: "apiserver-name", - Namespace: "apiserver-ns", - Generation: 17, - }, - Spec: v1.ApiServerSourceSpec{ - SourceSpec: duckv1.SourceSpec{ - Sink: sink, - }, - }, - Status: v1.ApiServerSourceStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - SinkURI: sinkUri, - }, - }, - }, - }, {name: "full", - in: &v1.ApiServerSource{ - ObjectMeta: metav1.ObjectMeta{ - Name: "apiserver-name", - Namespace: "apiserver-ns", - Generation: 17, - }, - Spec: v1.ApiServerSourceSpec{ - SourceSpec: duckv1.SourceSpec{ - Sink: sink, - CloudEventOverrides: &ceOverrides, - }, - }, - Status: v1.ApiServerSourceStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - SinkURI: sinkUri, - }, - }, - }, - }} - for _, test := range tests { - - t.Run(test.name, func(t *testing.T) { - down := &ApiServerSource{} - if err := down.ConvertFrom(context.Background(), test.in); err != nil { - t.Error("ConvertTo() =", err) - } - - got := (reflect.New(reflect.TypeOf(test.in).Elem()).Interface()).(apis.Convertible) - - if err := down.ConvertTo(context.Background(), got); err != nil { - t.Error("ConvertFrom() =", err) - } - if diff := cmp.Diff(test.in, got); diff != "" { - t.Error("roundtrip (-want, +got) =", diff) - } - }) - } -} - -// Since v1alpha1 to v1alpha2 is lossy. -func fixApiServerSourceDeprecated(in *ApiServerSource) *ApiServerSource { - for i := range in.Spec.Resources { - in.Spec.Resources[i].Controller = false - in.Spec.Resources[i].ControllerSelector = metav1.OwnerReference{} - } - if in.Spec.Sink != nil { - in.Spec.Sink.DeprecatedAPIVersion = "" - in.Spec.Sink.DeprecatedKind = "" - in.Spec.Sink.DeprecatedName = "" - in.Spec.Sink.DeprecatedNamespace = "" - } - return in -} diff --git a/pkg/apis/sources/v1alpha1/apiserver_defaults.go b/pkg/apis/sources/v1alpha1/apiserver_defaults.go deleted file mode 100644 index bf2992d9716..00000000000 --- a/pkg/apis/sources/v1alpha1/apiserver_defaults.go +++ /dev/null @@ -1,29 +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 v1alpha1 - -import ( - "context" -) - -func (s *ApiServerSource) SetDefaults(ctx context.Context) { - s.Spec.SetDefaults(ctx) -} - -func (ss *ApiServerSourceSpec) SetDefaults(ctx context.Context) { - // TODO anything? -} diff --git a/pkg/apis/sources/v1alpha1/apiserver_defaults_test.go b/pkg/apis/sources/v1alpha1/apiserver_defaults_test.go deleted file mode 100644 index 25f9e7defeb..00000000000 --- a/pkg/apis/sources/v1alpha1/apiserver_defaults_test.go +++ /dev/null @@ -1,28 +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 v1alpha1 - -import ( - "context" - "testing" -) - -// No-op test because method does nothing. -func TestAPIServerSourceDefaults(t *testing.T) { - s := ApiServerSource{} - s.SetDefaults(context.TODO()) -} diff --git a/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go b/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go deleted file mode 100644 index fba140a7e9a..00000000000 --- a/pkg/apis/sources/v1alpha1/apiserver_lifecycle.go +++ /dev/null @@ -1,146 +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 v1alpha1 - -import ( - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/pkg/apis" -) - -const ( - // ApiServerConditionReady has status True when the ApiServerSource is ready to send events. - ApiServerConditionReady = apis.ConditionReady - - // ApiServerConditionSinkProvided has status True when the ApiServerSource has been configured with a sink target. - ApiServerConditionSinkProvided apis.ConditionType = "SinkProvided" - - // ApiServerConditionDeployed has status True when the ApiServerSource has had it's deployment created. - ApiServerConditionDeployed apis.ConditionType = "Deployed" - - // ApiServerConditionSufficientPermissions has status True when the ApiServerSource has sufficient permissions to access resources. - ApiServerConditionSufficientPermissions apis.ConditionType = "SufficientPermissions" -) - -var apiserverCondSet = apis.NewLivingConditionSet( - ApiServerConditionSinkProvided, - ApiServerConditionDeployed, - ApiServerConditionSufficientPermissions, -) - -// GetGroupVersionKind returns the GroupVersionKind. -func (s *ApiServerSource) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("ApiServerSource") -} - -// GetUntypedSpec returns the spec of the ApiServerSource. -func (s *ApiServerSource) GetUntypedSpec() interface{} { - return s.Spec -} - -// GetCondition returns the condition currently associated with the given type, or nil. -func (s *ApiServerSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition { - return apiserverCondSet.Manage(s).GetCondition(t) -} - -// GetTopLevelCondition returns the top level condition. -func (s *ApiServerSourceStatus) GetTopLevelCondition() *apis.Condition { - return apiserverCondSet.Manage(s).GetTopLevelCondition() -} - -// InitializeConditions sets relevant unset conditions to Unknown state. -func (s *ApiServerSourceStatus) InitializeConditions() { - apiserverCondSet.Manage(s).InitializeConditions() -} - -// MarkSink sets the condition that the source has a sink configured. -func (s *ApiServerSourceStatus) MarkSink(uri string) { - s.SinkURI = nil - if len(uri) > 0 { - if u, err := apis.ParseURL(uri); err != nil { - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionSinkProvided, "SinkInvalid", "Failed to parse sink: %v", err) - } else { - s.SinkURI = u - apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionSinkProvided) - } - - } else { - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionSinkProvided, "SinkEmpty", "Sink has resolved to empty.") - } -} - -// MarkSinkWarnDeprecated sets the condition that the source has a sink configured and warns ref is deprecated. -func (s *ApiServerSourceStatus) MarkSinkWarnRefDeprecated(uri string) { - if u, err := apis.ParseURL(uri); err != nil { - s.SinkURI = nil - } else { - s.SinkURI = u - } - if len(uri) > 0 { - c := apis.Condition{ - Type: ApiServerConditionSinkProvided, - Status: corev1.ConditionTrue, - Severity: apis.ConditionSeverityError, - Message: "Using deprecated object ref fields when specifying spec.sink. Update to spec.sink.ref. These will be removed in the future.", - } - apiserverCondSet.Manage(s).SetCondition(c) - } else { - apiserverCondSet.Manage(s).MarkUnknown(ApiServerConditionSinkProvided, "SinkEmpty", "Sink has resolved to empty.%s", "") - } -} - -// MarkNoSink sets the condition that the source does not have a sink configured. -func (s *ApiServerSourceStatus) MarkNoSink(reason, messageFormat string, messageA ...interface{}) { - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionSinkProvided, reason, messageFormat, messageA...) -} - -// PropagateDeploymentAvailability uses the availability of the provided Deployment to determine if -// ApiServerConditionDeployed should be marked as true or false. -func (s *ApiServerSourceStatus) PropagateDeploymentAvailability(d *appsv1.Deployment) { - deploymentAvailableFound := false - for _, cond := range d.Status.Conditions { - if cond.Type == appsv1.DeploymentAvailable { - deploymentAvailableFound = true - if cond.Status == corev1.ConditionTrue { - apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionDeployed) - } else if cond.Status == corev1.ConditionFalse { - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionDeployed, cond.Reason, cond.Message) - } else if cond.Status == corev1.ConditionUnknown { - apiserverCondSet.Manage(s).MarkUnknown(ApiServerConditionDeployed, cond.Reason, cond.Message) - } - } - } - if !deploymentAvailableFound { - apiserverCondSet.Manage(s).MarkUnknown(ApiServerConditionDeployed, "DeploymentUnavailable", "The Deployment '%s' is unavailable.", d.Name) - } -} - -// MarkSufficientPermissions sets the condition that the source has enough permissions to access the resources. -func (s *ApiServerSourceStatus) MarkSufficientPermissions() { - apiserverCondSet.Manage(s).MarkTrue(ApiServerConditionSufficientPermissions) -} - -// MarkNoSufficientPermissions sets the condition that the source does not have enough permissions to access the resources -func (s *ApiServerSourceStatus) MarkNoSufficientPermissions(reason, messageFormat string, messageA ...interface{}) { - apiserverCondSet.Manage(s).MarkFalse(ApiServerConditionSufficientPermissions, reason, messageFormat, messageA...) -} - -// IsReady returns true if the resource is ready overall. -func (s *ApiServerSourceStatus) IsReady() bool { - return apiserverCondSet.Manage(s).IsHappy() -} diff --git a/pkg/apis/sources/v1alpha1/apiserver_lifecycle_test.go b/pkg/apis/sources/v1alpha1/apiserver_lifecycle_test.go deleted file mode 100644 index f35cf2188b0..00000000000 --- a/pkg/apis/sources/v1alpha1/apiserver_lifecycle_test.go +++ /dev/null @@ -1,304 +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 v1alpha1 - -import ( - "reflect" - "testing" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "k8s.io/apimachinery/pkg/runtime/schema" - - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - "knative.dev/pkg/apis" -) - -var ( - availableDeployment = &appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "available", - }, - Status: appsv1.DeploymentStatus{ - Conditions: []appsv1.DeploymentCondition{ - { - Type: appsv1.DeploymentAvailable, - Status: corev1.ConditionTrue, - }, - }, - }, - } - - unavailableDeployment = &appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "unavailable", - }, - Status: appsv1.DeploymentStatus{ - Conditions: []appsv1.DeploymentCondition{ - { - Type: appsv1.DeploymentAvailable, - Status: corev1.ConditionFalse, - }, - }, - }, - } - - unknownDeployment = &appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Name: "unknown", - }, - Status: appsv1.DeploymentStatus{ - Conditions: []appsv1.DeploymentCondition{ - { - Type: appsv1.DeploymentAvailable, - Status: corev1.ConditionUnknown, - }, - }, - }, - } -) - -func TestApiServerSourceGetGroupVersionKind(t *testing.T) { - r := &ApiServerSource{} - want := schema.GroupVersionKind{ - Group: "sources.knative.dev", - Version: "v1alpha1", - Kind: "ApiServerSource", - } - if got := r.GetGroupVersionKind(); got != want { - t.Errorf("got: %v, want: %v", got, want) - } -} - -func TestApiServerSourceStatusIsReady(t *testing.T) { - tests := []struct { - name string - s *ApiServerSourceStatus - wantConditionStatus corev1.ConditionStatus - want bool - }{{ - name: "uninitialized", - s: &ApiServerSourceStatus{}, - want: false, - }, { - name: "initialized", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - return s - }(), - wantConditionStatus: corev1.ConditionUnknown, - want: false, - }, { - name: "mark deployed", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.PropagateDeploymentAvailability(availableDeployment) - return s - }(), - wantConditionStatus: corev1.ConditionUnknown, - want: false, - }, { - name: "mark sink", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.MarkSink("uri://example") - return s - }(), - wantConditionStatus: corev1.ConditionUnknown, - want: false, - }, { - name: "mark sufficient permissions", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.MarkSufficientPermissions() - return s - }(), - wantConditionStatus: corev1.ConditionUnknown, - want: false, - }, { - name: "mark sink and sufficient permissions and deployed", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.MarkSink("uri://example") - s.MarkSufficientPermissions() - s.PropagateDeploymentAvailability(availableDeployment) - return s - }(), - wantConditionStatus: corev1.ConditionTrue, - want: true, - }, { - name: "mark sink and sufficient permissions and unavailable deployment", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.MarkSink("uri://example") - s.MarkSufficientPermissions() - s.PropagateDeploymentAvailability(unavailableDeployment) - return s - }(), - wantConditionStatus: corev1.ConditionFalse, - want: false, - }, { - name: "mark sink and sufficient permissions and unknown deployment", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.MarkSink("uri://example") - s.MarkSufficientPermissions() - s.PropagateDeploymentAvailability(unknownDeployment) - return s - }(), - wantConditionStatus: corev1.ConditionUnknown, - want: false, - }, { - name: "mark sink and sufficient permissions and not deployed", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.MarkSink("uri://example") - s.MarkSufficientPermissions() - s.PropagateDeploymentAvailability(&appsv1.Deployment{}) - return s - }(), - wantConditionStatus: corev1.ConditionUnknown, - want: false, - }, { - name: "mark sink and not enough permissions", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.MarkSink("uri://example") - s.MarkNoSufficientPermissions("areason", "amessage") - return s - }(), - wantConditionStatus: corev1.ConditionFalse, - want: false, - }} - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - if test.wantConditionStatus != "" { - gotConditionStatus := test.s.GetTopLevelCondition().Status - if gotConditionStatus != test.wantConditionStatus { - t.Errorf("unexpected condition status: want %v, got %v", test.wantConditionStatus, gotConditionStatus) - } - } - got := test.s.IsReady() - if got != test.want { - t.Errorf("unexpected readiness: want %v, got %v", test.want, got) - } - }) - } -} - -func TestApiServerSourceStatusGetCondition(t *testing.T) { - tests := []struct { - name string - s *ApiServerSourceStatus - condQuery apis.ConditionType - want *apis.Condition - }{{ - name: "uninitialized", - s: &ApiServerSourceStatus{}, - condQuery: ApiServerConditionReady, - want: nil, - }, { - name: "initialized", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - return s - }(), - condQuery: ApiServerConditionReady, - want: &apis.Condition{ - Type: ApiServerConditionReady, - Status: corev1.ConditionUnknown, - }, - }, { - name: "mark deployed", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.PropagateDeploymentAvailability(availableDeployment) - return s - }(), - condQuery: ApiServerConditionReady, - want: &apis.Condition{ - Type: ApiServerConditionReady, - Status: corev1.ConditionUnknown, - }, - }, { - name: "mark sink", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.MarkSink("uri://example") - return s - }(), - condQuery: ApiServerConditionReady, - want: &apis.Condition{ - Type: ApiServerConditionReady, - Status: corev1.ConditionUnknown, - }, - }, { - name: "mark sink and enough permissions and deployed", - s: func() *ApiServerSourceStatus { - s := &ApiServerSourceStatus{} - s.InitializeConditions() - s.MarkSink("uri://example") - s.MarkSufficientPermissions() - s.PropagateDeploymentAvailability(availableDeployment) - return s - }(), - condQuery: ApiServerConditionReady, - want: &apis.Condition{ - Type: ApiServerConditionReady, - Status: corev1.ConditionTrue, - }, - }} - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got := test.s.GetCondition(test.condQuery) - ignoreTime := cmpopts.IgnoreFields(apis.Condition{}, - "LastTransitionTime", "Severity") - if diff := cmp.Diff(test.want, got, ignoreTime); diff != "" { - t.Error("unexpected condition (-want, +got) =", diff) - } - }) - } -} - -func TestApiServerSourceGetters(t *testing.T) { - r := &ApiServerSource{ - Spec: ApiServerSourceSpec{ - ServiceAccountName: "test", - Mode: "test", - }, - } - if got, want := r.GetUntypedSpec(), r.Spec; !reflect.DeepEqual(got, want) { - t.Errorf("GetUntypedSpec() = %v, want: %v", got, want) - } -} diff --git a/pkg/apis/sources/v1alpha1/apiserver_types.go b/pkg/apis/sources/v1alpha1/apiserver_types.go deleted file mode 100644 index 0dc3811a237..00000000000 --- a/pkg/apis/sources/v1alpha1/apiserver_types.go +++ /dev/null @@ -1,123 +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 v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "knative.dev/eventing/pkg/apis/sources/v1alpha2" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" - "knative.dev/pkg/kmeta" -) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ApiServerSource is the Schema for the apiserversources API -type ApiServerSource struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec ApiServerSourceSpec `json:"spec,omitempty"` - Status ApiServerSourceStatus `json:"status,omitempty"` -} - -var ( - // Check that we can create OwnerReferences to an ApiServerSource. - _ kmeta.OwnerRefable = (*ApiServerSource)(nil) - - // Check that ApiServerSource can return its spec untyped. - _ apis.HasSpec = (*ApiServerSource)(nil) -) - -// ApiServerSourceSpec defines the desired state of ApiServerSource -type ApiServerSourceSpec struct { - // Resources is the list of resources to watch - Resources []ApiServerResource `json:"resources"` - - // ServiceAccountName is the name of the ServiceAccount to use to run this - // source. - // +optional - ServiceAccountName string `json:"serviceAccountName,omitempty"` - - // Sink is a reference to an object that will resolve to a domain name to use as the sink. - // +optional - Sink *duckv1beta1.Destination `json:"sink,omitempty"` - - // CloudEventOverrides defines overrides to control the output format and - // modifications of the event sent to the sink. - // +optional - CloudEventOverrides *duckv1.CloudEventOverrides `json:"ceOverrides,omitempty"` - - // ResourceOwner is an additional filter to only track resources that are - // owned by a specific resource type. If ResourceOwner matches Resources[n] - // then Resources[n] is allowed to pass the ResourceOwner filter. - // +optional - ResourceOwner *v1alpha2.APIVersionKind `json:"owner,omitempty"` - - // Mode is the mode the receive adapter controller runs under: Ref or Resource. - // `Ref` sends only the reference to the resource. - // `Resource` send the full resource. - Mode string `json:"mode,omitempty"` -} - -// ApiServerSourceStatus defines the observed state of ApiServerSource -type ApiServerSourceStatus struct { - // inherits duck/v1 SourceStatus, which currently provides: - // * ObservedGeneration - the 'Generation' of the Service that was last - // processed by the controller. - // * Conditions - the latest available observations of a resource's current - // state. - // * SinkURI - the current active sink URI that has been configured for the - // Source. - duckv1.SourceStatus `json:",inline"` -} - -// ApiServerResource defines the resource to watch -type ApiServerResource struct { - // API version of the resource to watch. - APIVersion string `json:"apiVersion"` - - // Kind of the resource to watch. - // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds - Kind string `json:"kind"` - - // LabelSelector restricts this source to objects with the selected labels - // More info: http://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors - LabelSelector metav1.LabelSelector `json:"labelSelector"` - - // ControllerSelector restricts this source to objects with a controlling owner reference of the specified kind. - // Only apiVersion and kind are used. Both are optional. - // Deprecated: Per-resource owner refs will no longer be supported in - // v1alpha2, please use Spec.Owner as a GKV. - ControllerSelector metav1.OwnerReference `json:"controllerSelector"` - - // If true, send an event referencing the object controlling the resource - // Deprecated: Per-resource controller flag will no longer be supported in - // v1alpha2, please use Spec.Owner as a GKV. - Controller bool `json:"controller"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ApiServerSourceList contains a list of ApiServerSource -type ApiServerSourceList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ApiServerSource `json:"items"` -} diff --git a/pkg/apis/sources/v1alpha1/apiserver_types_test.go b/pkg/apis/sources/v1alpha1/apiserver_types_test.go deleted file mode 100644 index 166ef50c11c..00000000000 --- a/pkg/apis/sources/v1alpha1/apiserver_types_test.go +++ /dev/null @@ -1,27 +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 v1alpha1 - -import "testing" - -func TestApiServerSource_GetGroupVersionKind(t *testing.T) { - ass := ApiServerSource{} - gvk := ass.GetGroupVersionKind() - if gvk.Kind != "ApiServerSource" { - t.Errorf("Should be ApiServerSource.") - } -} diff --git a/pkg/apis/sources/v1alpha1/apiserver_validation.go b/pkg/apis/sources/v1alpha1/apiserver_validation.go deleted file mode 100644 index 8c906871ec8..00000000000 --- a/pkg/apis/sources/v1alpha1/apiserver_validation.go +++ /dev/null @@ -1,56 +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 v1alpha1 - -import ( - "context" - - "knative.dev/pkg/apis" -) - -const ( - // RefMode produces payloads of ObjectReference - RefMode = "Ref" - // ResourceMode produces payloads of ResourceEvent - ResourceMode = "Resource" -) - -func (c *ApiServerSource) Validate(ctx context.Context) *apis.FieldError { - return c.Spec.Validate(ctx).ViaField("spec") -} - -func (cs *ApiServerSourceSpec) Validate(ctx context.Context) *apis.FieldError { - var errs *apis.FieldError - - // Validate mode, if can be empty or set as certain value - if cs.Mode != "" && cs.Mode != RefMode && cs.Mode != ResourceMode { - fe := &apis.FieldError{ - Message: "Mode is not valid", - Paths: []string{"mode"}, - } - errs = errs.Also(fe) - } - - // Validate sink - if cs.Sink == nil { - fe := apis.ErrMissingField("sink") - errs = errs.Also(fe) - } else if fe := cs.Sink.Validate(ctx); fe != nil { - errs = errs.Also(fe.ViaField("sink")) - } - return errs -} diff --git a/pkg/apis/sources/v1alpha1/apiserver_validation_test.go b/pkg/apis/sources/v1alpha1/apiserver_validation_test.go deleted file mode 100644 index 6ec51607a87..00000000000 --- a/pkg/apis/sources/v1alpha1/apiserver_validation_test.go +++ /dev/null @@ -1,98 +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 v1alpha1 - -import ( - "context" - "testing" - - "github.com/google/go-cmp/cmp" - corev1 "k8s.io/api/core/v1" - "knative.dev/pkg/apis" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" -) - -func TestAPIServerValidation(t *testing.T) { - tests := []struct { - name string - spec ApiServerSourceSpec - want *apis.FieldError - }{{ - name: "valid spec", - spec: ApiServerSourceSpec{ - Mode: "Resource", - Resources: []ApiServerResource{ - {}, - }, - Sink: &duckv1beta1.Destination{ - Ref: &corev1.ObjectReference{ - APIVersion: "v1alpha1", - Kind: "broker", - Name: "default", - }, - }, - }, - want: nil, - }, { - name: "empty sink", - spec: ApiServerSourceSpec{ - Mode: "Resource", - Resources: []ApiServerResource{ - {}, - }, - }, - want: func() *apis.FieldError { - var errs *apis.FieldError - fe := apis.ErrMissingField("sink") - errs = errs.Also(fe) - return errs - }(), - }, { - name: "invalid mode", - spec: ApiServerSourceSpec{ - Mode: "Test", - Resources: []ApiServerResource{ - {}, - }, - Sink: &duckv1beta1.Destination{ - Ref: &corev1.ObjectReference{ - APIVersion: "v1alpha1", - Kind: "broker", - Name: "default", - }, - }, - }, - want: func() *apis.FieldError { - var errs *apis.FieldError - fe := &apis.FieldError{ - Message: "Mode is not valid", - Paths: []string{"mode"}, - } - errs = errs.Also(fe) - return errs - }(), - }} - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got := test.spec.Validate(context.TODO()) - if diff := cmp.Diff(test.want.Error(), got.Error()); diff != "" { - t.Error("APIServerSourceSpec.Validate (-want, +got) =", diff) - } - }) - } -} diff --git a/pkg/apis/sources/v1alpha1/doc.go b/pkg/apis/sources/v1alpha1/doc.go deleted file mode 100644 index ecb0830e681..00000000000 --- a/pkg/apis/sources/v1alpha1/doc.go +++ /dev/null @@ -1,20 +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 v1alpha1 contains API Schema definitions for the sources v1alpha1 API group -// +k8s:deepcopy-gen=package -// +groupName=sources.knative.dev -package v1alpha1 diff --git a/pkg/apis/sources/v1alpha1/implements_test.go b/pkg/apis/sources/v1alpha1/implements_test.go deleted file mode 100644 index da15422299c..00000000000 --- a/pkg/apis/sources/v1alpha1/implements_test.go +++ /dev/null @@ -1,45 +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 v1alpha1 - -import ( - "testing" - - "knative.dev/pkg/apis/duck" - duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" -) - -func TestTypesImplements(t *testing.T) { - testCases := []struct { - instance interface{} - iface duck.Implementable - }{ - // ApiServerSource - {instance: &ApiServerSource{}, iface: &duckv1.Conditions{}}, - // SinkBinding - {instance: &SinkBinding{}, iface: &duckv1.Conditions{}}, - {instance: &SinkBinding{}, iface: &duckv1beta1.Source{}}, - {instance: &SinkBinding{}, iface: &duckv1alpha1.Binding{}}, - } - for _, tc := range testCases { - if err := duck.VerifyType(tc.instance, tc.iface); err != nil { - t.Error(err) - } - } -} diff --git a/pkg/apis/sources/v1alpha1/register.go b/pkg/apis/sources/v1alpha1/register.go deleted file mode 100644 index 8120c413cad..00000000000 --- a/pkg/apis/sources/v1alpha1/register.go +++ /dev/null @@ -1,55 +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 v1alpha1 - -import ( - "knative.dev/eventing/pkg/apis/sources" - - 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: sources.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, - &ApiServerSource{}, - &ApiServerSourceList{}, - &SinkBinding{}, - &SinkBindingList{}, - ) - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -} diff --git a/pkg/apis/sources/v1alpha1/register_test.go b/pkg/apis/sources/v1alpha1/register_test.go deleted file mode 100644 index fad04bc1a8a..00000000000 --- a/pkg/apis/sources/v1alpha1/register_test.go +++ /dev/null @@ -1,73 +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 v1alpha1 - -import ( - "testing" - - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - - "github.com/google/go-cmp/cmp" -) - -// Resource takes an unqualified resource and returns a Group qualified GroupResource -func TestResource(t *testing.T) { - want := schema.GroupResource{ - Group: "sources.knative.dev", - Resource: "foo", - } - - got := Resource("foo") - - if diff := cmp.Diff(want, got); diff != "" { - t.Error("unexpected resource (-want, +got) =", diff) - } -} - -// Kind takes an unqualified resource and returns a Group qualified GroupKind -func TestKind(t *testing.T) { - want := schema.GroupKind{ - Group: "sources.knative.dev", - Kind: "kind", - } - - got := Kind("kind") - - if diff := cmp.Diff(want, got); diff != "" { - t.Error("unexpected resource (-want, +got) =", diff) - } -} - -// TestKnownTypes makes sure that expected types get added. -func TestKnownTypes(t *testing.T) { - scheme := runtime.NewScheme() - addKnownTypes(scheme) - types := scheme.KnownTypes(SchemeGroupVersion) - - for _, name := range []string{ - "ApiServerSource", - "ApiServerSourceList", - "SinkBinding", - "SinkBindingList", - } { - if _, ok := types[name]; !ok { - t.Errorf("Did not find %q as registered type", name) - } - } - -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_context.go b/pkg/apis/sources/v1alpha1/sinkbinding_context.go deleted file mode 100644 index c419f3ec634..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_context.go +++ /dev/null @@ -1,43 +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 v1alpha1 - -import ( - "context" - - "knative.dev/pkg/apis" -) - -// sinkURIKey is used as the key for associating information -// with a context.Context. -type sinkURIKey struct{} - -// WithSinkURI notes on the context for binding that the resolved SinkURI -// is the provided apis.URL. -func WithSinkURI(ctx context.Context, uri *apis.URL) context.Context { - return context.WithValue(ctx, sinkURIKey{}, uri) -} - -// GetSinkURI accesses the apis.URL for the Sink URI that has been associated -// with this context. -func GetSinkURI(ctx context.Context) *apis.URL { - value := ctx.Value(sinkURIKey{}) - if value == nil { - return nil - } - return value.(*apis.URL) -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_context_test.go b/pkg/apis/sources/v1alpha1/sinkbinding_context_test.go deleted file mode 100644 index 8bcf03e683b..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_context_test.go +++ /dev/null @@ -1,43 +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 v1alpha1 - -import ( - "context" - "testing" - - "knative.dev/pkg/apis" -) - -func TestGetSinkURI(t *testing.T) { - ctx := context.Background() - - if uri := GetSinkURI(ctx); uri != nil { - t.Errorf("GetSinkURI() = %v, wanted nil", uri) - } - - want := &apis.URL{ - Scheme: "https", - Host: "knobots.io", - Path: "/omg/a/path", - } - ctx = WithSinkURI(ctx, want) - - if got := GetSinkURI(ctx); got != want { - t.Errorf("GetSinkURI() = %v, wanted %v", got, want) - } -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_conversion.go b/pkg/apis/sources/v1alpha1/sinkbinding_conversion.go deleted file mode 100644 index ba35d565054..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_conversion.go +++ /dev/null @@ -1,55 +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 v1alpha1 - -import ( - "context" - - "knative.dev/eventing/pkg/apis/sources/v1alpha2" - "knative.dev/pkg/apis" -) - -// ConvertTo implements apis.Convertible. -// Converts source from v1alpha1.SinkBinding into a higher version. -func (source *SinkBinding) ConvertTo(ctx context.Context, obj apis.Convertible) error { - switch sink := obj.(type) { - case *v1alpha2.SinkBinding: - sink.ObjectMeta = source.ObjectMeta - sink.Spec.SourceSpec = source.Spec.SourceSpec - sink.Spec.BindingSpec = source.Spec.BindingSpec - sink.Status.SourceStatus = source.Status.SourceStatus - return nil - default: - return apis.ConvertToViaProxy(ctx, source, &v1alpha2.SinkBinding{}, sink) - } -} - -// ConvertFrom implements apis.Convertible. -// Converts obj from a higher version into v1alpha1.SinkBinding. -func (sink *SinkBinding) ConvertFrom(ctx context.Context, obj apis.Convertible) error { - switch source := obj.(type) { - case *v1alpha2.SinkBinding: - sink.ObjectMeta = source.ObjectMeta - sink.Spec.Subject = source.Spec.Subject - sink.Spec.SourceSpec = source.Spec.SourceSpec - sink.Spec.BindingSpec = source.Spec.BindingSpec - sink.Status.SourceStatus = source.Status.SourceStatus - return nil - default: - return apis.ConvertFromViaProxy(ctx, source, &v1alpha2.SinkBinding{}, sink) - } -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go b/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go deleted file mode 100644 index 1eca4442fb5..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go +++ /dev/null @@ -1,294 +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 v1alpha1 - -import ( - "context" - "reflect" - "testing" - - "knative.dev/pkg/tracker" - - "github.com/google/go-cmp/cmp" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - v1 "knative.dev/eventing/pkg/apis/sources/v1" - "knative.dev/eventing/pkg/apis/sources/v1alpha2" - "knative.dev/eventing/pkg/apis/sources/v1beta1" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" -) - -func TestSinkBindingConversionBadType(t *testing.T) { - good, bad := &SinkBinding{}, &testObject{} - - if err := good.ConvertTo(context.Background(), bad); err == nil { - t.Errorf("ConvertTo() = %#v, wanted error", bad) - } - - if err := good.ConvertFrom(context.Background(), bad); err == nil { - t.Errorf("ConvertFrom() = %#v, wanted error", good) - } -} - -func TestSinkBindingConversionRoundTripUp(t *testing.T) { - versions := []apis.Convertible{&v1.SinkBinding{}, &v1beta1.SinkBinding{}, &v1alpha2.SinkBinding{}} - - path := apis.HTTP("") - path.Path = "/path" - sink := duckv1.Destination{ - Ref: &duckv1.KReference{ - Kind: "Foo", - Namespace: "Bar", - Name: "Baz", - APIVersion: "Baf", - }, - URI: path, - } - sinkUri := apis.HTTP("example.com") - sinkUri.Path = "path" - - subject := tracker.Reference{ - APIVersion: "API", - Kind: "K", - Namespace: "NS", - Name: "N", - } - - tests := []struct { - name string - in *SinkBinding - }{{name: "empty", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: SinkBindingSpec{}, - Status: SinkBindingStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - }, - }, - }, - }, {name: "simple configuration", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: SinkBindingSpec{ - SourceSpec: duckv1.SourceSpec{ - Sink: sink, - }, - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: subject, - }, - }, - Status: SinkBindingStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "Unknown", - }}, - }, - SinkURI: sinkUri, - }, - }, - }, - }, {name: "full", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: SinkBindingSpec{ - SourceSpec: duckv1.SourceSpec{ - Sink: sink, - CloudEventOverrides: &duckv1.CloudEventOverrides{ - Extensions: map[string]string{ - "foo": "bar", - "baz": "baf", - }, - }, - }, - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: subject, - }, - }, - Status: SinkBindingStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - SinkURI: sinkUri, - }, - }, - }, - }} - for _, test := range tests { - for _, version := range versions { - t.Run(test.name, func(t *testing.T) { - ver := version - if err := test.in.ConvertTo(context.Background(), ver); err != nil { - t.Error("ConvertTo() =", err) - } - - got := &SinkBinding{} - - if err := got.ConvertFrom(context.Background(), ver); err != nil { - t.Error("ConvertFrom() =", err) - } - if diff := cmp.Diff(test.in, got); diff != "" { - t.Error("roundtrip (-want, +got) =", diff) - } - }) - } - } -} - -// This tests round tripping from a higher version -> v1alpha1 and back to the higher version. -func TestSinkBindingConversionRoundTripDown(t *testing.T) { - path := apis.HTTP("") - path.Path = "/path" - sink := duckv1.Destination{ - Ref: &duckv1.KReference{ - Kind: "Foo", - Namespace: "Bar", - Name: "Baz", - APIVersion: "Baf", - }, - URI: path, - } - sinkUri := apis.HTTP("example.com") - sinkUri.Path = "path" - - ceOverrides := duckv1.CloudEventOverrides{ - Extensions: map[string]string{ - "foo": "bar", - "baz": "baf", - }, - } - - subject := tracker.Reference{ - APIVersion: "API", - Kind: "K", - Namespace: "NS", - Name: "N", - } - - tests := []struct { - name string - in apis.Convertible - }{{name: "empty", - in: &v1alpha2.SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: v1alpha2.SinkBindingSpec{}, - Status: v1alpha2.SinkBindingStatus{}, - }, - }, {name: "simple configuration", - in: &v1alpha2.SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: v1alpha2.SinkBindingSpec{ - SourceSpec: duckv1.SourceSpec{ - Sink: sink, - }, - }, - Status: v1alpha2.SinkBindingStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - SinkURI: sinkUri, - }, - }, - }, - }, {name: "full", - in: &v1beta1.SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ping-name", - Namespace: "ping-ns", - Generation: 17, - }, - Spec: v1beta1.SinkBindingSpec{ - SourceSpec: duckv1.SourceSpec{ - Sink: sink, - CloudEventOverrides: &ceOverrides, - }, - BindingSpec: duckv1beta1.BindingSpec{Subject: subject}, - }, - Status: v1beta1.SinkBindingStatus{ - SourceStatus: duckv1.SourceStatus{ - Status: duckv1.Status{ - ObservedGeneration: 1, - Conditions: duckv1.Conditions{{ - Type: "Ready", - Status: "True", - }}, - }, - SinkURI: sinkUri, - }, - }, - }, - }} - for _, test := range tests { - - t.Run(test.name, func(t *testing.T) { - down := &SinkBinding{} - if err := down.ConvertFrom(context.Background(), test.in); err != nil { - t.Error("ConvertTo() =", err) - } - - got := (reflect.New(reflect.TypeOf(test.in).Elem()).Interface()).(apis.Convertible) - - if err := down.ConvertTo(context.Background(), got); err != nil { - t.Error("ConvertFrom() =", err) - } - if diff := cmp.Diff(test.in, got); diff != "" { - t.Error("roundtrip (-want, +got) =", diff) - } - }) - } -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_defaults.go b/pkg/apis/sources/v1alpha1/sinkbinding_defaults.go deleted file mode 100644 index 44cde50939d..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_defaults.go +++ /dev/null @@ -1,34 +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 v1alpha1 - -import ( - "context" - - "knative.dev/pkg/apis" -) - -// SetDefaults implements apis.Defaultable -func (fb *SinkBinding) SetDefaults(ctx context.Context) { - if fb.Spec.Subject.Namespace == "" { - // Default the subject's namespace to our namespace. - fb.Spec.Subject.Namespace = fb.Namespace - } - - withNS := apis.WithinParent(ctx, fb.ObjectMeta) - fb.Spec.Sink.SetDefaults(withNS) -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_defaults_test.go b/pkg/apis/sources/v1alpha1/sinkbinding_defaults_test.go deleted file mode 100644 index 573f5d538a2..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_defaults_test.go +++ /dev/null @@ -1,151 +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 v1alpha1 - -import ( - "context" - "testing" - - "github.com/google/go-cmp/cmp" - 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/tracker" -) - -func TestSinkBindingDefaulting(t *testing.T) { - tests := []struct { - name string - in *SinkBinding - want *SinkBinding - }{{ - name: "namespace is defaulted", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "matt", - Namespace: "moore", - }, - Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: tracker.Reference{ - APIVersion: "apps/v1", - Kind: "Deployment", - Name: "jeanne", - }, - }, - SourceSpec: duckv1.SourceSpec{ - Sink: duckv1.Destination{ - Ref: &duckv1.KReference{ - APIVersion: "serving.knative.dev/v1", - Kind: "Service", - Name: "gemma", - }, - }, - }, - }, - }, - want: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "matt", - Namespace: "moore", - }, - Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: tracker.Reference{ - APIVersion: "apps/v1", - Kind: "Deployment", - Name: "jeanne", - // This is filled in by defaulting. - Namespace: "moore", - }, - }, - SourceSpec: duckv1.SourceSpec{ - Sink: duckv1.Destination{ - Ref: &duckv1.KReference{ - APIVersion: "serving.knative.dev/v1", - Kind: "Service", - Name: "gemma", - // This is filled in by defaulting. - Namespace: "moore", - }, - }, - }, - }, - }, - }, { - name: "no ref, given namespace", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "matt", - Namespace: "moore", - }, - Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: tracker.Reference{ - APIVersion: "apps/v1", - Kind: "Deployment", - Name: "jeanne", - Namespace: "lorefice", - }, - }, - SourceSpec: duckv1.SourceSpec{ - Sink: duckv1.Destination{ - URI: &apis.URL{ - Scheme: "http", - Host: "moore.dev", - }, - }, - }, - }, - }, - want: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "matt", - Namespace: "moore", - }, - Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: tracker.Reference{ - APIVersion: "apps/v1", - Kind: "Deployment", - Name: "jeanne", - Namespace: "lorefice", - }, - }, - SourceSpec: duckv1.SourceSpec{ - Sink: duckv1.Destination{ - URI: &apis.URL{ - Scheme: "http", - Host: "moore.dev", - }, - }, - }, - }, - }, - }} - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got := test.in - got.SetDefaults(context.Background()) - if !cmp.Equal(test.want, got) { - t.Error("SetDefaults (-want, +got) =", cmp.Diff(test.want, got)) - } - }) - } -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_lifecycle.go b/pkg/apis/sources/v1alpha1/sinkbinding_lifecycle.go deleted file mode 100644 index 2e9fad2ebd0..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_lifecycle.go +++ /dev/null @@ -1,152 +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 v1alpha1 - -import ( - "context" - "encoding/json" - - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - - "knative.dev/pkg/apis" - "knative.dev/pkg/apis/duck" - duckv1 "knative.dev/pkg/apis/duck/v1" - "knative.dev/pkg/logging" - "knative.dev/pkg/tracker" -) - -var sbCondSet = apis.NewLivingConditionSet() - -// GetGroupVersionKind returns the GroupVersionKind. -func (s *SinkBinding) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("SinkBinding") -} - -// GetUntypedSpec implements apis.HasSpec -func (s *SinkBinding) GetUntypedSpec() interface{} { - return s.Spec -} - -// GetSubject implements psbinding.Bindable -func (sb *SinkBinding) GetSubject() tracker.Reference { - return sb.Spec.Subject -} - -// GetBindingStatus implements psbinding.Bindable -func (sb *SinkBinding) GetBindingStatus() duck.BindableStatus { - return &sb.Status -} - -// SetObservedGeneration implements psbinding.BindableStatus -func (sbs *SinkBindingStatus) SetObservedGeneration(gen int64) { - sbs.ObservedGeneration = gen -} - -// InitializeConditions populates the SinkBindingStatus's conditions field -// with all of its conditions configured to Unknown. -func (sbs *SinkBindingStatus) InitializeConditions() { - sbCondSet.Manage(sbs).InitializeConditions() -} - -// MarkBindingUnavailable marks the SinkBinding's Ready condition to False with -// the provided reason and message. -func (sbs *SinkBindingStatus) MarkBindingUnavailable(reason, message string) { - sbCondSet.Manage(sbs).MarkFalse(SinkBindingConditionReady, reason, message) -} - -// MarkBindingAvailable marks the SinkBinding's Ready condition to True. -func (sbs *SinkBindingStatus) MarkBindingAvailable() { - sbCondSet.Manage(sbs).MarkTrue(SinkBindingConditionReady) -} - -// Do implements psbinding.Bindable -func (sb *SinkBinding) Do(ctx context.Context, ps *duckv1.WithPod) { - // First undo so that we can just unconditionally append below. - sb.Undo(ctx, ps) - - uri := GetSinkURI(ctx) - if uri == nil { - logging.FromContext(ctx).Errorf("No sink URI associated with context for %+v", sb) - return - } - - var ceOverrides string - if sb.Spec.CloudEventOverrides != nil { - if co, err := json.Marshal(sb.Spec.SourceSpec.CloudEventOverrides); err != nil { - logging.FromContext(ctx).Errorf("Failed to marshal CloudEventOverrides into JSON for %+v, %v", sb, err) - } else if len(co) > 0 { - ceOverrides = string(co) - } - } - - spec := ps.Spec.Template.Spec - for i := range spec.InitContainers { - spec.InitContainers[i].Env = append(spec.InitContainers[i].Env, corev1.EnvVar{ - Name: "K_SINK", - Value: uri.String(), - }) - spec.InitContainers[i].Env = append(spec.InitContainers[i].Env, corev1.EnvVar{ - Name: "K_CE_OVERRIDES", - Value: ceOverrides, - }) - } - for i := range spec.Containers { - spec.Containers[i].Env = append(spec.Containers[i].Env, corev1.EnvVar{ - Name: "K_SINK", - Value: uri.String(), - }) - spec.Containers[i].Env = append(spec.Containers[i].Env, corev1.EnvVar{ - Name: "K_CE_OVERRIDES", - Value: ceOverrides, - }) - } -} - -func (sb *SinkBinding) Undo(ctx context.Context, ps *duckv1.WithPod) { - spec := ps.Spec.Template.Spec - for i, c := range spec.InitContainers { - if len(c.Env) == 0 { - continue - } - env := make([]corev1.EnvVar, 0, len(spec.InitContainers[i].Env)) - for j, ev := range c.Env { - switch ev.Name { - case "K_SINK", "K_CE_OVERRIDES": - continue - default: - env = append(env, spec.InitContainers[i].Env[j]) - } - } - spec.InitContainers[i].Env = env - } - for i, c := range spec.Containers { - if len(c.Env) == 0 { - continue - } - env := make([]corev1.EnvVar, 0, len(spec.Containers[i].Env)) - for j, ev := range c.Env { - switch ev.Name { - case "K_SINK", "K_CE_OVERRIDES": - continue - default: - env = append(env, spec.Containers[i].Env[j]) - } - } - spec.Containers[i].Env = env - } -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_lifecycle_test.go b/pkg/apis/sources/v1alpha1/sinkbinding_lifecycle_test.go deleted file mode 100644 index 3d47298981a..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_lifecycle_test.go +++ /dev/null @@ -1,506 +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 v1alpha1 - -import ( - "context" - "reflect" - "testing" - - "github.com/google/go-cmp/cmp" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - "knative.dev/pkg/tracker" -) - -func TestSinkBindingGetGroupVersionKind(t *testing.T) { - r := &SinkBinding{} - want := schema.GroupVersionKind{ - Group: "sources.knative.dev", - Version: "v1alpha1", - Kind: "SinkBinding", - } - if got := r.GetGroupVersionKind(); got != want { - t.Errorf("got: %v, want: %v", got, want) - } -} - -func TestSinkBindingGetters(t *testing.T) { - r := &SinkBinding{ - Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: tracker.Reference{ - APIVersion: "foo", - }, - }, - }, - } - if got, want := r.GetUntypedSpec(), r.Spec; !reflect.DeepEqual(got, want) { - t.Errorf("GetUntypedSpec() = %v, want: %v", got, want) - } - if got, want := r.GetSubject(), r.Spec.Subject; !reflect.DeepEqual(got, want) { - t.Errorf("GetSubject() = %v, want: %v", got, want) - } - if got, want := r.GetBindingStatus(), &r.Status; !reflect.DeepEqual(got, want) { - t.Errorf("GetBindingStatus() = %v, want: %v", got, want) - } -} - -func TestSinkBindingSetObsGen(t *testing.T) { - r := &SinkBinding{ - Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: tracker.Reference{ - APIVersion: "foo", - }, - }, - }, - } - want := int64(3762) - r.GetBindingStatus().SetObservedGeneration(want) - if got := r.Status.ObservedGeneration; got != want { - t.Errorf("SetObservedGeneration() = %d, wanted %d", got, want) - } -} - -func TestSinkBindingStatusIsReady(t *testing.T) { - tests := []struct { - name string - s *SinkBindingStatus - want bool - }{{ - name: "uninitialized", - s: &SinkBindingStatus{}, - want: false, - }, { - name: "initialized", - s: func() *SinkBindingStatus { - s := &SinkBindingStatus{} - s.InitializeConditions() - return s - }(), - want: false, - }, { - name: "mark available", - s: func() *SinkBindingStatus { - s := &SinkBindingStatus{} - s.InitializeConditions() - s.MarkBindingUnavailable("TheReason", "this is the message") - return s - }(), - want: false, - }, { - name: "mark available", - s: func() *SinkBindingStatus { - s := &SinkBindingStatus{} - s.InitializeConditions() - s.MarkBindingAvailable() - return s - }(), - want: true, - }} - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got := test.s.IsReady() - if diff := cmp.Diff(test.want, got); diff != "" { - t.Errorf("%s: unexpected condition (-want, +got) = %v", test.name, diff) - } - }) - } -} - -func TestSinkBindingUndo(t *testing.T) { - tests := []struct { - name string - in *duckv1.WithPod - want *duckv1.WithPod - }{{ - name: "nothing to remove", - in: &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - }}, - }, - }, - }, - }, - want: &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - }}, - }, - }, - }, - }, - }, { - name: "lots to remove", - in: &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - InitContainers: []corev1.Container{{ - Name: "setup", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "FOO", - Value: "BAR", - }, { - Name: "K_SINK", - Value: "http://localhost:8080", - }, { - Name: "BAZ", - Value: "INGA", - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"foo":"bar"}}`, - }}, - }}, - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "FOO", - Value: "BAR", - }, { - Name: "K_SINK", - Value: "http://localhost:8080", - }, { - Name: "BAZ", - Value: "INGA", - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"foo":"bar"}}`, - }}, - }, { - Name: "sidecar", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "K_SINK", - Value: "http://localhost:8080", - }, { - Name: "BAZ", - Value: "INGA", - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"foo":"bar"}}`, - }}, - }}, - }, - }, - }, - }, - want: &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - InitContainers: []corev1.Container{{ - Name: "setup", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "FOO", - Value: "BAR", - }, { - Name: "BAZ", - Value: "INGA", - }}, - }}, - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "FOO", - Value: "BAR", - }, { - Name: "BAZ", - Value: "INGA", - }}, - }, { - Name: "sidecar", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "BAZ", - Value: "INGA", - }}, - }}, - }, - }, - }, - }, - }} - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got := test.in - sb := &SinkBinding{} - sb.Undo(context.Background(), got) - - if !cmp.Equal(got, test.want) { - t.Error("Undo (-want, +got):", cmp.Diff(test.want, got)) - } - }) - } -} - -func TestSinkBindingDo(t *testing.T) { - sinkURI := &apis.URL{ - Scheme: "http", - Host: "thing.ns.svc.cluster.local", - Path: "/a/path", - } - - overrides := duckv1.CloudEventOverrides{Extensions: map[string]string{"foo": "bar"}} - - tests := []struct { - name string - in *duckv1.WithPod - want *duckv1.WithPod - }{{ - name: "nothing to add", - in: &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "K_SINK", - Value: sinkURI.String(), - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"foo":"bar"}}`, - }}, - }}, - }, - }, - }, - }, - want: &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "K_SINK", - Value: sinkURI.String(), - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"foo":"bar"}}`, - }}, - }}, - }, - }, - }, - }, - }, { - name: "fix the URI", - in: &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "K_SINK", - Value: "the wrong value", - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"wrong":"value"}}`, - }}, - }}, - }, - }, - }, - }, - want: &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "K_SINK", - Value: sinkURI.String(), - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"foo":"bar"}}`, - }}, - }}, - }, - }, - }, - }, - }, { - name: "lots to add", - in: &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - InitContainers: []corev1.Container{{ - Name: "setup", - Image: "busybox", - }}, - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "FOO", - Value: "BAR", - }, { - Name: "BAZ", - Value: "INGA", - }}, - }, { - Name: "sidecar", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "BAZ", - Value: "INGA", - }}, - }}, - }, - }, - }, - }, - want: &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - InitContainers: []corev1.Container{{ - Name: "setup", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "K_SINK", - Value: sinkURI.String(), - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"foo":"bar"}}`, - }}, - }}, - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "FOO", - Value: "BAR", - }, { - Name: "BAZ", - Value: "INGA", - }, { - Name: "K_SINK", - Value: sinkURI.String(), - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"foo":"bar"}}`, - }}, - }, { - Name: "sidecar", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "BAZ", - Value: "INGA", - }, { - Name: "K_SINK", - Value: sinkURI.String(), - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"foo":"bar"}}`, - }}, - }}, - }, - }, - }, - }, - }} - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got := test.in - - ctx := WithSinkURI(context.Background(), sinkURI) - - sb := &SinkBinding{Spec: SinkBindingSpec{ - SourceSpec: duckv1.SourceSpec{ - CloudEventOverrides: &overrides, - }, - }} - sb.Do(ctx, got) - - if !cmp.Equal(got, test.want) { - t.Error("Undo (-want, +got):", cmp.Diff(test.want, got)) - } - }) - } -} - -func TestSinkBindingDoNoURI(t *testing.T) { - want := &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - Env: []corev1.EnvVar{}, - }}, - }, - }, - }, - } - got := &duckv1.WithPod{ - Spec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - Containers: []corev1.Container{{ - Name: "blah", - Image: "busybox", - Env: []corev1.EnvVar{{ - Name: "K_SINK", - Value: "this should be removed", - }, { - Name: "K_CE_OVERRIDES", - Value: `{"extensions":{"tobe":"removed"}}`, - }}, - }}, - }, - }, - }, - } - - sb := &SinkBinding{} - sb.Do(context.Background(), got) - - if !cmp.Equal(got, want) { - t.Error("Undo (-want, +got):", cmp.Diff(want, got)) - } -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_types.go b/pkg/apis/sources/v1alpha1/sinkbinding_types.go deleted file mode 100644 index 9a902b934f9..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_types.go +++ /dev/null @@ -1,79 +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 v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "knative.dev/pkg/apis" - duckv1 "knative.dev/pkg/apis/duck/v1" - duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - "knative.dev/pkg/kmeta" -) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:defaulter-gen=true - -// SinkBinding describes a Binding that is also a Source. -// The `sink` (from the Source duck) is resolved to a URL and -// then projected into the `subject` by augmenting the runtime -// contract of the referenced containers to have a `K_SINK` -// environment variable holding the endpoint to which to send -// cloud events. -type SinkBinding struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec SinkBindingSpec `json:"spec"` - Status SinkBindingStatus `json:"status"` -} - -// Check the interfaces that SinkBinding should be implementing. -var ( - _ runtime.Object = (*SinkBinding)(nil) - _ kmeta.OwnerRefable = (*SinkBinding)(nil) - _ apis.Validatable = (*SinkBinding)(nil) - _ apis.Defaultable = (*SinkBinding)(nil) - _ apis.HasSpec = (*SinkBinding)(nil) -) - -// SinkBindingSpec holds the desired state of the SinkBinding (from the client). -type SinkBindingSpec struct { - duckv1.SourceSpec `json:",inline"` - duckv1alpha1.BindingSpec `json:",inline"` -} - -const ( - // SinkBindingConditionReady is configured to indicate whether the Binding - // has been configured for resources subject to its runtime contract. - SinkBindingConditionReady = apis.ConditionReady -) - -// SinkBindingStatus communicates the observed state of the SinkBinding (from the controller). -type SinkBindingStatus struct { - duckv1.SourceStatus `json:",inline"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// SinkBindingList contains a list of SinkBinding -type SinkBindingList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []SinkBinding `json:"items"` -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_types_test.go b/pkg/apis/sources/v1alpha1/sinkbinding_types_test.go deleted file mode 100644 index 9242af7f80b..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_types_test.go +++ /dev/null @@ -1,27 +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 v1alpha1 - -import "testing" - -func TestSinkBinding_GetGroupVersionKind(t *testing.T) { - sb := SinkBinding{} - gvk := sb.GetGroupVersionKind() - if gvk.Kind != "SinkBinding" { - t.Errorf("Should be SinkBinding.") - } -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_validation.go b/pkg/apis/sources/v1alpha1/sinkbinding_validation.go deleted file mode 100644 index 1d82e89ce93..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_validation.go +++ /dev/null @@ -1,38 +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 v1alpha1 - -import ( - "context" - - "knative.dev/pkg/apis" -) - -// Validate implements apis.Validatable -func (fb *SinkBinding) Validate(ctx context.Context) *apis.FieldError { - err := fb.Spec.Validate(ctx).ViaField("spec") - if fb.Spec.Subject.Namespace != "" && fb.Namespace != fb.Spec.Subject.Namespace { - err = err.Also(apis.ErrInvalidValue(fb.Spec.Subject.Namespace, "spec.subject.namespace")) - } - return err -} - -// Validate implements apis.Validatable -func (fbs *SinkBindingSpec) Validate(ctx context.Context) *apis.FieldError { - return fbs.Subject.Validate(ctx).ViaField("subject").Also( - fbs.Sink.Validate(ctx).ViaField("sink")) -} diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_validation_test.go b/pkg/apis/sources/v1alpha1/sinkbinding_validation_test.go deleted file mode 100644 index e37f77732cc..00000000000 --- a/pkg/apis/sources/v1alpha1/sinkbinding_validation_test.go +++ /dev/null @@ -1,126 +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 v1alpha1 - -import ( - "context" - "testing" - - 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/tracker" -) - -func TestSinkBindingValidation(t *testing.T) { - tests := []struct { - name string - in *SinkBinding - want *apis.FieldError - }{{ - name: "missing subject namespace", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "matt", - Namespace: "moore", - }, - Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: tracker.Reference{ - APIVersion: "apps/v1", - Kind: "Deployment", - Name: "jeanne", - }, - }, - SourceSpec: duckv1.SourceSpec{ - Sink: duckv1.Destination{ - Ref: &duckv1.KReference{ - APIVersion: "serving.knative.dev/v1", - Kind: "Service", - Name: "gemma", - Namespace: "namespace", - }, - }, - }, - }, - }, - want: apis.ErrMissingField("spec.subject.namespace"), - }, { - name: "invalid subject namespace", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "matt", - Namespace: "moore", - }, - Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: tracker.Reference{ - APIVersion: "apps/v1", - Kind: "Deployment", - Name: "jeanne", - Namespace: "lorefice", - }, - }, - SourceSpec: duckv1.SourceSpec{ - Sink: duckv1.Destination{ - Ref: &duckv1.KReference{ - APIVersion: "serving.knative.dev/v1", - Kind: "Service", - Name: "gemma", - Namespace: "namespace", - }, - }, - }, - }, - }, - want: apis.ErrInvalidValue("lorefice", "spec.subject.namespace"), - }, { - name: "missing sink information", - in: &SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "matt", - Namespace: "moore", - }, - Spec: SinkBindingSpec{ - BindingSpec: duckv1alpha1.BindingSpec{ - Subject: tracker.Reference{ - APIVersion: "apps/v1", - Kind: "Deployment", - Name: "jeanne", - Namespace: "moore", - }, - }, - SourceSpec: duckv1.SourceSpec{ - Sink: duckv1.Destination{}, - }, - }, - }, - want: apis.ErrGeneric("expected at least one, got none", "spec.sink.ref", "spec.sink.uri"), - }} - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - got := test.in.Validate(context.Background()) - if (test.want != nil) != (got != nil) { - t.Errorf("Validation() = %v, wanted %v", got, test.want) - } else if test.want != nil && test.want.Error() != got.Error() { - t.Errorf("Validation() = %v, wanted %v", got, test.want) - } - }) - } -} diff --git a/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go deleted file mode 100644 index 1c73a0b5df1..00000000000 --- a/pkg/apis/sources/v1alpha1/zz_generated.deepcopy.go +++ /dev/null @@ -1,258 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by deepcopy-gen. DO NOT EDIT. - -package v1alpha1 - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" - v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" - v1 "knative.dev/pkg/apis/duck/v1" - v1beta1 "knative.dev/pkg/apis/duck/v1beta1" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApiServerResource) DeepCopyInto(out *ApiServerResource) { - *out = *in - in.LabelSelector.DeepCopyInto(&out.LabelSelector) - in.ControllerSelector.DeepCopyInto(&out.ControllerSelector) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApiServerResource. -func (in *ApiServerResource) DeepCopy() *ApiServerResource { - if in == nil { - return nil - } - out := new(ApiServerResource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApiServerSource) DeepCopyInto(out *ApiServerSource) { - *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 ApiServerSource. -func (in *ApiServerSource) DeepCopy() *ApiServerSource { - if in == nil { - return nil - } - out := new(ApiServerSource) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApiServerSource) 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 *ApiServerSourceList) DeepCopyInto(out *ApiServerSourceList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ApiServerSource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApiServerSourceList. -func (in *ApiServerSourceList) DeepCopy() *ApiServerSourceList { - if in == nil { - return nil - } - out := new(ApiServerSourceList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ApiServerSourceList) 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 *ApiServerSourceSpec) DeepCopyInto(out *ApiServerSourceSpec) { - *out = *in - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = make([]ApiServerResource, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Sink != nil { - in, out := &in.Sink, &out.Sink - *out = new(v1beta1.Destination) - (*in).DeepCopyInto(*out) - } - if in.CloudEventOverrides != nil { - in, out := &in.CloudEventOverrides, &out.CloudEventOverrides - *out = new(v1.CloudEventOverrides) - (*in).DeepCopyInto(*out) - } - if in.ResourceOwner != nil { - in, out := &in.ResourceOwner, &out.ResourceOwner - *out = new(v1alpha2.APIVersionKind) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApiServerSourceSpec. -func (in *ApiServerSourceSpec) DeepCopy() *ApiServerSourceSpec { - if in == nil { - return nil - } - out := new(ApiServerSourceSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ApiServerSourceStatus) DeepCopyInto(out *ApiServerSourceStatus) { - *out = *in - in.SourceStatus.DeepCopyInto(&out.SourceStatus) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApiServerSourceStatus. -func (in *ApiServerSourceStatus) DeepCopy() *ApiServerSourceStatus { - if in == nil { - return nil - } - out := new(ApiServerSourceStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SinkBinding) DeepCopyInto(out *SinkBinding) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBinding. -func (in *SinkBinding) DeepCopy() *SinkBinding { - if in == nil { - return nil - } - out := new(SinkBinding) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *SinkBinding) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SinkBindingList) DeepCopyInto(out *SinkBindingList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]SinkBinding, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingList. -func (in *SinkBindingList) DeepCopy() *SinkBindingList { - if in == nil { - return nil - } - out := new(SinkBindingList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *SinkBindingList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SinkBindingSpec) DeepCopyInto(out *SinkBindingSpec) { - *out = *in - in.SourceSpec.DeepCopyInto(&out.SourceSpec) - in.BindingSpec.DeepCopyInto(&out.BindingSpec) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingSpec. -func (in *SinkBindingSpec) DeepCopy() *SinkBindingSpec { - if in == nil { - return nil - } - out := new(SinkBindingSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *SinkBindingStatus) DeepCopyInto(out *SinkBindingStatus) { - *out = *in - in.SourceStatus.DeepCopyInto(&out.SourceStatus) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkBindingStatus. -func (in *SinkBindingStatus) DeepCopy() *SinkBindingStatus { - if in == nil { - return nil - } - out := new(SinkBindingStatus) - in.DeepCopyInto(out) - return out -} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 50413ec9706..278c5a8da66 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -29,7 +29,6 @@ import ( flowsv1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1" messagingv1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1" sourcesv1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1" - sourcesv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2" sourcesv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta1" sourcesv1beta2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta2" @@ -41,7 +40,6 @@ type Interface interface { EventingV1() eventingv1.EventingV1Interface FlowsV1() flowsv1.FlowsV1Interface MessagingV1() messagingv1.MessagingV1Interface - SourcesV1alpha1() sourcesv1alpha1.SourcesV1alpha1Interface SourcesV1alpha2() sourcesv1alpha2.SourcesV1alpha2Interface SourcesV1beta1() sourcesv1beta1.SourcesV1beta1Interface SourcesV1beta2() sourcesv1beta2.SourcesV1beta2Interface @@ -56,7 +54,6 @@ type Clientset struct { eventingV1 *eventingv1.EventingV1Client flowsV1 *flowsv1.FlowsV1Client messagingV1 *messagingv1.MessagingV1Client - sourcesV1alpha1 *sourcesv1alpha1.SourcesV1alpha1Client sourcesV1alpha2 *sourcesv1alpha2.SourcesV1alpha2Client sourcesV1beta1 *sourcesv1beta1.SourcesV1beta1Client sourcesV1beta2 *sourcesv1beta2.SourcesV1beta2Client @@ -83,11 +80,6 @@ func (c *Clientset) MessagingV1() messagingv1.MessagingV1Interface { return c.messagingV1 } -// SourcesV1alpha1 retrieves the SourcesV1alpha1Client -func (c *Clientset) SourcesV1alpha1() sourcesv1alpha1.SourcesV1alpha1Interface { - return c.sourcesV1alpha1 -} - // SourcesV1alpha2 retrieves the SourcesV1alpha2Client func (c *Clientset) SourcesV1alpha2() sourcesv1alpha2.SourcesV1alpha2Interface { return c.sourcesV1alpha2 @@ -145,10 +137,6 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } - cs.sourcesV1alpha1, err = sourcesv1alpha1.NewForConfig(&configShallowCopy) - if err != nil { - return nil, err - } cs.sourcesV1alpha2, err = sourcesv1alpha2.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -181,7 +169,6 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { cs.eventingV1 = eventingv1.NewForConfigOrDie(c) cs.flowsV1 = flowsv1.NewForConfigOrDie(c) cs.messagingV1 = messagingv1.NewForConfigOrDie(c) - cs.sourcesV1alpha1 = sourcesv1alpha1.NewForConfigOrDie(c) cs.sourcesV1alpha2 = sourcesv1alpha2.NewForConfigOrDie(c) cs.sourcesV1beta1 = sourcesv1beta1.NewForConfigOrDie(c) cs.sourcesV1beta2 = sourcesv1beta2.NewForConfigOrDie(c) @@ -198,7 +185,6 @@ func New(c rest.Interface) *Clientset { cs.eventingV1 = eventingv1.New(c) cs.flowsV1 = flowsv1.New(c) cs.messagingV1 = messagingv1.New(c) - cs.sourcesV1alpha1 = sourcesv1alpha1.New(c) cs.sourcesV1alpha2 = sourcesv1alpha2.New(c) cs.sourcesV1beta1 = sourcesv1beta1.New(c) cs.sourcesV1beta2 = sourcesv1beta2.New(c) diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index d5eb7f76186..2f2a1bf9503 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -35,8 +35,6 @@ import ( fakemessagingv1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1/fake" sourcesv1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1" fakesourcesv1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1/fake" - sourcesv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" - fakesourcesv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake" sourcesv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2" fakesourcesv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake" sourcesv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta1" @@ -112,11 +110,6 @@ func (c *Clientset) MessagingV1() messagingv1.MessagingV1Interface { return &fakemessagingv1.FakeMessagingV1{Fake: &c.Fake} } -// SourcesV1alpha1 retrieves the SourcesV1alpha1Client -func (c *Clientset) SourcesV1alpha1() sourcesv1alpha1.SourcesV1alpha1Interface { - return &fakesourcesv1alpha1.FakeSourcesV1alpha1{Fake: &c.Fake} -} - // SourcesV1alpha2 retrieves the SourcesV1alpha2Client func (c *Clientset) SourcesV1alpha2() sourcesv1alpha2.SourcesV1alpha2Interface { return &fakesourcesv1alpha2.FakeSourcesV1alpha2{Fake: &c.Fake} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 133b999e40c..398d68160e7 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -29,7 +29,6 @@ import ( flowsv1 "knative.dev/eventing/pkg/apis/flows/v1" messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1" sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" sourcesv1beta2 "knative.dev/eventing/pkg/apis/sources/v1beta2" @@ -43,7 +42,6 @@ var localSchemeBuilder = runtime.SchemeBuilder{ eventingv1.AddToScheme, flowsv1.AddToScheme, messagingv1.AddToScheme, - sourcesv1alpha1.AddToScheme, sourcesv1alpha2.AddToScheme, sourcesv1beta1.AddToScheme, sourcesv1beta2.AddToScheme, diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 92511bb996f..41f9d4da9d7 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -29,7 +29,6 @@ import ( flowsv1 "knative.dev/eventing/pkg/apis/flows/v1" messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1" sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" sourcesv1beta2 "knative.dev/eventing/pkg/apis/sources/v1beta2" @@ -43,7 +42,6 @@ var localSchemeBuilder = runtime.SchemeBuilder{ eventingv1.AddToScheme, flowsv1.AddToScheme, messagingv1.AddToScheme, - sourcesv1alpha1.AddToScheme, sourcesv1alpha2.AddToScheme, sourcesv1beta1.AddToScheme, sourcesv1beta2.AddToScheme, diff --git a/pkg/client/clientset/versioned/typed/sources/v1alpha1/apiserversource.go b/pkg/client/clientset/versioned/typed/sources/v1alpha1/apiserversource.go deleted file mode 100644 index d57720afe0e..00000000000 --- a/pkg/client/clientset/versioned/typed/sources/v1alpha1/apiserversource.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 ( - "context" - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" -) - -// ApiServerSourcesGetter has a method to return a ApiServerSourceInterface. -// A group's client should implement this interface. -type ApiServerSourcesGetter interface { - ApiServerSources(namespace string) ApiServerSourceInterface -} - -// ApiServerSourceInterface has methods to work with ApiServerSource resources. -type ApiServerSourceInterface interface { - Create(ctx context.Context, apiServerSource *v1alpha1.ApiServerSource, opts v1.CreateOptions) (*v1alpha1.ApiServerSource, error) - Update(ctx context.Context, apiServerSource *v1alpha1.ApiServerSource, opts v1.UpdateOptions) (*v1alpha1.ApiServerSource, error) - UpdateStatus(ctx context.Context, apiServerSource *v1alpha1.ApiServerSource, opts v1.UpdateOptions) (*v1alpha1.ApiServerSource, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.ApiServerSource, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.ApiServerSourceList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ApiServerSource, err error) - ApiServerSourceExpansion -} - -// apiServerSources implements ApiServerSourceInterface -type apiServerSources struct { - client rest.Interface - ns string -} - -// newApiServerSources returns a ApiServerSources -func newApiServerSources(c *SourcesV1alpha1Client, namespace string) *apiServerSources { - return &apiServerSources{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the apiServerSource, and returns the corresponding apiServerSource object, and an error if there is any. -func (c *apiServerSources) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Get(). - Namespace(c.ns). - Resource("apiserversources"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ApiServerSources that match those selectors. -func (c *apiServerSources) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ApiServerSourceList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.ApiServerSourceList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("apiserversources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested apiServerSources. -func (c *apiServerSources) Watch(ctx context.Context, 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("apiserversources"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a apiServerSource and creates it. Returns the server's representation of the apiServerSource, and an error, if there is any. -func (c *apiServerSources) Create(ctx context.Context, apiServerSource *v1alpha1.ApiServerSource, opts v1.CreateOptions) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Post(). - Namespace(c.ns). - Resource("apiserversources"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(apiServerSource). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a apiServerSource and updates it. Returns the server's representation of the apiServerSource, and an error, if there is any. -func (c *apiServerSources) Update(ctx context.Context, apiServerSource *v1alpha1.ApiServerSource, opts v1.UpdateOptions) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("apiserversources"). - Name(apiServerSource.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(apiServerSource). - Do(ctx). - 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 *apiServerSources) UpdateStatus(ctx context.Context, apiServerSource *v1alpha1.ApiServerSource, opts v1.UpdateOptions) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Put(). - Namespace(c.ns). - Resource("apiserversources"). - Name(apiServerSource.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(apiServerSource). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the apiServerSource and deletes it. Returns an error if one occurs. -func (c *apiServerSources) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("apiserversources"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *apiServerSources) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("apiserversources"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched apiServerSource. -func (c *apiServerSources) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ApiServerSource, err error) { - result = &v1alpha1.ApiServerSource{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("apiserversources"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/sources/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/sources/v1alpha1/doc.go deleted file mode 100644 index f905d3a2158..00000000000 --- a/pkg/client/clientset/versioned/typed/sources/v1alpha1/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/doc.go deleted file mode 100644 index d5a46ef5532..00000000000 --- a/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_apiserversource.go b/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_apiserversource.go deleted file mode 100644 index b57e34b0398..00000000000 --- a/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_apiserversource.go +++ /dev/null @@ -1,142 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 ( - "context" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" -) - -// FakeApiServerSources implements ApiServerSourceInterface -type FakeApiServerSources struct { - Fake *FakeSourcesV1alpha1 - ns string -} - -var apiserversourcesResource = schema.GroupVersionResource{Group: "sources.knative.dev", Version: "v1alpha1", Resource: "apiserversources"} - -var apiserversourcesKind = schema.GroupVersionKind{Group: "sources.knative.dev", Version: "v1alpha1", Kind: "ApiServerSource"} - -// Get takes name of the apiServerSource, and returns the corresponding apiServerSource object, and an error if there is any. -func (c *FakeApiServerSources) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ApiServerSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(apiserversourcesResource, c.ns, name), &v1alpha1.ApiServerSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ApiServerSource), err -} - -// List takes label and field selectors, and returns the list of ApiServerSources that match those selectors. -func (c *FakeApiServerSources) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.ApiServerSourceList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(apiserversourcesResource, apiserversourcesKind, c.ns, opts), &v1alpha1.ApiServerSourceList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.ApiServerSourceList{ListMeta: obj.(*v1alpha1.ApiServerSourceList).ListMeta} - for _, item := range obj.(*v1alpha1.ApiServerSourceList).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 apiServerSources. -func (c *FakeApiServerSources) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(apiserversourcesResource, c.ns, opts)) - -} - -// Create takes the representation of a apiServerSource and creates it. Returns the server's representation of the apiServerSource, and an error, if there is any. -func (c *FakeApiServerSources) Create(ctx context.Context, apiServerSource *v1alpha1.ApiServerSource, opts v1.CreateOptions) (result *v1alpha1.ApiServerSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(apiserversourcesResource, c.ns, apiServerSource), &v1alpha1.ApiServerSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ApiServerSource), err -} - -// Update takes the representation of a apiServerSource and updates it. Returns the server's representation of the apiServerSource, and an error, if there is any. -func (c *FakeApiServerSources) Update(ctx context.Context, apiServerSource *v1alpha1.ApiServerSource, opts v1.UpdateOptions) (result *v1alpha1.ApiServerSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(apiserversourcesResource, c.ns, apiServerSource), &v1alpha1.ApiServerSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ApiServerSource), 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 *FakeApiServerSources) UpdateStatus(ctx context.Context, apiServerSource *v1alpha1.ApiServerSource, opts v1.UpdateOptions) (*v1alpha1.ApiServerSource, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(apiserversourcesResource, "status", c.ns, apiServerSource), &v1alpha1.ApiServerSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ApiServerSource), err -} - -// Delete takes name of the apiServerSource and deletes it. Returns an error if one occurs. -func (c *FakeApiServerSources) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(apiserversourcesResource, c.ns, name), &v1alpha1.ApiServerSource{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeApiServerSources) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(apiserversourcesResource, c.ns, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha1.ApiServerSourceList{}) - return err -} - -// Patch applies the patch and returns the patched apiServerSource. -func (c *FakeApiServerSources) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.ApiServerSource, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(apiserversourcesResource, c.ns, name, pt, data, subresources...), &v1alpha1.ApiServerSource{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.ApiServerSource), err -} diff --git a/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go b/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go deleted file mode 100644 index 10b94e09bba..00000000000 --- a/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sinkbinding.go +++ /dev/null @@ -1,142 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 ( - "context" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" -) - -// FakeSinkBindings implements SinkBindingInterface -type FakeSinkBindings struct { - Fake *FakeSourcesV1alpha1 - ns string -} - -var sinkbindingsResource = schema.GroupVersionResource{Group: "sources.knative.dev", Version: "v1alpha1", Resource: "sinkbindings"} - -var sinkbindingsKind = schema.GroupVersionKind{Group: "sources.knative.dev", Version: "v1alpha1", Kind: "SinkBinding"} - -// Get takes name of the sinkBinding, and returns the corresponding sinkBinding object, and an error if there is any. -func (c *FakeSinkBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SinkBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(sinkbindingsResource, c.ns, name), &v1alpha1.SinkBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.SinkBinding), err -} - -// List takes label and field selectors, and returns the list of SinkBindings that match those selectors. -func (c *FakeSinkBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SinkBindingList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(sinkbindingsResource, sinkbindingsKind, c.ns, opts), &v1alpha1.SinkBindingList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1alpha1.SinkBindingList{ListMeta: obj.(*v1alpha1.SinkBindingList).ListMeta} - for _, item := range obj.(*v1alpha1.SinkBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested sinkBindings. -func (c *FakeSinkBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(sinkbindingsResource, c.ns, opts)) - -} - -// Create takes the representation of a sinkBinding and creates it. Returns the server's representation of the sinkBinding, and an error, if there is any. -func (c *FakeSinkBindings) Create(ctx context.Context, sinkBinding *v1alpha1.SinkBinding, opts v1.CreateOptions) (result *v1alpha1.SinkBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(sinkbindingsResource, c.ns, sinkBinding), &v1alpha1.SinkBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.SinkBinding), err -} - -// Update takes the representation of a sinkBinding and updates it. Returns the server's representation of the sinkBinding, and an error, if there is any. -func (c *FakeSinkBindings) Update(ctx context.Context, sinkBinding *v1alpha1.SinkBinding, opts v1.UpdateOptions) (result *v1alpha1.SinkBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(sinkbindingsResource, c.ns, sinkBinding), &v1alpha1.SinkBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.SinkBinding), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeSinkBindings) UpdateStatus(ctx context.Context, sinkBinding *v1alpha1.SinkBinding, opts v1.UpdateOptions) (*v1alpha1.SinkBinding, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(sinkbindingsResource, "status", c.ns, sinkBinding), &v1alpha1.SinkBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.SinkBinding), err -} - -// Delete takes name of the sinkBinding and deletes it. Returns an error if one occurs. -func (c *FakeSinkBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(sinkbindingsResource, c.ns, name), &v1alpha1.SinkBinding{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeSinkBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(sinkbindingsResource, c.ns, listOpts) - - _, err := c.Fake.Invokes(action, &v1alpha1.SinkBindingList{}) - return err -} - -// Patch applies the patch and returns the patched sinkBinding. -func (c *FakeSinkBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SinkBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(sinkbindingsResource, c.ns, name, pt, data, subresources...), &v1alpha1.SinkBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1alpha1.SinkBinding), err -} diff --git a/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go b/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go deleted file mode 100644 index a84fb96fbb0..00000000000 --- a/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake/fake_sources_client.go +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" -) - -type FakeSourcesV1alpha1 struct { - *testing.Fake -} - -func (c *FakeSourcesV1alpha1) ApiServerSources(namespace string) v1alpha1.ApiServerSourceInterface { - return &FakeApiServerSources{c, namespace} -} - -func (c *FakeSourcesV1alpha1) SinkBindings(namespace string) v1alpha1.SinkBindingInterface { - return &FakeSinkBindings{c, namespace} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeSourcesV1alpha1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go deleted file mode 100644 index 9a0bdd4992e..00000000000 --- a/pkg/client/clientset/versioned/typed/sources/v1alpha1/generated_expansion.go +++ /dev/null @@ -1,23 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 ApiServerSourceExpansion interface{} - -type SinkBindingExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go b/pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go deleted file mode 100644 index 8711d7e6a33..00000000000 --- a/pkg/client/clientset/versioned/typed/sources/v1alpha1/sinkbinding.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 ( - "context" - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" -) - -// SinkBindingsGetter has a method to return a SinkBindingInterface. -// A group's client should implement this interface. -type SinkBindingsGetter interface { - SinkBindings(namespace string) SinkBindingInterface -} - -// SinkBindingInterface has methods to work with SinkBinding resources. -type SinkBindingInterface interface { - Create(ctx context.Context, sinkBinding *v1alpha1.SinkBinding, opts v1.CreateOptions) (*v1alpha1.SinkBinding, error) - Update(ctx context.Context, sinkBinding *v1alpha1.SinkBinding, opts v1.UpdateOptions) (*v1alpha1.SinkBinding, error) - UpdateStatus(ctx context.Context, sinkBinding *v1alpha1.SinkBinding, opts v1.UpdateOptions) (*v1alpha1.SinkBinding, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.SinkBinding, error) - List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.SinkBindingList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SinkBinding, err error) - SinkBindingExpansion -} - -// sinkBindings implements SinkBindingInterface -type sinkBindings struct { - client rest.Interface - ns string -} - -// newSinkBindings returns a SinkBindings -func newSinkBindings(c *SourcesV1alpha1Client, namespace string) *sinkBindings { - return &sinkBindings{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the sinkBinding, and returns the corresponding sinkBinding object, and an error if there is any. -func (c *sinkBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Get(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of SinkBindings that match those selectors. -func (c *sinkBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.SinkBindingList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1alpha1.SinkBindingList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("sinkbindings"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested sinkBindings. -func (c *sinkBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("sinkbindings"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a sinkBinding and creates it. Returns the server's representation of the sinkBinding, and an error, if there is any. -func (c *sinkBindings) Create(ctx context.Context, sinkBinding *v1alpha1.SinkBinding, opts v1.CreateOptions) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Post(). - Namespace(c.ns). - Resource("sinkbindings"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(sinkBinding). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a sinkBinding and updates it. Returns the server's representation of the sinkBinding, and an error, if there is any. -func (c *sinkBindings) Update(ctx context.Context, sinkBinding *v1alpha1.SinkBinding, opts v1.UpdateOptions) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Put(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(sinkBinding.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(sinkBinding). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *sinkBindings) UpdateStatus(ctx context.Context, sinkBinding *v1alpha1.SinkBinding, opts v1.UpdateOptions) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Put(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(sinkBinding.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(sinkBinding). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the sinkBinding and deletes it. Returns an error if one occurs. -func (c *sinkBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("sinkbindings"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *sinkBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("sinkbindings"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched sinkBinding. -func (c *sinkBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.SinkBinding, err error) { - result = &v1alpha1.SinkBinding{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("sinkbindings"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go b/pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go deleted file mode 100644 index 43796ea86fa..00000000000 --- a/pkg/client/clientset/versioned/typed/sources/v1alpha1/sources_client.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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/eventing/pkg/apis/sources/v1alpha1" - "knative.dev/eventing/pkg/client/clientset/versioned/scheme" -) - -type SourcesV1alpha1Interface interface { - RESTClient() rest.Interface - ApiServerSourcesGetter - SinkBindingsGetter -} - -// SourcesV1alpha1Client is used to interact with features provided by the sources.knative.dev group. -type SourcesV1alpha1Client struct { - restClient rest.Interface -} - -func (c *SourcesV1alpha1Client) ApiServerSources(namespace string) ApiServerSourceInterface { - return newApiServerSources(c, namespace) -} - -func (c *SourcesV1alpha1Client) SinkBindings(namespace string) SinkBindingInterface { - return newSinkBindings(c, namespace) -} - -// NewForConfig creates a new SourcesV1alpha1Client for the given config. -func NewForConfig(c *rest.Config) (*SourcesV1alpha1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &SourcesV1alpha1Client{client}, nil -} - -// NewForConfigOrDie creates a new SourcesV1alpha1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *SourcesV1alpha1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new SourcesV1alpha1Client for the given RESTClient. -func New(c rest.Interface) *SourcesV1alpha1Client { - return &SourcesV1alpha1Client{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 *SourcesV1alpha1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 5f652e407fb..c213c1fb085 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -28,7 +28,6 @@ import ( flowsv1 "knative.dev/eventing/pkg/apis/flows/v1" messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1" sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1" - v1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" v1beta2 "knative.dev/eventing/pkg/apis/sources/v1beta2" @@ -92,12 +91,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case sourcesv1.SchemeGroupVersion.WithResource("sinkbindings"): return &genericInformer{resource: resource.GroupResource(), informer: f.Sources().V1().SinkBindings().Informer()}, nil - // Group=sources.knative.dev, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("apiserversources"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Sources().V1alpha1().ApiServerSources().Informer()}, nil - case v1alpha1.SchemeGroupVersion.WithResource("sinkbindings"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Sources().V1alpha1().SinkBindings().Informer()}, nil - // Group=sources.knative.dev, Version=v1alpha2 case v1alpha2.SchemeGroupVersion.WithResource("apiserversources"): return &genericInformer{resource: resource.GroupResource(), informer: f.Sources().V1alpha2().ApiServerSources().Informer()}, nil diff --git a/pkg/client/informers/externalversions/sources/interface.go b/pkg/client/informers/externalversions/sources/interface.go index 7608c5d167f..03c4673aaa5 100644 --- a/pkg/client/informers/externalversions/sources/interface.go +++ b/pkg/client/informers/externalversions/sources/interface.go @@ -21,7 +21,6 @@ package sources import ( internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" v1 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1" - v1alpha1 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha1" v1alpha2 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha2" v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1beta1" v1beta2 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1beta2" @@ -29,8 +28,6 @@ import ( // 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 // V1alpha2 provides access to shared informers for resources in V1alpha2. V1alpha2() v1alpha2.Interface // V1beta1 provides access to shared informers for resources in V1beta1. @@ -52,11 +49,6 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList 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) -} - // V1alpha2 returns a new v1alpha2.Interface. func (g *group) V1alpha2() v1alpha2.Interface { return v1alpha2.New(g.factory, g.namespace, g.tweakListOptions) diff --git a/pkg/client/informers/externalversions/sources/v1alpha1/apiserversource.go b/pkg/client/informers/externalversions/sources/v1alpha1/apiserversource.go deleted file mode 100644 index 9ddb73a95a8..00000000000 --- a/pkg/client/informers/externalversions/sources/v1alpha1/apiserversource.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 ( - "context" - 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" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - versioned "knative.dev/eventing/pkg/client/clientset/versioned" - internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "knative.dev/eventing/pkg/client/listers/sources/v1alpha1" -) - -// ApiServerSourceInformer provides access to a shared informer and lister for -// ApiServerSources. -type ApiServerSourceInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1alpha1.ApiServerSourceLister -} - -type apiServerSourceInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewApiServerSourceInformer constructs a new informer for ApiServerSource 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 NewApiServerSourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredApiServerSourceInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredApiServerSourceInformer constructs a new informer for ApiServerSource 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 NewFilteredApiServerSourceInformer(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.SourcesV1alpha1().ApiServerSources(namespace).List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.SourcesV1alpha1().ApiServerSources(namespace).Watch(context.TODO(), options) - }, - }, - &sourcesv1alpha1.ApiServerSource{}, - resyncPeriod, - indexers, - ) -} - -func (f *apiServerSourceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredApiServerSourceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *apiServerSourceInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&sourcesv1alpha1.ApiServerSource{}, f.defaultInformer) -} - -func (f *apiServerSourceInformer) Lister() v1alpha1.ApiServerSourceLister { - return v1alpha1.NewApiServerSourceLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/informers/externalversions/sources/v1alpha1/interface.go b/pkg/client/informers/externalversions/sources/v1alpha1/interface.go deleted file mode 100644 index ee9accd8f50..00000000000 --- a/pkg/client/informers/externalversions/sources/v1alpha1/interface.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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/eventing/pkg/client/informers/externalversions/internalinterfaces" -) - -// Interface provides access to all the informers in this group version. -type Interface interface { - // ApiServerSources returns a ApiServerSourceInformer. - ApiServerSources() ApiServerSourceInformer - // SinkBindings returns a SinkBindingInformer. - SinkBindings() SinkBindingInformer -} - -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} -} - -// ApiServerSources returns a ApiServerSourceInformer. -func (v *version) ApiServerSources() ApiServerSourceInformer { - return &apiServerSourceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} - -// SinkBindings returns a SinkBindingInformer. -func (v *version) SinkBindings() SinkBindingInformer { - return &sinkBindingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} diff --git a/pkg/client/informers/externalversions/sources/v1alpha1/sinkbinding.go b/pkg/client/informers/externalversions/sources/v1alpha1/sinkbinding.go deleted file mode 100644 index bda0da9a662..00000000000 --- a/pkg/client/informers/externalversions/sources/v1alpha1/sinkbinding.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 ( - "context" - 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" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - versioned "knative.dev/eventing/pkg/client/clientset/versioned" - internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "knative.dev/eventing/pkg/client/listers/sources/v1alpha1" -) - -// SinkBindingInformer provides access to a shared informer and lister for -// SinkBindings. -type SinkBindingInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1alpha1.SinkBindingLister -} - -type sinkBindingInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewSinkBindingInformer constructs a new informer for SinkBinding 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 NewSinkBindingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredSinkBindingInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredSinkBindingInformer constructs a new informer for SinkBinding 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 NewFilteredSinkBindingInformer(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.SourcesV1alpha1().SinkBindings(namespace).List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.SourcesV1alpha1().SinkBindings(namespace).Watch(context.TODO(), options) - }, - }, - &sourcesv1alpha1.SinkBinding{}, - resyncPeriod, - indexers, - ) -} - -func (f *sinkBindingInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredSinkBindingInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *sinkBindingInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&sourcesv1alpha1.SinkBinding{}, f.defaultInformer) -} - -func (f *sinkBindingInformer) Lister() v1alpha1.SinkBindingLister { - return v1alpha1.NewSinkBindingLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/injection/informers/sources/v1alpha1/apiserversource/apiserversource.go b/pkg/client/injection/informers/sources/v1alpha1/apiserversource/apiserversource.go deleted file mode 100644 index 29c470e88fc..00000000000 --- a/pkg/client/injection/informers/sources/v1alpha1/apiserversource/apiserversource.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 apiserversource - -import ( - context "context" - - v1alpha1 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha1" - factory "knative.dev/eventing/pkg/client/injection/informers/factory" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -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.Sources().V1alpha1().ApiServerSources() - return context.WithValue(ctx, Key{}, inf), inf.Informer() -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context) v1alpha1.ApiServerSourceInformer { - untyped := ctx.Value(Key{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha1.ApiServerSourceInformer from context.") - } - return untyped.(v1alpha1.ApiServerSourceInformer) -} diff --git a/pkg/client/injection/informers/sources/v1alpha1/apiserversource/fake/fake.go b/pkg/client/injection/informers/sources/v1alpha1/apiserversource/fake/fake.go deleted file mode 100644 index 02537746b62..00000000000 --- a/pkg/client/injection/informers/sources/v1alpha1/apiserversource/fake/fake.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 "context" - - fake "knative.dev/eventing/pkg/client/injection/informers/factory/fake" - apiserversource "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha1/apiserversource" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" -) - -var Get = apiserversource.Get - -func init() { - injection.Fake.RegisterInformer(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, controller.Informer) { - f := fake.Get(ctx) - inf := f.Sources().V1alpha1().ApiServerSources() - return context.WithValue(ctx, apiserversource.Key{}, inf), inf.Informer() -} diff --git a/pkg/client/injection/informers/sources/v1alpha1/apiserversource/filtered/apiserversource.go b/pkg/client/injection/informers/sources/v1alpha1/apiserversource/filtered/apiserversource.go deleted file mode 100644 index 0137600017a..00000000000 --- a/pkg/client/injection/informers/sources/v1alpha1/apiserversource/filtered/apiserversource.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 filtered - -import ( - context "context" - - v1alpha1 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha1" - filtered "knative.dev/eventing/pkg/client/injection/informers/factory/filtered" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -func init() { - injection.Default.RegisterFilteredInformers(withInformer) -} - -// Key is used for associating the Informer inside the context.Context. -type Key struct { - Selector string -} - -func withInformer(ctx context.Context) (context.Context, []controller.Informer) { - untyped := ctx.Value(filtered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - infs := []controller.Informer{} - for _, selector := range labelSelectors { - f := filtered.Get(ctx, selector) - inf := f.Sources().V1alpha1().ApiServerSources() - ctx = context.WithValue(ctx, Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context, selector string) v1alpha1.ApiServerSourceInformer { - untyped := ctx.Value(Key{Selector: selector}) - if untyped == nil { - logging.FromContext(ctx).Panicf( - "Unable to fetch knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha1.ApiServerSourceInformer with selector %s from context.", selector) - } - return untyped.(v1alpha1.ApiServerSourceInformer) -} diff --git a/pkg/client/injection/informers/sources/v1alpha1/apiserversource/filtered/fake/fake.go b/pkg/client/injection/informers/sources/v1alpha1/apiserversource/filtered/fake/fake.go deleted file mode 100644 index d4e9029a56d..00000000000 --- a/pkg/client/injection/informers/sources/v1alpha1/apiserversource/filtered/fake/fake.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 "context" - - factoryfiltered "knative.dev/eventing/pkg/client/injection/informers/factory/filtered" - filtered "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha1/apiserversource/filtered" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -var Get = filtered.Get - -func init() { - injection.Fake.RegisterFilteredInformers(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, []controller.Informer) { - untyped := ctx.Value(factoryfiltered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - infs := []controller.Informer{} - for _, selector := range labelSelectors { - f := factoryfiltered.Get(ctx, selector) - inf := f.Sources().V1alpha1().ApiServerSources() - ctx = context.WithValue(ctx, filtered.Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} diff --git a/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/fake/fake.go b/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/fake/fake.go deleted file mode 100644 index 41166d9527f..00000000000 --- a/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/fake/fake.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 "context" - - fake "knative.dev/eventing/pkg/client/injection/informers/factory/fake" - sinkbinding "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha1/sinkbinding" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" -) - -var Get = sinkbinding.Get - -func init() { - injection.Fake.RegisterInformer(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, controller.Informer) { - f := fake.Get(ctx) - inf := f.Sources().V1alpha1().SinkBindings() - return context.WithValue(ctx, sinkbinding.Key{}, inf), inf.Informer() -} diff --git a/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/filtered/fake/fake.go b/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/filtered/fake/fake.go deleted file mode 100644 index 3ce49e474ef..00000000000 --- a/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/filtered/fake/fake.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 "context" - - factoryfiltered "knative.dev/eventing/pkg/client/injection/informers/factory/filtered" - filtered "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/filtered" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -var Get = filtered.Get - -func init() { - injection.Fake.RegisterFilteredInformers(withInformer) -} - -func withInformer(ctx context.Context) (context.Context, []controller.Informer) { - untyped := ctx.Value(factoryfiltered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - infs := []controller.Informer{} - for _, selector := range labelSelectors { - f := factoryfiltered.Get(ctx, selector) - inf := f.Sources().V1alpha1().SinkBindings() - ctx = context.WithValue(ctx, filtered.Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} diff --git a/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/filtered/sinkbinding.go b/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/filtered/sinkbinding.go deleted file mode 100644 index 78f76110afa..00000000000 --- a/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/filtered/sinkbinding.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 filtered - -import ( - context "context" - - v1alpha1 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha1" - filtered "knative.dev/eventing/pkg/client/injection/informers/factory/filtered" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -func init() { - injection.Default.RegisterFilteredInformers(withInformer) -} - -// Key is used for associating the Informer inside the context.Context. -type Key struct { - Selector string -} - -func withInformer(ctx context.Context) (context.Context, []controller.Informer) { - untyped := ctx.Value(filtered.LabelKey{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch labelkey from context.") - } - labelSelectors := untyped.([]string) - infs := []controller.Informer{} - for _, selector := range labelSelectors { - f := filtered.Get(ctx, selector) - inf := f.Sources().V1alpha1().SinkBindings() - ctx = context.WithValue(ctx, Key{Selector: selector}, inf) - infs = append(infs, inf.Informer()) - } - return ctx, infs -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context, selector string) v1alpha1.SinkBindingInformer { - untyped := ctx.Value(Key{Selector: selector}) - if untyped == nil { - logging.FromContext(ctx).Panicf( - "Unable to fetch knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha1.SinkBindingInformer with selector %s from context.", selector) - } - return untyped.(v1alpha1.SinkBindingInformer) -} diff --git a/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/sinkbinding.go b/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/sinkbinding.go deleted file mode 100644 index 8ee4fa06df2..00000000000 --- a/pkg/client/injection/informers/sources/v1alpha1/sinkbinding/sinkbinding.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 sinkbinding - -import ( - context "context" - - v1alpha1 "knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha1" - factory "knative.dev/eventing/pkg/client/injection/informers/factory" - controller "knative.dev/pkg/controller" - injection "knative.dev/pkg/injection" - logging "knative.dev/pkg/logging" -) - -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.Sources().V1alpha1().SinkBindings() - return context.WithValue(ctx, Key{}, inf), inf.Informer() -} - -// Get extracts the typed informer from the context. -func Get(ctx context.Context) v1alpha1.SinkBindingInformer { - untyped := ctx.Value(Key{}) - if untyped == nil { - logging.FromContext(ctx).Panic( - "Unable to fetch knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha1.SinkBindingInformer from context.") - } - return untyped.(v1alpha1.SinkBindingInformer) -} diff --git a/pkg/client/listers/sources/v1alpha1/apiserversource.go b/pkg/client/listers/sources/v1alpha1/apiserversource.go deleted file mode 100644 index f8e7e359abc..00000000000 --- a/pkg/client/listers/sources/v1alpha1/apiserversource.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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/eventing/pkg/apis/sources/v1alpha1" -) - -// ApiServerSourceLister helps list ApiServerSources. -// All objects returned here must be treated as read-only. -type ApiServerSourceLister interface { - // List lists all ApiServerSources in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.ApiServerSource, err error) - // ApiServerSources returns an object that can list and get ApiServerSources. - ApiServerSources(namespace string) ApiServerSourceNamespaceLister - ApiServerSourceListerExpansion -} - -// apiServerSourceLister implements the ApiServerSourceLister interface. -type apiServerSourceLister struct { - indexer cache.Indexer -} - -// NewApiServerSourceLister returns a new ApiServerSourceLister. -func NewApiServerSourceLister(indexer cache.Indexer) ApiServerSourceLister { - return &apiServerSourceLister{indexer: indexer} -} - -// List lists all ApiServerSources in the indexer. -func (s *apiServerSourceLister) List(selector labels.Selector) (ret []*v1alpha1.ApiServerSource, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.ApiServerSource)) - }) - return ret, err -} - -// ApiServerSources returns an object that can list and get ApiServerSources. -func (s *apiServerSourceLister) ApiServerSources(namespace string) ApiServerSourceNamespaceLister { - return apiServerSourceNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// ApiServerSourceNamespaceLister helps list and get ApiServerSources. -// All objects returned here must be treated as read-only. -type ApiServerSourceNamespaceLister interface { - // List lists all ApiServerSources in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.ApiServerSource, err error) - // Get retrieves the ApiServerSource from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.ApiServerSource, error) - ApiServerSourceNamespaceListerExpansion -} - -// apiServerSourceNamespaceLister implements the ApiServerSourceNamespaceLister -// interface. -type apiServerSourceNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all ApiServerSources in the indexer for a given namespace. -func (s apiServerSourceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ApiServerSource, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.ApiServerSource)) - }) - return ret, err -} - -// Get retrieves the ApiServerSource from the indexer for a given namespace and name. -func (s apiServerSourceNamespaceLister) Get(name string) (*v1alpha1.ApiServerSource, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("apiserversource"), name) - } - return obj.(*v1alpha1.ApiServerSource), nil -} diff --git a/pkg/client/listers/sources/v1alpha1/expansion_generated.go b/pkg/client/listers/sources/v1alpha1/expansion_generated.go deleted file mode 100644 index 7b13363e49d..00000000000 --- a/pkg/client/listers/sources/v1alpha1/expansion_generated.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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 - -// ApiServerSourceListerExpansion allows custom methods to be added to -// ApiServerSourceLister. -type ApiServerSourceListerExpansion interface{} - -// ApiServerSourceNamespaceListerExpansion allows custom methods to be added to -// ApiServerSourceNamespaceLister. -type ApiServerSourceNamespaceListerExpansion interface{} - -// SinkBindingListerExpansion allows custom methods to be added to -// SinkBindingLister. -type SinkBindingListerExpansion interface{} - -// SinkBindingNamespaceListerExpansion allows custom methods to be added to -// SinkBindingNamespaceLister. -type SinkBindingNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/sources/v1alpha1/sinkbinding.go b/pkg/client/listers/sources/v1alpha1/sinkbinding.go deleted file mode 100644 index 686511ec07e..00000000000 --- a/pkg/client/listers/sources/v1alpha1/sinkbinding.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright 2021 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT 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/eventing/pkg/apis/sources/v1alpha1" -) - -// SinkBindingLister helps list SinkBindings. -// All objects returned here must be treated as read-only. -type SinkBindingLister interface { - // List lists all SinkBindings in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.SinkBinding, err error) - // SinkBindings returns an object that can list and get SinkBindings. - SinkBindings(namespace string) SinkBindingNamespaceLister - SinkBindingListerExpansion -} - -// sinkBindingLister implements the SinkBindingLister interface. -type sinkBindingLister struct { - indexer cache.Indexer -} - -// NewSinkBindingLister returns a new SinkBindingLister. -func NewSinkBindingLister(indexer cache.Indexer) SinkBindingLister { - return &sinkBindingLister{indexer: indexer} -} - -// List lists all SinkBindings in the indexer. -func (s *sinkBindingLister) List(selector labels.Selector) (ret []*v1alpha1.SinkBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.SinkBinding)) - }) - return ret, err -} - -// SinkBindings returns an object that can list and get SinkBindings. -func (s *sinkBindingLister) SinkBindings(namespace string) SinkBindingNamespaceLister { - return sinkBindingNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// SinkBindingNamespaceLister helps list and get SinkBindings. -// All objects returned here must be treated as read-only. -type SinkBindingNamespaceLister interface { - // List lists all SinkBindings in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1alpha1.SinkBinding, err error) - // Get retrieves the SinkBinding from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1alpha1.SinkBinding, error) - SinkBindingNamespaceListerExpansion -} - -// sinkBindingNamespaceLister implements the SinkBindingNamespaceLister -// interface. -type sinkBindingNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all SinkBindings in the indexer for a given namespace. -func (s sinkBindingNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.SinkBinding, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1alpha1.SinkBinding)) - }) - return ret, err -} - -// Get retrieves the SinkBinding from the indexer for a given namespace and name. -func (s sinkBindingNamespaceLister) Get(name string) (*v1alpha1.SinkBinding, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1alpha1.Resource("sinkbinding"), name) - } - return obj.(*v1alpha1.SinkBinding), nil -} diff --git a/pkg/reconciler/testing/listers.go b/pkg/reconciler/testing/listers.go index 34b98df6d97..bec38446f3c 100644 --- a/pkg/reconciler/testing/listers.go +++ b/pkg/reconciler/testing/listers.go @@ -31,12 +31,10 @@ import ( corev1listers "k8s.io/client-go/listers/core/v1" rbacv1listers "k8s.io/client-go/listers/rbac/v1" "k8s.io/client-go/tools/cache" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" sourcesv1beta2 "knative.dev/eventing/pkg/apis/sources/v1beta2" fakeeventingclientset "knative.dev/eventing/pkg/client/clientset/versioned/fake" - sourcelisters "knative.dev/eventing/pkg/client/listers/sources/v1alpha1" sourcev1alpha2listers "knative.dev/eventing/pkg/client/listers/sources/v1alpha2" sourcev1beta1listers "knative.dev/eventing/pkg/client/listers/sources/v1beta1" sourcev1beta2listers "knative.dev/eventing/pkg/client/listers/sources/v1beta2" @@ -118,14 +116,6 @@ func (l *Listers) GetAllObjects() []runtime.Object { return all } -func (l *Listers) GetApiServerSourceLister() sourcelisters.ApiServerSourceLister { - return sourcelisters.NewApiServerSourceLister(l.indexerFor(&sourcesv1alpha1.ApiServerSource{})) -} - -func (l *Listers) GetSinkBindingLister() sourcelisters.SinkBindingLister { - return sourcelisters.NewSinkBindingLister(l.indexerFor(&sourcesv1alpha1.SinkBinding{})) -} - func (l *Listers) GetPingSourceV1beta1Lister() sourcev1beta1listers.PingSourceLister { return sourcev1beta1listers.NewPingSourceLister(l.indexerFor(&sourcesv1beta1.PingSource{})) } diff --git a/pkg/reconciler/testing/v1/sinkbinding.go b/pkg/reconciler/testing/v1/sinkbinding.go index 1ff11cdddfd..301f9bf1246 100644 --- a/pkg/reconciler/testing/v1/sinkbinding.go +++ b/pkg/reconciler/testing/v1/sinkbinding.go @@ -23,7 +23,7 @@ import ( "knative.dev/pkg/tracker" ) -// SinkBindingOption enables further configuration of a v1alpha1 SinkBinding. +// SinkBindingOption enables further configuration of a v1 SinkBinding. type SinkBindingOption func(*sourcesv1.SinkBinding) // NewSinkBinding creates a SinkBinding with SinkBindingOptions diff --git a/pkg/reconciler/testing/v1alpha1/sinkbinding.go b/pkg/reconciler/testing/v1alpha1/sinkbinding.go deleted file mode 100644 index 753e46826a2..00000000000 --- a/pkg/reconciler/testing/v1alpha1/sinkbinding.go +++ /dev/null @@ -1,63 +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 testing - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" - duckv1 "knative.dev/pkg/apis/duck/v1" - "knative.dev/pkg/tracker" -) - -// SinkBindingOption enables further configuration of a v1alpha1 SinkBinding. -type SinkBindingOption func(*sourcesv1alpha1.SinkBinding) - -// NewSinkBinding creates a v1alpha1 SinkBinding with SinkBindingOptions -func NewSinkBinding(name, namespace string, o ...SinkBindingOption) *sourcesv1alpha1.SinkBinding { - c := &sourcesv1alpha1.SinkBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: name, - Namespace: namespace, - }, - } - for _, opt := range o { - opt(c) - } - //c.SetDefaults(context.Background()) // TODO: We should add defaults and validation. - return c -} - -// WithSubject assigns the subject of the SinkBinding. -func WithSubject(subject tracker.Reference) SinkBindingOption { - return func(sb *sourcesv1alpha1.SinkBinding) { - sb.Spec.Subject = subject - } -} - -// WithSink assigns the sink of the SinkBinding. -func WithSink(sink duckv1.Destination) SinkBindingOption { - return func(sb *sourcesv1alpha1.SinkBinding) { - sb.Spec.Sink = sink - } -} - -// WithCloudEventOverrides assigns the CloudEventsOverrides of the SinkBinding. -func WithCloudEventOverrides(overrides duckv1.CloudEventOverrides) SinkBindingOption { - return func(sb *sourcesv1alpha1.SinkBinding) { - sb.Spec.CloudEventOverrides = &overrides - } -} diff --git a/pkg/reconciler/testing/v1beta1/listers.go b/pkg/reconciler/testing/v1beta1/listers.go index 2b460407773..ec82595d98c 100644 --- a/pkg/reconciler/testing/v1beta1/listers.go +++ b/pkg/reconciler/testing/v1beta1/listers.go @@ -32,12 +32,10 @@ import ( rbacv1listers "k8s.io/client-go/listers/rbac/v1" "k8s.io/client-go/tools/cache" eventingv1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" fakeeventingclientset "knative.dev/eventing/pkg/client/clientset/versioned/fake" eventingv1beta1listers "knative.dev/eventing/pkg/client/listers/eventing/v1beta1" - sourcelisters "knative.dev/eventing/pkg/client/listers/sources/v1alpha1" sourcev1alpha2listers "knative.dev/eventing/pkg/client/listers/sources/v1alpha2" sourcev1beta1listers "knative.dev/eventing/pkg/client/listers/sources/v1beta1" duckv1 "knative.dev/pkg/apis/duck/v1" @@ -124,14 +122,6 @@ func (l *Listers) GetEventTypeLister() eventingv1beta1listers.EventTypeLister { return eventingv1beta1listers.NewEventTypeLister(l.indexerFor(&eventingv1beta1.EventType{})) } -func (l *Listers) GetApiServerSourceLister() sourcelisters.ApiServerSourceLister { - return sourcelisters.NewApiServerSourceLister(l.indexerFor(&sourcesv1alpha1.ApiServerSource{})) -} - -func (l *Listers) GetSinkBindingLister() sourcelisters.SinkBindingLister { - return sourcelisters.NewSinkBindingLister(l.indexerFor(&sourcesv1alpha1.SinkBinding{})) -} - func (l *Listers) GetPingSourceV1beta1Lister() sourcev1beta1listers.PingSourceLister { return sourcev1beta1listers.NewPingSourceLister(l.indexerFor(&sourcesv1beta1.PingSource{})) } diff --git a/test/e2e/source_sinkbinding_v1alpha1_test.go b/test/e2e/source_sinkbinding_v1alpha1_test.go deleted file mode 100644 index adb85388c6f..00000000000 --- a/test/e2e/source_sinkbinding_v1alpha1_test.go +++ /dev/null @@ -1,210 +0,0 @@ -// +build e2e - -/* -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 e2e - -import ( - "context" - "fmt" - "testing" - - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/uuid" - - . "github.com/cloudevents/sdk-go/v2/test" - appsv1 "k8s.io/api/apps/v1" - batchv1 "k8s.io/api/batch/v1" - batchv1beta1 "k8s.io/api/batch/v1beta1" - duckv1 "knative.dev/pkg/apis/duck/v1" - pkgTest "knative.dev/pkg/test" - "knative.dev/pkg/tracker" - - "knative.dev/eventing/test/lib/recordevents" - "knative.dev/eventing/test/lib/resources" - - rttestingv1alpha1 "knative.dev/eventing/pkg/reconciler/testing/v1alpha1" -) - -func TestSinkBindingDeployment(t *testing.T) { - const ( - sinkBindingName = "e2e-sink-binding" - deploymentName = "e2e-sink-binding-deployment" - // the heartbeats image is built from test_images/heartbeats - imageName = "heartbeats" - - recordEventPodName = "e2e-sink-binding-recordevent-pod" - ) - - client := setup(t, true) - defer tearDown(client) - - ctx := context.Background() - - // create event record pod - eventTracker, _ := recordevents.StartEventRecordOrFail(ctx, client, recordEventPodName) - extensionSecret := string(uuid.NewUUID()) - - // create sink binding - sinkBinding := rttestingv1alpha1.NewSinkBinding( - sinkBindingName, - client.Namespace, - rttestingv1alpha1.WithSink(duckv1.Destination{Ref: resources.KnativeRefForService(recordEventPodName, client.Namespace)}), - rttestingv1alpha1.WithSubject(tracker.Reference{ - APIVersion: "apps/v1", - Kind: "Deployment", - Namespace: client.Namespace, - Name: deploymentName, - }), - rttestingv1alpha1.WithCloudEventOverrides(duckv1.CloudEventOverrides{Extensions: map[string]string{ - "sinkbinding": extensionSecret, - }}), - ) - client.CreateSinkBindingV1Alpha1OrFail(sinkBinding) - - message := fmt.Sprintf("msg %s TestSinkBindingDeployment", uuid.NewUUID()) - client.CreateDeploymentOrFail(&appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: client.Namespace, - Name: deploymentName, - }, - Spec: appsv1.DeploymentSpec{ - Selector: &metav1.LabelSelector{ - MatchLabels: map[string]string{ - "foo": "bar", - }, - }, - Template: corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: map[string]string{ - "foo": "bar", - }, - }, - Spec: corev1.PodSpec{ - Containers: []corev1.Container{{ - Name: imageName, - Image: pkgTest.ImagePath(imageName), - ImagePullPolicy: corev1.PullIfNotPresent, - Args: []string{"--msg=" + message}, - Env: []corev1.EnvVar{{ - Name: "POD_NAME", - Value: deploymentName, - }, { - Name: "POD_NAMESPACE", - Value: client.Namespace, - }}, - }}, - }, - }, - }, - }) - - // wait for all test resources to be ready - client.WaitForAllTestResourcesReadyOrFail(ctx) - - eventTracker.AssertAtLeast(2, recordevents.MatchEvent( - recordevents.MatchHeartBeatsImageMessage(message), - HasSource(fmt.Sprintf("https://knative.dev/eventing/test/heartbeats/#%s/%s", client.Namespace, deploymentName)), - HasExtension("sinkbinding", extensionSecret), - )) -} - -func TestSinkBindingCronJob(t *testing.T) { - const ( - sinkBindingName = "e2e-sink-binding" - deploymentName = "e2e-sink-binding-cronjob" - // the heartbeats image is built from test_images/heartbeats - imageName = "heartbeats" - - recordEventPod = "e2e-sink-binding-recordevent-pod" - ) - - client := setup(t, true) - defer tearDown(client) - - ctx := context.Background() - - // create event logger pod and service - eventTracker, _ := recordevents.StartEventRecordOrFail(ctx, client, recordEventPod) - // create sink binding - sinkBinding := rttestingv1alpha1.NewSinkBinding( - sinkBindingName, - client.Namespace, - rttestingv1alpha1.WithSink(duckv1.Destination{Ref: resources.KnativeRefForService(recordEventPod, client.Namespace)}), - rttestingv1alpha1.WithSubject(tracker.Reference{ - APIVersion: "batch/v1", - Kind: "Job", - Namespace: client.Namespace, - Selector: &metav1.LabelSelector{ - MatchLabels: map[string]string{ - "foo": "bar", - }, - }, - }), - ) - client.CreateSinkBindingV1Alpha1OrFail(sinkBinding) - - message := fmt.Sprintf("msg %s TestSinkBindingCronJob", uuid.NewUUID()) - client.CreateCronJobOrFail(&batchv1beta1.CronJob{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: client.Namespace, - Name: deploymentName, - }, - Spec: batchv1beta1.CronJobSpec{ - Schedule: "* * * * *", - JobTemplate: batchv1beta1.JobTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: map[string]string{ - "foo": "bar", - }, - }, - Spec: batchv1.JobSpec{ - Template: corev1.PodTemplateSpec{ - Spec: corev1.PodSpec{ - RestartPolicy: corev1.RestartPolicyNever, - Containers: []corev1.Container{{ - Name: imageName, - Image: pkgTest.ImagePath(imageName), - ImagePullPolicy: corev1.PullIfNotPresent, - Args: []string{"--msg=" + message}, - Env: []corev1.EnvVar{{ - Name: "ONE_SHOT", - Value: "true", - }, { - Name: "POD_NAME", - Value: deploymentName, - }, { - Name: "POD_NAMESPACE", - Value: client.Namespace, - }}, - }}, - }, - }, - }, - }, - }, - }) - - // wait for all test resources to be ready - client.WaitForAllTestResourcesReadyOrFail(ctx) - - // verify the logger service receives the event - eventTracker.AssertAtLeast(2, recordevents.MatchEvent( - recordevents.MatchHeartBeatsImageMessage(message), - HasSource(fmt.Sprintf("https://knative.dev/eventing/test/heartbeats/#%s/%s", client.Namespace, deploymentName)), - )) -} diff --git a/test/e2e_flags.go b/test/e2e_flags.go index ff21986bf2a..0abd69d85c0 100644 --- a/test/e2e_flags.go +++ b/test/e2e_flags.go @@ -36,8 +36,8 @@ const ( "implementation to have been installed, and only one value. brokerclass " + "must be (for now) 'MTChannelBasedBroker'." SourceUsage = "The names of the source type metas, separated by comma. " + - `Example: "sources.knative.dev/v1alpha1:ApiServerSource,` + - `sources.knative.dev/v1alpha1:PingSource".` + `Example: "sources.knative.dev/v1:ApiServerSource,` + + `sources.knative.dev/v1beta2:PingSource".` BrokerUsage = "The name of the broker type metas, separated by comma. " + `Example: "eventing.knative.dev/v1:MTChannelBasedBroker` BrokerNameUsage = "When testing a pre-existing broker, specify the Broker name so the conformance tests " + diff --git a/test/lib/creation.go b/test/lib/creation.go index 574c5d3aff2..022d136b87d 100644 --- a/test/lib/creation.go +++ b/test/lib/creation.go @@ -38,7 +38,6 @@ import ( flowsv1 "knative.dev/eventing/pkg/apis/flows/v1" messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1" sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1" - sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" sourcesv1beta2 "knative.dev/eventing/pkg/apis/sources/v1beta2" @@ -322,23 +321,6 @@ func (c *Client) CreateFlowsParallelOrFail(parallel *flowsv1.Parallel) { c.Tracker.AddObj(parallel) } -// CreateSinkBindingV1Alpha1OrFail will create a SinkBinding or fail the test if there is an error. -func (c *Client) CreateSinkBindingV1Alpha1OrFail(sb *sourcesv1alpha1.SinkBinding) { - c.T.Logf("Creating sinkbinding %+v", sb) - sbInterface := c.Eventing.SourcesV1alpha1().SinkBindings(c.Namespace) - err := c.RetryWebhookErrors(func(attempts int) (err error) { - _, e := sbInterface.Create(context.Background(), sb, metav1.CreateOptions{}) - if e != nil { - c.T.Logf("Failed to create sinkbinding %q: %v", sb.Name, e) - } - return e - }) - if err != nil && !errors.IsAlreadyExists(err) { - c.T.Fatalf("Failed to create sinkbinding %q: %v", sb.Name, err) - } - c.Tracker.AddObj(sb) -} - // CreateSinkBindingV1Alpha2OrFail will create a SinkBinding or fail the test if there is an error. func (c *Client) CreateSinkBindingV1Alpha2OrFail(sb *sourcesv1alpha2.SinkBinding) { c.T.Logf("Creating sinkbinding %+v", sb)