From 331bf4915aeace288f747758b7504272bacb578b Mon Sep 17 00:00:00 2001 From: Evan Anderson Date: Tue, 6 Nov 2018 00:47:38 +0000 Subject: [PATCH] Rename Sinkable to Addressable. Temporarily use Addressable for Callable as well. --- Gopkg.lock | 4 +- Gopkg.toml | 2 +- docs/spec/interfaces.md | 79 ++--- docs/spec/overview.md | 24 +- docs/spec/spec.md | 18 +- pkg/apis/eventing/v1alpha1/channel_types.go | 44 +-- .../eventing/v1alpha1/channel_types_test.go | 46 +-- pkg/apis/eventing/v1alpha1/implements_test.go | 3 +- .../eventing/v1alpha1/subscription_types.go | 2 +- .../v1alpha1/zz_generated.deepcopy.go | 2 +- .../eventing/inmemory/channel/reconcile.go | 2 +- .../inmemory/channel/reconcile_test.go | 12 +- .../eventing/subscription/reconcile.go | 24 +- .../eventing/subscription/reconcile_test.go | 72 ++--- pkg/sidecar/fanout/fanout_handler_test.go | 42 +-- .../apis/duck/v1alpha1/addressable_types.go | 96 ++++++ .../apis/duck/v1alpha1/channelable_types.go | 104 ------ .../duck/v1alpha1/legacy_targetable_types.go | 10 +- .../pkg/apis/duck/v1alpha1/register.go | 8 +- ...e_types.go => retired_targetable_types.go} | 14 +- .../pkg/apis/duck/v1alpha1/sinkable_types.go | 94 ------ .../apis/duck/v1alpha1/subscribable_types.go | 105 ------ .../duck/v1alpha1/zz_generated.deepcopy.go | 306 +++--------------- 23 files changed, 349 insertions(+), 764 deletions(-) create mode 100644 vendor/github.com/knative/pkg/apis/duck/v1alpha1/addressable_types.go delete mode 100644 vendor/github.com/knative/pkg/apis/duck/v1alpha1/channelable_types.go rename vendor/github.com/knative/pkg/apis/duck/v1alpha1/{targetable_types.go => retired_targetable_types.go} (84%) delete mode 100644 vendor/github.com/knative/pkg/apis/duck/v1alpha1/sinkable_types.go delete mode 100644 vendor/github.com/knative/pkg/apis/duck/v1alpha1/subscribable_types.go diff --git a/Gopkg.lock b/Gopkg.lock index 00a2677f75a..a5d964dd8d0 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -300,7 +300,7 @@ revision = "5c1d8c8469d1ed34b2aecf4c2305b3a57fff2ee3" [[projects]] - digest = "1:9dd034878e35ffe80dd0a4d7991521acce80f33cc7d3d5e21c7944bb2874e037" + digest = "1:7777b78ab28a8f10918bdcdb043f4150d27da3181fafd69a1b15935197bf9d4c" name = "github.com/knative/pkg" packages = [ "apis", @@ -335,7 +335,7 @@ "webhook", ] pruneopts = "NUT" - revision = "04b40fd38ac1cf17e0426b79860c792fd593ce71" + revision = "a8160c7d728d26da67e596c5b1975877082a26e6" [[projects]] digest = "1:63f3974f3afe3dc5b6a115c0d53b0897cd01be6880c4bf5d014fc69a95db6ed1" diff --git a/Gopkg.toml b/Gopkg.toml index 7b6ce137575..159890fe31a 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -77,7 +77,7 @@ required = [ [[override]] name = "github.com/knative/pkg" # HEAD as of 2018-11-02 - revision = "04b40fd38ac1cf17e0426b79860c792fd593ce71" + revision = "a8160c7d728d26da67e596c5b1975877082a26e6" [[constraint]] name = "github.com/knative/serving" diff --git a/docs/spec/interfaces.md b/docs/spec/interfaces.md index ff2bba3d28e..37fc779c3fd 100644 --- a/docs/spec/interfaces.md +++ b/docs/spec/interfaces.md @@ -1,60 +1,65 @@ # Interface Contracts -## Targetable +## Addressable -A **Targetable** resource represents an endpoint that receives events and -optionally returns events to forward downstream. One example of a _Targetable_ -is a function. +An **Addressable** resource receives events over a network transport +(currently only HTTP is supported). The _Addressable_ returns success when it +has successfully handled the event (for example, by committing it to stable +storage). When used as an _Addressable_, only the acknowledgement or return +code is used to determine whether the event was handled successfully. One +example of an _Addressable_ is a _Channel_. ### Control Plane -A **Targetable** resource MUST expose a `status.targetable.domainInternal` -field. The _domainInternal_ value is an internal domain name that is capable of -receiving event deliveries. _Targetable_ resources may be referenced in the -`subscriber` section of a _Subscription_. +An **Addressable** resource MUST expose a `status.address.hostname` field. +The _hostname_ value is a cluster-resolvable DNS name which is capable of +receiving event deliveries. _Addressable_ resources may be referenced in the +`reply` section of a _Subscription_, and also by other custom resources acting +as an event Source. ### Data Plane -The **Targetable** resource receives one event and returns zero or more events -in response. The returned events are not required to be related to the received -event. The _Targetable_ should return a successful response if the event was -processed successfully. - -The _Targetable_ is not responsible for ensuring successful delivery of any -received or returned event. It may receive the same event multiple times even -if it previously indicated success. +An **Addressable** resource will only respond to requests with success or +failure. Any payload (including a valid CloudEvent) returned to the sender +will be ignored. An _Addressable_ may receive the same event multiple times +even if it previously indicated success. --- -## Sinkable +## Callable -A **Sinkable** resource receives events and takes responsibility for further -delivery. Unlike _Targetable_, a _Sinkable_ cannot return events in its -response. One example of a _Sinkable_ is a _Channel_ as the target of a -_Subscription_'s `reply` field. +A **Callable** resource represents an _Addressable_ endpoint which receives +events and optionally returns events to forward downstream. One example of a +_Callable_ is a function. Note that all _Callable_ resources are _Addressable_ +(they accept an event and return a status code when completed), but not all +_Addressable_ resources are _Callable_. - +A **Callable** resource MUST expose a `status.address.hostname` field (like +_Addressable_). The _hostname_ value is a cluster-resolvable DNS name which is +capable of receiving event deliveries and returning a resulting event in the +reply.. _Callable_ resources may be referenced in the `subscriber` section of +a _Subscription_. -### Control Plane + ### Data Plane -A **Sinkable** resource will only respond to requests with success of failure. -Any payload (including a valid CloudEvent) returned to the sender will be -ignored. It may receive the same event multiple times even if it previously -indicated success. +The **Callable** resource receives one event and returns zero or more events +in response. The returned events are not required to be related to the received +event. The _Callable_ should return a successful response if the event was +processed successfully. + +The _Callable_ is not responsible for ensuring successful delivery of any +received or returned event. It may receive the same event multiple times even +if it previously indicated success. --- diff --git a/docs/spec/overview.md b/docs/spec/overview.md index d0fd814364f..dfb136224fe 100644 --- a/docs/spec/overview.md +++ b/docs/spec/overview.md @@ -3,17 +3,17 @@ The API defines and provides a complete implementation for [Subscription](spec.md#kind-subscription) and abstract resource definitions for [Channels](spec.md#kind-channel) and -[ClusterChannelProvisioners](spec.md#kind-clusterchannelprovisioner) which may -be fulfilled by multiple backing implementations (much like the Kubernetes -Ingress resource). +[ClusterChannelProvisioners](spec.md#kind-clusterchannelprovisioner) which +may be fulfilled by multiple backing implementations (much like the +Kubernetes Ingress resource). With extensibility and composability as a goal of Knative Eventing, the eventing API defines several resources that can be reduced down to well understood contracts. These eventing resource interfaces may be fulfilled by other Kubernetes objects and then composed in the same way as the concrete -objects. The interfaces are ([Sinkable](interfaces.md#sinkable), +objects. The interfaces are ([Addressable](interfaces.md#addressable), [Subscribable](interfaces.md#Subscribable), -[Targetable](interfaces.md#targetable)). For more details, see +[Callable](interfaces.md#callable)). For more details, see [Interface Contracts](interfaces.md). - A **Subscription** describes the transformation of an event and optional @@ -43,14 +43,14 @@ Sources](https://github.com/knative/eventing-sources). **Subscriptions** describe a flow of events from one _Channel_ to the next Channel\* through transformations (such as a Knative Service which processes CloudEvents over HTTP). A _Subscription_ controller resolves the addresses of -transformations (`call`) and destination storage (`result`) through the -_Targetable_ and _Sinkable_ interface contracts, and writes the resolved -addresses to the _Channel_ in the `from` reference. _Subscriptions_ do not need -to specify both a transformation and a storage destination, but at least one -must be provided. +transformations (`subscriber`) and destination storage (`result`) through the +_Callable_ and _Addressable_ interface contracts, and writes the resolved +addresses to the _Channel_ in the `channel` reference. _Subscriptions_ do not +need to specify both a transformation and a storage destination, but at least +one must be provided. All event delivery linkage from a **Subscription** is 1:1 – only a single -`from`, `call`, and `result` may be provided. +`channel`, `subscriber`, and `result` may be provided. For more details, see [Kind: Subscription](spec.md#kind-subscription). @@ -58,7 +58,7 @@ For more details, see [Kind: Subscription](spec.md#kind-subscription). **Channel** provides an event delivery mechanism which can fan out received events to multiple destinations via _Subscriptions_. A _Channel_ has a single -inbound _Sinkable_ interface which may accept events delivered directly or +inbound _Addressable_ interface which may accept events delivered directly or forwarded from multiple _Subscriptions_. Different _Channels_ may implement different degrees of persistence. Event delivery order is dependent on the backing implementation of the _Channel_ provided by the diff --git a/docs/spec/spec.md b/docs/spec/spec.md index a84c4f73bbd..5ff623fc712 100644 --- a/docs/spec/spec.md +++ b/docs/spec/spec.md @@ -41,10 +41,10 @@ its subscribers._ #### Status -| Field | Type | Description | Constraints | -| ---------- | ---------- | --------------------------------------------------------------------------------------------------------------------------- | ----------- | -| sinkable | Sinkable | Address to the endpoint as top-level domain that will distribute traffic over the provided targets from inside the cluster. | | -| conditions | Conditions | Channel conditions. | | +| Field | Type | Description | Constraints | +| ---------- | ----------- | -------------------------------------------------------------------------------------------- | ----------- | +| address | Addressable | Address of the endpoint which meets the [_Addressable_ contract](interfaces.md#addressable). | | +| conditions | Conditions | Channel conditions. | | ##### Conditions @@ -70,7 +70,7 @@ its subscribers._ ### group: eventing.knative.dev/v1alpha1 -_Describes a linkage between a Channel and a Targetable and/or Sinkable._ +_Describes a linkage between a Channel and a Callable and/or Addressable channel._ ### Object Schema @@ -152,10 +152,10 @@ or a Channel system that receives and delivers events._ ### SubscriberSpec -| Field | Type | Description | Constraints | -| ------------------- | --------------- | ----------- | -------------------------- | -| ref1 | ObjectReference | | Must adhere to Targetable. | -| dnsName1 | String | | | +| Field | Type | Description | Constraints | +| ------------------- | --------------- | ----------- | ------------------------ | +| ref1 | ObjectReference | | Must adhere to Callable. | +| dnsName1 | String | | | 1: One of (ref, dnsName), Required. diff --git a/pkg/apis/eventing/v1alpha1/channel_types.go b/pkg/apis/eventing/v1alpha1/channel_types.go index aea8620132e..afcf9805211 100644 --- a/pkg/apis/eventing/v1alpha1/channel_types.go +++ b/pkg/apis/eventing/v1alpha1/channel_types.go @@ -30,7 +30,7 @@ import ( // +genclient:noStatus // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// Channel is an abstract resource that implements the Sinkable contract. +// Channel is an abstract resource that implements the Addressable contract. // The Provisioner provisions infrastructure to accepts events and // deliver to Subscriptions. type Channel struct { @@ -67,8 +67,8 @@ type ChannelSpec struct { // Provisioner defines the name of the Provisioner backing this channel. Provisioner *corev1.ObjectReference `json:"provisioner,omitempty"` - // Arguments defines the arguments to pass to the Provisioner which provisions - // this Channel. + // Arguments defines the arguments to pass to the Provisioner which + // provisions this Channel. // +optional Arguments *runtime.RawExtension `json:"arguments,omitempty"` @@ -76,7 +76,7 @@ type ChannelSpec struct { Subscribable *eventingduck.Subscribable `json:"subscribable,omitempty"` } -var chanCondSet = duckv1alpha1.NewLivingConditionSet(ChannelConditionProvisioned, ChannelConditionSinkable) +var chanCondSet = duckv1alpha1.NewLivingConditionSet(ChannelConditionProvisioned, ChannelConditionAddressable) // ChannelStatus represents the current state of a Channel. type ChannelStatus struct { @@ -88,10 +88,12 @@ type ChannelStatus struct { // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty"` - // Channel is Sinkable. It currently exposes the endpoint as top-level domain - // that will distribute traffic over the provided targets from inside the cluster. + // Channel is Addressable. It currently exposes the endpoint as a + // fully-qualified DNS name which will distribute traffic over the + // provided targets from inside the cluster. + // // It generally has the form {channel}.{namespace}.svc.cluster.local - Sinkable duckv1alpha1.Sinkable `json:"sinkable,omitempty"` + Address duckv1alpha1.Addressable `json:"address,omitempty"` // Represents the latest available observations of a channel's current state. // +optional @@ -101,17 +103,17 @@ type ChannelStatus struct { } const ( - // ChannelConditionReady has status True when the Channel is ready to accept - // traffic. + // ChannelConditionReady has status True when the Channel is ready to + // accept traffic. ChannelConditionReady = duckv1alpha1.ConditionReady - // ChannelConditionProvisioned has status True when the Channel's backing - // resources have been provisioned. + // ChannelConditionProvisioned has status True when the Channel's + // backing resources have been provisioned. ChannelConditionProvisioned duckv1alpha1.ConditionType = "Provisioned" - // ChannelConditionSinkable has status true when this Channel meets the Sinkable contract and - // has a non-empty domainInternal. - ChannelConditionSinkable duckv1alpha1.ConditionType = "Sinkable" + // ChannelConditionAddressable has status true when this Channel meets + // the Addressable contract and has a non-empty hostname. + ChannelConditionAddressable duckv1alpha1.ConditionType = "Addressable" ) // GetCondition returns the condition currently associated with the given type, or nil. @@ -134,14 +136,14 @@ func (cs *ChannelStatus) MarkProvisioned() { chanCondSet.Manage(cs).MarkTrue(ChannelConditionProvisioned) } -// SetSinkable makes this Channel sinkable by setting the domainInternal. It also sets the -// ChannelConditionSinkable to true. -func (cs *ChannelStatus) SetSinkable(domainInternal string) { - cs.Sinkable.DomainInternal = domainInternal - if domainInternal != "" { - chanCondSet.Manage(cs).MarkTrue(ChannelConditionSinkable) +// SetAddress makes this Channel addressable by setting the hostname. It also +// sets the ChannelConditionAddressable to true. +func (cs *ChannelStatus) SetAddress(hostname string) { + cs.Address.Hostname = hostname + if hostname != "" { + chanCondSet.Manage(cs).MarkTrue(ChannelConditionAddressable) } else { - chanCondSet.Manage(cs).MarkFalse(ChannelConditionSinkable, "emptyDomainInternal", "domainInternal is the empty string") + chanCondSet.Manage(cs).MarkFalse(ChannelConditionAddressable, "emptyHostname", "hostname is the empty string") } } diff --git a/pkg/apis/eventing/v1alpha1/channel_types_test.go b/pkg/apis/eventing/v1alpha1/channel_types_test.go index 3cdee5c281d..ed9d3737713 100644 --- a/pkg/apis/eventing/v1alpha1/channel_types_test.go +++ b/pkg/apis/eventing/v1alpha1/channel_types_test.go @@ -94,13 +94,13 @@ func TestChannelInitializeConditions(t *testing.T) { cs: &ChannelStatus{}, want: &ChannelStatus{ Conditions: []duckv1alpha1.Condition{{ - Type: ChannelConditionProvisioned, + Type: ChannelConditionAddressable, Status: corev1.ConditionUnknown, }, { - Type: ChannelConditionReady, + Type: ChannelConditionProvisioned, Status: corev1.ConditionUnknown, }, { - Type: ChannelConditionSinkable, + Type: ChannelConditionReady, Status: corev1.ConditionUnknown, }}, }, @@ -114,14 +114,14 @@ func TestChannelInitializeConditions(t *testing.T) { }, want: &ChannelStatus{ Conditions: []duckv1alpha1.Condition{{ + Type: ChannelConditionAddressable, + Status: corev1.ConditionUnknown, + }, { Type: ChannelConditionProvisioned, Status: corev1.ConditionFalse, }, { Type: ChannelConditionReady, Status: corev1.ConditionUnknown, - }, { - Type: ChannelConditionSinkable, - Status: corev1.ConditionUnknown, }}, }, }, { @@ -134,14 +134,14 @@ func TestChannelInitializeConditions(t *testing.T) { }, want: &ChannelStatus{ Conditions: []duckv1alpha1.Condition{{ + Type: ChannelConditionAddressable, + Status: corev1.ConditionUnknown, + }, { Type: ChannelConditionProvisioned, Status: corev1.ConditionTrue, }, { Type: ChannelConditionReady, Status: corev1.ConditionUnknown, - }, { - Type: ChannelConditionSinkable, - Status: corev1.ConditionUnknown, }}}, }, } @@ -161,17 +161,17 @@ func TestChannelIsReady(t *testing.T) { tests := []struct { name string markProvisioned bool - setSinkable bool + setAddress bool wantReady bool }{{ name: "all happy", markProvisioned: true, - setSinkable: true, + setAddress: true, wantReady: true, }, { name: "one sad", markProvisioned: false, - setSinkable: true, + setAddress: true, wantReady: false, }} for _, test := range tests { @@ -180,8 +180,8 @@ func TestChannelIsReady(t *testing.T) { if test.markProvisioned { cs.MarkProvisioned() } - if test.setSinkable { - cs.SetSinkable("foo.bar") + if test.setAddress { + cs.SetAddress("foo.bar") } got := cs.IsReady() if test.wantReady != got { @@ -191,7 +191,7 @@ func TestChannelIsReady(t *testing.T) { } } -func TestChannelStatus_SetSinkable(t *testing.T) { +func TestChannelStatus_SetAddressable(t *testing.T) { testCases := map[string]struct { domainInternal string want *ChannelStatus @@ -199,14 +199,14 @@ func TestChannelStatus_SetSinkable(t *testing.T) { "empty string": { want: &ChannelStatus{ Conditions: []duckv1alpha1.Condition{ - // Note that Ready is here because when the condition is marked False, duck - // automatically sets Ready to false. { - Type: ChannelConditionReady, + Type: ChannelConditionAddressable, Status: corev1.ConditionFalse, }, + // Note that Ready is here because when the condition is marked False, duck + // automatically sets Ready to false. { - Type: ChannelConditionSinkable, + Type: ChannelConditionReady, Status: corev1.ConditionFalse, }, }, @@ -215,12 +215,12 @@ func TestChannelStatus_SetSinkable(t *testing.T) { "has domain": { domainInternal: "test-domain", want: &ChannelStatus{ - Sinkable: duckv1alpha1.Sinkable{ - DomainInternal: "test-domain", + Address: duckv1alpha1.Addressable{ + Hostname: "test-domain", }, Conditions: []duckv1alpha1.Condition{ { - Type: ChannelConditionSinkable, + Type: ChannelConditionAddressable, Status: corev1.ConditionTrue, }, }, @@ -230,7 +230,7 @@ func TestChannelStatus_SetSinkable(t *testing.T) { for n, tc := range testCases { t.Run(n, func(t *testing.T) { cs := &ChannelStatus{} - cs.SetSinkable(tc.domainInternal) + cs.SetAddress(tc.domainInternal) if diff := cmp.Diff(tc.want, cs, ignoreTransitionTimeMessageAndReason); diff != "" { t.Errorf("unexpected conditions (-want, +got) = %v", diff) } diff --git a/pkg/apis/eventing/v1alpha1/implements_test.go b/pkg/apis/eventing/v1alpha1/implements_test.go index 9e701cf8659..84768e12091 100644 --- a/pkg/apis/eventing/v1alpha1/implements_test.go +++ b/pkg/apis/eventing/v1alpha1/implements_test.go @@ -28,8 +28,9 @@ func TestTypesImplements(t *testing.T) { }{ // Channel {instance: &Channel{}, iface: &duckv1alpha1.Conditions{}}, + {instance: &Channel{}, iface: &emptyGen}, {instance: &Channel{}, iface: &eventingduck.Subscribable{}}, - {instance: &Channel{}, iface: &duckv1alpha1.Sinkable{}}, + {instance: &Channel{}, iface: &duckv1alpha1.Addressable{}}, // ClusterChannelProvisioner {instance: &ClusterChannelProvisioner{}, iface: &duckv1alpha1.Conditions{}}, // Subscription diff --git a/pkg/apis/eventing/v1alpha1/subscription_types.go b/pkg/apis/eventing/v1alpha1/subscription_types.go index 97a60e60670..1d7b2950eeb 100644 --- a/pkg/apis/eventing/v1alpha1/subscription_types.go +++ b/pkg/apis/eventing/v1alpha1/subscription_types.go @@ -124,7 +124,7 @@ type SubscriberSpec struct { // Only one of these can be specified // Reference to an object that will be used to find the target - // endpoint. + // endpoint, which should implement the Addressable duck type. // For example, this could be a reference to a Route resource // or a Knative Service resource. // TODO: Specify the required fields the target object must diff --git a/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go index 8b14c429ef1..56b501996f4 100644 --- a/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/eventing/v1alpha1/zz_generated.deepcopy.go @@ -134,7 +134,7 @@ func (in *ChannelSpec) DeepCopy() *ChannelSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChannelStatus) DeepCopyInto(out *ChannelStatus) { *out = *in - out.Sinkable = in.Sinkable + out.Address = in.Address if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make(apis_duck_v1alpha1.Conditions, len(*in)) diff --git a/pkg/controller/eventing/inmemory/channel/reconcile.go b/pkg/controller/eventing/inmemory/channel/reconcile.go index 7d63e34925b..405312dbcc9 100644 --- a/pkg/controller/eventing/inmemory/channel/reconcile.go +++ b/pkg/controller/eventing/inmemory/channel/reconcile.go @@ -146,7 +146,7 @@ func (r *reconciler) reconcile(ctx context.Context, c *eventingv1alpha1.Channel) logger.Info("Error creating the Channel's K8s Service", zap.Error(err)) return err } else { - c.Status.SetSinkable(controller.ServiceHostName(svc.Name, svc.Namespace)) + c.Status.SetAddress(controller.ServiceHostName(svc.Name, svc.Namespace)) } if err := r.createVirtualService(ctx, c); err != nil { diff --git a/pkg/controller/eventing/inmemory/channel/reconcile_test.go b/pkg/controller/eventing/inmemory/channel/reconcile_test.go index 7f679d9360e..16199c19bc5 100644 --- a/pkg/controller/eventing/inmemory/channel/reconcile_test.go +++ b/pkg/controller/eventing/inmemory/channel/reconcile_test.go @@ -352,7 +352,7 @@ func TestReconcile(t *testing.T) { WantPresent: []runtime.Object{ // TODO: This should have a useful error message saying that the VirtualService // failed. - makeChannelWithFinalizerAndSinkable(), + makeChannelWithFinalizerAndAddress(), }, WantErrMsg: testErrorMessage, }, @@ -369,7 +369,7 @@ func TestReconcile(t *testing.T) { WantPresent: []runtime.Object{ // TODO: This should have a useful error message saying that the VirtualService // failed. - makeChannelWithFinalizerAndSinkable(), + makeChannelWithFinalizerAndAddress(), }, WantErrMsg: testErrorMessage, }, @@ -515,15 +515,15 @@ func makeChannel() *eventingv1alpha1.Channel { return c } -func makeChannelWithFinalizerAndSinkable() *eventingv1alpha1.Channel { +func makeChannelWithFinalizerAndAddress() *eventingv1alpha1.Channel { c := makeChannelWithFinalizer() - c.Status.SetSinkable(fmt.Sprintf("%s-channel.%s.svc.cluster.local", c.Name, c.Namespace)) + c.Status.SetAddress(fmt.Sprintf("%s-channel.%s.svc.cluster.local", c.Name, c.Namespace)) return c } func makeReadyChannel() *eventingv1alpha1.Channel { - // Ready channels have the finalizer and are Sinkable. - c := makeChannelWithFinalizerAndSinkable() + // Ready channels have the finalizer and are Addressable. + c := makeChannelWithFinalizerAndAddress() c.Status.MarkProvisioned() return c } diff --git a/pkg/controller/eventing/subscription/reconcile.go b/pkg/controller/eventing/subscription/reconcile.go index 3d36c23aaaf..7ba8bcba534 100644 --- a/pkg/controller/eventing/subscription/reconcile.go +++ b/pkg/controller/eventing/subscription/reconcile.go @@ -167,9 +167,9 @@ func (r *reconciler) updateStatus(subscription *v1alpha1.Subscription) (*v1alpha } // resolveSubscriberSpec resolves the Spec.Call object. If it's an -// ObjectReference will resolve the object and treat it as a Targetable. If +// ObjectReference will resolve the object and treat it as a Callable. If // it's DNSName then it's used as is. -// TODO: Once Service Routes, etc. support Targetable, use that. +// TODO: Once Service Routes, etc. support Callable, use that. // func (r *reconciler) resolveSubscriberSpec(namespace string, s v1alpha1.SubscriberSpec) (string, error) { if s.DNSName != nil && *s.DNSName != "" { @@ -177,7 +177,7 @@ func (r *reconciler) resolveSubscriberSpec(namespace string, s v1alpha1.Subscrib } // K8s services are special cased. They can be called, even though they do not satisfy the - // Targetable interface. + // Callable interface. if s.Ref != nil && s.Ref.APIVersion == "v1" && s.Ref.Kind == "Service" { svc := &corev1.Service{} svcKey := types.NamespacedName{ @@ -197,17 +197,17 @@ func (r *reconciler) resolveSubscriberSpec(namespace string, s v1alpha1.Subscrib glog.Warningf("Failed to fetch SubscriberSpec target %+v: %s", s.Ref, err) return "", err } - t := duckv1alpha1.Target{} + t := duckv1alpha1.AddressableType{} err = duck.FromUnstructured(obj, &t) if err != nil { glog.Warningf("Failed to deserialize legacy target: %s", err) return "", err } - if t.Status.Targetable != nil { - return domainToURL(t.Status.Targetable.DomainInternal), nil + if t.Status.Address != nil { + return domainToURL(t.Status.Address.Hostname), nil } - return "", fmt.Errorf("status does not contain targetable") + return "", fmt.Errorf("status does not contain address") } // resolveResult resolves the Spec.Result object. @@ -217,16 +217,16 @@ func (r *reconciler) resolveResult(namespace string, replyStrategy v1alpha1.Repl glog.Warningf("Failed to fetch ReplyStrategy channel %+v: %s", replyStrategy, err) return "", err } - s := duckv1alpha1.Sink{} + s := duckv1alpha1.AddressableType{} err = duck.FromUnstructured(obj, &s) if err != nil { - glog.Warningf("Failed to deserialize Sinkable target: %s", err) + glog.Warningf("Failed to deserialize Addressable target: %s", err) return "", err } - if s.Status.Sinkable != nil { - return domainToURL(s.Status.Sinkable.DomainInternal), nil + if s.Status.Address != nil { + return domainToURL(s.Status.Address.Hostname), nil } - return "", fmt.Errorf("status does not contain sinkable") + return "", fmt.Errorf("status does not contain address") } // fetchObjectReference fetches an object based on ObjectReference. diff --git a/pkg/controller/eventing/subscription/reconcile_test.go b/pkg/controller/eventing/subscription/reconcile_test.go index 349cf106404..7259a40476c 100644 --- a/pkg/controller/eventing/subscription/reconcile_test.go +++ b/pkg/controller/eventing/subscription/reconcile_test.go @@ -54,7 +54,7 @@ const ( testNS = "testnamespace" k8sServiceName = "testk8sservice" k8sServiceDNS = "testk8sservice.testnamespace.svc.cluster.local" - otherSinkableDNS = "other-sinkable-channel.mynamespace.svc.cluster.local" + otherAddressableDNS = "other-sinkable-channel.mynamespace.svc.cluster.local" ) func init() { @@ -107,8 +107,8 @@ var testCases = []controllertesting.TestCase{ "name": routeName, }, "status": map[string]interface{}{ - "targetable": map[string]interface{}{ - "domainInternal": targetDNS, + "address": map[string]interface{}{ + "hostname": targetDNS, }, }, }, @@ -126,8 +126,8 @@ var testCases = []controllertesting.TestCase{ "subscribable": map[string]interface{}{}, }, "status": map[string]interface{}{ - "sinkable": map[string]interface{}{ - "domainInternal": sinkableDNS, + "address": map[string]interface{}{ + "hostname": sinkableDNS, }, }, }, @@ -160,14 +160,14 @@ var testCases = []controllertesting.TestCase{ }, }, }, { - Name: "Valid channel, subscriber is not targetable", + Name: "Valid channel, subscriber is not callable", InitialState: []runtime.Object{ getNewSubscription(), }, WantPresent: []runtime.Object{ getNewSubscriptionWithUnknownConditions(), }, - WantErrMsg: "status does not contain targetable", + WantErrMsg: "status does not contain address", Scheme: scheme.Scheme, Objects: []runtime.Object{ // Source channel @@ -234,19 +234,19 @@ var testCases = []controllertesting.TestCase{ "name": routeName, }, "status": map[string]interface{}{ - "targetable": map[string]interface{}{ - "domainInternal": targetDNS, + "address": map[string]interface{}{ + "hostname": targetDNS, }, }, }, }, }, }, { - Name: "valid channel, subscriber, result is not sinkable", + Name: "valid channel, subscriber, result is not addressable", InitialState: []runtime.Object{ getNewSubscription(), }, - WantErrMsg: "status does not contain sinkable", + WantErrMsg: "status does not contain address", WantPresent: []runtime.Object{ // TODO: Again this works on gke cluster, but I need to set // something else up here. later... @@ -279,8 +279,8 @@ var testCases = []controllertesting.TestCase{ "name": routeName, }, "status": map[string]interface{}{ - "targetable": map[string]interface{}{ - "domainInternal": targetDNS, + "address": map[string]interface{}{ + "hostname": targetDNS, }, }, }, @@ -339,8 +339,8 @@ var testCases = []controllertesting.TestCase{ "name": routeName, }, "status": map[string]interface{}{ - "targetable": map[string]interface{}{ - "domainInternal": targetDNS, + "address": map[string]interface{}{ + "hostname": targetDNS, }, }, }, @@ -358,8 +358,8 @@ var testCases = []controllertesting.TestCase{ "subscribable": map[string]interface{}{}, }, "status": map[string]interface{}{ - "sinkable": map[string]interface{}{ - "domainInternal": sinkableDNS, + "address": map[string]interface{}{ + "hostname": sinkableDNS, }, }, }, @@ -390,7 +390,7 @@ var testCases = []controllertesting.TestCase{ "name": fromChannelName, }, "spec": map[string]interface{}{ - "channelable": map[string]interface{}{}, + "subscribable": map[string]interface{}{}, }, }, }, @@ -404,8 +404,8 @@ var testCases = []controllertesting.TestCase{ "name": routeName, }, "status": map[string]interface{}{ - "targetable": map[string]interface{}{ - "domainInternal": targetDNS, + "address": map[string]interface{}{ + "hostname": targetDNS, }, }, }, @@ -436,7 +436,7 @@ var testCases = []controllertesting.TestCase{ "name": fromChannelName, }, "spec": map[string]interface{}{ - "channelable": map[string]interface{}{}, + "subscribable": map[string]interface{}{}, }, }, }, @@ -450,11 +450,11 @@ var testCases = []controllertesting.TestCase{ "name": resultChannelName, }, "spec": map[string]interface{}{ - "channelable": map[string]interface{}{}, + "subscribable": map[string]interface{}{}, }, "status": map[string]interface{}{ - "sinkable": map[string]interface{}{ - "domainInternal": sinkableDNS, + "address": map[string]interface{}{ + "hostname": sinkableDNS, }, }, }, @@ -514,8 +514,8 @@ var testCases = []controllertesting.TestCase{ "subscribable": map[string]interface{}{}, }, "status": map[string]interface{}{ - "sinkable": map[string]interface{}{ - "domainInternal": sinkableDNS, + "address": map[string]interface{}{ + "hostname": sinkableDNS, }, }, }, @@ -574,8 +574,8 @@ var testCases = []controllertesting.TestCase{ "name": routeName, }, "status": map[string]interface{}{ - "targetable": map[string]interface{}{ - "domainInternal": targetDNS, + "address": map[string]interface{}{ + "hostname": targetDNS, }, }, }, @@ -593,8 +593,8 @@ var testCases = []controllertesting.TestCase{ "subscribable": map[string]interface{}{}, }, "status": map[string]interface{}{ - "sinkable": map[string]interface{}{ - "domainInternal": sinkableDNS, + "address": map[string]interface{}{ + "hostname": sinkableDNS, }, }, }, @@ -669,8 +669,8 @@ var testCases = []controllertesting.TestCase{ "name": routeName, }, "status": map[string]interface{}{ - "targetable": map[string]interface{}{ - "domainInternal": targetDNS, + "address": map[string]interface{}{ + "hostname": targetDNS, }, }, }, @@ -688,8 +688,8 @@ var testCases = []controllertesting.TestCase{ "subscribable": map[string]interface{}{}, }, "status": map[string]interface{}{ - "sinkable": map[string]interface{}{ - "domainInternal": sinkableDNS, + "address": map[string]interface{}{ + "hostname": sinkableDNS, }, }, }, @@ -744,7 +744,7 @@ func rename(sub *eventingv1alpha1.Subscription) *eventingv1alpha1.Subscription { sub.Name = "renamed" sub.UID = "renamed-UID" sub.Status.PhysicalSubscription.SubscriberURI = "" - sub.Status.PhysicalSubscription.ReplyURI = otherSinkableDNS + sub.Status.PhysicalSubscription.ReplyURI = otherAddressableDNS return sub } @@ -975,7 +975,7 @@ func getChannelWithMultipleSubscriptions() *eventingv1alpha1.Channel { Name: "renamed", UID: "renamed-UID", }, - ReplyURI: otherSinkableDNS, + ReplyURI: otherAddressableDNS, }, }, }, diff --git a/pkg/sidecar/fanout/fanout_handler_test.go b/pkg/sidecar/fanout/fanout_handler_test.go index 464afcff9b2..4df6ef744ed 100644 --- a/pkg/sidecar/fanout/fanout_handler_test.go +++ b/pkg/sidecar/fanout/fanout_handler_test.go @@ -36,7 +36,7 @@ import ( // servers. const ( replaceSubscriber = "replaceSubscriber" - replaceSinkable = "replaceSinkable" + replaceChannel = "replaceChannel" ) var ( @@ -62,7 +62,7 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { timeout time.Duration subs []eventingduck.ChannelSubscriberSpec subscriber func(http.ResponseWriter, *http.Request) - sinkable func(http.ResponseWriter, *http.Request) + channel func(http.ResponseWriter, *http.Request) expectedStatus int }{ "rejected by receiver": { @@ -97,10 +97,10 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { "reply fails": { subs: []eventingduck.ChannelSubscriberSpec{ { - ReplyURI: replaceSinkable, + ReplyURI: replaceChannel, }, }, - sinkable: func(writer http.ResponseWriter, _ *http.Request) { + channel: func(writer http.ResponseWriter, _ *http.Request) { writer.WriteHeader(http.StatusNotFound) }, expectedStatus: http.StatusInternalServerError, @@ -116,15 +116,15 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { }, expectedStatus: http.StatusInternalServerError, }, - "subscriber succeeds, sinkable fails": { + "subscriber succeeds, result fails": { subs: []eventingduck.ChannelSubscriberSpec{ { SubscriberURI: replaceSubscriber, - ReplyURI: replaceSinkable, + ReplyURI: replaceChannel, }, }, subscriber: callableSucceed, - sinkable: func(writer http.ResponseWriter, _ *http.Request) { + channel: func(writer http.ResponseWriter, _ *http.Request) { writer.WriteHeader(http.StatusForbidden) }, expectedStatus: http.StatusInternalServerError, @@ -133,11 +133,11 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { subs: []eventingduck.ChannelSubscriberSpec{ { SubscriberURI: replaceSubscriber, - ReplyURI: replaceSinkable, + ReplyURI: replaceChannel, }, }, subscriber: callableSucceed, - sinkable: func(writer http.ResponseWriter, _ *http.Request) { + channel: func(writer http.ResponseWriter, _ *http.Request) { writer.WriteHeader(http.StatusAccepted) }, expectedStatus: http.StatusAccepted, @@ -146,34 +146,34 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { subs: []eventingduck.ChannelSubscriberSpec{ { SubscriberURI: replaceSubscriber, - ReplyURI: replaceSinkable, + ReplyURI: replaceChannel, }, { SubscriberURI: replaceSubscriber, - ReplyURI: replaceSinkable, + ReplyURI: replaceChannel, }, }, subscriber: callableSucceed, - sinkable: (&succeedOnce{}).handler, + channel: (&succeedOnce{}).handler, expectedStatus: http.StatusInternalServerError, }, "all subs succeed": { subs: []eventingduck.ChannelSubscriberSpec{ { SubscriberURI: replaceSubscriber, - ReplyURI: replaceSinkable, + ReplyURI: replaceChannel, }, { SubscriberURI: replaceSubscriber, - ReplyURI: replaceSinkable, + ReplyURI: replaceChannel, }, { SubscriberURI: replaceSubscriber, - ReplyURI: replaceSinkable, + ReplyURI: replaceChannel, }, }, subscriber: callableSucceed, - sinkable: func(writer http.ResponseWriter, _ *http.Request) { + channel: func(writer http.ResponseWriter, _ *http.Request) { writer.WriteHeader(http.StatusAccepted) }, expectedStatus: http.StatusAccepted, @@ -188,10 +188,10 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { handler: tc.subscriber, }) defer callableServer.Close() - sinkableServer := httptest.NewServer(&fakeHandler{ - handler: tc.sinkable, + channelServer := httptest.NewServer(&fakeHandler{ + handler: tc.channel, }) - defer sinkableServer.Close() + defer channelServer.Close() // Rewrite the subs to use the servers we just started. subs := make([]eventingduck.ChannelSubscriberSpec, 0) @@ -199,8 +199,8 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { if sub.SubscriberURI == replaceSubscriber { sub.SubscriberURI = callableServer.URL[7:] // strip the leading 'http://' } - if sub.ReplyURI == replaceSinkable { - sub.ReplyURI = sinkableServer.URL[7:] // strip the leading 'http://' + if sub.ReplyURI == replaceChannel { + sub.ReplyURI = channelServer.URL[7:] // strip the leading 'http://' } subs = append(subs, sub) } diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/addressable_types.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/addressable_types.go new file mode 100644 index 00000000000..0bf1f986dc0 --- /dev/null +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/addressable_types.go @@ -0,0 +1,96 @@ +/* +Copyright 2018 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + + "github.com/knative/pkg/apis" + "github.com/knative/pkg/apis/duck" +) + +// Addressable provides a generic mechanism for a custom resource +// definition to indicate a destination for message delivery. +// (Currently, only hostname is supported, and HTTP is implied. In the +// future, additional schemes may be supported, and path components +// ala UI may also be supported.) + +// Addressable is the schema for the destination information. This is +// typically stored in the object's `status`, as this information may +// be generated by the controller. +type Addressable struct { + Hostname string `json:"hostname,omitempty"` +} + + +// Addressable is an Implementable "duck type". +var _ duck.Implementable = (*Addressable)(nil) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// AddressableType is a skeleton type wrapping Addressable in the manner we expect +// resource writers defining compatible resources to embed it. We will +// typically use this type to deserialize Addressable ObjectReferences and +// access the Addressable data. This is not a real resource. +type AddressableType struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Status AddressStatus `json:"status"` +} + +// AddressStatus shows how we expect folks to embed Addressable in +// their Status field. +type AddressStatus struct { + Address *Addressable `json:"address,omitempty"` +} + +// Verify AddressableType resources meet duck contracts. +var _ duck.Populatable = (*AddressableType)(nil) +var _ apis.Listable = (*AddressableType)(nil) + +// GetFullType implements duck.Implementable +func (_ *Addressable) GetFullType() duck.Populatable { + return &AddressableType{} +} + +// Populate implements duck.Populatable +func (t *AddressableType) Populate() { + t.Status = AddressStatus{ + &Addressable{ + // Populate ALL fields + Hostname: "this is not empty", + }, + } +} + +// GetListType implements apis.Listable +func (r *AddressableType) GetListType() runtime.Object { + return &AddressableTypeList{} +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// AddressableTypeList is a list of AddressableType resources +type AddressableTypeList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []AddressableType `json:"items"` +} diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/channelable_types.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/channelable_types.go deleted file mode 100644 index ba60d3b8025..00000000000 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/channelable_types.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2018 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" -) - -// Channelable is the schema for the channelable portion of the spec -// section of the resource. -type Channelable struct { - // TODO: What is actually required here for Channel spec. - // This is the list of subscriptions for this channel. - Subscribers []ChannelSubscriberSpec `json:"subscribers,omitempty"` -} - -// ChannelSubscriberSpec defines a single subscriber to a Channel. -// CallableURI is the endpoint for the call -// SinkableURI is the endpoint for the result -// At least one of them must be present. -type ChannelSubscriberSpec struct { - // +optional - CallableURI string `json:"callableURI,omitempty"` - // +optional - SinkableURI string `json:"sinkableURI,omitempty"` -} - - -// Channelable is an Implementable "duck type". -var _ duck.Implementable = (*Channelable)(nil) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Channel is a skeleton type wrapping Channelable in the manner we expect -// resource writers defining compatible resources to embed it. We will -// typically use this type to deserialize Channelable ObjectReferences and -// access the Channelable data. This is not a real resource. -type Channel struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - // ChannelSpec is the part where Channelable object is - // configured as to be compatible with Channelable contract. - Spec ChannelSpec `json:"spec"` -} - -// ChannelSpec shows how we expect folks to embed Channelable in -// their Spec field. -type ChannelSpec struct { - Channelable *Channelable `json:"channelable,omitempty"` -} - -// In order for Channelable to be Implementable, Channel must be Populatable. -var _ duck.Populatable = (*Channel)(nil) - -// Ensure Channel satisfies apis.Listable -var _ apis.Listable = (*Channel)(nil) - -// GetFullType implements duck.Implementable -func (_ *Channelable) GetFullType() duck.Populatable { - return &Channel{} -} - -// Populate implements duck.Populatable -func (t *Channel) Populate() { - t.Spec.Channelable = &Channelable{ - // Populate ALL fields - Subscribers: []ChannelSubscriberSpec{{"call1", "sink2"}, {"call2", "sink2"}}, - } -} - -// GetListType implements apis.Listable -func (r *Channel) GetListType() runtime.Object { - return &ChannelList{} -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ChannelList is a list of Channel resources -type ChannelList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - Items []Channel `json:"items"` -} diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/legacy_targetable_types.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/legacy_targetable_types.go index 6bfc0881805..ee50201e83c 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/legacy_targetable_types.go +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/legacy_targetable_types.go @@ -24,19 +24,19 @@ import ( "github.com/knative/pkg/apis/duck" ) -// LegacyTargetable left around until we migrate to Targetable in the -// dependent resources. Targetable has more structure in the way it +// LegacyTargetable left around until we migrate to Addressable in the +// dependent resources. Addressable has more structure in the way it // defines the fields. LegacyTargetable only assumed a single string // in the Status field and we're moving towards defining proper structs // under Status rather than strings. // This is to support existing resources until they migrate. // -// Do not use this for anything new, use Targetable +// Do not use this for anything new, use Addressable -// LegacyTargetable is the old schema for the targetable portion +// LegacyTargetable is the old schema for the addressable portion // of the payload // -// For new resources use Targetable. +// For new resources use Addressable. type LegacyTargetable struct { DomainInternal string `json:"domainInternal,omitempty"` } diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/register.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/register.go index f3bfc5ae1d1..a0264e576e0 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/register.go +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/register.go @@ -45,20 +45,16 @@ var ( func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes( SchemeGroupVersion, - &Channel{}, - (&Channel{}).GetListType(), &KResource{}, (&KResource{}).GetListType(), &Generational{}, (&Generational{}).GetListType(), + &AddressableType{}, + (&AddressableType{}).GetListType(), &Target{}, (&Target{}).GetListType(), &LegacyTarget{}, (&LegacyTarget{}).GetListType(), - &Sink{}, - (&Sink{}).GetListType(), - &Subscription{}, - (&Subscription{}).GetListType(), ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/targetable_types.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/retired_targetable_types.go similarity index 84% rename from vendor/github.com/knative/pkg/apis/duck/v1alpha1/targetable_types.go rename to vendor/github.com/knative/pkg/apis/duck/v1alpha1/retired_targetable_types.go index 5cd454ba52b..695e11c3f65 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/targetable_types.go +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/retired_targetable_types.go @@ -24,11 +24,15 @@ import ( "github.com/knative/pkg/apis/duck" ) -// Targetable is very similar concept as Sinkable. However, at the -// transport level they have different contracts and hence Sinkable -// and Targetable are two distinct resources. - -// Targetable is the schema for the targetable portion of the payload +// Targetable is an earlier version of the Callable interface. +// Callable is a higher-level interface which implements Addressable +// but further promises that the destination may synchronously return +// response messages in reply to a message. +// +// Targetable implementations should instead implement Addressable and +// include an `eventing.knative.dev/returns=any` annotation. + +// Targetable is retired; implement Addressable for now. type Targetable struct { DomainInternal string `json:"domainInternal,omitempty"` } diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/sinkable_types.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/sinkable_types.go deleted file mode 100644 index 2ad0ab5e3e9..00000000000 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/sinkable_types.go +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright 2018 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" -) - -// Sinkable is very similar concept as Targetable. However, at the -// transport level they have different contracts and hence Sinkable -// and Targetable are two distinct resources. - -// Sinkable is the schema for the sinkable portion of the payload -type Sinkable struct { - DomainInternal string `json:"domainInternal,omitempty"` -} - - -// Sinkable is an Implementable "duck type". -var _ duck.Implementable = (*Sinkable)(nil) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Sink is a skeleton type wrapping Sinkable in the manner we expect -// resource writers defining compatible resources to embed it. We will -// typically use this type to deserialize Sinkable ObjectReferences and -// access the Sinkable data. This is not a real resource. -type Sink struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Status SinkStatus `json:"status"` -} - -// SinkStatus shows how we expect folks to embed Sinkable in -// their Status field. -type SinkStatus struct { - Sinkable *Sinkable `json:"sinkable,omitempty"` -} - -// In order for Sinkable to be Implementable, Sink must be Populatable. -var _ duck.Populatable = (*Sink)(nil) - -// Ensure Sink satisfies apis.Listable -var _ apis.Listable = (*Sink)(nil) - -// GetFullType implements duck.Implementable -func (_ *Sinkable) GetFullType() duck.Populatable { - return &Sink{} -} - -// Populate implements duck.Populatable -func (t *Sink) Populate() { - t.Status = SinkStatus{ - &Sinkable{ - // Populate ALL fields - DomainInternal: "this is not empty", - }, - } -} - -// GetListType implements apis.Listable -func (r *Sink) GetListType() runtime.Object { - return &SinkList{} -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// SinkList is a list of Sink resources -type SinkList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - Items []Sink `json:"items"` -} diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/subscribable_types.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/subscribable_types.go deleted file mode 100644 index e8d03f890d4..00000000000 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/subscribable_types.go +++ /dev/null @@ -1,105 +0,0 @@ -/* -Copyright 2018 The Knative Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package v1alpha1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - - "github.com/knative/pkg/apis" - "github.com/knative/pkg/apis/duck" -) - -// Subscribable is the schema for the subscribable portion of the payload. -// It is a reference to actual object that implements Channelable duck -// type. -type Subscribable struct { - // Channelable is a reference to the actual resource - // that provides the ability to perform Subscription capabilities. - // This may point to object itself (for example Channel) or to another - // object providing the actual capabilities.. - Channelable corev1.ObjectReference `json:"channelable,omitempty"` -} - - -// Subscribable is an Implementable "duck type". -var _ duck.Implementable = (*Subscribable)(nil) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Subscription is a skeleton type wrapping the notion that this object -// can be subscribed to. SubscriptionStatus provides the reference -// (in a form of Subscribable) to the object that you can actually create -// a subscription to. -// We will typically use this type to deserialize Subscription objects -// to access the Subscripion data. This is not a real resource. -type Subscription struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - // SubscriptionStatus is the part of the Status where a Subscribable - // object points to the underlying Channelable object that fullfills - // the SubscribableSpec contract. Note that this can be a self-link - // for example for concrete Channel implementations. - Status SubscriptionStatus `json:"status"` -} - -// SubscriptionStatus shows how we expect folks to embed Subscribable in -// their Status field. -type SubscriptionStatus struct { - Subscribable *Subscribable `json:"subscribable,omitempty"` -} - -// In order for Subscribable to be Implementable, Subscribable must be Populatable. -var _ duck.Populatable = (*Subscription)(nil) - -// Ensure Subscription satisfies apis.Listable -var _ apis.Listable = (*Subscription)(nil) - -// GetFullType implements duck.Implementable -func (_ *Subscribable) GetFullType() duck.Populatable { - return &Subscription{} -} - -// Populate implements duck.Populatable -func (t *Subscription) Populate() { - t.Status.Subscribable = &Subscribable{ - // Populate ALL fields - Channelable: corev1.ObjectReference{ - Name: "placeholdername", - APIVersion: "apiversionhere", - Kind: "ChannelKindHere", - }, - } -} - -// GetListType implements apis.Listable -func (r *Subscription) GetListType() runtime.Object { - return &SubscriptionList{} -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// SubscribableList is a list of Subscribable resources -type SubscriptionList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata"` - - Items []Subscription `json:"items"` -} diff --git a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go index 203f1ec5b31..731c7059dc0 100644 --- a/vendor/github.com/knative/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/github.com/knative/pkg/apis/duck/v1alpha1/zz_generated.deepcopy.go @@ -25,123 +25,102 @@ import ( ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Channel) DeepCopyInto(out *Channel) { +func (in *AddressStatus) DeepCopyInto(out *AddressStatus) { *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) + if in.Address != nil { + in, out := &in.Address, &out.Address + *out = new(Addressable) + **out = **in + } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Channel. -func (in *Channel) DeepCopy() *Channel { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddressStatus. +func (in *AddressStatus) DeepCopy() *AddressStatus { if in == nil { return nil } - out := new(Channel) + out := new(AddressStatus) in.DeepCopyInto(out) return out } -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Channel) 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 *ChannelList) DeepCopyInto(out *ChannelList) { +func (in *Addressable) DeepCopyInto(out *Addressable) { *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Channel, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelList. -func (in *ChannelList) DeepCopy() *ChannelList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Addressable. +func (in *Addressable) DeepCopy() *Addressable { if in == nil { return nil } - out := new(ChannelList) + out := new(Addressable) in.DeepCopyInto(out) return out } -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ChannelList) 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 *ChannelSpec) DeepCopyInto(out *ChannelSpec) { +func (in *AddressableType) DeepCopyInto(out *AddressableType) { *out = *in - if in.Channelable != nil { - in, out := &in.Channelable, &out.Channelable - *out = new(Channelable) - (*in).DeepCopyInto(*out) - } + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Status.DeepCopyInto(&out.Status) return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelSpec. -func (in *ChannelSpec) DeepCopy() *ChannelSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddressableType. +func (in *AddressableType) DeepCopy() *AddressableType { if in == nil { return nil } - out := new(ChannelSpec) + out := new(AddressableType) in.DeepCopyInto(out) return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ChannelSubscriberSpec) DeepCopyInto(out *ChannelSubscriberSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChannelSubscriberSpec. -func (in *ChannelSubscriberSpec) DeepCopy() *ChannelSubscriberSpec { - if in == nil { - return nil +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AddressableType) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c } - out := new(ChannelSubscriberSpec) - in.DeepCopyInto(out) - return out + return nil } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Channelable) DeepCopyInto(out *Channelable) { +func (in *AddressableTypeList) DeepCopyInto(out *AddressableTypeList) { *out = *in - if in.Subscribers != nil { - in, out := &in.Subscribers, &out.Subscribers - *out = make([]ChannelSubscriberSpec, len(*in)) - copy(*out, *in) + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AddressableType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Channelable. -func (in *Channelable) DeepCopy() *Channelable { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddressableTypeList. +func (in *AddressableTypeList) DeepCopy() *AddressableTypeList { if in == nil { return nil } - out := new(Channelable) + out := new(AddressableTypeList) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AddressableTypeList) 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 *Condition) DeepCopyInto(out *Condition) { *out = *in @@ -416,201 +395,6 @@ func (in *LegacyTargetable) DeepCopy() *LegacyTargetable { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Sink) DeepCopyInto(out *Sink) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Sink. -func (in *Sink) DeepCopy() *Sink { - if in == nil { - return nil - } - out := new(Sink) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Sink) 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 *SinkList) DeepCopyInto(out *SinkList) { - *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Sink, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkList. -func (in *SinkList) DeepCopy() *SinkList { - if in == nil { - return nil - } - out := new(SinkList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *SinkList) 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 *SinkStatus) DeepCopyInto(out *SinkStatus) { - *out = *in - if in.Sinkable != nil { - in, out := &in.Sinkable, &out.Sinkable - *out = new(Sinkable) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SinkStatus. -func (in *SinkStatus) DeepCopy() *SinkStatus { - if in == nil { - return nil - } - out := new(SinkStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Sinkable) DeepCopyInto(out *Sinkable) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Sinkable. -func (in *Sinkable) DeepCopy() *Sinkable { - if in == nil { - return nil - } - out := new(Sinkable) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Subscribable) DeepCopyInto(out *Subscribable) { - *out = *in - out.Channelable = in.Channelable - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subscribable. -func (in *Subscribable) DeepCopy() *Subscribable { - if in == nil { - return nil - } - out := new(Subscribable) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Subscription) DeepCopyInto(out *Subscription) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Subscription. -func (in *Subscription) DeepCopy() *Subscription { - if in == nil { - return nil - } - out := new(Subscription) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Subscription) 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 *SubscriptionList) DeepCopyInto(out *SubscriptionList) { - *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Subscription, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionList. -func (in *SubscriptionList) DeepCopy() *SubscriptionList { - if in == nil { - return nil - } - out := new(SubscriptionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *SubscriptionList) 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 *SubscriptionStatus) DeepCopyInto(out *SubscriptionStatus) { - *out = *in - if in.Subscribable != nil { - in, out := &in.Subscribable, &out.Subscribable - *out = new(Subscribable) - **out = **in - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SubscriptionStatus. -func (in *SubscriptionStatus) DeepCopy() *SubscriptionStatus { - if in == nil { - return nil - } - out := new(SubscriptionStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Target) DeepCopyInto(out *Target) { *out = *in