From b745cad5518eb001687434a241e47827d79990d1 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Wed, 26 Sep 2018 13:12:48 -0700 Subject: [PATCH 01/23] Unit tests for passthrough headers. --- pkg/buses/bus.go | 3 +- pkg/buses/message_dispatcher.go | 29 +++++--- pkg/buses/message_dispatcher_test.go | 100 +++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 11 deletions(-) create mode 100644 pkg/buses/message_dispatcher_test.go diff --git a/pkg/buses/bus.go b/pkg/buses/bus.go index ccc2596eec8..0ee44279a26 100644 --- a/pkg/buses/bus.go +++ b/pkg/buses/bus.go @@ -193,7 +193,6 @@ func (b *bus) dispatchMessage(subscription *channelsv1alpha1.Subscription, messa subscriber := subscription.Spec.Subscriber defaults := DispatchDefaults{ Namespace: subscription.Namespace, - ReplyTo: subscription.Spec.ReplyTo, } - return b.dispatcher.DispatchMessage(message, subscriber, defaults) + return b.dispatcher.DispatchMessage(message, subscriber, subscription.Spec.ReplyTo, defaults) } diff --git a/pkg/buses/message_dispatcher.go b/pkg/buses/message_dispatcher.go index ffb055dd2bb..29d62c2ef73 100644 --- a/pkg/buses/message_dispatcher.go +++ b/pkg/buses/message_dispatcher.go @@ -29,9 +29,14 @@ import ( const correlationIDHeaderName = "Knative-Correlation-Id" +// httpDoer is an interface for making HTTP requests. +type httpDoer interface { + Do(*http.Request) (*http.Response, error) +} + // MessageDispatcher dispatches messages to a destination over HTTP. type MessageDispatcher struct { - httpClient *http.Client + httpClient httpDoer forwardHeaders map[string]bool forwardPrefixes []string supportedSchemes map[string]bool @@ -42,7 +47,6 @@ type MessageDispatcher struct { // DispatchDefaults provides default parameter values used when dispatching a message. type DispatchDefaults struct { Namespace string - ReplyTo string } // NewMessageDispatcher creates a new message dispatcher that can dispatch @@ -66,14 +70,21 @@ func NewMessageDispatcher(logger *zap.SugaredLogger) *MessageDispatcher { // The destination and replyTo are DNS names. For names with a single label, // the default namespace is used to expand it into a fully qualified name // within the cluster. -func (d *MessageDispatcher) DispatchMessage(message *Message, destination string, defaults DispatchDefaults) error { - destinationURL := d.resolveURL(destination, defaults.Namespace) - reply, err := d.executeRequest(destinationURL, message) - if err != nil { - return fmt.Errorf("Unable to complete request %v", err) +func (d *MessageDispatcher) DispatchMessage(message *Message, destination, replyTo string, defaults DispatchDefaults) error { + var err error + // Default to replying with the original message. If there is a destination, then replace it + // with the response from the call to the destination instead. + reply := message + if destination != "" { + destinationURL := d.resolveURL(destination, defaults.Namespace) + reply, err = d.executeRequest(destinationURL, message) + if err != nil { + return fmt.Errorf("Unable to complete request %v", err) + } } - if defaults.ReplyTo != "" && reply != nil { - replyToURL := d.resolveURL(defaults.ReplyTo, defaults.Namespace) + + if replyTo != "" && reply != nil { + replyToURL := d.resolveURL(replyTo, defaults.Namespace) _, err = d.executeRequest(replyToURL, reply) if err != nil { return fmt.Errorf("Failed to forward reply %v", err) diff --git a/pkg/buses/message_dispatcher_test.go b/pkg/buses/message_dispatcher_test.go new file mode 100644 index 00000000000..110a90e5f1d --- /dev/null +++ b/pkg/buses/message_dispatcher_test.go @@ -0,0 +1,100 @@ +/* +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 buses + +import ( + "bytes" + "github.com/google/go-cmp/cmp" + "go.uber.org/zap" + "io/ioutil" + "net/http" + "strings" + "testing" +) + +func TestDispatchMessage(t *testing.T) { + testCases := map[string]struct { + message *Message + expectedHeaders http.Header + }{ + "filter unwanted headers": { + message: &Message{ + Headers: map[string]string{ + "do-not-forward": "header", + }, + Payload: []byte("{}"), + }, + expectedHeaders: map[string][]string{}, + }, + "multiple forward prefixes": { + message: &Message{ + Headers: map[string]string{ + "x-request-id": "id123", + "knative-1": "knative-1-value", + "knative-2": "knative-2-value", + "ce-abc": "ce-abc-value", + }, + Payload: []byte("{}"), + }, + expectedHeaders: map[string][]string{ + "x-request-id": {"id123"}, + "knative-1": {"knative-1-value"}, + "knative-2": {"knative-2-value"}, + "ce-abc": {"ce-abc-value"}, + }, + }, + } + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + md := NewMessageDispatcher(zap.NewNop().Sugar()) + fc := &fakeHttpClient{} + md.httpClient = fc + err := md.DispatchMessage(tc.message, "destination", "", DispatchDefaults{}) + if err != nil { + t.Errorf("Unexpected error dispatching message: %v", err) + } + if diff := headerDiff(tc.expectedHeaders, fc.requestHeaders); diff != "" { + t.Errorf("Unexpected request headers (-wanted, +got): %v", diff) + } + }) + } +} + +type fakeHttpClient struct { + requestHeaders http.Header +} + +var _ httpDoer = &fakeHttpClient{} + +func (f *fakeHttpClient) Do(r *http.Request) (*http.Response, error) { + f.requestHeaders = r.Header + return &http.Response{ + StatusCode: http.StatusAccepted, + Body: ioutil.NopCloser(bytes.NewBufferString("body")), + }, nil +} + +func headerDiff(expected http.Header, actual http.Header) string { + // HTTP header names are case-insensitive, so normalize them to lower case for comparison. + for _, headers := range []http.Header{expected, actual} { + for n, v := range headers { + delete(headers, n) + headers[strings.ToLower(n)] = v + } + } + return cmp.Diff(expected, actual) +} From 0f949d5dd9913528bef3ff32ded20010828be3c6 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Wed, 26 Sep 2018 14:59:40 -0700 Subject: [PATCH 02/23] Unit tests. --- pkg/buses/message_dispatcher.go | 33 +-- pkg/buses/message_dispatcher_test.go | 292 ++++++++++++++++++++++++--- 2 files changed, 285 insertions(+), 40 deletions(-) diff --git a/pkg/buses/message_dispatcher.go b/pkg/buses/message_dispatcher.go index 29d62c2ef73..c9b3afc7896 100644 --- a/pkg/buses/message_dispatcher.go +++ b/pkg/buses/message_dispatcher.go @@ -104,23 +104,24 @@ func (d *MessageDispatcher) executeRequest(url *url.URL, message *Message) (*Mes if err != nil { return nil, err } - if res != nil { - if res.StatusCode < 200 || res.StatusCode >= 300 { - // reject non-successful (2xx) responses - return nil, fmt.Errorf("unexpected HTTP response, expected 2xx, got %d", res.StatusCode) - } - headers := d.fromHTTPHeaders(res.Header) - // TODO: add configurable whitelisting of propagated headers/prefixes (configmap?) - if correlationID, ok := message.Headers[correlationIDHeaderName]; ok { - headers[correlationIDHeaderName] = correlationID - } - payload, err := ioutil.ReadAll(res.Body) - if err != nil { - return nil, fmt.Errorf("Unable to read response %v", err) - } - return &Message{headers, payload}, nil + if res.StatusCode < 200 || res.StatusCode >= 300 { + // reject non-successful (2xx) responses + return nil, fmt.Errorf("unexpected HTTP response, expected 2xx, got %d", res.StatusCode) + } + headers := d.fromHTTPHeaders(res.Header) + // TODO: add configurable whitelisting of propagated headers/prefixes (configmap?) + if correlationID, ok := message.Headers[correlationIDHeaderName]; ok { + headers[correlationIDHeaderName] = correlationID + } + payload, err := ioutil.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("Unable to read response %v", err) + } + if len(payload) == 0 { + // The response body is empty, the event has 'finished'. + return nil, nil } - return nil, nil + return &Message{headers, payload}, nil } // toHTTPHeaders converts message headers to HTTP headers. diff --git a/pkg/buses/message_dispatcher_test.go b/pkg/buses/message_dispatcher_test.go index 110a90e5f1d..7ee8aa81a65 100644 --- a/pkg/buses/message_dispatcher_test.go +++ b/pkg/buses/message_dispatcher_test.go @@ -28,66 +28,310 @@ import ( func TestDispatchMessage(t *testing.T) { testCases := map[string]struct { - message *Message - expectedHeaders http.Header + destination string + replyTo string + message *Message + fakeResponse *http.Response + expectedErr bool + expectedDestRequest *requestValidation + expectedReplyRequest *requestValidation }{ - "filter unwanted headers": { + "destination - only": { + destination: "test-destination-svc.test-namespace.svc.cluster.local", message: &Message{ Headers: map[string]string{ + // do-not-forward should not get forwarded. "do-not-forward": "header", + "x-request-id": "id123", + "knative-1": "knative-1-value", + "knative-2": "knative-2-value", + "ce-abc": "ce-abc-value", }, - Payload: []byte("{}"), + Payload: []byte("destination"), }, - expectedHeaders: map[string][]string{}, + expectedDestRequest: &requestValidation{ + url: "http://test-destination-svc.test-namespace.svc.cluster.local/", + headers: map[string][]string{ + "x-request-id": {"id123"}, + "knative-1": {"knative-1-value"}, + "knative-2": {"knative-2-value"}, + "ce-abc": {"ce-abc-value"}, + }, + body: "destination", + }, + }, + "destination - only -- error": { + destination: "test-destination-svc.test-namespace.svc.cluster.local", + message: &Message{ + Headers: map[string]string{ + // do-not-forward should not get forwarded. + "do-not-forward": "header", + "x-request-id": "id123", + "knative-1": "knative-1-value", + "knative-2": "knative-2-value", + "ce-abc": "ce-abc-value", + }, + Payload: []byte("destination"), + }, + expectedDestRequest: &requestValidation{ + url: "http://test-destination-svc.test-namespace.svc.cluster.local/", + headers: map[string][]string{ + "x-request-id": {"id123"}, + "knative-1": {"knative-1-value"}, + "knative-2": {"knative-2-value"}, + "ce-abc": {"ce-abc-value"}, + }, + body: "destination", + }, + fakeResponse: &http.Response{ + StatusCode: http.StatusNotFound, + Body: ioutil.NopCloser(bytes.NewBufferString("destination-response")), + }, + expectedErr: true, + }, + "reply - only": { + replyTo: "test-reply-svc.test-namespace.svc.cluster.local", + message: &Message{ + Headers: map[string]string{ + // do-not-forward should not get forwarded. + "do-not-forward": "header", + "x-request-id": "id123", + "knative-1": "knative-1-value", + "knative-2": "knative-2-value", + "ce-abc": "ce-abc-value", + }, + Payload: []byte("replyTo"), + }, + expectedReplyRequest: &requestValidation{ + url: "http://test-reply-svc.test-namespace.svc.cluster.local/", + headers: map[string][]string{ + "x-request-id": {"id123"}, + "knative-1": {"knative-1-value"}, + "knative-2": {"knative-2-value"}, + "ce-abc": {"ce-abc-value"}, + }, + body: "replyTo", + }, + }, + "reply - only -- error": { + replyTo: "test-reply-svc.test-namespace.svc.cluster.local", + message: &Message{ + Headers: map[string]string{ + // do-not-forward should not get forwarded. + "do-not-forward": "header", + "x-request-id": "id123", + "knative-1": "knative-1-value", + "knative-2": "knative-2-value", + "ce-abc": "ce-abc-value", + }, + Payload: []byte("replyTo"), + }, + expectedReplyRequest: &requestValidation{ + url: "http://test-reply-svc.test-namespace.svc.cluster.local/", + headers: map[string][]string{ + "x-request-id": {"id123"}, + "knative-1": {"knative-1-value"}, + "knative-2": {"knative-2-value"}, + "ce-abc": {"ce-abc-value"}, + }, + body: "replyTo", + }, + fakeResponse: &http.Response{ + StatusCode: http.StatusNotFound, + Body: ioutil.NopCloser(bytes.NewBufferString("destination-response")), + }, + expectedErr: true, + }, + "destination and reply - dest returns bad status code": { + destination: "test-destination-svc.test-namespace.svc.cluster.local", + replyTo: "test-reply-svc.test-namespace.svc.cluster.local", + message: &Message{ + Headers: map[string]string{ + // do-not-forward should not get forwarded. + "do-not-forward": "header", + "x-request-id": "id123", + "knative-1": "knative-1-value", + "knative-2": "knative-2-value", + "ce-abc": "ce-abc-value", + }, + Payload: []byte("destination"), + }, + expectedDestRequest: &requestValidation{ + url: "http://test-destination-svc.test-namespace.svc.cluster.local/", + headers: map[string][]string{ + "x-request-id": {"id123"}, + "knative-1": {"knative-1-value"}, + "knative-2": {"knative-2-value"}, + "ce-abc": {"ce-abc-value"}, + }, + body: "destination", + }, + fakeResponse: &http.Response{ + StatusCode: http.StatusInternalServerError, + Body: ioutil.NopCloser(bytes.NewBufferString("destination-response")), + }, + expectedErr: true, }, - "multiple forward prefixes": { + "destination and reply - dest returns empty body": { + destination: "test-destination-svc.test-namespace.svc.cluster.local", + replyTo: "test-reply-svc.test-namespace.svc.cluster.local", message: &Message{ Headers: map[string]string{ - "x-request-id": "id123", - "knative-1": "knative-1-value", - "knative-2": "knative-2-value", - "ce-abc": "ce-abc-value", + // do-not-forward should not get forwarded. + "do-not-forward": "header", + "x-request-id": "id123", + "knative-1": "knative-1-value", + "knative-2": "knative-2-value", + "ce-abc": "ce-abc-value", + }, + Payload: []byte("destination"), + }, + expectedDestRequest: &requestValidation{ + url: "http://test-destination-svc.test-namespace.svc.cluster.local/", + headers: map[string][]string{ + "x-request-id": {"id123"}, + "knative-1": {"knative-1-value"}, + "knative-2": {"knative-2-value"}, + "ce-abc": {"ce-abc-value"}, + }, + body: "destination", + }, + fakeResponse: &http.Response{ + StatusCode: http.StatusAccepted, + Header: map[string][]string{ + "do-not-passthrough": {"no"}, + "x-request-id": {"altered-id"}, + "knative-1": {"new-knative-1-value"}, + "ce-abc": {"new-ce-abc-value"}, + }, + Body: ioutil.NopCloser(bytes.NewBufferString("")), + }, + }, + "destination and reply": { + destination: "test-destination-svc.test-namespace.svc.cluster.local", + replyTo: "test-reply-svc.test-namespace.svc.cluster.local", + message: &Message{ + Headers: map[string]string{ + // do-not-forward should not get forwarded. + "do-not-forward": "header", + "x-request-id": "id123", + "knative-1": "knative-1-value", + "knative-2": "knative-2-value", + "ce-abc": "ce-abc-value", + }, + Payload: []byte("destination"), + }, + expectedDestRequest: &requestValidation{ + url: "http://test-destination-svc.test-namespace.svc.cluster.local/", + headers: map[string][]string{ + "x-request-id": {"id123"}, + "knative-1": {"knative-1-value"}, + "knative-2": {"knative-2-value"}, + "ce-abc": {"ce-abc-value"}, + }, + body: "destination", + }, + fakeResponse: &http.Response{ + StatusCode: http.StatusAccepted, + Header: map[string][]string{ + "do-not-passthrough": {"no"}, + "x-request-id": {"altered-id"}, + "knative-1": {"new-knative-1-value"}, + "ce-abc": {"new-ce-abc-value"}, }, - Payload: []byte("{}"), + Body: ioutil.NopCloser(bytes.NewBufferString("destination-response")), }, - expectedHeaders: map[string][]string{ - "x-request-id": {"id123"}, - "knative-1": {"knative-1-value"}, - "knative-2": {"knative-2-value"}, - "ce-abc": {"ce-abc-value"}, + expectedReplyRequest: &requestValidation{ + url: "http://test-reply-svc.test-namespace.svc.cluster.local/", + headers: map[string][]string{ + "x-request-id": {"altered-id"}, + "knative-1": {"new-knative-1-value"}, + "ce-abc": {"new-ce-abc-value"}, + }, + body: "destination-response", }, }, } for n, tc := range testCases { t.Run(n, func(t *testing.T) { md := NewMessageDispatcher(zap.NewNop().Sugar()) - fc := &fakeHttpClient{} + fc := &fakeHttpClient{ + response: tc.fakeResponse, + } md.httpClient = fc - err := md.DispatchMessage(tc.message, "destination", "", DispatchDefaults{}) - if err != nil { - t.Errorf("Unexpected error dispatching message: %v", err) + err := md.DispatchMessage(tc.message, tc.destination, tc.replyTo, DispatchDefaults{}) + if tc.expectedErr != (err != nil) { + t.Errorf("Unexpected error from DispatchRequest. Expected %v. Actual: %v", tc.expectedErr, err) + } + if tc.expectedDestRequest != nil { + rv := fc.popRequest(t) + assertEquality(t, *tc.expectedDestRequest, rv) + } + if tc.expectedReplyRequest != nil { + rv := fc.popRequest(t) + assertEquality(t, *tc.expectedReplyRequest, rv) } - if diff := headerDiff(tc.expectedHeaders, fc.requestHeaders); diff != "" { - t.Errorf("Unexpected request headers (-wanted, +got): %v", diff) + if len(fc.requests) != 0 { + t.Errorf("Unexpected requests: %+v", fc.requests) } }) } } +type requestValidation struct { + url string + headers http.Header + body string +} + type fakeHttpClient struct { - requestHeaders http.Header + t *testing.T + response *http.Response + requests []requestValidation } var _ httpDoer = &fakeHttpClient{} func (f *fakeHttpClient) Do(r *http.Request) (*http.Response, error) { - f.requestHeaders = r.Header + body, err := ioutil.ReadAll(r.Body) + if err != nil { + f.t.Error("Failed to read the request body") + } + f.requests = append(f.requests, requestValidation{ + url: r.URL.String(), + headers: r.Header, + body: string(body), + }) + if f.response != nil { + return f.response, nil + } return &http.Response{ StatusCode: http.StatusAccepted, Body: ioutil.NopCloser(bytes.NewBufferString("body")), }, nil } +func (f *fakeHttpClient) popRequest(t *testing.T) requestValidation { + if len(f.requests) == 0 { + t.Error("Unable to pop request") + } + rv := f.requests[0] + f.requests = f.requests[1:] + return rv +} + +func assertEquality(t *testing.T, expected, actual requestValidation) { + if diff := cmp.Diff(expected.url, actual.url); diff != "" { + t.Errorf("Unexpected URL (-wanted, +got): %v", diff) + } + if diff := headerDiff(expected.headers, actual.headers); diff != "" { + t.Errorf("Unexpected request headers (-wanted, +got): %v", diff) + } + if diff := cmp.Diff(expected.body, actual.body); diff != "" { + t.Errorf("Unexpected body (-want, +got): %v", diff) + } +} + func headerDiff(expected http.Header, actual http.Header) string { // HTTP header names are case-insensitive, so normalize them to lower case for comparison. for _, headers := range []http.Header{expected, actual} { From fd2ad477d88d5c22c6c22cb629133453477118c7 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Wed, 26 Sep 2018 15:22:46 -0700 Subject: [PATCH 03/23] Initial fanout sidecar. --- cmd/fanoutsidecar/kodata/LICENSE | 201 + cmd/fanoutsidecar/kodata/VENDOR-LICENSE | 5805 +++++++++++++++++ cmd/fanoutsidecar/main.go | 62 + pkg/buses/message_receiver.go | 4 +- pkg/sidecar/clientfactory/client_factory.go | 36 + .../clientfactory/client_factory_test.go | 33 + .../clientfactory/fake/fake_client_factory.go | 75 + .../configmaphandler/config_map_handler.go | 191 + .../config_map_handler_test.go | 367 ++ pkg/sidecar/fanout/fanout_handler.go | 181 + pkg/sidecar/fanout/fanout_handler_test.go | 502 ++ .../multi_channel_fanout_handler.go | 121 + .../multi_channel_fanout_handler_test.go | 406 ++ pkg/sidecar/swappable/swappable.go | 69 + 14 files changed, 8051 insertions(+), 2 deletions(-) create mode 100644 cmd/fanoutsidecar/kodata/LICENSE create mode 100644 cmd/fanoutsidecar/kodata/VENDOR-LICENSE create mode 100644 cmd/fanoutsidecar/main.go create mode 100644 pkg/sidecar/clientfactory/client_factory.go create mode 100644 pkg/sidecar/clientfactory/client_factory_test.go create mode 100644 pkg/sidecar/clientfactory/fake/fake_client_factory.go create mode 100644 pkg/sidecar/configmaphandler/config_map_handler.go create mode 100644 pkg/sidecar/configmaphandler/config_map_handler_test.go create mode 100644 pkg/sidecar/fanout/fanout_handler.go create mode 100644 pkg/sidecar/fanout/fanout_handler_test.go create mode 100644 pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go create mode 100644 pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go create mode 100644 pkg/sidecar/swappable/swappable.go diff --git a/cmd/fanoutsidecar/kodata/LICENSE b/cmd/fanoutsidecar/kodata/LICENSE new file mode 100644 index 00000000000..261eeb9e9f8 --- /dev/null +++ b/cmd/fanoutsidecar/kodata/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/cmd/fanoutsidecar/kodata/VENDOR-LICENSE b/cmd/fanoutsidecar/kodata/VENDOR-LICENSE new file mode 100644 index 00000000000..332850b0579 --- /dev/null +++ b/cmd/fanoutsidecar/kodata/VENDOR-LICENSE @@ -0,0 +1,5805 @@ + +=========================================================== +Import: github.com/knative/eventing/vendor/cloud.google.com/go + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/beorn7/perks + +Copyright (C) 2013 Blake Mizerany + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/davecgh/go-spew + +ISC License + +Copyright (c) 2012-2016 Dave Collins + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/ghodss/yaml + +The MIT License (MIT) + +Copyright (c) 2014 Sam Ghods + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/go-logr/logr + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/go-logr/zapr + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/gogo/protobuf + +Protocol Buffers for Go with Gadgets + +Copyright (c) 2013, The GoGo Authors. All rights reserved. +http://github.com/gogo/protobuf + +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/golang/glog + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/golang/groupcache + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work + +To apply the Apache License to your work, attach the following boilerplate +notice, with the fields enclosed by brackets "[]" replaced with your own +identifying information. (Don't include the brackets!) The text should be +enclosed in the appropriate comment syntax for the file format. We also +recommend that a file or class name and description of purpose be included on +the same "printed page" as the copyright notice for easier identification within +third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/golang/protobuf + +Go support for Protocol Buffers - Google's data interchange format + +Copyright 2010 The Go Authors. All rights reserved. +https://github.com/golang/protobuf + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/google/btree + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/google/go-cmp + +Copyright (c) 2017 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/google/gofuzz + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/google/uuid + +Copyright (c) 2009,2014 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/googleapis/gnostic + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/gregjones/httpcache + +Copyright © 2012 Greg Jones (greg.jones@gmail.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/hashicorp/golang-lru + +Mozilla Public License, version 2.0 + +1. Definitions + +1.1. "Contributor" + + means each individual or legal entity that creates, contributes to the + creation of, or owns Covered Software. + +1.2. "Contributor Version" + + means the combination of the Contributions of others (if any) used by a + Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + + means Source Code Form to which the initial Contributor has attached the + notice in Exhibit A, the Executable Form of such Source Code Form, and + Modifications of such Source Code Form, in each case including portions + thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + a. that the initial Contributor has attached the notice described in + Exhibit B to the Covered Software; or + + b. that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the terms of + a Secondary License. + +1.6. "Executable Form" + + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + + means a work that combines Covered Software with other material, in a + separate file or files, that is not Covered Software. + +1.8. "License" + + means this document. + +1.9. "Licensable" + + means having the right to grant, to the maximum extent possible, whether + at the time of the initial grant or subsequently, any and all of the + rights conveyed by this License. + +1.10. "Modifications" + + means any of the following: + + a. any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered Software; or + + b. any new file in Source Code Form that contains any Covered Software. + +1.11. "Patent Claims" of a Contributor + + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the License, + by the making, using, selling, offering for sale, having made, import, + or transfer of either its Contributions or its Contributor Version. + +1.12. "Secondary License" + + means either the GNU General Public License, Version 2.0, the GNU Lesser + General Public License, Version 2.1, the GNU Affero General Public + License, Version 3.0, or any later versions of those licenses. + +1.13. "Source Code Form" + + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that controls, is + controlled by, or is under common control with You. For purposes of this + definition, "control" means (a) the power, direct or indirect, to cause + the direction or management of such entity, whether by contract or + otherwise, or (b) ownership of more than fifty percent (50%) of the + outstanding shares or beneficial ownership of such entity. + + +2. License Grants and Conditions + +2.1. Grants + + Each Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + + a. under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + + b. under Patent Claims of such Contributor to make, use, sell, offer for + sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + + The licenses granted in Section 2.1 with respect to any Contribution + become effective for each Contribution on the date the Contributor first + distributes such Contribution. + +2.3. Limitations on Grant Scope + + The licenses granted in this Section 2 are the only rights granted under + this License. No additional rights or licenses will be implied from the + distribution or licensing of Covered Software under this License. + Notwithstanding Section 2.1(b) above, no patent license is granted by a + Contributor: + + a. for any code that a Contributor has removed from Covered Software; or + + b. for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + + c. under Patent Claims infringed by Covered Software in the absence of + its Contributions. + + This License does not grant any rights in the trademarks, service marks, + or logos of any Contributor (except as may be necessary to comply with + the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + + No Contributor makes additional grants as a result of Your choice to + distribute the Covered Software under a subsequent version of this + License (see Section 10.2) or under the terms of a Secondary License (if + permitted under the terms of Section 3.3). + +2.5. Representation + + Each Contributor represents that the Contributor believes its + Contributions are its original creation(s) or it has sufficient rights to + grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + + This License is not intended to limit any rights You have under + applicable copyright doctrines of fair use, fair dealing, or other + equivalents. + +2.7. Conditions + + Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in + Section 2.1. + + +3. Responsibilities + +3.1. Distribution of Source Form + + All distribution of Covered Software in Source Code Form, including any + Modifications that You create or to which You contribute, must be under + the terms of this License. You must inform recipients that the Source + Code Form of the Covered Software is governed by the terms of this + License, and how they can obtain a copy of this License. You may not + attempt to alter or restrict the recipients' rights in the Source Code + Form. + +3.2. Distribution of Executable Form + + If You distribute Covered Software in Executable Form then: + + a. such Covered Software must also be made available in Source Code Form, + as described in Section 3.1, and You must inform recipients of the + Executable Form how they can obtain a copy of such Source Code Form by + reasonable means in a timely manner, at a charge no more than the cost + of distribution to the recipient; and + + b. You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter the + recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + + You may create and distribute a Larger Work under terms of Your choice, + provided that You also comply with the requirements of this License for + the Covered Software. If the Larger Work is a combination of Covered + Software with a work governed by one or more Secondary Licenses, and the + Covered Software is not Incompatible With Secondary Licenses, this + License permits You to additionally distribute such Covered Software + under the terms of such Secondary License(s), so that the recipient of + the Larger Work may, at their option, further distribute the Covered + Software under the terms of either this License or such Secondary + License(s). + +3.4. Notices + + You may not remove or alter the substance of any license notices + (including copyright notices, patent notices, disclaimers of warranty, or + limitations of liability) contained within the Source Code Form of the + Covered Software, except that You may alter any license notices to the + extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + + You may choose to offer, and to charge a fee for, warranty, support, + indemnity or liability obligations to one or more recipients of Covered + Software. However, You may do so only on Your own behalf, and not on + behalf of any Contributor. You must make it absolutely clear that any + such warranty, support, indemnity, or liability obligation is offered by + You alone, and You hereby agree to indemnify every Contributor for any + liability incurred by such Contributor as a result of warranty, support, + indemnity or liability terms You offer. You may include additional + disclaimers of warranty and limitations of liability specific to any + jurisdiction. + +4. Inability to Comply Due to Statute or Regulation + + If it is impossible for You to comply with any of the terms of this License + with respect to some or all of the Covered Software due to statute, + judicial order, or regulation then You must: (a) comply with the terms of + this License to the maximum extent possible; and (b) describe the + limitations and the code they affect. Such description must be placed in a + text file included with all distributions of the Covered Software under + this License. Except to the extent prohibited by statute or regulation, + such description must be sufficiently detailed for a recipient of ordinary + skill to be able to understand it. + +5. Termination + +5.1. The rights granted under this License will terminate automatically if You + fail to comply with any of its terms. However, if You become compliant, + then the rights granted under this License from a particular Contributor + are reinstated (a) provisionally, unless and until such Contributor + explicitly and finally terminates Your grants, and (b) on an ongoing + basis, if such Contributor fails to notify You of the non-compliance by + some reasonable means prior to 60 days after You have come back into + compliance. Moreover, Your grants from a particular Contributor are + reinstated on an ongoing basis if such Contributor notifies You of the + non-compliance by some reasonable means, this is the first time You have + received notice of non-compliance with this License from such + Contributor, and You become compliant prior to 30 days after Your receipt + of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent + infringement claim (excluding declaratory judgment actions, + counter-claims, and cross-claims) alleging that a Contributor Version + directly or indirectly infringes any patent, then the rights granted to + You by any and all Contributors for the Covered Software under Section + 2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user + license agreements (excluding distributors and resellers) which have been + validly granted by You or Your distributors under this License prior to + termination shall survive termination. + +6. Disclaimer of Warranty + + Covered Software is provided under this License on an "as is" basis, + without warranty of any kind, either expressed, implied, or statutory, + including, without limitation, warranties that the Covered Software is free + of defects, merchantable, fit for a particular purpose or non-infringing. + The entire risk as to the quality and performance of the Covered Software + is with You. Should any Covered Software prove defective in any respect, + You (not any Contributor) assume the cost of any necessary servicing, + repair, or correction. This disclaimer of warranty constitutes an essential + part of this License. No use of any Covered Software is authorized under + this License except under this disclaimer. + +7. Limitation of Liability + + Under no circumstances and under no legal theory, whether tort (including + negligence), contract, or otherwise, shall any Contributor, or anyone who + distributes Covered Software as permitted above, be liable to You for any + direct, indirect, special, incidental, or consequential damages of any + character including, without limitation, damages for lost profits, loss of + goodwill, work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses, even if such party shall have been + informed of the possibility of such damages. This limitation of liability + shall not apply to liability for death or personal injury resulting from + such party's negligence to the extent applicable law prohibits such + limitation. Some jurisdictions do not allow the exclusion or limitation of + incidental or consequential damages, so this exclusion and limitation may + not apply to You. + +8. Litigation + + Any litigation relating to this License may be brought only in the courts + of a jurisdiction where the defendant maintains its principal place of + business and such litigation shall be governed by laws of that + jurisdiction, without reference to its conflict-of-law provisions. Nothing + in this Section shall prevent a party's ability to bring cross-claims or + counter-claims. + +9. Miscellaneous + + This License represents the complete agreement concerning the subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. Any law or regulation which provides that + the language of a contract shall be construed against the drafter shall not + be used to construe this License against a Contributor. + + +10. Versions of the License + +10.1. New Versions + + Mozilla Foundation is the license steward. Except as provided in Section + 10.3, no one other than the license steward has the right to modify or + publish new versions of this License. Each version will be given a + distinguishing version number. + +10.2. Effect of New Versions + + You may distribute the Covered Software under the terms of the version + of the License under which You originally received the Covered Software, + or under the terms of any subsequent version published by the license + steward. + +10.3. Modified Versions + + If you create software not governed by this License, and you want to + create a new license for such software, you may create and use a + modified version of this License if you rename the license and remove + any references to the name of the license steward (except to note that + such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary + Licenses If You choose to distribute Source Code Form that is + Incompatible With Secondary Licenses under the terms of this version of + the License, the notice described in Exhibit B of this License must be + attached. + +Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the + terms of the Mozilla Public License, v. + 2.0. If a copy of the MPL was not + distributed with this file, You can + obtain one at + http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular file, +then You may include the notice in a location (such as a LICENSE file in a +relevant directory) where a recipient would be likely to look for such a +notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice + + This Source Code Form is "Incompatible + With Secondary Licenses", as defined by + the Mozilla Public License, v. 2.0. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/imdario/mergo + +Copyright (c) 2013 Dario Castañé. All rights reserved. +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/json-iterator/go + +MIT License + +Copyright (c) 2016 json-iterator + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/knative/pkg + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/mattbaird/jsonpatch + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/matttproud/golang_protobuf_extensions + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/modern-go/concurrent + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/modern-go/reflect2 + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/peterbourgon/diskv + +Copyright (c) 2011-2012 Peter Bourgon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/prometheus/client_golang + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/prometheus/client_model + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/prometheus/common + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/prometheus/procfs + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/spf13/pflag + +Copyright (c) 2012 Alex Ogier. All rights reserved. +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/go.uber.org/atomic + +Copyright (c) 2016 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/go.uber.org/multierr + +Copyright (c) 2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/go.uber.org/zap + +Copyright (c) 2016-2017 Uber Technologies, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/golang.org/x/crypto + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/golang.org/x/net + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/golang.org/x/oauth2 + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/golang.org/x/sys + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/golang.org/x/text + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/golang.org/x/time + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/gopkg.in/inf.v0 + +Copyright (c) 2012 Péter Surányi. Portions Copyright (c) 2009 The Go +Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/gopkg.in/yaml.v2 + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/k8s.io/api + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/k8s.io/apimachinery + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/k8s.io/client-go + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/k8s.io/kube-openapi + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +=========================================================== +Import: github.com/knative/eventing/vendor/sigs.k8s.io/controller-runtime + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/cmd/fanoutsidecar/main.go b/cmd/fanoutsidecar/main.go new file mode 100644 index 00000000000..7238246c8e6 --- /dev/null +++ b/cmd/fanoutsidecar/main.go @@ -0,0 +1,62 @@ +/* +Copyright 2018 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// A sidecar that implements filtering of Cloud Events sent out via HTTP. Implemented as an HTTP +// proxy that the main containers need to write through. + +package main + +import ( + "flag" + "fmt" + "github.com/knative/eventing/pkg/sidecar/clientfactory" + "github.com/knative/eventing/pkg/sidecar/configmaphandler" + "go.uber.org/zap" + "net/http" + "time" +) + +const ( + port = 11235 +) + +var ( + readTimeout = time.Minute + writeTimeout = time.Minute +) + +func main() { + flag.Parse() + + logger, err := zap.NewProduction() + if err != nil { + panic(err) + } + + cmh, err := configmaphandler.NewHandler(logger, configmaphandler.ConfigDir, &clientfactory.Standard{}) + if err != nil { + logger.Fatal("Unable to create configmaphandler.Handler", zap.Error(err)) + } + s := &http.Server{ + Addr: fmt.Sprintf(":%v", port), + Handler: cmh, + ErrorLog: zap.NewStdLog(logger), + ReadTimeout: readTimeout, + WriteTimeout: writeTimeout, + } + logger.Info("Fanout sidecar Listening...") + s.ListenAndServe() +} diff --git a/pkg/buses/message_receiver.go b/pkg/buses/message_receiver.go index 7639a7aec51..a8cf46089ca 100644 --- a/pkg/buses/message_receiver.go +++ b/pkg/buses/message_receiver.go @@ -103,7 +103,7 @@ func (r *MessageReceiver) stop(srv *http.Server) { func (r *MessageReceiver) HandleRequest(res http.ResponseWriter, req *http.Request) { host := req.Host r.logger.Infof("Received request for %s", host) - channel := r.parseChannel(host) + channel := ParseChannel(host) message, err := r.fromRequest(req) if err != nil { @@ -165,7 +165,7 @@ func (r *MessageReceiver) fromHTTPHeaders(headers http.Header) map[string]string // parseChannel converts the channel's hostname into a channel // reference. -func (r *MessageReceiver) parseChannel(host string) ChannelReference { +func ParseChannel(host string) ChannelReference { chunks := strings.Split(host, ".") return ChannelReference{ Name: chunks[0], diff --git a/pkg/sidecar/clientfactory/client_factory.go b/pkg/sidecar/clientfactory/client_factory.go new file mode 100644 index 00000000000..17651fffc57 --- /dev/null +++ b/pkg/sidecar/clientfactory/client_factory.go @@ -0,0 +1,36 @@ +/* +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 clientfactory + +import "net/http" + +// ClientFactory creates HTTP clients. +type ClientFactory interface { + Create() (HttpDoer, error) +} + +// ClientFactory that creates http.Client. +type Standard struct{} + +func (_ *Standard) Create() (HttpDoer, error) { + return &http.Client{}, nil +} + +// Makes generic HTTP requests. +type HttpDoer interface { + Do(req *http.Request) (*http.Response, error) +} diff --git a/pkg/sidecar/clientfactory/client_factory_test.go b/pkg/sidecar/clientfactory/client_factory_test.go new file mode 100644 index 00000000000..264d68d4c41 --- /dev/null +++ b/pkg/sidecar/clientfactory/client_factory_test.go @@ -0,0 +1,33 @@ +/* +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 clientfactory + +import ( + "net/http" + "testing" +) + +func TestStandard_Create(t *testing.T) { + s := &Standard{} + c, err := s.Create() + if err != nil { + t.Errorf("Received an error creating a client interface: %v", err) + } + if _, ok := c.(*http.Client); !ok { + t.Errorf("clientfactory.Standard did not create an *http.Client") + } +} diff --git a/pkg/sidecar/clientfactory/fake/fake_client_factory.go b/pkg/sidecar/clientfactory/fake/fake_client_factory.go new file mode 100644 index 00000000000..6d182553baa --- /dev/null +++ b/pkg/sidecar/clientfactory/fake/fake_client_factory.go @@ -0,0 +1,75 @@ +/* +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 fake + +import ( + "errors" + "github.com/knative/eventing/pkg/sidecar/clientfactory" + "net/http" + "sync" +) + +// A fake ClientFactory that will return the errors or responses specified. As well as record all +// requests made. +type ClientFactory struct { + // Error to return when calling Create(). + CreateErr error + // Guards req. + reqMu sync.Mutex + // The HTTP requests made. Only access when holding reqMu. + req []*http.Request + + // Error to return when calling Do(). + RespErr error + + // Resp are the responses to send out. All entries are sent once, except for the last response, + // which is sent on all subsequent calls to Do(). + Resp []*http.Response +} + +func (f *ClientFactory) Create() (clientfactory.HttpDoer, error) { + if f.CreateErr != nil { + return nil, f.CreateErr + } + return f, nil +} + +func (f *ClientFactory) Do(r *http.Request) (*http.Response, error) { + f.reqMu.Lock() + defer f.reqMu.Unlock() + f.req = append(f.req, r) + if f.RespErr != nil { + return nil, f.RespErr + } + if len(f.Resp) == 0 { + return nil, errors.New("test failure -- no response in fake.ClientFactory") + } + resp := f.Resp[0] + if len(f.Resp) > 1 { + f.Resp = f.Resp[1:] + } + return resp, nil +} + +// GetRequests return all the requests made so far. +func (f *ClientFactory) GetRequests() []*http.Request { + f.reqMu.Lock() + defer f.reqMu.Unlock() + rv := make([]*http.Request, len(f.req)) + copy(rv, f.req) + return rv +} diff --git a/pkg/sidecar/configmaphandler/config_map_handler.go b/pkg/sidecar/configmaphandler/config_map_handler.go new file mode 100644 index 00000000000..c0c55f852a8 --- /dev/null +++ b/pkg/sidecar/configmaphandler/config_map_handler.go @@ -0,0 +1,191 @@ +/* +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 configmaphandler + +import ( + "bytes" + "encoding/json" + "fmt" + "github.com/fsnotify/fsnotify" + "github.com/knative/eventing/pkg/sidecar/clientfactory" + "github.com/knative/eventing/pkg/sidecar/multichannelfanout" + "github.com/knative/pkg/configmap" + "go.uber.org/zap" + "k8s.io/apimachinery/pkg/util/yaml" + "net/http" + "sync/atomic" +) + +const ( + // The mount path of the configMap volume. + ConfigDir = "/etc/config/fanout_sidecar" + // The config key that contains all the configuration data. + multiChannelFanoutConfigKey = "multiChannelFanoutConfig" +) + +// http.Handler that monitors an attached ConfigMap volume for updated configuration and updates its +// behavior based on the configuration. +type configMapHandler struct { + logger *zap.Logger + // The directory to read the configMap from. + dir string + // Stop the watcher by closing this channel. Expected to only be used by tests. + watcherStopCh chan<- bool + // The current multichannelfanout.Handler to delegate HTTP requests to. Never use this directly, + // instead use {get,set}MultiChannelFanoutHandler, which enforces the type we expect. + fanout atomic.Value +} + +// NewHandler creates a new configmaphandler.Handler. +func NewHandler(logger *zap.Logger, dir string, clientFactory clientfactory.ClientFactory) (http.Handler, error) { + conf, err := readConfigMap(logger, dir) + if err != nil { + logger.Error("Unable to read configMap", zap.Error(err)) + return nil, err + } + + logger.Info("Read initial configMap", zap.Any("conf", conf)) + + mcfh, err := multichannelfanout.NewHandler(logger, conf, clientFactory) + if err != nil { + logger.Error("Unable to create multichannelfanout.Handler: %v", zap.Error(err)) + return nil, err + } + + cmh := &configMapHandler{ + logger: logger, + dir: dir, + } + cmh.setMultiChannelFanoutHandler(mcfh) + watcherStopCh, err := cmh.startWatcher(dir) + if err != nil { + logger.Error("Unable to start the configMap file watcher", zap.Error(err)) + return nil, err + } + cmh.watcherStopCh = watcherStopCh + return cmh, nil +} + +// getMultiChannelFanoutHandler gets the current multichannelfanout.Handler to delegate all HTTP +// requests to. +func (cmh *configMapHandler) getMultiChannelFanoutHandler() *multichannelfanout.Handler { + return cmh.fanout.Load().(*multichannelfanout.Handler) +} + +// setMultiChannelFanoutHandler sets a new multichannelfanout.Handler to delegate all subsequent +// HTTP requests to. +func (cmh *configMapHandler) setMultiChannelFanoutHandler(new *multichannelfanout.Handler) { + cmh.fanout.Store(new) +} + +// readConfigMap attempts to read the configMap from the attached volume. +func readConfigMap(logger *zap.Logger, dir string) (multichannelfanout.Config, error) { + cm, err := configmap.Load(dir) + if err != nil { + logger.Error("Unable to read configMap", zap.Error(err)) + return multichannelfanout.Config{}, err + } + + if _, present := cm[multiChannelFanoutConfigKey]; !present { + logger.Error("Expected key not found", zap.String("key", multiChannelFanoutConfigKey)) + return multichannelfanout.Config{}, fmt.Errorf("expected key not found: %v", multiChannelFanoutConfigKey) + } + jb, err := yaml.ToJSON([]byte(cm[multiChannelFanoutConfigKey])) + if err != nil { + logger.Error("Unable to convert multiChannelFanoutConfig to JSON", zap.Error(err)) + return multichannelfanout.Config{}, err + } + var conf multichannelfanout.Config + err = unmarshallJsonDisallowUnknownFields(jb, &conf) + return conf, err +} + +// readConfigMapAndUpdateSubs reads the configMap data and updates configuration of cmh.fanout, if +// it has changed. +// +// Note that this is often called multiple times when the configMap is updated, so it should do its +// best to discard redundant calls. +func (cmh *configMapHandler) readConfigMapAndUpdateConfig() { + conf, err := readConfigMap(cmh.logger, cmh.dir) + if err != nil { + cmh.logger.Error("Unable to read the configMap", zap.Error(err)) + return + } + current := cmh.getMultiChannelFanoutHandler() + if diff := current.ConfigDiff(conf); diff != "" { + cmh.logger.Info("Updating multiChannelFanout config", zap.String("diff (-old, +new)", diff)) + updated, err := current.CopyWithNewConfig(conf) + if err != nil { + cmh.logger.Error("Unable to create updated multichannelfanout.Handler", zap.Error(err)) + return + } + cmh.setMultiChannelFanoutHandler(updated) + } else { + cmh.logger.Info("fanout config unchanged") + } +} + +// startWatcher starts a background go routine that gets events when the filesystem in configDir is +// changed. +func (cmh *configMapHandler) startWatcher(dir string) (chan<- bool, error) { + watcher, err := fsnotify.NewWatcher() + if err != nil { + return nil, err + } + stopCh := make(chan bool) + go func() { + for { + select { + case _, ok := <-watcher.Events: + if !ok { + // Channel closed. + cmh.logger.Error("watcher.Events channel closed") // TODO: Should this be fatal? + return + } + cmh.readConfigMapAndUpdateConfig() + case err, ok := <-watcher.Errors: + if !ok { + // Channel closed. + cmh.logger.Error("watcher.Errors channel closed") // TODO: Should this be fatal? + return + } + cmh.logger.Error("watcher.Errors", zap.Error(err)) + case _, ok := <-stopCh: + if !ok { + // stopCh has been closed + return + } + } + } + }() + + return stopCh, watcher.Add(dir) +} + +// ServeHTTP delegates all HTTP requests to the current multichannelfanout.Handler. +func (cmh *configMapHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + // Hand work off to the current multi channel fanout handler. + cmh.getMultiChannelFanoutHandler().ServeHTTP(w, r) +} + +// unmarshallJsonDisallowUnknownFields unmarshalls JSON, but unlike json.Unmarshall, will fail if +// given an unknown field (rather than json.Unmarshall's ignoring the unknown field). +func unmarshallJsonDisallowUnknownFields(jb []byte, v interface{}) error { + d := json.NewDecoder(bytes.NewReader(jb)) + d.DisallowUnknownFields() + return d.Decode(v) +} diff --git a/pkg/sidecar/configmaphandler/config_map_handler_test.go b/pkg/sidecar/configmaphandler/config_map_handler_test.go new file mode 100644 index 00000000000..ff88b6c6963 --- /dev/null +++ b/pkg/sidecar/configmaphandler/config_map_handler_test.go @@ -0,0 +1,367 @@ +/* +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 configmaphandler + +import ( + "fmt" + "github.com/google/go-cmp/cmp" + "github.com/knative/eventing/pkg/sidecar/clientfactory/fake" + "github.com/knative/eventing/pkg/sidecar/fanout" + "github.com/knative/eventing/pkg/sidecar/multichannelfanout" + "go.uber.org/zap" + "io" + "io/ioutil" + "net/http" + "net/http/httptest" + "os" + "strings" + "testing" + "time" +) + +func TestReadConfigMap(t *testing.T) { + testCases := []struct { + name string + createDir bool + config string + expected multichannelfanout.Config + expectedErr bool + }{ + { + name: "dir does not exist", + createDir: false, + }, + { + name: "no data", + createDir: true, + expectedErr: true, + }, + { + name: "invalid YAML", + createDir: true, + config: ` + key: + - value + - different indent level + `, + expectedErr: true, + }, + { + name: "valid YAML -- invalid JSON", + config: "{ nil: Key }", + createDir: true, + expectedErr: true, + }, + { + name: "unknown field", + config: "{ channelConfigs: [ { not: a-defined-field } ] }", + createDir: true, + expectedErr: true, + }, + { + name: "valid", + createDir: true, + config: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - callDomain: event-changer.default.svc.cluster.local + toDomain: message-dumper-bar.default.svc.cluster.local + - callDomain: message-dumper-foo.default.svc.cluster.local + - toDomain: message-dumper-bar.default.svc.cluster.local + - namespace: default + name: c2 + fanoutConfig: + subscriptions: + - toDomain: message-dumper-foo.default.svc.cluster.local + - namespace: other + name: c3 + fanoutConfig: + subscriptions: + - toDomain: message-dumper-foo.default.svc.cluster.local + `, + expected: multichannelfanout.Config{ + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: "default", + Name: "c1", + FanoutConfig: fanout.Config{ + Subscriptions: []fanout.Subscription{ + { + CallDomain: "event-changer.default.svc.cluster.local", + ToDomain: "message-dumper-bar.default.svc.cluster.local", + }, + { + CallDomain: "message-dumper-foo.default.svc.cluster.local", + }, + { + ToDomain: "message-dumper-bar.default.svc.cluster.local", + }, + }, + }, + }, + { + Namespace: "default", + Name: "c2", + FanoutConfig: fanout.Config{ + Subscriptions: []fanout.Subscription{ + { + ToDomain: "message-dumper-foo.default.svc.cluster.local", + }, + }, + }, + }, + { + Namespace: "other", + Name: "c3", + FanoutConfig: fanout.Config{ + Subscriptions: []fanout.Subscription{ + { + ToDomain: "message-dumper-foo.default.svc.cluster.local", + }, + }, + }, + }, + }, + }, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + var dir string + if tc.createDir { + dir = createTempDir(t) + defer os.RemoveAll(dir) + } else { + dir = "/tmp/doesNotExist" + } + writeConfig(t, dir, tc.config) + c, e := readConfigMap(zap.NewNop(), dir) + if tc.expectedErr { + if e == nil { + t.Errorf("Expected an error, actual nil") + } + return + } + if !cmp.Equal(c, tc.expected) { + t.Errorf("Unexpected config. Expected '%v'. Actual '%v'.", tc.expected, c) + } + }) + } +} + +func TestNewHandler(t *testing.T) { + testCases := []struct { + name string + createDir bool + config string + expectErr bool + }{ + { + name: "dir does not exist", + createDir: false, + expectErr: true, + }, + { + name: "duplicate channel key", + createDir: true, + config: ` + channelConfigs: + - namespace: default + name: duplicate + - namespace: default + name: duplicate + `, + expectErr: true, + }, + { + name: "success", + createDir: true, + config: ` + channelConfigs: [] + `, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + var dir string + if tc.createDir { + dir = createTempDir(t) + defer os.RemoveAll(dir) + } else { + dir = "/tmp/doesNotExist" + } + writeConfig(t, dir, tc.config) + cmh, err := NewHandler(zap.NewNop(), dir, &fake.ClientFactory{}) + if err == nil { + // This is not yet about the logic of the test, just ensuring we don't accidentally + // leave the channel open, which will leave the watcher running. + defer close(cmh.(*configMapHandler).watcherStopCh) + } + if tc.expectErr { + if err == nil { + t.Errorf("Expected an error, actually nil") + } + return + } + }) + } +} + +func TestServeHTTP(t *testing.T) { + testCases := []struct { + name string + initialConfig string + updatedConfig string + expectedInitialDomain string + expectedUpdatedDomain string + }{ + { + name: "send to config", + initialConfig: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - toDomain: initial-domain + `, + expectedInitialDomain: "initial-domain", + }, + { + name: "change config", + initialConfig: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - toDomain: initial-domain + `, + expectedInitialDomain: "initial-domain", + updatedConfig: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - toDomain: updated-domain + `, + expectedUpdatedDomain: "updated-domain", + }, + { + name: "bad config update -- keeps serving old config", + initialConfig: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - toDomain: initial-domain + `, + expectedInitialDomain: "initial-domain", + updatedConfig: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - toDomain: updated-domain + # Duplicate namespace/name + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - toDomain: updated-domain + `, + expectedUpdatedDomain: "initial-domain", + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + dir := createTempDir(t) + defer os.RemoveAll(dir) + writeConfig(t, dir, tc.initialConfig) + + cf := &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusOK, + Body: body(""), + }, + }, + } + cmh, _ := NewHandler(zap.NewNop(), dir, cf) + + w := httptest.NewRecorder() + cmh.ServeHTTP(w, makeRequest("default", "c1")) + if w.Result().StatusCode != http.StatusOK { + t.Errorf("Unexpected initial status code: %v", w.Result().StatusCode) + } + if initialHost := cf.GetRequests()[0].Host; initialHost != tc.expectedInitialDomain { + t.Errorf("Sent initial request to wrong domain. Expected: '%v'. Actual '%v'", tc.expectedInitialDomain, initialHost) + } + + if tc.updatedConfig != "" { + writeConfig(t, dir, tc.updatedConfig) + // The watcher is running in another routine, give it some time to notice the + // change. + time.Sleep(100 * time.Millisecond) + w = httptest.NewRecorder() + cmh.ServeHTTP(w, makeRequest("default", "c1")) + if w.Result().StatusCode != http.StatusOK { + t.Errorf("Unexpected updated status code: %v", w.Result().StatusCode) + } + if updatedDomain := cf.GetRequests()[1].Host; updatedDomain != tc.expectedUpdatedDomain { + t.Errorf("Sent updated request to wrong domain. Expected: '%v'. Actual: '%v'", tc.expectedUpdatedDomain, updatedDomain) + } + } + }) + } +} + +func createTempDir(t *testing.T) string { + dir, err := ioutil.TempDir("", "configMapHandlerTest") + if err != nil { + t.Errorf("Unable to make temp directory: %v", err) + } + return dir +} + +func writeConfig(t *testing.T, dir, config string) { + if config != "" { + // Golang editors tend to replace leading spaces with tabs. YAML is left whitespace + // sensitive, so let's replace the tabs with spaces. + leftSpaceConfig := strings.Replace(config, "\t", " ", -1) + err := ioutil.WriteFile(fmt.Sprintf("%s/%s", dir, multiChannelFanoutConfigKey), []byte(leftSpaceConfig), 0700) + if err != nil { + t.Errorf("Problem writing the config file: %v", err) + } + } +} + +func body(body string) io.ReadCloser { + return ioutil.NopCloser(strings.NewReader(body)) +} + +func makeRequest(namespace, name string) *http.Request { + r := httptest.NewRequest("POST", "http://example/", body("")) + r.Header.Add(multichannelfanout.ChannelKeyHeader, multichannelfanout.MakeChannelKey(namespace, name)) + return r +} diff --git a/pkg/sidecar/fanout/fanout_handler.go b/pkg/sidecar/fanout/fanout_handler.go new file mode 100644 index 00000000000..661ca322c09 --- /dev/null +++ b/pkg/sidecar/fanout/fanout_handler.go @@ -0,0 +1,181 @@ +/* +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 fanout + +import ( + "fmt" + "github.com/knative/eventing/pkg/buses" + "github.com/knative/eventing/pkg/sidecar/clientfactory" + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "go.uber.org/zap" + "math/rand" + "net/http" + "sync" +) + +const ( + // The header attached to requests sent through the MessageReceiver. It is used to correlate the + // request going into the MessageReceiver and the request coming out of the MessageReceiver. + // Note that it _must_ be in the headers forwarded by the MessageReceiver. + uniqueFanoutHeader = "Knative-Fanout-Message-Tracker" +) + +// Configuration for a fanout.Handler. +type Config struct { + Subscriptions []duckv1alpha1.ChannelSubscriberSpec `json:"subscriptions"` +} + +// http.Handler that takes a single request in and fans it out to N other servers. +type fanoutHandler struct { + logger *zap.Logger + config Config + clientFactory clientfactory.ClientFactory + + receivedMessages *messageStorage + + receiver *buses.MessageReceiver + dispatcher *buses.MessageDispatcher +} + +var _ http.Handler = &fanoutHandler{} + +func NewHandler(logger *zap.Logger, config Config, cf clientfactory.ClientFactory) http.Handler { + handler := &fanoutHandler{ + logger: logger, + config: config, + clientFactory: cf, + dispatcher : buses.NewMessageDispatcher(logger.Sugar()), + receivedMessages: &messageStorage{ + messages: make(map[string]*buses.Message), + }, + } + // The receiver function needs to point back at the handler itself, so setup it after + // initialization. + handler.receiver = buses.NewMessageReceiver(createReceiverFunction(handler), logger.Sugar()) + return handler +} + +func createReceiverFunction(f *fanoutHandler) func(buses.ChannelReference, *buses.Message) error { + return func(_ buses.ChannelReference, m *buses.Message) error { + f.logger.Debug("Putting message", zap.String("key", m.Headers[uniqueFanoutHeader])) + f.receivedMessages.Put(m) + return nil + } +} + +// ServeHTTP takes the request, fans it out to each subscription in f.config. If all the fanned out +// requests return successfully, then return successfully. Else, return failure. +func (f *fanoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + key := addTrackingHeader(r) + receiverResponse := &response{} + f.receiver.HandleRequest(receiverResponse, r) + + if receiverResponse.statusCode != http.StatusAccepted { + f.logger.Info("MessageReceiver rejected the request", zap.Int("statusCode", receiverResponse.statusCode)) + w.WriteHeader(receiverResponse.statusCode) + return + } + + f.logger.Debug("Pulling message", zap.String("key", key)) + m, err := f.receivedMessages.Pull(key) + if err != nil { + f.logger.Info("Could not find tracked message", zap.Error(err), zap.Any("key", r.Header[uniqueFanoutHeader])) + w.WriteHeader(http.StatusInternalServerError) + return + } + removeTrackingHeader(m) + + errorCh := make(chan error, len(f.config.Subscriptions)) + for _, sub := range f.config.Subscriptions { + go func(s duckv1alpha1.ChannelSubscriberSpec) { + errorCh <- f.makeFanoutRequest(r, *m, s) + }(sub) + } + + sc := http.StatusOK + for range f.config.Subscriptions { + if err = <-errorCh; err != nil { + f.logger.Error("Fanout had an error", zap.Error(err)) + sc = http.StatusInternalServerError + } + } + + w.WriteHeader(sc) +} + +// makeFanoutRequest sends the request to exactly one subscription. It handles both the `call` and +// the `to` portions of the subscription. +func (f *fanoutHandler) makeFanoutRequest(r *http.Request, m buses.Message, sub duckv1alpha1.ChannelSubscriberSpec) error { + return f.dispatcher.DispatchMessage(&m, sub.CallableDomain, sub.SinkableDomain, buses.DispatchDefaults{}) +} + +// response is used to capture the statusCode returned by the messageReceiver. +type response struct { + statusCode int +} + +var _ http.ResponseWriter = &response{} + +func (*response) Header() http.Header { + return http.Header{} +} + +func (*response) Write(b []byte) (int, error) { + return len(b), nil +} + +func (r *response) WriteHeader(statusCode int) { + r.statusCode = statusCode +} + + +type messageStorage struct { + messagesLock sync.Mutex + messages map[string]*buses.Message +} + +func (ms *messageStorage) Put(m *buses.Message) { + key := m.Headers[uniqueFanoutHeader] + + ms.messagesLock.Lock() + defer ms.messagesLock.Unlock() + + ms.messages[key] = m +} + +func (ms *messageStorage) Pull(key string) (*buses.Message, error) { + ms.messagesLock.Lock() + defer ms.messagesLock.Unlock() + + if m, ok := ms.messages[key]; ok { + delete(ms.messages, key) + return m, nil + } else { + return nil, fmt.Errorf("could not find message: %v", key) + } +} + +func addTrackingHeader(r *http.Request) string { + // Use two random 63 bit ints, as a poor approximation of a UUID. + key := fmt.Sprintf("%X-%X", rand.Int63(), rand.Int63()) + r.Header.Set(uniqueFanoutHeader, key) + return key +} + +func removeTrackingHeader(m *buses.Message) { + delete(m.Headers, uniqueFanoutHeader) +} diff --git a/pkg/sidecar/fanout/fanout_handler_test.go b/pkg/sidecar/fanout/fanout_handler_test.go new file mode 100644 index 00000000000..61b17ff97eb --- /dev/null +++ b/pkg/sidecar/fanout/fanout_handler_test.go @@ -0,0 +1,502 @@ +/* +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 fanout + +import ( + "errors" + "fmt" + "github.com/knative/eventing/pkg/sidecar/clientfactory/fake" + "go.uber.org/zap" + "io" + "io/ioutil" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +func TestIs2xx(t *testing.T) { + testCases := []struct { + sc int + is2xx bool + }{ + { + sc: http.StatusContinue, + is2xx: false, + }, + { + sc: http.StatusOK, + is2xx: true, + }, + { + sc: http.StatusCreated, + is2xx: true, + }, + { + sc: http.StatusAccepted, + is2xx: true, + }, + { + sc: http.StatusNoContent, + is2xx: true, + }, + { + sc: http.StatusAlreadyReported, + is2xx: true, + }, + { + sc: http.StatusBadRequest, + is2xx: false, + }, + { + sc: http.StatusUnauthorized, + is2xx: false, + }, + { + sc: http.StatusForbidden, + is2xx: false, + }, + { + sc: http.StatusNotFound, + is2xx: false, + }, + { + sc: http.StatusMethodNotAllowed, + is2xx: false, + }, + { + sc: http.StatusNotAcceptable, + is2xx: false, + }, + { + sc: http.StatusConflict, + is2xx: false, + }, + { + sc: http.StatusGone, + is2xx: false, + }, + { + sc: http.StatusPreconditionFailed, + is2xx: false, + }, + { + sc: http.StatusTooManyRequests, + is2xx: false, + }, + { + sc: http.StatusInternalServerError, + is2xx: false, + }, + { + sc: http.StatusServiceUnavailable, + is2xx: false, + }, + } + for _, tc := range testCases { + t.Run(fmt.Sprintf("%v", tc.sc), func(t *testing.T) { + resp := &http.Response{ + StatusCode: tc.sc, + } + if is2xx(resp) != tc.is2xx { + t.Errorf("Unexpected is2xx for %v. Expected %v. Actual %v", tc.sc, tc.is2xx, is2xx(resp)) + } + }) + } +} + +func TestDomainToUrl(t *testing.T) { + expected := "http://foobar/" + if actual := domainToURL("foobar"); expected != actual { + t.Errorf("Unexpected domainToURL. Expected: '%v'. Actual: '%v'", expected, actual) + } +} + +func TestServeHTTP(t *testing.T) { + testCases := []struct { + name string + subs []Subscription + cf *fake.ClientFactory + origBody io.Reader + expectedStatus int + }{ + { + name: "cannot read orig body", + subs: []Subscription{}, + origBody: &failingReader{}, + cf: &fake.ClientFactory{}, + expectedStatus: http.StatusInternalServerError, + }, + { + name: "no subs", + subs: []Subscription{}, + origBody: body(""), + cf: &fake.ClientFactory{}, + expectedStatus: http.StatusOK, + }, + { + name: "one sub -- failed", + subs: []Subscription{ + { + ToDomain: "todomain", + }, + }, + origBody: body(""), + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusNotFound, + Body: body(""), + }, + }, + }, + expectedStatus: http.StatusInternalServerError, + }, + { + name: "one sub -- succeeded", + subs: []Subscription{ + { + ToDomain: "todomain", + }, + }, + origBody: body(""), + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusOK, + Body: body(""), + }, + }, + }, + expectedStatus: http.StatusOK, + }, + { + name: "two subs -- one fails", + subs: []Subscription{ + { + ToDomain: "todomain", + }, + { + CallDomain: "calldomain", + }, + }, + origBody: body(""), + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusForbidden, + Body: body(""), + }, + { + StatusCode: http.StatusOK, + Body: body(""), + }, + }, + }, + expectedStatus: http.StatusInternalServerError, + }, + { + name: "two subs -- both succeed", + subs: []Subscription{ + { + ToDomain: "todomain", + }, + { + CallDomain: "calldomain", + }, + }, + origBody: body(""), + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusOK, + Body: body(""), + }, + }, + }, + expectedStatus: http.StatusOK, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + config := Config{ + Subscriptions: tc.subs, + } + f := NewHandler(zap.NewNop(), config, tc.cf) + + r := httptest.NewRequest("POST", "http://unused/", tc.origBody) + + w := httptest.NewRecorder() + f.ServeHTTP(w, r) + + if w.Result().StatusCode != tc.expectedStatus { + t.Errorf("Unexpected status code. Expected %v. Actual %v.", tc.expectedStatus, w.Result().StatusCode) + } + }) + } +} + +func TestMakeFanoutRequest(t *testing.T) { + testCases := []struct { + name string + cf *fake.ClientFactory + sub Subscription + origBody string + expectedErr bool + expectedNumReq int + expectedReqBodies []string + }{ + { + name: "`call` fails", + sub: Subscription{ + CallDomain: "calldomain", + }, + cf: &fake.ClientFactory{ + RespErr: errors.New("error making request"), + }, + expectedErr: true, + expectedNumReq: 1, + }, + { + name: "`call` non-2xx", + sub: Subscription{ + CallDomain: "calldomain", + }, + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusForbidden, + Body: body(""), + }, + }, + }, + expectedErr: true, + expectedNumReq: 1, + }, + { + name: "`only `call`", + sub: Subscription{ + CallDomain: "calldomain", + }, + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusOK, + Body: body(""), + }, + }, + }, + origBody: "{orig:body}", + expectedNumReq: 1, + expectedReqBodies: []string{ + "{orig:body}", + }, + }, + { + name: "`to` fails", + sub: Subscription{ + ToDomain: "todomain", + }, + cf: &fake.ClientFactory{ + RespErr: errors.New("error making request"), + }, + expectedErr: true, + expectedNumReq: 1, + }, + { + name: "`to` non-2xx", + sub: Subscription{ + ToDomain: "todomain", + }, + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusInternalServerError, + Body: body(""), + }, + }, + }, + expectedErr: true, + expectedNumReq: 1, + }, + { + name: "only `to`", + sub: Subscription{ + ToDomain: "todomain", + }, + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusOK, + Body: body(""), + }, + }, + }, + origBody: "{orig:body}", + expectedNumReq: 1, + expectedReqBodies: []string{ + "{orig:body}", + }, + }, + { + name: "`call` and `to`", + sub: Subscription{ + CallDomain: "calldomain", + ToDomain: "todomain", + }, + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusOK, + Body: body("{call:body}"), + }, + }, + }, + origBody: "{orig:body}", + expectedNumReq: 2, + expectedReqBodies: []string{ + "{orig:body}", + "{call:body}", + }, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + f := fanoutHandler{ + logger: zap.NewNop(), + clientFactory: tc.cf, + } + r := httptest.NewRequest("POST", "http://unused/", nil) + err := f.makeFanoutRequest(r, []byte(tc.origBody), tc.sub) + reqs := tc.cf.GetRequests() + if numReq := len(reqs); numReq != tc.expectedNumReq { + t.Errorf("Incorrect number of requests. Expected %v. Actual %v", tc.expectedNumReq, reqs) + } + if tc.expectedErr { + if err == nil { + t.Errorf("Expected an error making the fanout request. Actual: nil") + } + return + } + for i := range tc.expectedReqBodies { + expected := tc.expectedReqBodies[i] + actualBytes, _ := ioutil.ReadAll(reqs[i].Body) + actual := string(actualBytes) + if actual != expected { + t.Errorf("Unexpected req body. Index %v. Expected %v. Actual %v.", i, expected, actual) + } + } + }) + } +} + +func TestMakeRequest(t *testing.T) { + testCases := []struct { + name string + method string + cf *fake.ClientFactory + origHeaders http.Header + body string + expectedErr bool + expectedStatusCode int + expectedBody string + }{ + { + name: "bad method", + method: "not_a_valid::/method", + expectedErr: true, + }, + { + name: "bad client factory", + method: "POST", + cf: &fake.ClientFactory{ + CreateErr: errors.New("test-induced client creation failure"), + }, + expectedErr: true, + }, + { + name: "unable to make request", + method: "POST", + cf: &fake.ClientFactory{ + RespErr: errors.New("test-induced HTTP Do failure"), + }, + expectedErr: true, + }, + { + name: "bad status code", + method: "POST", + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusNotFound, + Body: body(""), + }, + }, + }, + expectedErr: true, + }, + { + name: "good response", + method: "POST", + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusOK, + Body: body("{hello:world}"), + }, + }, + }, + expectedStatusCode: http.StatusOK, + expectedBody: "{hello:world}", + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + f := &fanoutHandler{ + logger: zap.NewNop(), + clientFactory: tc.cf, + } + or := &http.Request{ + Method: tc.method, + Header: tc.origHeaders, + } + resp, err := f.makeRequest(or, strings.NewReader(tc.body), "domain") + if tc.expectedErr { + if err == nil { + t.Errorf("Expected an error, but did not get one.") + } + return + } else if err != nil { + t.Errorf("Unexpected error. %v", err) + } + if actual, _ := ioutil.ReadAll(resp.Body); resp.StatusCode != tc.expectedStatusCode || string(actual) != tc.expectedBody { + t.Errorf("Unexpected response. Expected: %v, '%v'. Actual '%v'.", tc.expectedStatusCode, tc.expectedBody, resp) + } + + }) + } +} + +func body(body string) io.ReadCloser { + return ioutil.NopCloser(strings.NewReader(body)) +} + +type failingReader struct{} + +func (_ *failingReader) Read(p []byte) (int, error) { + return 0, errors.New("test-induced error reading") +} diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go new file mode 100644 index 00000000000..e282c658404 --- /dev/null +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go @@ -0,0 +1,121 @@ +/* +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 multichannelfanout + +import ( + "fmt" + "github.com/google/go-cmp/cmp" + "github.com/knative/eventing/pkg/buses" + "github.com/knative/eventing/pkg/sidecar/clientfactory" + "github.com/knative/eventing/pkg/sidecar/fanout" + "go.uber.org/zap" + "net/http" +) + +const ( + // The header injected into requests to state which `Channel` this request is being sent on. The + // value is in the format created by multichannelfanout.MakeChannelKey(). + ChannelKeyHeader = "X-Channel-Key" +) + +// The configuration of this handler. +type Config struct { + // The configuration of each channel in this handler. + ChannelConfigs []ChannelConfig `json:"channelConfigs"` +} + +type ChannelConfig struct { + Namespace string `json:"namespace"` + Name string `json:"name"` + FanoutConfig fanout.Config `json:"fanoutConfig"` +} + +// MakeChannelKey creates the value to be sent in the HTTP header +// multichannelfanout.ChannelKeyHeader. This represents the `Channel` the request is being sent +// upon. +func MakeChannelKey(namespace, name string) string { + return fmt.Sprintf("%s/%s", namespace, name) +} + +// makeChannelKeyFromConfig creates the channel key for a given channelConfig. It is a helper around +// MakeChannelKey. +func makeChannelKeyFromConfig(config ChannelConfig) string { + return MakeChannelKey(config.Namespace, config.Name) +} + +// getChannelKey extracts the channel key from the given HTTP request. +func getChannelKey(r *http.Request) string { + cr := buses.ParseChannel(r.Host) + return fmt.Sprintf("%s/%s", cr.Namespace, cr.Name) +} + +// Handler is an http.Handler that looks in the HTTP headers of a request for the +// multichannelfanout.ChannelKeyHeader and uses its value to determine which fanout.Handler to +// delegate the request to. +type Handler struct { + logger *zap.Logger + handlers map[string]http.Handler + config Config + clientFactory clientfactory.ClientFactory +} + +func NewHandler(logger *zap.Logger, conf Config, cf clientfactory.ClientFactory) (*Handler, error) { + handlers := make(map[string]http.Handler, len(conf.ChannelConfigs)) + + for _, cc := range conf.ChannelConfigs { + key := makeChannelKeyFromConfig(cc) + handler := fanout.NewHandler(logger, cc.FanoutConfig, cf) + if _, present := handlers[key]; present { + logger.Error("Duplicate channel key", zap.String("channelKey", key)) + return nil, fmt.Errorf("duplicate channel key: %v", key) + } + handlers[key] = handler + } + + return &Handler{ + logger: logger, + config: conf, + handlers: handlers, + clientFactory: cf, + }, nil +} + +// ConfigDiffs diffs the new config with the existing config. If there are no differences, then the +// empty string is returned. If there are differences, then a non-empty string is returned +// describing the differences. +func (h *Handler) ConfigDiff(updated Config) string { + return cmp.Diff(h.config, updated) +} + +// CopyWithNewConfig creates a new copy of this Handler with all the fields identical, except the +// new Handler uses conf, rather than copying the existing Handler's config. +func (h *Handler) CopyWithNewConfig(conf Config) (*Handler, error) { + return NewHandler(h.logger, conf, h.clientFactory) +} + +// ServeHTTP delegates the actual handling of the request to a fanout.Handler, based on the +// request's channel key. +func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + channelKey:= getChannelKey(r) + fh, ok := h.handlers[channelKey] + if !ok { + h.logger.Error("Unable to find a handler for request", zap.String("channelKey", channelKey)) + w.WriteHeader(http.StatusInternalServerError) + return + } + fh.ServeHTTP(w, r) +} diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go new file mode 100644 index 00000000000..769843f567f --- /dev/null +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go @@ -0,0 +1,406 @@ +/* +Copyright 2018 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT 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 multichannelfanout + +import ( + "fmt" + "github.com/google/go-cmp/cmp" + "github.com/knative/eventing/pkg/sidecar/clientfactory/fake" + "github.com/knative/eventing/pkg/sidecar/fanout" + "go.uber.org/zap" + "io/ioutil" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +func TestMakeChannelKey(t *testing.T) { + testCases := []struct { + namespace string + name string + key string + }{ + { + namespace: "default", + name: "channel", + key: "default/channel", + }, + { + namespace: "foo", + name: "bar", + key: "foo/bar", + }, + } + for _, tc := range testCases { + name := fmt.Sprintf("%s, %s -> %s", tc.namespace, tc.name, tc.key) + t.Run(name, func(t *testing.T) { + if key := MakeChannelKey(tc.namespace, tc.name); key != tc.key { + t.Errorf("Unexpected ChannelKey. Expected '%v'. Actual '%v'", tc.key, key) + } + }) + } +} + +func TestGetChannelKey(t *testing.T) { + testCases := []struct { + name string + headers map[string]string + expected string + expectedErr bool + }{ + { + name: "no header", + expectedErr: true, + }, + { + name: "header missing", + headers: map[string]string{ + "User-Agent": "1234", + }, + expectedErr: true, + }, + { + name: "header present without value", + headers: map[string]string{ + ChannelKeyHeader: "", + }, + expected: "", + }, + { + name: "header present", + headers: map[string]string{ + ChannelKeyHeader: "default/c1", + }, + expected: "default/c1", + }, + } + requestWithHeaders := func(headers map[string]string) *http.Request { + r := httptest.NewRequest("POST", "http://target/", strings.NewReader("{}")) + for existing := range r.Header { + r.Header.Del(existing) + } + for h, v := range headers { + r.Header.Set(h, v) + } + return r + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + r := requestWithHeaders(tc.headers) + key, err := getChannelKey(r) + if tc.expectedErr { + if err == nil { + t.Errorf("Expected an error, did not get one.") + } + } + if key != tc.expected { + t.Errorf("Incorrect channel key. Expected '%v'. Actual '%v'", tc.expected, key) + } + }) + } +} + +func TestNewHandler(t *testing.T) { + testCases := []struct { + name string + config Config + createErr string + }{ + { + name: "duplicate channel key", + config: Config{ + ChannelConfigs: []ChannelConfig{ + { + Namespace: "default", + Name: "duplicate", + }, + { + Namespace: "default", + Name: "duplicate", + }, + }, + }, + createErr: "duplicate channel key: default/duplicate", + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + _, err := NewHandler(zap.NewNop(), tc.config, &fake.ClientFactory{}) + if tc.createErr != "" { + if err == nil { + t.Errorf("Expected NewHandler error: '%v'. Actual nil", tc.createErr) + } else if err.Error() != tc.createErr { + t.Errorf("Unexpected NewHandler error. Expected '%v'. Actual '%v'", tc.createErr, err) + } + return + } else if err != nil { + t.Errorf("Unexpected NewHandler error. Expected nil. Actual '%v'", err) + } + }) + } +} + +func TestCopyWithNewConfig(t *testing.T) { + orig := Config{ + ChannelConfigs: []ChannelConfig{ + { + Namespace: "default", + Name: "c1", + FanoutConfig: fanout.Config{ + Subscriptions: []fanout.Subscription{ + { + CallDomain: "calldomain", + }, + }, + }, + }, + }, + } + updated := Config{ + ChannelConfigs: []ChannelConfig{ + { + Namespace: "default", + Name: "somethingdifferent", + FanoutConfig: fanout.Config{ + Subscriptions: []fanout.Subscription{ + { + ToDomain: "todomain", + }, + }, + }, + }, + }, + } + if cmp.Equal(orig, updated) { + t.Errorf("Orig and updated must be different") + } + h, err := NewHandler(zap.NewNop(), orig, &fake.ClientFactory{ + CreateErr: fmt.Errorf("random error that makes this client unique"), + }) + if err != nil { + t.Errorf("Unable to create handler, %v", err) + } + if !cmp.Equal(h.config, orig) { + t.Errorf("Incorrect config. Expected '%v'. Actual '%v'", orig, h.config) + } + newH, err := h.CopyWithNewConfig(updated) + if err != nil { + t.Errorf("Unable to copy handler: %v", err) + } + if h.logger != newH.logger { + t.Errorf("Did not copy logger") + } + if h.clientFactory != newH.clientFactory { + t.Errorf("Did not copy clientFactory") + } + if !cmp.Equal(newH.config, updated) { + t.Errorf("Incorrect copied config. Expected '%v'. Actual '%v'", updated, newH.config) + } +} + +func TestConfigDiff(t *testing.T) { + config := Config{ + ChannelConfigs: []ChannelConfig{ + { + Namespace: "default", + Name: "c1", + FanoutConfig: fanout.Config{ + Subscriptions: []fanout.Subscription{ + { + CallDomain: "calldomain", + }, + }, + }, + }, + }, + } + testCases := []struct { + name string + orig Config + updated Config + expectedDiff bool + }{ + { + name: "same", + orig: config, + updated: config, + expectedDiff: false, + }, + { + name: "different", + orig: config, + updated: Config{ + ChannelConfigs: []ChannelConfig{ + { + Namespace: "default", + Name: "c1", + FanoutConfig: fanout.Config{ + Subscriptions: []fanout.Subscription{ + { + CallDomain: "different", + }, + }, + }, + }, + }, + }, + expectedDiff: true, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + h, err := NewHandler(zap.NewNop(), tc.orig, &fake.ClientFactory{}) + if err != nil { + t.Errorf("Unable to create handler: %v", err) + } + diff := h.ConfigDiff(tc.updated) + + if hasDiff := diff != ""; hasDiff != tc.expectedDiff { + t.Errorf("Unexpected diff result. Expected %v. Actual %v", tc.expectedDiff, hasDiff) + } + }) + } +} + +func TestServeHTTP(t *testing.T) { + testCases := []struct { + name string + config Config + cf *fake.ClientFactory + h http.Header + key string + expectedStatusCode int + requestDomain string + }{ + { + name: "non-existent channel", + config: Config{}, + cf: &fake.ClientFactory{}, + key: "default/does-not-exist", + expectedStatusCode: http.StatusInternalServerError, + }, + { + name: "no channel key", + config: Config{}, + cf: &fake.ClientFactory{}, + key: "", + expectedStatusCode: http.StatusBadRequest, + }, + { + name: "pass through failure", + config: Config{ + ChannelConfigs: []ChannelConfig{ + { + Namespace: "default", + Name: "first-channel", + FanoutConfig: fanout.Config{ + Subscriptions: []fanout.Subscription{ + { + ToDomain: "first-to-domain", + }, + }, + }, + }, + }, + }, + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusInternalServerError, + Body: ioutil.NopCloser(strings.NewReader("{}")), + }, + }, + }, + key: "default/first-channel", + expectedStatusCode: http.StatusInternalServerError, + }, + { + name: "choose channel", + config: Config{ + ChannelConfigs: []ChannelConfig{ + { + Namespace: "default", + Name: "first-channel", + FanoutConfig: fanout.Config{ + Subscriptions: []fanout.Subscription{ + { + ToDomain: "first-to-domain", + }, + }, + }, + }, + { + Namespace: "default", + Name: "second-channel", + FanoutConfig: fanout.Config{ + Subscriptions: []fanout.Subscription{ + { + CallDomain: "second-call-domain", + }, + }, + }, + }, + }, + }, + cf: &fake.ClientFactory{ + Resp: []*http.Response{ + { + StatusCode: http.StatusOK, + Body: ioutil.NopCloser(strings.NewReader("{}")), + }, + }, + }, + key: "default/second-channel", + requestDomain: "second-call-domain", + expectedStatusCode: http.StatusOK, + }, + } + requestWithChannelKey := func(key string) *http.Request { + r := httptest.NewRequest("POST", "http://target/", strings.NewReader("{}")) + if key != "" { + r.Header.Set(ChannelKeyHeader, key) + } + return r + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + h, err := NewHandler(zap.NewNop(), tc.config, tc.cf) + if err != nil { + t.Errorf("Unexpected NewHandler error: '%v'", err) + } + + r := requestWithChannelKey(tc.key) + w := httptest.NewRecorder() + h.ServeHTTP(w, r) + resp := w.Result() + if resp.StatusCode != tc.expectedStatusCode { + t.Errorf("Unexpected status code. Expected %v, actual %v", tc.expectedStatusCode, resp.StatusCode) + } + if w.Body.String() != "" { + t.Errorf("Expected empty response body. Actual: %v", w.Body) + } + if tc.requestDomain != "" { + reqs := tc.cf.GetRequests() + if reqs[0].Host != tc.requestDomain { + t.Errorf("Called incorrect domain. Expected: '%v'. Actual '%v'", tc.requestDomain, reqs[0].Host) + } + } + }) + } +} diff --git a/pkg/sidecar/swappable/swappable.go b/pkg/sidecar/swappable/swappable.go new file mode 100644 index 00000000000..188c0b00819 --- /dev/null +++ b/pkg/sidecar/swappable/swappable.go @@ -0,0 +1,69 @@ +/* +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 swappable + +import ( + "github.com/knative/eventing/pkg/sidecar/clientfactory" + "github.com/knative/eventing/pkg/sidecar/multichannelfanout" + "go.uber.org/zap" + "net/http" + "sync/atomic" +) + +// http.Handler that atomically swapping between underlying handlers. +type Handler struct { + // The current multichannelfanout.Handler to delegate HTTP requests to. Never use this directly, + // instead use {get,set}MultiChannelFanoutHandler, which enforces the type we expect. + fanout atomic.Value + logger *zap.Logger +} + +// NewHandler creates a new swappable.Handler. +func NewHandler(handler *multichannelfanout.Handler, logger *zap.Logger) (*Handler, error) { + h := &Handler{ + logger: logger.With(zap.String("httpHandler", "swappable")), + } + h.SetMultiChannelFanoutHandler(handler) + return h, nil +} + +func NewEmptyHandler(logger *zap.Logger, cf clientfactory.ClientFactory) (*Handler, error) { + h, err := multichannelfanout.NewHandler(logger, multichannelfanout.Config{}, cf) + if err != nil { + return nil, err + } + return NewHandler(h, logger) +} + +// getMultiChannelFanoutHandler gets the current multichannelfanout.Handler to delegate all HTTP +// requests to. +func (h *Handler) GetMultiChannelFanoutHandler() *multichannelfanout.Handler { + return h.fanout.Load().(*multichannelfanout.Handler) +} + +// setMultiChannelFanoutHandler sets a new multichannelfanout.Handler to delegate all subsequent +// HTTP requests to. +func (h *Handler) SetMultiChannelFanoutHandler(new *multichannelfanout.Handler) { + h.fanout.Store(new) +} + +// ServeHTTP delegates all HTTP requests to the current multichannelfanout.Handler. +func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + // Hand work off to the current multi channel fanout handler. + h.logger.Debug("ServeHTTP request received") + h.GetMultiChannelFanoutHandler().ServeHTTP(w, r) +} From b850e29365d0f0ddbecf55b2bd4c60440ba109fa Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Wed, 26 Sep 2018 15:41:37 -0700 Subject: [PATCH 04/23] Switch to ChannelSubscriberSpec. --- .../config_map_handler_test.go | 19 ++-- pkg/sidecar/fanout/fanout_handler.go | 4 +- pkg/sidecar/fanout/fanout_handler_test.go | 59 +++++------ .../multi_channel_fanout_handler_test.go | 99 ++++--------------- pkg/sidecar/swappable/swappable_test.go | 17 ++++ 5 files changed, 78 insertions(+), 120 deletions(-) create mode 100644 pkg/sidecar/swappable/swappable_test.go diff --git a/pkg/sidecar/configmaphandler/config_map_handler_test.go b/pkg/sidecar/configmaphandler/config_map_handler_test.go index ff88b6c6963..41629f3ffed 100644 --- a/pkg/sidecar/configmaphandler/config_map_handler_test.go +++ b/pkg/sidecar/configmaphandler/config_map_handler_test.go @@ -22,6 +22,7 @@ import ( "github.com/knative/eventing/pkg/sidecar/clientfactory/fake" "github.com/knative/eventing/pkg/sidecar/fanout" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" "go.uber.org/zap" "io" "io/ioutil" @@ -102,16 +103,16 @@ func TestReadConfigMap(t *testing.T) { Namespace: "default", Name: "c1", FanoutConfig: fanout.Config{ - Subscriptions: []fanout.Subscription{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - CallDomain: "event-changer.default.svc.cluster.local", - ToDomain: "message-dumper-bar.default.svc.cluster.local", + CallableDomain: "event-changer.default.svc.cluster.local", + SinkableDomain: "message-dumper-bar.default.svc.cluster.local", }, { - CallDomain: "message-dumper-foo.default.svc.cluster.local", + CallableDomain: "message-dumper-foo.default.svc.cluster.local", }, { - ToDomain: "message-dumper-bar.default.svc.cluster.local", + SinkableDomain: "message-dumper-bar.default.svc.cluster.local", }, }, }, @@ -120,9 +121,9 @@ func TestReadConfigMap(t *testing.T) { Namespace: "default", Name: "c2", FanoutConfig: fanout.Config{ - Subscriptions: []fanout.Subscription{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - ToDomain: "message-dumper-foo.default.svc.cluster.local", + SinkableDomain: "message-dumper-foo.default.svc.cluster.local", }, }, }, @@ -131,9 +132,9 @@ func TestReadConfigMap(t *testing.T) { Namespace: "other", Name: "c3", FanoutConfig: fanout.Config{ - Subscriptions: []fanout.Subscription{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - ToDomain: "message-dumper-foo.default.svc.cluster.local", + SinkableDomain: "message-dumper-foo.default.svc.cluster.local", }, }, }, diff --git a/pkg/sidecar/fanout/fanout_handler.go b/pkg/sidecar/fanout/fanout_handler.go index 661ca322c09..6f647224799 100644 --- a/pkg/sidecar/fanout/fanout_handler.go +++ b/pkg/sidecar/fanout/fanout_handler.go @@ -91,7 +91,7 @@ func (f *fanoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } f.logger.Debug("Pulling message", zap.String("key", key)) - m, err := f.receivedMessages.Pull(key) + m, err := f.receivedMessages.pull(key) if err != nil { f.logger.Info("Could not find tracked message", zap.Error(err), zap.Any("key", r.Header[uniqueFanoutHeader])) w.WriteHeader(http.StatusInternalServerError) @@ -157,7 +157,7 @@ func (ms *messageStorage) Put(m *buses.Message) { ms.messages[key] = m } -func (ms *messageStorage) Pull(key string) (*buses.Message, error) { +func (ms *messageStorage) pull(key string) (*buses.Message, error) { ms.messagesLock.Lock() defer ms.messagesLock.Unlock() diff --git a/pkg/sidecar/fanout/fanout_handler_test.go b/pkg/sidecar/fanout/fanout_handler_test.go index 61b17ff97eb..d7937296a58 100644 --- a/pkg/sidecar/fanout/fanout_handler_test.go +++ b/pkg/sidecar/fanout/fanout_handler_test.go @@ -20,6 +20,7 @@ import ( "errors" "fmt" "github.com/knative/eventing/pkg/sidecar/clientfactory/fake" + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" "go.uber.org/zap" "io" "io/ioutil" @@ -129,30 +130,30 @@ func TestDomainToUrl(t *testing.T) { func TestServeHTTP(t *testing.T) { testCases := []struct { name string - subs []Subscription + subs []duckv1alpha1.ChannelSubscriberSpec cf *fake.ClientFactory origBody io.Reader expectedStatus int }{ { name: "cannot read orig body", - subs: []Subscription{}, + subs: []duckv1alpha1.ChannelSubscriberSpec{}, origBody: &failingReader{}, cf: &fake.ClientFactory{}, expectedStatus: http.StatusInternalServerError, }, { name: "no subs", - subs: []Subscription{}, + subs: []duckv1alpha1.ChannelSubscriberSpec{}, origBody: body(""), cf: &fake.ClientFactory{}, expectedStatus: http.StatusOK, }, { name: "one sub -- failed", - subs: []Subscription{ + subs: []duckv1alpha1.ChannelSubscriberSpec{ { - ToDomain: "todomain", + SinkableDomain: "todomain", }, }, origBody: body(""), @@ -168,9 +169,9 @@ func TestServeHTTP(t *testing.T) { }, { name: "one sub -- succeeded", - subs: []Subscription{ + subs: []duckv1alpha1.ChannelSubscriberSpec{ { - ToDomain: "todomain", + SinkableDomain: "todomain", }, }, origBody: body(""), @@ -186,12 +187,12 @@ func TestServeHTTP(t *testing.T) { }, { name: "two subs -- one fails", - subs: []Subscription{ + subs: []duckv1alpha1.ChannelSubscriberSpec{ { - ToDomain: "todomain", + SinkableDomain: "todomain", }, { - CallDomain: "calldomain", + CallableDomain: "calldomain", }, }, origBody: body(""), @@ -211,12 +212,12 @@ func TestServeHTTP(t *testing.T) { }, { name: "two subs -- both succeed", - subs: []Subscription{ + subs: []duckv1alpha1.ChannelSubscriberSpec{ { - ToDomain: "todomain", + SinkableDomain: "todomain", }, { - CallDomain: "calldomain", + CallableDomain: "calldomain", }, }, origBody: body(""), @@ -254,7 +255,7 @@ func TestMakeFanoutRequest(t *testing.T) { testCases := []struct { name string cf *fake.ClientFactory - sub Subscription + sub duckv1alpha1.ChannelSubscriberSpec origBody string expectedErr bool expectedNumReq int @@ -262,8 +263,8 @@ func TestMakeFanoutRequest(t *testing.T) { }{ { name: "`call` fails", - sub: Subscription{ - CallDomain: "calldomain", + sub: duckv1alpha1.ChannelSubscriberSpec{ + CallableDomain: "calldomain", }, cf: &fake.ClientFactory{ RespErr: errors.New("error making request"), @@ -273,8 +274,8 @@ func TestMakeFanoutRequest(t *testing.T) { }, { name: "`call` non-2xx", - sub: Subscription{ - CallDomain: "calldomain", + sub: duckv1alpha1.ChannelSubscriberSpec{ + CallableDomain: "calldomain", }, cf: &fake.ClientFactory{ Resp: []*http.Response{ @@ -289,8 +290,8 @@ func TestMakeFanoutRequest(t *testing.T) { }, { name: "`only `call`", - sub: Subscription{ - CallDomain: "calldomain", + sub: duckv1alpha1.ChannelSubscriberSpec{ + CallableDomain: "calldomain", }, cf: &fake.ClientFactory{ Resp: []*http.Response{ @@ -308,8 +309,8 @@ func TestMakeFanoutRequest(t *testing.T) { }, { name: "`to` fails", - sub: Subscription{ - ToDomain: "todomain", + sub: duckv1alpha1.ChannelSubscriberSpec{ + SinkableDomain: "todomain", }, cf: &fake.ClientFactory{ RespErr: errors.New("error making request"), @@ -319,8 +320,8 @@ func TestMakeFanoutRequest(t *testing.T) { }, { name: "`to` non-2xx", - sub: Subscription{ - ToDomain: "todomain", + sub: duckv1alpha1.ChannelSubscriberSpec{ + SinkableDomain: "todomain", }, cf: &fake.ClientFactory{ Resp: []*http.Response{ @@ -335,8 +336,8 @@ func TestMakeFanoutRequest(t *testing.T) { }, { name: "only `to`", - sub: Subscription{ - ToDomain: "todomain", + sub: duckv1alpha1.ChannelSubscriberSpec{ + SinkableDomain: "todomain", }, cf: &fake.ClientFactory{ Resp: []*http.Response{ @@ -354,9 +355,9 @@ func TestMakeFanoutRequest(t *testing.T) { }, { name: "`call` and `to`", - sub: Subscription{ - CallDomain: "calldomain", - ToDomain: "todomain", + sub: duckv1alpha1.ChannelSubscriberSpec{ + CallableDomain: "calldomain", + SinkableDomain: "todomain", }, cf: &fake.ClientFactory{ Resp: []*http.Response{ diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go index 769843f567f..b4d62c78d8f 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go @@ -21,6 +21,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/knative/eventing/pkg/sidecar/clientfactory/fake" "github.com/knative/eventing/pkg/sidecar/fanout" + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" "go.uber.org/zap" "io/ioutil" "net/http" @@ -56,65 +57,6 @@ func TestMakeChannelKey(t *testing.T) { } } -func TestGetChannelKey(t *testing.T) { - testCases := []struct { - name string - headers map[string]string - expected string - expectedErr bool - }{ - { - name: "no header", - expectedErr: true, - }, - { - name: "header missing", - headers: map[string]string{ - "User-Agent": "1234", - }, - expectedErr: true, - }, - { - name: "header present without value", - headers: map[string]string{ - ChannelKeyHeader: "", - }, - expected: "", - }, - { - name: "header present", - headers: map[string]string{ - ChannelKeyHeader: "default/c1", - }, - expected: "default/c1", - }, - } - requestWithHeaders := func(headers map[string]string) *http.Request { - r := httptest.NewRequest("POST", "http://target/", strings.NewReader("{}")) - for existing := range r.Header { - r.Header.Del(existing) - } - for h, v := range headers { - r.Header.Set(h, v) - } - return r - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - r := requestWithHeaders(tc.headers) - key, err := getChannelKey(r) - if tc.expectedErr { - if err == nil { - t.Errorf("Expected an error, did not get one.") - } - } - if key != tc.expected { - t.Errorf("Incorrect channel key. Expected '%v'. Actual '%v'", tc.expected, key) - } - }) - } -} - func TestNewHandler(t *testing.T) { testCases := []struct { name string @@ -163,9 +105,9 @@ func TestCopyWithNewConfig(t *testing.T) { Namespace: "default", Name: "c1", FanoutConfig: fanout.Config{ - Subscriptions: []fanout.Subscription{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - CallDomain: "calldomain", + CallableDomain: "calldomain", }, }, }, @@ -178,9 +120,9 @@ func TestCopyWithNewConfig(t *testing.T) { Namespace: "default", Name: "somethingdifferent", FanoutConfig: fanout.Config{ - Subscriptions: []fanout.Subscription{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - ToDomain: "todomain", + SinkableDomain: "todomain", }, }, }, @@ -221,9 +163,9 @@ func TestConfigDiff(t *testing.T) { Namespace: "default", Name: "c1", FanoutConfig: fanout.Config{ - Subscriptions: []fanout.Subscription{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - CallDomain: "calldomain", + CallableDomain: "calldomain", }, }, }, @@ -251,9 +193,9 @@ func TestConfigDiff(t *testing.T) { Namespace: "default", Name: "c1", FanoutConfig: fanout.Config{ - Subscriptions: []fanout.Subscription{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - CallDomain: "different", + CallableDomain: "different", }, }, }, @@ -292,7 +234,7 @@ func TestServeHTTP(t *testing.T) { name: "non-existent channel", config: Config{}, cf: &fake.ClientFactory{}, - key: "default/does-not-exist", + key: "default.does-not-exist", expectedStatusCode: http.StatusInternalServerError, }, { @@ -310,9 +252,9 @@ func TestServeHTTP(t *testing.T) { Namespace: "default", Name: "first-channel", FanoutConfig: fanout.Config{ - Subscriptions: []fanout.Subscription{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - ToDomain: "first-to-domain", + SinkableDomain: "first-to-domain", }, }, }, @@ -327,7 +269,7 @@ func TestServeHTTP(t *testing.T) { }, }, }, - key: "default/first-channel", + key: "first-channel.default", expectedStatusCode: http.StatusInternalServerError, }, { @@ -338,9 +280,9 @@ func TestServeHTTP(t *testing.T) { Namespace: "default", Name: "first-channel", FanoutConfig: fanout.Config{ - Subscriptions: []fanout.Subscription{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - ToDomain: "first-to-domain", + SinkableDomain: "first-to-domain", }, }, }, @@ -349,9 +291,9 @@ func TestServeHTTP(t *testing.T) { Namespace: "default", Name: "second-channel", FanoutConfig: fanout.Config{ - Subscriptions: []fanout.Subscription{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - CallDomain: "second-call-domain", + CallableDomain: "second-call-domain", }, }, }, @@ -366,16 +308,13 @@ func TestServeHTTP(t *testing.T) { }, }, }, - key: "default/second-channel", + key: "second-channel.default", requestDomain: "second-call-domain", expectedStatusCode: http.StatusOK, }, } requestWithChannelKey := func(key string) *http.Request { - r := httptest.NewRequest("POST", "http://target/", strings.NewReader("{}")) - if key != "" { - r.Header.Set(ChannelKeyHeader, key) - } + r := httptest.NewRequest("POST", fmt.Sprintf("http://%s/", key), strings.NewReader("{}")) return r } for _, tc := range testCases { diff --git a/pkg/sidecar/swappable/swappable_test.go b/pkg/sidecar/swappable/swappable_test.go new file mode 100644 index 00000000000..bac440efb7b --- /dev/null +++ b/pkg/sidecar/swappable/swappable_test.go @@ -0,0 +1,17 @@ +/* +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 swappable From 9e0c7f69ce3276257e33c45212975bd93535037d Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Thu, 27 Sep 2018 12:48:58 -0700 Subject: [PATCH 05/23] Fanout tests work. --- .../configmaphandler/config_map_handler.go | 5 +- pkg/sidecar/fanout/fanout_handler.go | 45 +- pkg/sidecar/fanout/fanout_handler_test.go | 570 +++++------------- .../multi_channel_fanout_handler.go | 23 +- .../multi_channel_fanout_handler_test.go | 22 +- pkg/sidecar/swappable/swappable.go | 5 +- 6 files changed, 211 insertions(+), 459 deletions(-) diff --git a/pkg/sidecar/configmaphandler/config_map_handler.go b/pkg/sidecar/configmaphandler/config_map_handler.go index c0c55f852a8..7a362dd38b2 100644 --- a/pkg/sidecar/configmaphandler/config_map_handler.go +++ b/pkg/sidecar/configmaphandler/config_map_handler.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "github.com/fsnotify/fsnotify" - "github.com/knative/eventing/pkg/sidecar/clientfactory" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" "github.com/knative/pkg/configmap" "go.uber.org/zap" @@ -51,7 +50,7 @@ type configMapHandler struct { } // NewHandler creates a new configmaphandler.Handler. -func NewHandler(logger *zap.Logger, dir string, clientFactory clientfactory.ClientFactory) (http.Handler, error) { +func NewHandler(logger *zap.Logger, dir string) (http.Handler, error) { conf, err := readConfigMap(logger, dir) if err != nil { logger.Error("Unable to read configMap", zap.Error(err)) @@ -60,7 +59,7 @@ func NewHandler(logger *zap.Logger, dir string, clientFactory clientfactory.Clie logger.Info("Read initial configMap", zap.Any("conf", conf)) - mcfh, err := multichannelfanout.NewHandler(logger, conf, clientFactory) + mcfh, err := multichannelfanout.NewHandler(logger, conf) if err != nil { logger.Error("Unable to create multichannelfanout.Handler: %v", zap.Error(err)) return nil, err diff --git a/pkg/sidecar/fanout/fanout_handler.go b/pkg/sidecar/fanout/fanout_handler.go index 6f647224799..13e380f43e4 100644 --- a/pkg/sidecar/fanout/fanout_handler.go +++ b/pkg/sidecar/fanout/fanout_handler.go @@ -19,19 +19,22 @@ package fanout import ( "fmt" "github.com/knative/eventing/pkg/buses" - "github.com/knative/eventing/pkg/sidecar/clientfactory" duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" "go.uber.org/zap" "math/rand" "net/http" "sync" + "time" ) const ( // The header attached to requests sent through the MessageReceiver. It is used to correlate the - // request going into the MessageReceiver and the request coming out of the MessageReceiver. - // Note that it _must_ be in the headers forwarded by the MessageReceiver. + // request going into the MessageReceiver and the request coming out of the MessageReceiver. It + // is removed before being sent downstream. + // Note that it MUST be in the headers forwarded by the MessageReceiver. uniqueFanoutHeader = "Knative-Fanout-Message-Tracker" + + defaultTimeout = 1 * time.Minute ) // Configuration for a fanout.Handler. @@ -41,27 +44,28 @@ type Config struct { // http.Handler that takes a single request in and fans it out to N other servers. type fanoutHandler struct { - logger *zap.Logger - config Config - clientFactory clientfactory.ClientFactory + config Config receivedMessages *messageStorage + receiver *buses.MessageReceiver + dispatcher *buses.MessageDispatcher + + timeout time.Duration - receiver *buses.MessageReceiver - dispatcher *buses.MessageDispatcher + logger *zap.Logger } var _ http.Handler = &fanoutHandler{} -func NewHandler(logger *zap.Logger, config Config, cf clientfactory.ClientFactory) http.Handler { +func NewHandler(logger *zap.Logger, config Config) http.Handler { handler := &fanoutHandler{ - logger: logger, - config: config, - clientFactory: cf, - dispatcher : buses.NewMessageDispatcher(logger.Sugar()), + logger: logger, + config: config, + dispatcher: buses.NewMessageDispatcher(logger.Sugar()), receivedMessages: &messageStorage{ messages: make(map[string]*buses.Message), }, + timeout: defaultTimeout, } // The receiver function needs to point back at the handler itself, so setup it after // initialization. @@ -107,10 +111,18 @@ func (f *fanoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } sc := http.StatusOK +Loop: for range f.config.Subscriptions { - if err = <-errorCh; err != nil { - f.logger.Error("Fanout had an error", zap.Error(err)) + select { + case err := <-errorCh: + if err != nil { + f.logger.Error("Fanout had an error", zap.Error(err)) + sc = http.StatusInternalServerError + } + case <-time.After(f.timeout): + f.logger.Error("Fanout timed out") sc = http.StatusInternalServerError + break Loop } } @@ -142,10 +154,9 @@ func (r *response) WriteHeader(statusCode int) { r.statusCode = statusCode } - type messageStorage struct { messagesLock sync.Mutex - messages map[string]*buses.Message + messages map[string]*buses.Message } func (ms *messageStorage) Put(m *buses.Message) { diff --git a/pkg/sidecar/fanout/fanout_handler_test.go b/pkg/sidecar/fanout/fanout_handler_test.go index d7937296a58..831b9184026 100644 --- a/pkg/sidecar/fanout/fanout_handler_test.go +++ b/pkg/sidecar/fanout/fanout_handler_test.go @@ -19,8 +19,9 @@ package fanout import ( "errors" "fmt" - "github.com/knative/eventing/pkg/sidecar/clientfactory/fake" + "github.com/knative/eventing/pkg/buses" duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "go.uber.org/atomic" "go.uber.org/zap" "io" "io/ioutil" @@ -28,476 +29,229 @@ import ( "net/http/httptest" "strings" "testing" + "time" ) -func TestIs2xx(t *testing.T) { - testCases := []struct { - sc int - is2xx bool - }{ - { - sc: http.StatusContinue, - is2xx: false, - }, - { - sc: http.StatusOK, - is2xx: true, - }, - { - sc: http.StatusCreated, - is2xx: true, - }, - { - sc: http.StatusAccepted, - is2xx: true, - }, - { - sc: http.StatusNoContent, - is2xx: true, - }, - { - sc: http.StatusAlreadyReported, - is2xx: true, - }, - { - sc: http.StatusBadRequest, - is2xx: false, - }, - { - sc: http.StatusUnauthorized, - is2xx: false, - }, - { - sc: http.StatusForbidden, - is2xx: false, - }, - { - sc: http.StatusNotFound, - is2xx: false, - }, - { - sc: http.StatusMethodNotAllowed, - is2xx: false, - }, - { - sc: http.StatusNotAcceptable, - is2xx: false, - }, - { - sc: http.StatusConflict, - is2xx: false, - }, - { - sc: http.StatusGone, - is2xx: false, - }, - { - sc: http.StatusPreconditionFailed, - is2xx: false, - }, - { - sc: http.StatusTooManyRequests, - is2xx: false, - }, - { - sc: http.StatusInternalServerError, - is2xx: false, - }, - { - sc: http.StatusServiceUnavailable, - is2xx: false, - }, - } - for _, tc := range testCases { - t.Run(fmt.Sprintf("%v", tc.sc), func(t *testing.T) { - resp := &http.Response{ - StatusCode: tc.sc, - } - if is2xx(resp) != tc.is2xx { - t.Errorf("Unexpected is2xx for %v. Expected %v. Actual %v", tc.sc, tc.is2xx, is2xx(resp)) - } - }) - } -} +// Domains used in subscriptions, which will be replaced by the real domains of the started HTTP +// servers. +const ( + replaceCallable = "replaceCallable" + replaceSinkable = "replaceSinkable" +) -func TestDomainToUrl(t *testing.T) { - expected := "http://foobar/" - if actual := domainToURL("foobar"); expected != actual { - t.Errorf("Unexpected domainToURL. Expected: '%v'. Actual: '%v'", expected, actual) - } -} +var ( + cloudEventReq = httptest.NewRequest("POST", "http://channelname.channelnamespace/", body(cloudEvent)) + cloudEvent = `{ + "cloudEventsVersion" : "0.1", + "eventType" : "com.example.someevent", + "eventTypeVersion" : "1.0", + "source" : "/mycontext", + "eventID" : "A234-1234-1234", + "eventTime" : "2018-04-05T17:31:00Z", + "extensions" : { + "comExampleExtension" : "value" + }, + "contentType" : "text/xml", + "data" : "" +}` +) -func TestServeHTTP(t *testing.T) { - testCases := []struct { - name string +func TestFanoutHandler_ServeHTTP(t *testing.T) { + testCases := map[string]struct { + receiverFunc func(buses.ChannelReference, *buses.Message) error + timeout time.Duration subs []duckv1alpha1.ChannelSubscriberSpec - cf *fake.ClientFactory - origBody io.Reader + callable func(http.ResponseWriter, *http.Request) + sinkable func(http.ResponseWriter, *http.Request) expectedStatus int }{ - { - name: "cannot read orig body", - subs: []duckv1alpha1.ChannelSubscriberSpec{}, - origBody: &failingReader{}, - cf: &fake.ClientFactory{}, + "rejected by receiver": { + receiverFunc: func(buses.ChannelReference, *buses.Message) error { + return errors.New("Rejected by test-receiver") + }, expectedStatus: http.StatusInternalServerError, }, - { - name: "no subs", - subs: []duckv1alpha1.ChannelSubscriberSpec{}, - origBody: body(""), - cf: &fake.ClientFactory{}, - expectedStatus: http.StatusOK, + "could not find tracked message": { + receiverFunc: func(buses.ChannelReference, *buses.Message) error { + // Not being written to messageStorage. + return nil + }, + expectedStatus: http.StatusInternalServerError, }, - { - name: "one sub -- failed", + "fanout times out": { + timeout: time.Millisecond, subs: []duckv1alpha1.ChannelSubscriberSpec{ { - SinkableDomain: "todomain", + CallableDomain: replaceCallable, }, }, - origBody: body(""), - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusNotFound, - Body: body(""), - }, - }, + callable: func(writer http.ResponseWriter, _ *http.Request) { + time.Sleep(10 * time.Millisecond) + writer.WriteHeader(http.StatusOK) }, expectedStatus: http.StatusInternalServerError, }, - { - name: "one sub -- succeeded", + "zero subs succeed": { + subs: []duckv1alpha1.ChannelSubscriberSpec{}, + expectedStatus: http.StatusOK, + }, + "empty sub succeeds": { subs: []duckv1alpha1.ChannelSubscriberSpec{ - { - SinkableDomain: "todomain", - }, - }, - origBody: body(""), - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusOK, - Body: body(""), - }, - }, + {}, }, expectedStatus: http.StatusOK, }, - { - name: "two subs -- one fails", + "sinkable fails": { subs: []duckv1alpha1.ChannelSubscriberSpec{ { - SinkableDomain: "todomain", - }, - { - CallableDomain: "calldomain", + SinkableDomain: replaceSinkable, }, }, - origBody: body(""), - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusForbidden, - Body: body(""), - }, - { - StatusCode: http.StatusOK, - Body: body(""), - }, - }, + sinkable: func(writer http.ResponseWriter, _ *http.Request) { + writer.WriteHeader(http.StatusNotFound) }, expectedStatus: http.StatusInternalServerError, }, - { - name: "two subs -- both succeed", + "callable fails": { subs: []duckv1alpha1.ChannelSubscriberSpec{ { - SinkableDomain: "todomain", - }, - { - CallableDomain: "calldomain", - }, - }, - origBody: body(""), - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusOK, - Body: body(""), - }, + CallableDomain: replaceCallable, }, }, - expectedStatus: http.StatusOK, - }, - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - config := Config{ - Subscriptions: tc.subs, - } - f := NewHandler(zap.NewNop(), config, tc.cf) - - r := httptest.NewRequest("POST", "http://unused/", tc.origBody) - - w := httptest.NewRecorder() - f.ServeHTTP(w, r) - - if w.Result().StatusCode != tc.expectedStatus { - t.Errorf("Unexpected status code. Expected %v. Actual %v.", tc.expectedStatus, w.Result().StatusCode) - } - }) - } -} - -func TestMakeFanoutRequest(t *testing.T) { - testCases := []struct { - name string - cf *fake.ClientFactory - sub duckv1alpha1.ChannelSubscriberSpec - origBody string - expectedErr bool - expectedNumReq int - expectedReqBodies []string - }{ - { - name: "`call` fails", - sub: duckv1alpha1.ChannelSubscriberSpec{ - CallableDomain: "calldomain", - }, - cf: &fake.ClientFactory{ - RespErr: errors.New("error making request"), + callable: func(writer http.ResponseWriter, _ *http.Request) { + writer.WriteHeader(http.StatusNotFound) }, - expectedErr: true, - expectedNumReq: 1, - }, - { - name: "`call` non-2xx", - sub: duckv1alpha1.ChannelSubscriberSpec{ - CallableDomain: "calldomain", - }, - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusForbidden, - Body: body(""), - }, - }, - }, - expectedErr: true, - expectedNumReq: 1, + expectedStatus: http.StatusInternalServerError, }, - { - name: "`only `call`", - sub: duckv1alpha1.ChannelSubscriberSpec{ - CallableDomain: "calldomain", - }, - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusOK, - Body: body(""), - }, + "callable succeeds, sinkable fails": { + subs: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: replaceCallable, + SinkableDomain: replaceSinkable, }, }, - origBody: "{orig:body}", - expectedNumReq: 1, - expectedReqBodies: []string{ - "{orig:body}", + callable: callableSucceed, + sinkable: func(writer http.ResponseWriter, _ *http.Request) { + writer.WriteHeader(http.StatusForbidden) }, + expectedStatus: http.StatusInternalServerError, }, - { - name: "`to` fails", - sub: duckv1alpha1.ChannelSubscriberSpec{ - SinkableDomain: "todomain", + "one sub succeeds": { + subs: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: replaceCallable, + SinkableDomain: replaceSinkable, + }, }, - cf: &fake.ClientFactory{ - RespErr: errors.New("error making request"), + callable: callableSucceed, + sinkable: func(writer http.ResponseWriter, _ *http.Request) { + writer.WriteHeader(http.StatusAccepted) }, - expectedErr: true, - expectedNumReq: 1, + expectedStatus: http.StatusOK, }, - { - name: "`to` non-2xx", - sub: duckv1alpha1.ChannelSubscriberSpec{ - SinkableDomain: "todomain", - }, - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusInternalServerError, - Body: body(""), - }, + "one sub succeeds, one sub fails": { + subs: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: replaceCallable, + SinkableDomain: replaceSinkable, }, - }, - expectedErr: true, - expectedNumReq: 1, - }, - { - name: "only `to`", - sub: duckv1alpha1.ChannelSubscriberSpec{ - SinkableDomain: "todomain", - }, - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusOK, - Body: body(""), - }, + { + CallableDomain: replaceCallable, + SinkableDomain: replaceSinkable, }, }, - origBody: "{orig:body}", - expectedNumReq: 1, - expectedReqBodies: []string{ - "{orig:body}", - }, + callable: callableSucceed, + sinkable: (&succeedOnce{}).handler, + expectedStatus: http.StatusInternalServerError, }, - { - name: "`call` and `to`", - sub: duckv1alpha1.ChannelSubscriberSpec{ - CallableDomain: "calldomain", - SinkableDomain: "todomain", - }, - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusOK, - Body: body("{call:body}"), - }, + "all subs succeed": { + subs: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: replaceCallable, + SinkableDomain: replaceSinkable, + }, + { + CallableDomain: replaceCallable, + SinkableDomain: replaceSinkable, + }, + { + CallableDomain: replaceCallable, + SinkableDomain: replaceSinkable, }, }, - origBody: "{orig:body}", - expectedNumReq: 2, - expectedReqBodies: []string{ - "{orig:body}", - "{call:body}", + callable: callableSucceed, + sinkable: func(writer http.ResponseWriter, _ *http.Request) { + writer.WriteHeader(http.StatusAccepted) }, + expectedStatus: http.StatusOK, }, } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - f := fanoutHandler{ - logger: zap.NewNop(), - clientFactory: tc.cf, + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + callableServer := httptest.NewServer(&fakeHandler{ + handler: tc.callable, + }) + defer callableServer.Close() + sinkableServer := httptest.NewServer(&fakeHandler{ + handler: tc.sinkable, + }) + defer sinkableServer.Close() + + // Rewrite the subs to use the servers we just started. + subs := make([]duckv1alpha1.ChannelSubscriberSpec, 0) + for _, sub := range tc.subs { + if sub.CallableDomain == replaceCallable { + sub.CallableDomain = callableServer.URL[7:] // strip the leading 'http://' + } + if sub.SinkableDomain == replaceSinkable { + sub.SinkableDomain = sinkableServer.URL[7:] // strip the leading 'http://' + } + subs = append(subs, sub) } - r := httptest.NewRequest("POST", "http://unused/", nil) - err := f.makeFanoutRequest(r, []byte(tc.origBody), tc.sub) - reqs := tc.cf.GetRequests() - if numReq := len(reqs); numReq != tc.expectedNumReq { - t.Errorf("Incorrect number of requests. Expected %v. Actual %v", tc.expectedNumReq, reqs) + + h := NewHandler(zap.NewNop(), Config{Subscriptions: subs}).(*fanoutHandler) + if tc.receiverFunc != nil { + h.receiver = buses.NewMessageReceiver(tc.receiverFunc, zap.NewNop().Sugar()) } - if tc.expectedErr { - if err == nil { - t.Errorf("Expected an error making the fanout request. Actual: nil") - } - return + if tc.timeout != 0 { + h.timeout = tc.timeout } - for i := range tc.expectedReqBodies { - expected := tc.expectedReqBodies[i] - actualBytes, _ := ioutil.ReadAll(reqs[i].Body) - actual := string(actualBytes) - if actual != expected { - t.Errorf("Unexpected req body. Index %v. Expected %v. Actual %v.", i, expected, actual) - } + + w := httptest.NewRecorder() + fmt.Sprintf("hello %v", n) + h.ServeHTTP(w, cloudEventReq) + if w.Code != tc.expectedStatus { + t.Errorf("Unexpected status code. Expected %v, Actual %v", tc.expectedStatus, w.Code) } }) } } -func TestMakeRequest(t *testing.T) { - testCases := []struct { - name string - method string - cf *fake.ClientFactory - origHeaders http.Header - body string - expectedErr bool - expectedStatusCode int - expectedBody string - }{ - { - name: "bad method", - method: "not_a_valid::/method", - expectedErr: true, - }, - { - name: "bad client factory", - method: "POST", - cf: &fake.ClientFactory{ - CreateErr: errors.New("test-induced client creation failure"), - }, - expectedErr: true, - }, - { - name: "unable to make request", - method: "POST", - cf: &fake.ClientFactory{ - RespErr: errors.New("test-induced HTTP Do failure"), - }, - expectedErr: true, - }, - { - name: "bad status code", - method: "POST", - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusNotFound, - Body: body(""), - }, - }, - }, - expectedErr: true, - }, - { - name: "good response", - method: "POST", - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusOK, - Body: body("{hello:world}"), - }, - }, - }, - expectedStatusCode: http.StatusOK, - expectedBody: "{hello:world}", - }, - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - f := &fanoutHandler{ - logger: zap.NewNop(), - clientFactory: tc.cf, - } - or := &http.Request{ - Method: tc.method, - Header: tc.origHeaders, - } - resp, err := f.makeRequest(or, strings.NewReader(tc.body), "domain") - if tc.expectedErr { - if err == nil { - t.Errorf("Expected an error, but did not get one.") - } - return - } else if err != nil { - t.Errorf("Unexpected error. %v", err) - } - if actual, _ := ioutil.ReadAll(resp.Body); resp.StatusCode != tc.expectedStatusCode || string(actual) != tc.expectedBody { - t.Errorf("Unexpected response. Expected: %v, '%v'. Actual '%v'.", tc.expectedStatusCode, tc.expectedBody, resp) - } +type fakeHandler struct { + handler func(http.ResponseWriter, *http.Request) +} - }) +func (h *fakeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + r.Body.Close() + h.handler(w, r) +} + +type succeedOnce struct { + called atomic.Bool +} + +func (s *succeedOnce) handler(w http.ResponseWriter, _ *http.Request) { + if s.called.CAS(false, true) { + w.WriteHeader(http.StatusOK) + } else { + w.WriteHeader(http.StatusForbidden) } } func body(body string) io.ReadCloser { return ioutil.NopCloser(strings.NewReader(body)) } - -type failingReader struct{} - -func (_ *failingReader) Read(p []byte) (int, error) { - return 0, errors.New("test-induced error reading") +func callableSucceed(writer http.ResponseWriter, _ *http.Request) { + writer.WriteHeader(http.StatusOK) + writer.Write([]byte(cloudEvent)) } diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go index e282c658404..b225de0cd64 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go @@ -20,7 +20,6 @@ import ( "fmt" "github.com/google/go-cmp/cmp" "github.com/knative/eventing/pkg/buses" - "github.com/knative/eventing/pkg/sidecar/clientfactory" "github.com/knative/eventing/pkg/sidecar/fanout" "go.uber.org/zap" "net/http" @@ -67,18 +66,17 @@ func getChannelKey(r *http.Request) string { // multichannelfanout.ChannelKeyHeader and uses its value to determine which fanout.Handler to // delegate the request to. type Handler struct { - logger *zap.Logger - handlers map[string]http.Handler - config Config - clientFactory clientfactory.ClientFactory + logger *zap.Logger + handlers map[string]http.Handler + config Config } -func NewHandler(logger *zap.Logger, conf Config, cf clientfactory.ClientFactory) (*Handler, error) { +func NewHandler(logger *zap.Logger, conf Config) (*Handler, error) { handlers := make(map[string]http.Handler, len(conf.ChannelConfigs)) for _, cc := range conf.ChannelConfigs { key := makeChannelKeyFromConfig(cc) - handler := fanout.NewHandler(logger, cc.FanoutConfig, cf) + handler := fanout.NewHandler(logger, cc.FanoutConfig) if _, present := handlers[key]; present { logger.Error("Duplicate channel key", zap.String("channelKey", key)) return nil, fmt.Errorf("duplicate channel key: %v", key) @@ -87,10 +85,9 @@ func NewHandler(logger *zap.Logger, conf Config, cf clientfactory.ClientFactory) } return &Handler{ - logger: logger, - config: conf, - handlers: handlers, - clientFactory: cf, + logger: logger, + config: conf, + handlers: handlers, }, nil } @@ -104,13 +101,13 @@ func (h *Handler) ConfigDiff(updated Config) string { // CopyWithNewConfig creates a new copy of this Handler with all the fields identical, except the // new Handler uses conf, rather than copying the existing Handler's config. func (h *Handler) CopyWithNewConfig(conf Config) (*Handler, error) { - return NewHandler(h.logger, conf, h.clientFactory) + return NewHandler(h.logger, conf) } // ServeHTTP delegates the actual handling of the request to a fanout.Handler, based on the // request's channel key. func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - channelKey:= getChannelKey(r) + channelKey := getChannelKey(r) fh, ok := h.handlers[channelKey] if !ok { h.logger.Error("Unable to find a handler for request", zap.String("channelKey", channelKey)) diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go index b4d62c78d8f..405ade14af1 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go @@ -83,7 +83,7 @@ func TestNewHandler(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - _, err := NewHandler(zap.NewNop(), tc.config, &fake.ClientFactory{}) + _, err := NewHandler(zap.NewNop(), tc.config) if tc.createErr != "" { if err == nil { t.Errorf("Expected NewHandler error: '%v'. Actual nil", tc.createErr) @@ -107,7 +107,7 @@ func TestCopyWithNewConfig(t *testing.T) { FanoutConfig: fanout.Config{ Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - CallableDomain: "calldomain", + CallableDomain: "callabledomain", }, }, }, @@ -122,7 +122,7 @@ func TestCopyWithNewConfig(t *testing.T) { FanoutConfig: fanout.Config{ Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - SinkableDomain: "todomain", + SinkableDomain: "sinkabledomain", }, }, }, @@ -132,9 +132,7 @@ func TestCopyWithNewConfig(t *testing.T) { if cmp.Equal(orig, updated) { t.Errorf("Orig and updated must be different") } - h, err := NewHandler(zap.NewNop(), orig, &fake.ClientFactory{ - CreateErr: fmt.Errorf("random error that makes this client unique"), - }) + h, err := NewHandler(zap.NewNop(), orig) if err != nil { t.Errorf("Unable to create handler, %v", err) } @@ -148,9 +146,6 @@ func TestCopyWithNewConfig(t *testing.T) { if h.logger != newH.logger { t.Errorf("Did not copy logger") } - if h.clientFactory != newH.clientFactory { - t.Errorf("Did not copy clientFactory") - } if !cmp.Equal(newH.config, updated) { t.Errorf("Incorrect copied config. Expected '%v'. Actual '%v'", updated, newH.config) } @@ -165,7 +160,7 @@ func TestConfigDiff(t *testing.T) { FanoutConfig: fanout.Config{ Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - CallableDomain: "calldomain", + CallableDomain: "callabledomain", }, }, }, @@ -207,7 +202,7 @@ func TestConfigDiff(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - h, err := NewHandler(zap.NewNop(), tc.orig, &fake.ClientFactory{}) + h, err := NewHandler(zap.NewNop(), tc.orig) if err != nil { t.Errorf("Unable to create handler: %v", err) } @@ -224,7 +219,6 @@ func TestServeHTTP(t *testing.T) { testCases := []struct { name string config Config - cf *fake.ClientFactory h http.Header key string expectedStatusCode int @@ -233,14 +227,12 @@ func TestServeHTTP(t *testing.T) { { name: "non-existent channel", config: Config{}, - cf: &fake.ClientFactory{}, key: "default.does-not-exist", expectedStatusCode: http.StatusInternalServerError, }, { name: "no channel key", config: Config{}, - cf: &fake.ClientFactory{}, key: "", expectedStatusCode: http.StatusBadRequest, }, @@ -319,7 +311,7 @@ func TestServeHTTP(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - h, err := NewHandler(zap.NewNop(), tc.config, tc.cf) + h, err := NewHandler(zap.NewNop(), tc.config) if err != nil { t.Errorf("Unexpected NewHandler error: '%v'", err) } diff --git a/pkg/sidecar/swappable/swappable.go b/pkg/sidecar/swappable/swappable.go index 188c0b00819..b047ff0f977 100644 --- a/pkg/sidecar/swappable/swappable.go +++ b/pkg/sidecar/swappable/swappable.go @@ -17,7 +17,6 @@ limitations under the License. package swappable import ( - "github.com/knative/eventing/pkg/sidecar/clientfactory" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" "go.uber.org/zap" "net/http" @@ -41,8 +40,8 @@ func NewHandler(handler *multichannelfanout.Handler, logger *zap.Logger) (*Handl return h, nil } -func NewEmptyHandler(logger *zap.Logger, cf clientfactory.ClientFactory) (*Handler, error) { - h, err := multichannelfanout.NewHandler(logger, multichannelfanout.Config{}, cf) +func NewEmptyHandler(logger *zap.Logger) (*Handler, error) { + h, err := multichannelfanout.NewHandler(logger, multichannelfanout.Config{}) if err != nil { return nil, err } From b03f91cf1cf981708e959148fc5142948b19cd38 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Thu, 27 Sep 2018 14:10:54 -0700 Subject: [PATCH 06/23] MultiChannelFanoutHandler tests work. --- .../multi_channel_fanout_handler_test.go | 90 ++++++++++--------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go index 405ade14af1..16a99135168 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go @@ -19,17 +19,20 @@ package multichannelfanout import ( "fmt" "github.com/google/go-cmp/cmp" - "github.com/knative/eventing/pkg/sidecar/clientfactory/fake" "github.com/knative/eventing/pkg/sidecar/fanout" duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" "go.uber.org/zap" - "io/ioutil" "net/http" "net/http/httptest" "strings" "testing" ) +const ( + // The httptest.Server's host name will replace this value in all ChannelConfigs. + replaceDomain = "replaceDomain" +) + func TestMakeChannelKey(t *testing.T) { testCases := []struct { namespace string @@ -216,28 +219,19 @@ func TestConfigDiff(t *testing.T) { } func TestServeHTTP(t *testing.T) { - testCases := []struct { + testCases := map[string]struct { name string config Config - h http.Header + respStatusCode int key string expectedStatusCode int - requestDomain string }{ - { - name: "non-existent channel", + "non-existent channel": { config: Config{}, key: "default.does-not-exist", expectedStatusCode: http.StatusInternalServerError, }, - { - name: "no channel key", - config: Config{}, - key: "", - expectedStatusCode: http.StatusBadRequest, - }, - { - name: "pass through failure", + "pass through failure": { config: Config{ ChannelConfigs: []ChannelConfig{ { @@ -246,26 +240,18 @@ func TestServeHTTP(t *testing.T) { FanoutConfig: fanout.Config{ Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - SinkableDomain: "first-to-domain", + SinkableDomain: replaceDomain, }, }, }, }, }, }, - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusInternalServerError, - Body: ioutil.NopCloser(strings.NewReader("{}")), - }, - }, - }, + respStatusCode: http.StatusInternalServerError, key: "first-channel.default", expectedStatusCode: http.StatusInternalServerError, }, - { - name: "choose channel", + "choose channel": { config: Config{ ChannelConfigs: []ChannelConfig{ { @@ -285,23 +271,15 @@ func TestServeHTTP(t *testing.T) { FanoutConfig: fanout.Config{ Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { - CallableDomain: "second-call-domain", + CallableDomain: replaceDomain, }, }, }, }, }, }, - cf: &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusOK, - Body: ioutil.NopCloser(strings.NewReader("{}")), - }, - }, - }, + respStatusCode: http.StatusOK, key: "second-channel.default", - requestDomain: "second-call-domain", expectedStatusCode: http.StatusOK, }, } @@ -309,8 +287,14 @@ func TestServeHTTP(t *testing.T) { r := httptest.NewRequest("POST", fmt.Sprintf("http://%s/", key), strings.NewReader("{}")) return r } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + server := httptest.NewServer(&fakeHandler{statusCode: tc.respStatusCode}) + defer server.Close() + + // Rewrite the replaceDomains to call the server we just created. + replaceDomains(tc.config, server.URL[7:]) + h, err := NewHandler(zap.NewNop(), tc.config) if err != nil { t.Errorf("Unexpected NewHandler error: '%v'", err) @@ -326,12 +310,30 @@ func TestServeHTTP(t *testing.T) { if w.Body.String() != "" { t.Errorf("Expected empty response body. Actual: %v", w.Body) } - if tc.requestDomain != "" { - reqs := tc.cf.GetRequests() - if reqs[0].Host != tc.requestDomain { - t.Errorf("Called incorrect domain. Expected: '%v'. Actual '%v'", tc.requestDomain, reqs[0].Host) - } - } }) } } + +func replaceDomains(config Config, replacement string) { + for i, cc := range config.ChannelConfigs { + for j, sub := range cc.FanoutConfig.Subscriptions { + if sub.CallableDomain == replaceDomain { + sub.CallableDomain = replacement + } + if sub.SinkableDomain == replaceDomain { + sub.SinkableDomain = replacement + } + cc.FanoutConfig.Subscriptions[j] = sub + } + config.ChannelConfigs[i] = cc + } +} + +type fakeHandler struct { + statusCode int +} + +func (h *fakeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + defer r.Body.Close() + w.WriteHeader(h.statusCode) +} From 6ed11df127cda056bc0167212a90fcda7f825d2f Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Thu, 27 Sep 2018 14:16:11 -0700 Subject: [PATCH 07/23] Remove ClientFactory. --- cmd/fanoutsidecar/main.go | 3 +- pkg/sidecar/clientfactory/client_factory.go | 36 --------- .../clientfactory/client_factory_test.go | 33 -------- .../clientfactory/fake/fake_client_factory.go | 75 ------------------- .../config_map_handler_test.go | 4 +- 5 files changed, 3 insertions(+), 148 deletions(-) delete mode 100644 pkg/sidecar/clientfactory/client_factory.go delete mode 100644 pkg/sidecar/clientfactory/client_factory_test.go delete mode 100644 pkg/sidecar/clientfactory/fake/fake_client_factory.go diff --git a/cmd/fanoutsidecar/main.go b/cmd/fanoutsidecar/main.go index 7238246c8e6..97efbd2178b 100644 --- a/cmd/fanoutsidecar/main.go +++ b/cmd/fanoutsidecar/main.go @@ -22,7 +22,6 @@ package main import ( "flag" "fmt" - "github.com/knative/eventing/pkg/sidecar/clientfactory" "github.com/knative/eventing/pkg/sidecar/configmaphandler" "go.uber.org/zap" "net/http" @@ -46,7 +45,7 @@ func main() { panic(err) } - cmh, err := configmaphandler.NewHandler(logger, configmaphandler.ConfigDir, &clientfactory.Standard{}) + cmh, err := configmaphandler.NewHandler(logger, configmaphandler.ConfigDir) if err != nil { logger.Fatal("Unable to create configmaphandler.Handler", zap.Error(err)) } diff --git a/pkg/sidecar/clientfactory/client_factory.go b/pkg/sidecar/clientfactory/client_factory.go deleted file mode 100644 index 17651fffc57..00000000000 --- a/pkg/sidecar/clientfactory/client_factory.go +++ /dev/null @@ -1,36 +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 clientfactory - -import "net/http" - -// ClientFactory creates HTTP clients. -type ClientFactory interface { - Create() (HttpDoer, error) -} - -// ClientFactory that creates http.Client. -type Standard struct{} - -func (_ *Standard) Create() (HttpDoer, error) { - return &http.Client{}, nil -} - -// Makes generic HTTP requests. -type HttpDoer interface { - Do(req *http.Request) (*http.Response, error) -} diff --git a/pkg/sidecar/clientfactory/client_factory_test.go b/pkg/sidecar/clientfactory/client_factory_test.go deleted file mode 100644 index 264d68d4c41..00000000000 --- a/pkg/sidecar/clientfactory/client_factory_test.go +++ /dev/null @@ -1,33 +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 clientfactory - -import ( - "net/http" - "testing" -) - -func TestStandard_Create(t *testing.T) { - s := &Standard{} - c, err := s.Create() - if err != nil { - t.Errorf("Received an error creating a client interface: %v", err) - } - if _, ok := c.(*http.Client); !ok { - t.Errorf("clientfactory.Standard did not create an *http.Client") - } -} diff --git a/pkg/sidecar/clientfactory/fake/fake_client_factory.go b/pkg/sidecar/clientfactory/fake/fake_client_factory.go deleted file mode 100644 index 6d182553baa..00000000000 --- a/pkg/sidecar/clientfactory/fake/fake_client_factory.go +++ /dev/null @@ -1,75 +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 fake - -import ( - "errors" - "github.com/knative/eventing/pkg/sidecar/clientfactory" - "net/http" - "sync" -) - -// A fake ClientFactory that will return the errors or responses specified. As well as record all -// requests made. -type ClientFactory struct { - // Error to return when calling Create(). - CreateErr error - // Guards req. - reqMu sync.Mutex - // The HTTP requests made. Only access when holding reqMu. - req []*http.Request - - // Error to return when calling Do(). - RespErr error - - // Resp are the responses to send out. All entries are sent once, except for the last response, - // which is sent on all subsequent calls to Do(). - Resp []*http.Response -} - -func (f *ClientFactory) Create() (clientfactory.HttpDoer, error) { - if f.CreateErr != nil { - return nil, f.CreateErr - } - return f, nil -} - -func (f *ClientFactory) Do(r *http.Request) (*http.Response, error) { - f.reqMu.Lock() - defer f.reqMu.Unlock() - f.req = append(f.req, r) - if f.RespErr != nil { - return nil, f.RespErr - } - if len(f.Resp) == 0 { - return nil, errors.New("test failure -- no response in fake.ClientFactory") - } - resp := f.Resp[0] - if len(f.Resp) > 1 { - f.Resp = f.Resp[1:] - } - return resp, nil -} - -// GetRequests return all the requests made so far. -func (f *ClientFactory) GetRequests() []*http.Request { - f.reqMu.Lock() - defer f.reqMu.Unlock() - rv := make([]*http.Request, len(f.req)) - copy(rv, f.req) - return rv -} diff --git a/pkg/sidecar/configmaphandler/config_map_handler_test.go b/pkg/sidecar/configmaphandler/config_map_handler_test.go index 41629f3ffed..41096c4a921 100644 --- a/pkg/sidecar/configmaphandler/config_map_handler_test.go +++ b/pkg/sidecar/configmaphandler/config_map_handler_test.go @@ -209,7 +209,7 @@ func TestNewHandler(t *testing.T) { dir = "/tmp/doesNotExist" } writeConfig(t, dir, tc.config) - cmh, err := NewHandler(zap.NewNop(), dir, &fake.ClientFactory{}) + cmh, err := NewHandler(zap.NewNop(), dir) if err == nil { // This is not yet about the logic of the test, just ensuring we don't accidentally // leave the channel open, which will leave the watcher running. @@ -308,7 +308,7 @@ func TestServeHTTP(t *testing.T) { }, }, } - cmh, _ := NewHandler(zap.NewNop(), dir, cf) + cmh, _ := NewHandler(zap.NewNop(), dir) w := httptest.NewRecorder() cmh.ServeHTTP(w, makeRequest("default", "c1")) From 7de128d46c686be042275cf656bb14efa2d69064 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Thu, 27 Sep 2018 15:12:33 -0700 Subject: [PATCH 08/23] All tests working. --- .../config_map_handler_test.go | 102 +++++++++------ .../multi_channel_fanout_handler.go | 10 +- .../multi_channel_fanout_handler_test.go | 2 +- pkg/sidecar/swappable/swappable.go | 6 +- pkg/sidecar/swappable/swappable_test.go | 119 ++++++++++++++++++ 5 files changed, 187 insertions(+), 52 deletions(-) diff --git a/pkg/sidecar/configmaphandler/config_map_handler_test.go b/pkg/sidecar/configmaphandler/config_map_handler_test.go index 41096c4a921..0b847d467e7 100644 --- a/pkg/sidecar/configmaphandler/config_map_handler_test.go +++ b/pkg/sidecar/configmaphandler/config_map_handler_test.go @@ -19,10 +19,10 @@ package configmaphandler import ( "fmt" "github.com/google/go-cmp/cmp" - "github.com/knative/eventing/pkg/sidecar/clientfactory/fake" "github.com/knative/eventing/pkg/sidecar/fanout" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "go.uber.org/atomic" "go.uber.org/zap" "io" "io/ioutil" @@ -34,6 +34,10 @@ import ( "time" ) +const ( + replaceDomain = "replaceDomain" +) + func TestReadConfigMap(t *testing.T) { testCases := []struct { name string @@ -82,20 +86,20 @@ func TestReadConfigMap(t *testing.T) { name: c1 fanoutConfig: subscriptions: - - callDomain: event-changer.default.svc.cluster.local - toDomain: message-dumper-bar.default.svc.cluster.local - - callDomain: message-dumper-foo.default.svc.cluster.local - - toDomain: message-dumper-bar.default.svc.cluster.local + - callableDomain: event-changer.default.svc.cluster.local + sinkableDomain: message-dumper-bar.default.svc.cluster.local + - callableDomain: message-dumper-foo.default.svc.cluster.local + - sinkableDomain: message-dumper-bar.default.svc.cluster.local - namespace: default name: c2 fanoutConfig: subscriptions: - - toDomain: message-dumper-foo.default.svc.cluster.local + - sinkableDomain: message-dumper-foo.default.svc.cluster.local - namespace: other name: c3 fanoutConfig: subscriptions: - - toDomain: message-dumper-foo.default.svc.cluster.local + - sinkableDomain: message-dumper-foo.default.svc.cluster.local `, expected: multichannelfanout.Config{ ChannelConfigs: []multichannelfanout.ChannelConfig{ @@ -106,7 +110,7 @@ func TestReadConfigMap(t *testing.T) { Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ { CallableDomain: "event-changer.default.svc.cluster.local", - SinkableDomain: "message-dumper-bar.default.svc.cluster.local", + SinkableDomain: "message-dumper-bar.default.svc.cluster.local", }, { CallableDomain: "message-dumper-foo.default.svc.cluster.local", @@ -227,11 +231,12 @@ func TestNewHandler(t *testing.T) { func TestServeHTTP(t *testing.T) { testCases := []struct { - name string - initialConfig string - updatedConfig string - expectedInitialDomain string - expectedUpdatedDomain string + name string + initialConfig string + updatedConfig string + initialRequests int32 + initialRequestsAfterUpdate int32 + updateRequests int32 }{ { name: "send to config", @@ -241,9 +246,9 @@ func TestServeHTTP(t *testing.T) { name: c1 fanoutConfig: subscriptions: - - toDomain: initial-domain + - sinkableDomain: replaceDomain `, - expectedInitialDomain: "initial-domain", + initialRequests: 1, }, { name: "change config", @@ -253,18 +258,18 @@ func TestServeHTTP(t *testing.T) { name: c1 fanoutConfig: subscriptions: - - toDomain: initial-domain + - sinkableDomain: replaceDomain `, - expectedInitialDomain: "initial-domain", + initialRequests: 1, updatedConfig: ` channelConfigs: - namespace: default name: c1 fanoutConfig: subscriptions: - - toDomain: updated-domain + - sinkableDomain: replaceDomain `, - expectedUpdatedDomain: "updated-domain", + updateRequests: 1, }, { name: "bad config update -- keeps serving old config", @@ -274,40 +279,39 @@ func TestServeHTTP(t *testing.T) { name: c1 fanoutConfig: subscriptions: - - toDomain: initial-domain + - sinkableDomain: replaceDomain `, - expectedInitialDomain: "initial-domain", + initialRequests: 1, updatedConfig: ` channelConfigs: - namespace: default name: c1 fanoutConfig: subscriptions: - - toDomain: updated-domain + - sinkableDomain: replaceDomain # Duplicate namespace/name - namespace: default name: c1 fanoutConfig: subscriptions: - - toDomain: updated-domain + - sinkableDomain: replaceDomain `, - expectedUpdatedDomain: "initial-domain", + initialRequestsAfterUpdate: 2, }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + initialHandler := &fakeHandler{} + initialServer := httptest.NewServer(initialHandler) + defer initialServer.Close() + updateHandler := &fakeHandler{} + updateServer := httptest.NewServer(updateHandler) + defer updateServer.Close() + dir := createTempDir(t) defer os.RemoveAll(dir) - writeConfig(t, dir, tc.initialConfig) + writeConfig(t, dir, replaceDomains(tc.initialConfig, initialServer.URL[7:])) - cf := &fake.ClientFactory{ - Resp: []*http.Response{ - { - StatusCode: http.StatusOK, - Body: body(""), - }, - }, - } cmh, _ := NewHandler(zap.NewNop(), dir) w := httptest.NewRecorder() @@ -315,12 +319,13 @@ func TestServeHTTP(t *testing.T) { if w.Result().StatusCode != http.StatusOK { t.Errorf("Unexpected initial status code: %v", w.Result().StatusCode) } - if initialHost := cf.GetRequests()[0].Host; initialHost != tc.expectedInitialDomain { - t.Errorf("Sent initial request to wrong domain. Expected: '%v'. Actual '%v'", tc.expectedInitialDomain, initialHost) + if tc.initialRequests != initialHandler.requests.Load() { + t.Errorf("Incorrect initial request count. Expected %v. Actual %v.", + tc.initialRequests, initialHandler.requests.Load()) } if tc.updatedConfig != "" { - writeConfig(t, dir, tc.updatedConfig) + writeConfig(t, dir, replaceDomains(tc.updatedConfig, updateServer.URL[7:])) // The watcher is running in another routine, give it some time to notice the // change. time.Sleep(100 * time.Millisecond) @@ -329,8 +334,12 @@ func TestServeHTTP(t *testing.T) { if w.Result().StatusCode != http.StatusOK { t.Errorf("Unexpected updated status code: %v", w.Result().StatusCode) } - if updatedDomain := cf.GetRequests()[1].Host; updatedDomain != tc.expectedUpdatedDomain { - t.Errorf("Sent updated request to wrong domain. Expected: '%v'. Actual: '%v'", tc.expectedUpdatedDomain, updatedDomain) + if tc.updateRequests != updateHandler.requests.Load() { + t.Errorf("Incorrect update request count. Expected %v. Actual %v.", tc.updateRequests, updateHandler.requests.Load()) + } + if tc.initialRequestsAfterUpdate != 0 && tc.initialRequestsAfterUpdate != initialHandler.requests.Load() { + t.Errorf("Incorrect requests to initialHandler after config update. Expected %v, actual %v", + tc.initialRequestsAfterUpdate, initialHandler.requests.Load()) } } }) @@ -362,7 +371,20 @@ func body(body string) io.ReadCloser { } func makeRequest(namespace, name string) *http.Request { - r := httptest.NewRequest("POST", "http://example/", body("")) - r.Header.Add(multichannelfanout.ChannelKeyHeader, multichannelfanout.MakeChannelKey(namespace, name)) + r := httptest.NewRequest("POST", fmt.Sprintf("http://%s.%s/", name, namespace), body("")) return r } + +type fakeHandler struct { + requests atomic.Int32 +} + +func (h *fakeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + defer r.Body.Close() + w.WriteHeader(http.StatusOK) + h.requests.Inc() +} + +func replaceDomains(config, replacement string) string { + return strings.Replace(config, replaceDomain, replacement, -1) +} diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go index b225de0cd64..5228b55e6e3 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go @@ -25,12 +25,6 @@ import ( "net/http" ) -const ( - // The header injected into requests to state which `Channel` this request is being sent on. The - // value is in the format created by multichannelfanout.MakeChannelKey(). - ChannelKeyHeader = "X-Channel-Key" -) - // The configuration of this handler. type Config struct { // The configuration of each channel in this handler. @@ -46,14 +40,14 @@ type ChannelConfig struct { // MakeChannelKey creates the value to be sent in the HTTP header // multichannelfanout.ChannelKeyHeader. This represents the `Channel` the request is being sent // upon. -func MakeChannelKey(namespace, name string) string { +func makeChannelKey(namespace, name string) string { return fmt.Sprintf("%s/%s", namespace, name) } // makeChannelKeyFromConfig creates the channel key for a given channelConfig. It is a helper around // MakeChannelKey. func makeChannelKeyFromConfig(config ChannelConfig) string { - return MakeChannelKey(config.Namespace, config.Name) + return makeChannelKey(config.Namespace, config.Name) } // getChannelKey extracts the channel key from the given HTTP request. diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go index 16a99135168..57be69cd0e4 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go @@ -53,7 +53,7 @@ func TestMakeChannelKey(t *testing.T) { for _, tc := range testCases { name := fmt.Sprintf("%s, %s -> %s", tc.namespace, tc.name, tc.key) t.Run(name, func(t *testing.T) { - if key := MakeChannelKey(tc.namespace, tc.name); key != tc.key { + if key := makeChannelKey(tc.namespace, tc.name); key != tc.key { t.Errorf("Unexpected ChannelKey. Expected '%v'. Actual '%v'", tc.key, key) } }) diff --git a/pkg/sidecar/swappable/swappable.go b/pkg/sidecar/swappable/swappable.go index b047ff0f977..6c8f75d0d9e 100644 --- a/pkg/sidecar/swappable/swappable.go +++ b/pkg/sidecar/swappable/swappable.go @@ -32,12 +32,12 @@ type Handler struct { } // NewHandler creates a new swappable.Handler. -func NewHandler(handler *multichannelfanout.Handler, logger *zap.Logger) (*Handler, error) { +func NewHandler(handler *multichannelfanout.Handler, logger *zap.Logger) *Handler { h := &Handler{ logger: logger.With(zap.String("httpHandler", "swappable")), } h.SetMultiChannelFanoutHandler(handler) - return h, nil + return h } func NewEmptyHandler(logger *zap.Logger) (*Handler, error) { @@ -45,7 +45,7 @@ func NewEmptyHandler(logger *zap.Logger) (*Handler, error) { if err != nil { return nil, err } - return NewHandler(h, logger) + return NewHandler(h, logger), nil } // getMultiChannelFanoutHandler gets the current multichannelfanout.Handler to delegate all HTTP diff --git a/pkg/sidecar/swappable/swappable_test.go b/pkg/sidecar/swappable/swappable_test.go index bac440efb7b..55de79207bd 100644 --- a/pkg/sidecar/swappable/swappable_test.go +++ b/pkg/sidecar/swappable/swappable_test.go @@ -15,3 +15,122 @@ limitations under the License. */ package swappable + +import ( + "fmt" + "github.com/knative/eventing/pkg/sidecar/fanout" + "github.com/knative/eventing/pkg/sidecar/multichannelfanout" + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "go.uber.org/zap" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +const ( + namespace = "default" + name = "channel1" + replaceDomain = "replaceDomain" +) + +func TestHandler(t *testing.T) { + testCases := map[string]struct { + configs []multichannelfanout.Config + }{ + "config change": { + configs: []multichannelfanout.Config{ + { + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: namespace, + Name: name, + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: replaceDomain, + }, + }, + }, + }, + }, + }, + { + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: namespace, + Name: name, + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + SinkableDomain: replaceDomain, + }, + }, + }, + }, + }, + }, + }, + }, + } + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + h, err := NewEmptyHandler(zap.NewNop()) + if err != nil { + t.Errorf("Unexpected error creating handler: %v", err) + } + for _, c := range tc.configs { + updateConfigAndTest(t, h, c) + } + }) + } +} + +func updateConfigAndTest(t *testing.T, h *Handler, config multichannelfanout.Config) { + server := httptest.NewServer(&successHandler{}) + defer server.Close() + + nh, err := multichannelfanout.NewHandler(zap.NewNop(), replaceDomains(config, server.URL[7:])) + if err != nil { + t.Errorf("Unexpected error creating multiChannelFanoutHandler: %v", err) + } + orig := h.GetMultiChannelFanoutHandler() + h.SetMultiChannelFanoutHandler(nh) + if orig == h.GetMultiChannelFanoutHandler() { + t.Errorf("Expected the inner multiChannelFanoutHandler to change, it didn't: %v", orig) + } + + w := httptest.NewRecorder() + h.ServeHTTP(w, makeRequest(namespace, name)) + if w.Code != http.StatusOK { + t.Errorf("Unexpected response code. Expected 200. Actual %v", w.Code) + } +} + +type successHandler struct{} + +func (*successHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + r.Body.Close() +} + +func makeRequest(namespace, name string) *http.Request { + r := httptest.NewRequest("POST", fmt.Sprintf("http://%s.%s/", name, namespace), strings.NewReader("")) + return r +} + +func replaceDomains(c multichannelfanout.Config, replacement string) multichannelfanout.Config { + for i, cc := range c.ChannelConfigs { + for j, sub := range cc.FanoutConfig.Subscriptions { + if sub.SinkableDomain == replaceDomain { + sub.SinkableDomain = replacement + } + if sub.CallableDomain == replaceDomain { + sub.CallableDomain = replacement + } + cc.FanoutConfig.Subscriptions[j] = sub + } + c.ChannelConfigs[i] = cc + } + return c +} From b7bdd18992e140c02ae14b7eea3fef858fe69a6d Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Thu, 27 Sep 2018 17:58:59 -0700 Subject: [PATCH 09/23] Remove erroneous messages from storage. --- pkg/sidecar/fanout/fanout_handler.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/sidecar/fanout/fanout_handler.go b/pkg/sidecar/fanout/fanout_handler.go index 13e380f43e4..798005a6a4d 100644 --- a/pkg/sidecar/fanout/fanout_handler.go +++ b/pkg/sidecar/fanout/fanout_handler.go @@ -91,6 +91,8 @@ func (f *fanoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if receiverResponse.statusCode != http.StatusAccepted { f.logger.Info("MessageReceiver rejected the request", zap.Int("statusCode", receiverResponse.statusCode)) w.WriteHeader(receiverResponse.statusCode) + // We don't care about the message, we just don't want it to stay in the map forever. + f.receivedMessages.pull(key) return } From 5f690907b66bcba0181d585263537572dafeaa83 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Thu, 27 Sep 2018 18:06:28 -0700 Subject: [PATCH 10/23] Run hack/update-deps.sh. --- Gopkg.lock | 12 +- third_party/VENDOR-LICENSE | 34 ++ vendor/github.com/fsnotify/fsnotify/AUTHORS | 52 ++ vendor/github.com/fsnotify/fsnotify/LICENSE | 28 + vendor/github.com/fsnotify/fsnotify/fen.go | 37 ++ .../github.com/fsnotify/fsnotify/fsnotify.go | 66 +++ .../github.com/fsnotify/fsnotify/inotify.go | 337 +++++++++++ .../fsnotify/fsnotify/inotify_poller.go | 187 ++++++ vendor/github.com/fsnotify/fsnotify/kqueue.go | 521 ++++++++++++++++ .../fsnotify/fsnotify/open_mode_bsd.go | 11 + .../fsnotify/fsnotify/open_mode_darwin.go | 12 + .../github.com/fsnotify/fsnotify/windows.go | 561 ++++++++++++++++++ 12 files changed, 1857 insertions(+), 1 deletion(-) create mode 100644 vendor/github.com/fsnotify/fsnotify/AUTHORS create mode 100644 vendor/github.com/fsnotify/fsnotify/LICENSE create mode 100644 vendor/github.com/fsnotify/fsnotify/fen.go create mode 100644 vendor/github.com/fsnotify/fsnotify/fsnotify.go create mode 100644 vendor/github.com/fsnotify/fsnotify/inotify.go create mode 100644 vendor/github.com/fsnotify/fsnotify/inotify_poller.go create mode 100644 vendor/github.com/fsnotify/fsnotify/kqueue.go create mode 100644 vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go create mode 100644 vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go create mode 100644 vendor/github.com/fsnotify/fsnotify/windows.go diff --git a/Gopkg.lock b/Gopkg.lock index ea36adaf014..2841d6a8709 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -71,6 +71,14 @@ revision = "44cc805cf13205b55f69e14bcb69867d1ae92f98" version = "v1.1.0" +[[projects]] + digest = "1:1b91ae0dc69a41d4c2ed23ea5cffb721ea63f5037ca4b81e6d6771fbb8f45129" + name = "github.com/fsnotify/fsnotify" + packages = ["."] + pruneopts = "NUT" + revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" + version = "v1.4.7" + [[projects]] digest = "1:81466b4218bf6adddac2572a30ac733a9255919bc2f470b4827a317bd4ee1756" name = "github.com/ghodss/yaml" @@ -1049,6 +1057,7 @@ "github.com/Shopify/sarama", "github.com/bsm/sarama-cluster", "github.com/davecgh/go-spew/spew", + "github.com/fsnotify/fsnotify", "github.com/golang/glog", "github.com/google/go-cmp/cmp", "github.com/google/go-cmp/cmp/cmpopts", @@ -1069,8 +1078,8 @@ "github.com/knative/serving/pkg/apis/serving/v1alpha1", "github.com/knative/serving/pkg/client/clientset/versioned", "github.com/knative/test-infra", - "github.com/mattbaird/jsonpatch", "github.com/prometheus/client_golang/prometheus/promhttp", + "go.uber.org/atomic", "go.uber.org/zap", "go.uber.org/zap/zapcore", "golang.org/x/net/context", @@ -1099,6 +1108,7 @@ "k8s.io/apimachinery/pkg/util/sets/types", "k8s.io/apimachinery/pkg/util/validation", "k8s.io/apimachinery/pkg/util/wait", + "k8s.io/apimachinery/pkg/util/yaml", "k8s.io/apimachinery/pkg/watch", "k8s.io/client-go/discovery", "k8s.io/client-go/discovery/fake", diff --git a/third_party/VENDOR-LICENSE b/third_party/VENDOR-LICENSE index d28593bbdba..45ce934d7ba 100644 --- a/third_party/VENDOR-LICENSE +++ b/third_party/VENDOR-LICENSE @@ -254,6 +254,40 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +=========================================================== +Import: github.com/knative/eventing/vendor/github.com/fsnotify/fsnotify + +Copyright (c) 2012 The Go Authors. All rights reserved. +Copyright (c) 2012 fsnotify Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + =========================================================== Import: github.com/knative/eventing/vendor/github.com/ghodss/yaml diff --git a/vendor/github.com/fsnotify/fsnotify/AUTHORS b/vendor/github.com/fsnotify/fsnotify/AUTHORS new file mode 100644 index 00000000000..5ab5d41c547 --- /dev/null +++ b/vendor/github.com/fsnotify/fsnotify/AUTHORS @@ -0,0 +1,52 @@ +# Names should be added to this file as +# Name or Organization +# The email address is not required for organizations. + +# You can update this list using the following command: +# +# $ git shortlog -se | awk '{print $2 " " $3 " " $4}' + +# Please keep the list sorted. + +Aaron L +Adrien Bustany +Amit Krishnan +Anmol Sethi +Bjørn Erik Pedersen +Bruno Bigras +Caleb Spare +Case Nelson +Chris Howey +Christoffer Buchholz +Daniel Wagner-Hall +Dave Cheney +Evan Phoenix +Francisco Souza +Hari haran +John C Barstow +Kelvin Fo +Ken-ichirou MATSUZAWA +Matt Layher +Nathan Youngman +Nickolai Zeldovich +Patrick +Paul Hammond +Pawel Knap +Pieter Droogendijk +Pursuit92 +Riku Voipio +Rob Figueiredo +Rodrigo Chiossi +Slawek Ligus +Soge Zhang +Tiffany Jernigan +Tilak Sharma +Tom Payne +Travis Cline +Tudor Golubenco +Vahe Khachikyan +Yukang +bronze1man +debrando +henrikedwards +铁哥 diff --git a/vendor/github.com/fsnotify/fsnotify/LICENSE b/vendor/github.com/fsnotify/fsnotify/LICENSE new file mode 100644 index 00000000000..f21e5408009 --- /dev/null +++ b/vendor/github.com/fsnotify/fsnotify/LICENSE @@ -0,0 +1,28 @@ +Copyright (c) 2012 The Go Authors. All rights reserved. +Copyright (c) 2012 fsnotify Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/fsnotify/fsnotify/fen.go b/vendor/github.com/fsnotify/fsnotify/fen.go new file mode 100644 index 00000000000..ced39cb881e --- /dev/null +++ b/vendor/github.com/fsnotify/fsnotify/fen.go @@ -0,0 +1,37 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build solaris + +package fsnotify + +import ( + "errors" +) + +// Watcher watches a set of files, delivering events to a channel. +type Watcher struct { + Events chan Event + Errors chan error +} + +// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. +func NewWatcher() (*Watcher, error) { + return nil, errors.New("FEN based watcher not yet supported for fsnotify\n") +} + +// Close removes all watches and closes the events channel. +func (w *Watcher) Close() error { + return nil +} + +// Add starts watching the named file or directory (non-recursively). +func (w *Watcher) Add(name string) error { + return nil +} + +// Remove stops watching the the named file or directory (non-recursively). +func (w *Watcher) Remove(name string) error { + return nil +} diff --git a/vendor/github.com/fsnotify/fsnotify/fsnotify.go b/vendor/github.com/fsnotify/fsnotify/fsnotify.go new file mode 100644 index 00000000000..190bf0de575 --- /dev/null +++ b/vendor/github.com/fsnotify/fsnotify/fsnotify.go @@ -0,0 +1,66 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !plan9 + +// Package fsnotify provides a platform-independent interface for file system notifications. +package fsnotify + +import ( + "bytes" + "errors" + "fmt" +) + +// Event represents a single file system notification. +type Event struct { + Name string // Relative path to the file or directory. + Op Op // File operation that triggered the event. +} + +// Op describes a set of file operations. +type Op uint32 + +// These are the generalized file operations that can trigger a notification. +const ( + Create Op = 1 << iota + Write + Remove + Rename + Chmod +) + +func (op Op) String() string { + // Use a buffer for efficient string concatenation + var buffer bytes.Buffer + + if op&Create == Create { + buffer.WriteString("|CREATE") + } + if op&Remove == Remove { + buffer.WriteString("|REMOVE") + } + if op&Write == Write { + buffer.WriteString("|WRITE") + } + if op&Rename == Rename { + buffer.WriteString("|RENAME") + } + if op&Chmod == Chmod { + buffer.WriteString("|CHMOD") + } + if buffer.Len() == 0 { + return "" + } + return buffer.String()[1:] // Strip leading pipe +} + +// String returns a string representation of the event in the form +// "file: REMOVE|WRITE|..." +func (e Event) String() string { + return fmt.Sprintf("%q: %s", e.Name, e.Op.String()) +} + +// Common errors that can be reported by a watcher +var ErrEventOverflow = errors.New("fsnotify queue overflow") diff --git a/vendor/github.com/fsnotify/fsnotify/inotify.go b/vendor/github.com/fsnotify/fsnotify/inotify.go new file mode 100644 index 00000000000..d9fd1b88a05 --- /dev/null +++ b/vendor/github.com/fsnotify/fsnotify/inotify.go @@ -0,0 +1,337 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build linux + +package fsnotify + +import ( + "errors" + "fmt" + "io" + "os" + "path/filepath" + "strings" + "sync" + "unsafe" + + "golang.org/x/sys/unix" +) + +// Watcher watches a set of files, delivering events to a channel. +type Watcher struct { + Events chan Event + Errors chan error + mu sync.Mutex // Map access + fd int + poller *fdPoller + watches map[string]*watch // Map of inotify watches (key: path) + paths map[int]string // Map of watched paths (key: watch descriptor) + done chan struct{} // Channel for sending a "quit message" to the reader goroutine + doneResp chan struct{} // Channel to respond to Close +} + +// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. +func NewWatcher() (*Watcher, error) { + // Create inotify fd + fd, errno := unix.InotifyInit1(unix.IN_CLOEXEC) + if fd == -1 { + return nil, errno + } + // Create epoll + poller, err := newFdPoller(fd) + if err != nil { + unix.Close(fd) + return nil, err + } + w := &Watcher{ + fd: fd, + poller: poller, + watches: make(map[string]*watch), + paths: make(map[int]string), + Events: make(chan Event), + Errors: make(chan error), + done: make(chan struct{}), + doneResp: make(chan struct{}), + } + + go w.readEvents() + return w, nil +} + +func (w *Watcher) isClosed() bool { + select { + case <-w.done: + return true + default: + return false + } +} + +// Close removes all watches and closes the events channel. +func (w *Watcher) Close() error { + if w.isClosed() { + return nil + } + + // Send 'close' signal to goroutine, and set the Watcher to closed. + close(w.done) + + // Wake up goroutine + w.poller.wake() + + // Wait for goroutine to close + <-w.doneResp + + return nil +} + +// Add starts watching the named file or directory (non-recursively). +func (w *Watcher) Add(name string) error { + name = filepath.Clean(name) + if w.isClosed() { + return errors.New("inotify instance already closed") + } + + const agnosticEvents = unix.IN_MOVED_TO | unix.IN_MOVED_FROM | + unix.IN_CREATE | unix.IN_ATTRIB | unix.IN_MODIFY | + unix.IN_MOVE_SELF | unix.IN_DELETE | unix.IN_DELETE_SELF + + var flags uint32 = agnosticEvents + + w.mu.Lock() + defer w.mu.Unlock() + watchEntry := w.watches[name] + if watchEntry != nil { + flags |= watchEntry.flags | unix.IN_MASK_ADD + } + wd, errno := unix.InotifyAddWatch(w.fd, name, flags) + if wd == -1 { + return errno + } + + if watchEntry == nil { + w.watches[name] = &watch{wd: uint32(wd), flags: flags} + w.paths[wd] = name + } else { + watchEntry.wd = uint32(wd) + watchEntry.flags = flags + } + + return nil +} + +// Remove stops watching the named file or directory (non-recursively). +func (w *Watcher) Remove(name string) error { + name = filepath.Clean(name) + + // Fetch the watch. + w.mu.Lock() + defer w.mu.Unlock() + watch, ok := w.watches[name] + + // Remove it from inotify. + if !ok { + return fmt.Errorf("can't remove non-existent inotify watch for: %s", name) + } + + // We successfully removed the watch if InotifyRmWatch doesn't return an + // error, we need to clean up our internal state to ensure it matches + // inotify's kernel state. + delete(w.paths, int(watch.wd)) + delete(w.watches, name) + + // inotify_rm_watch will return EINVAL if the file has been deleted; + // the inotify will already have been removed. + // watches and pathes are deleted in ignoreLinux() implicitly and asynchronously + // by calling inotify_rm_watch() below. e.g. readEvents() goroutine receives IN_IGNORE + // so that EINVAL means that the wd is being rm_watch()ed or its file removed + // by another thread and we have not received IN_IGNORE event. + success, errno := unix.InotifyRmWatch(w.fd, watch.wd) + if success == -1 { + // TODO: Perhaps it's not helpful to return an error here in every case. + // the only two possible errors are: + // EBADF, which happens when w.fd is not a valid file descriptor of any kind. + // EINVAL, which is when fd is not an inotify descriptor or wd is not a valid watch descriptor. + // Watch descriptors are invalidated when they are removed explicitly or implicitly; + // explicitly by inotify_rm_watch, implicitly when the file they are watching is deleted. + return errno + } + + return nil +} + +type watch struct { + wd uint32 // Watch descriptor (as returned by the inotify_add_watch() syscall) + flags uint32 // inotify flags of this watch (see inotify(7) for the list of valid flags) +} + +// readEvents reads from the inotify file descriptor, converts the +// received events into Event objects and sends them via the Events channel +func (w *Watcher) readEvents() { + var ( + buf [unix.SizeofInotifyEvent * 4096]byte // Buffer for a maximum of 4096 raw events + n int // Number of bytes read with read() + errno error // Syscall errno + ok bool // For poller.wait + ) + + defer close(w.doneResp) + defer close(w.Errors) + defer close(w.Events) + defer unix.Close(w.fd) + defer w.poller.close() + + for { + // See if we have been closed. + if w.isClosed() { + return + } + + ok, errno = w.poller.wait() + if errno != nil { + select { + case w.Errors <- errno: + case <-w.done: + return + } + continue + } + + if !ok { + continue + } + + n, errno = unix.Read(w.fd, buf[:]) + // If a signal interrupted execution, see if we've been asked to close, and try again. + // http://man7.org/linux/man-pages/man7/signal.7.html : + // "Before Linux 3.8, reads from an inotify(7) file descriptor were not restartable" + if errno == unix.EINTR { + continue + } + + // unix.Read might have been woken up by Close. If so, we're done. + if w.isClosed() { + return + } + + if n < unix.SizeofInotifyEvent { + var err error + if n == 0 { + // If EOF is received. This should really never happen. + err = io.EOF + } else if n < 0 { + // If an error occurred while reading. + err = errno + } else { + // Read was too short. + err = errors.New("notify: short read in readEvents()") + } + select { + case w.Errors <- err: + case <-w.done: + return + } + continue + } + + var offset uint32 + // We don't know how many events we just read into the buffer + // While the offset points to at least one whole event... + for offset <= uint32(n-unix.SizeofInotifyEvent) { + // Point "raw" to the event in the buffer + raw := (*unix.InotifyEvent)(unsafe.Pointer(&buf[offset])) + + mask := uint32(raw.Mask) + nameLen := uint32(raw.Len) + + if mask&unix.IN_Q_OVERFLOW != 0 { + select { + case w.Errors <- ErrEventOverflow: + case <-w.done: + return + } + } + + // If the event happened to the watched directory or the watched file, the kernel + // doesn't append the filename to the event, but we would like to always fill the + // the "Name" field with a valid filename. We retrieve the path of the watch from + // the "paths" map. + w.mu.Lock() + name, ok := w.paths[int(raw.Wd)] + // IN_DELETE_SELF occurs when the file/directory being watched is removed. + // This is a sign to clean up the maps, otherwise we are no longer in sync + // with the inotify kernel state which has already deleted the watch + // automatically. + if ok && mask&unix.IN_DELETE_SELF == unix.IN_DELETE_SELF { + delete(w.paths, int(raw.Wd)) + delete(w.watches, name) + } + w.mu.Unlock() + + if nameLen > 0 { + // Point "bytes" at the first byte of the filename + bytes := (*[unix.PathMax]byte)(unsafe.Pointer(&buf[offset+unix.SizeofInotifyEvent])) + // The filename is padded with NULL bytes. TrimRight() gets rid of those. + name += "/" + strings.TrimRight(string(bytes[0:nameLen]), "\000") + } + + event := newEvent(name, mask) + + // Send the events that are not ignored on the events channel + if !event.ignoreLinux(mask) { + select { + case w.Events <- event: + case <-w.done: + return + } + } + + // Move to the next event in the buffer + offset += unix.SizeofInotifyEvent + nameLen + } + } +} + +// Certain types of events can be "ignored" and not sent over the Events +// channel. Such as events marked ignore by the kernel, or MODIFY events +// against files that do not exist. +func (e *Event) ignoreLinux(mask uint32) bool { + // Ignore anything the inotify API says to ignore + if mask&unix.IN_IGNORED == unix.IN_IGNORED { + return true + } + + // If the event is not a DELETE or RENAME, the file must exist. + // Otherwise the event is ignored. + // *Note*: this was put in place because it was seen that a MODIFY + // event was sent after the DELETE. This ignores that MODIFY and + // assumes a DELETE will come or has come if the file doesn't exist. + if !(e.Op&Remove == Remove || e.Op&Rename == Rename) { + _, statErr := os.Lstat(e.Name) + return os.IsNotExist(statErr) + } + return false +} + +// newEvent returns an platform-independent Event based on an inotify mask. +func newEvent(name string, mask uint32) Event { + e := Event{Name: name} + if mask&unix.IN_CREATE == unix.IN_CREATE || mask&unix.IN_MOVED_TO == unix.IN_MOVED_TO { + e.Op |= Create + } + if mask&unix.IN_DELETE_SELF == unix.IN_DELETE_SELF || mask&unix.IN_DELETE == unix.IN_DELETE { + e.Op |= Remove + } + if mask&unix.IN_MODIFY == unix.IN_MODIFY { + e.Op |= Write + } + if mask&unix.IN_MOVE_SELF == unix.IN_MOVE_SELF || mask&unix.IN_MOVED_FROM == unix.IN_MOVED_FROM { + e.Op |= Rename + } + if mask&unix.IN_ATTRIB == unix.IN_ATTRIB { + e.Op |= Chmod + } + return e +} diff --git a/vendor/github.com/fsnotify/fsnotify/inotify_poller.go b/vendor/github.com/fsnotify/fsnotify/inotify_poller.go new file mode 100644 index 00000000000..cc7db4b22ef --- /dev/null +++ b/vendor/github.com/fsnotify/fsnotify/inotify_poller.go @@ -0,0 +1,187 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build linux + +package fsnotify + +import ( + "errors" + + "golang.org/x/sys/unix" +) + +type fdPoller struct { + fd int // File descriptor (as returned by the inotify_init() syscall) + epfd int // Epoll file descriptor + pipe [2]int // Pipe for waking up +} + +func emptyPoller(fd int) *fdPoller { + poller := new(fdPoller) + poller.fd = fd + poller.epfd = -1 + poller.pipe[0] = -1 + poller.pipe[1] = -1 + return poller +} + +// Create a new inotify poller. +// This creates an inotify handler, and an epoll handler. +func newFdPoller(fd int) (*fdPoller, error) { + var errno error + poller := emptyPoller(fd) + defer func() { + if errno != nil { + poller.close() + } + }() + poller.fd = fd + + // Create epoll fd + poller.epfd, errno = unix.EpollCreate1(0) + if poller.epfd == -1 { + return nil, errno + } + // Create pipe; pipe[0] is the read end, pipe[1] the write end. + errno = unix.Pipe2(poller.pipe[:], unix.O_NONBLOCK) + if errno != nil { + return nil, errno + } + + // Register inotify fd with epoll + event := unix.EpollEvent{ + Fd: int32(poller.fd), + Events: unix.EPOLLIN, + } + errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.fd, &event) + if errno != nil { + return nil, errno + } + + // Register pipe fd with epoll + event = unix.EpollEvent{ + Fd: int32(poller.pipe[0]), + Events: unix.EPOLLIN, + } + errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.pipe[0], &event) + if errno != nil { + return nil, errno + } + + return poller, nil +} + +// Wait using epoll. +// Returns true if something is ready to be read, +// false if there is not. +func (poller *fdPoller) wait() (bool, error) { + // 3 possible events per fd, and 2 fds, makes a maximum of 6 events. + // I don't know whether epoll_wait returns the number of events returned, + // or the total number of events ready. + // I decided to catch both by making the buffer one larger than the maximum. + events := make([]unix.EpollEvent, 7) + for { + n, errno := unix.EpollWait(poller.epfd, events, -1) + if n == -1 { + if errno == unix.EINTR { + continue + } + return false, errno + } + if n == 0 { + // If there are no events, try again. + continue + } + if n > 6 { + // This should never happen. More events were returned than should be possible. + return false, errors.New("epoll_wait returned more events than I know what to do with") + } + ready := events[:n] + epollhup := false + epollerr := false + epollin := false + for _, event := range ready { + if event.Fd == int32(poller.fd) { + if event.Events&unix.EPOLLHUP != 0 { + // This should not happen, but if it does, treat it as a wakeup. + epollhup = true + } + if event.Events&unix.EPOLLERR != 0 { + // If an error is waiting on the file descriptor, we should pretend + // something is ready to read, and let unix.Read pick up the error. + epollerr = true + } + if event.Events&unix.EPOLLIN != 0 { + // There is data to read. + epollin = true + } + } + if event.Fd == int32(poller.pipe[0]) { + if event.Events&unix.EPOLLHUP != 0 { + // Write pipe descriptor was closed, by us. This means we're closing down the + // watcher, and we should wake up. + } + if event.Events&unix.EPOLLERR != 0 { + // If an error is waiting on the pipe file descriptor. + // This is an absolute mystery, and should never ever happen. + return false, errors.New("Error on the pipe descriptor.") + } + if event.Events&unix.EPOLLIN != 0 { + // This is a regular wakeup, so we have to clear the buffer. + err := poller.clearWake() + if err != nil { + return false, err + } + } + } + } + + if epollhup || epollerr || epollin { + return true, nil + } + return false, nil + } +} + +// Close the write end of the poller. +func (poller *fdPoller) wake() error { + buf := make([]byte, 1) + n, errno := unix.Write(poller.pipe[1], buf) + if n == -1 { + if errno == unix.EAGAIN { + // Buffer is full, poller will wake. + return nil + } + return errno + } + return nil +} + +func (poller *fdPoller) clearWake() error { + // You have to be woken up a LOT in order to get to 100! + buf := make([]byte, 100) + n, errno := unix.Read(poller.pipe[0], buf) + if n == -1 { + if errno == unix.EAGAIN { + // Buffer is empty, someone else cleared our wake. + return nil + } + return errno + } + return nil +} + +// Close all poller file descriptors, but not the one passed to it. +func (poller *fdPoller) close() { + if poller.pipe[1] != -1 { + unix.Close(poller.pipe[1]) + } + if poller.pipe[0] != -1 { + unix.Close(poller.pipe[0]) + } + if poller.epfd != -1 { + unix.Close(poller.epfd) + } +} diff --git a/vendor/github.com/fsnotify/fsnotify/kqueue.go b/vendor/github.com/fsnotify/fsnotify/kqueue.go new file mode 100644 index 00000000000..86e76a3d676 --- /dev/null +++ b/vendor/github.com/fsnotify/fsnotify/kqueue.go @@ -0,0 +1,521 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build freebsd openbsd netbsd dragonfly darwin + +package fsnotify + +import ( + "errors" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "sync" + "time" + + "golang.org/x/sys/unix" +) + +// Watcher watches a set of files, delivering events to a channel. +type Watcher struct { + Events chan Event + Errors chan error + done chan struct{} // Channel for sending a "quit message" to the reader goroutine + + kq int // File descriptor (as returned by the kqueue() syscall). + + mu sync.Mutex // Protects access to watcher data + watches map[string]int // Map of watched file descriptors (key: path). + externalWatches map[string]bool // Map of watches added by user of the library. + dirFlags map[string]uint32 // Map of watched directories to fflags used in kqueue. + paths map[int]pathInfo // Map file descriptors to path names for processing kqueue events. + fileExists map[string]bool // Keep track of if we know this file exists (to stop duplicate create events). + isClosed bool // Set to true when Close() is first called +} + +type pathInfo struct { + name string + isDir bool +} + +// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. +func NewWatcher() (*Watcher, error) { + kq, err := kqueue() + if err != nil { + return nil, err + } + + w := &Watcher{ + kq: kq, + watches: make(map[string]int), + dirFlags: make(map[string]uint32), + paths: make(map[int]pathInfo), + fileExists: make(map[string]bool), + externalWatches: make(map[string]bool), + Events: make(chan Event), + Errors: make(chan error), + done: make(chan struct{}), + } + + go w.readEvents() + return w, nil +} + +// Close removes all watches and closes the events channel. +func (w *Watcher) Close() error { + w.mu.Lock() + if w.isClosed { + w.mu.Unlock() + return nil + } + w.isClosed = true + + // copy paths to remove while locked + var pathsToRemove = make([]string, 0, len(w.watches)) + for name := range w.watches { + pathsToRemove = append(pathsToRemove, name) + } + w.mu.Unlock() + // unlock before calling Remove, which also locks + + for _, name := range pathsToRemove { + w.Remove(name) + } + + // send a "quit" message to the reader goroutine + close(w.done) + + return nil +} + +// Add starts watching the named file or directory (non-recursively). +func (w *Watcher) Add(name string) error { + w.mu.Lock() + w.externalWatches[name] = true + w.mu.Unlock() + _, err := w.addWatch(name, noteAllEvents) + return err +} + +// Remove stops watching the the named file or directory (non-recursively). +func (w *Watcher) Remove(name string) error { + name = filepath.Clean(name) + w.mu.Lock() + watchfd, ok := w.watches[name] + w.mu.Unlock() + if !ok { + return fmt.Errorf("can't remove non-existent kevent watch for: %s", name) + } + + const registerRemove = unix.EV_DELETE + if err := register(w.kq, []int{watchfd}, registerRemove, 0); err != nil { + return err + } + + unix.Close(watchfd) + + w.mu.Lock() + isDir := w.paths[watchfd].isDir + delete(w.watches, name) + delete(w.paths, watchfd) + delete(w.dirFlags, name) + w.mu.Unlock() + + // Find all watched paths that are in this directory that are not external. + if isDir { + var pathsToRemove []string + w.mu.Lock() + for _, path := range w.paths { + wdir, _ := filepath.Split(path.name) + if filepath.Clean(wdir) == name { + if !w.externalWatches[path.name] { + pathsToRemove = append(pathsToRemove, path.name) + } + } + } + w.mu.Unlock() + for _, name := range pathsToRemove { + // Since these are internal, not much sense in propagating error + // to the user, as that will just confuse them with an error about + // a path they did not explicitly watch themselves. + w.Remove(name) + } + } + + return nil +} + +// Watch all events (except NOTE_EXTEND, NOTE_LINK, NOTE_REVOKE) +const noteAllEvents = unix.NOTE_DELETE | unix.NOTE_WRITE | unix.NOTE_ATTRIB | unix.NOTE_RENAME + +// keventWaitTime to block on each read from kevent +var keventWaitTime = durationToTimespec(100 * time.Millisecond) + +// addWatch adds name to the watched file set. +// The flags are interpreted as described in kevent(2). +// Returns the real path to the file which was added, if any, which may be different from the one passed in the case of symlinks. +func (w *Watcher) addWatch(name string, flags uint32) (string, error) { + var isDir bool + // Make ./name and name equivalent + name = filepath.Clean(name) + + w.mu.Lock() + if w.isClosed { + w.mu.Unlock() + return "", errors.New("kevent instance already closed") + } + watchfd, alreadyWatching := w.watches[name] + // We already have a watch, but we can still override flags. + if alreadyWatching { + isDir = w.paths[watchfd].isDir + } + w.mu.Unlock() + + if !alreadyWatching { + fi, err := os.Lstat(name) + if err != nil { + return "", err + } + + // Don't watch sockets. + if fi.Mode()&os.ModeSocket == os.ModeSocket { + return "", nil + } + + // Don't watch named pipes. + if fi.Mode()&os.ModeNamedPipe == os.ModeNamedPipe { + return "", nil + } + + // Follow Symlinks + // Unfortunately, Linux can add bogus symlinks to watch list without + // issue, and Windows can't do symlinks period (AFAIK). To maintain + // consistency, we will act like everything is fine. There will simply + // be no file events for broken symlinks. + // Hence the returns of nil on errors. + if fi.Mode()&os.ModeSymlink == os.ModeSymlink { + name, err = filepath.EvalSymlinks(name) + if err != nil { + return "", nil + } + + w.mu.Lock() + _, alreadyWatching = w.watches[name] + w.mu.Unlock() + + if alreadyWatching { + return name, nil + } + + fi, err = os.Lstat(name) + if err != nil { + return "", nil + } + } + + watchfd, err = unix.Open(name, openMode, 0700) + if watchfd == -1 { + return "", err + } + + isDir = fi.IsDir() + } + + const registerAdd = unix.EV_ADD | unix.EV_CLEAR | unix.EV_ENABLE + if err := register(w.kq, []int{watchfd}, registerAdd, flags); err != nil { + unix.Close(watchfd) + return "", err + } + + if !alreadyWatching { + w.mu.Lock() + w.watches[name] = watchfd + w.paths[watchfd] = pathInfo{name: name, isDir: isDir} + w.mu.Unlock() + } + + if isDir { + // Watch the directory if it has not been watched before, + // or if it was watched before, but perhaps only a NOTE_DELETE (watchDirectoryFiles) + w.mu.Lock() + + watchDir := (flags&unix.NOTE_WRITE) == unix.NOTE_WRITE && + (!alreadyWatching || (w.dirFlags[name]&unix.NOTE_WRITE) != unix.NOTE_WRITE) + // Store flags so this watch can be updated later + w.dirFlags[name] = flags + w.mu.Unlock() + + if watchDir { + if err := w.watchDirectoryFiles(name); err != nil { + return "", err + } + } + } + return name, nil +} + +// readEvents reads from kqueue and converts the received kevents into +// Event values that it sends down the Events channel. +func (w *Watcher) readEvents() { + eventBuffer := make([]unix.Kevent_t, 10) + +loop: + for { + // See if there is a message on the "done" channel + select { + case <-w.done: + break loop + default: + } + + // Get new events + kevents, err := read(w.kq, eventBuffer, &keventWaitTime) + // EINTR is okay, the syscall was interrupted before timeout expired. + if err != nil && err != unix.EINTR { + select { + case w.Errors <- err: + case <-w.done: + break loop + } + continue + } + + // Flush the events we received to the Events channel + for len(kevents) > 0 { + kevent := &kevents[0] + watchfd := int(kevent.Ident) + mask := uint32(kevent.Fflags) + w.mu.Lock() + path := w.paths[watchfd] + w.mu.Unlock() + event := newEvent(path.name, mask) + + if path.isDir && !(event.Op&Remove == Remove) { + // Double check to make sure the directory exists. This can happen when + // we do a rm -fr on a recursively watched folders and we receive a + // modification event first but the folder has been deleted and later + // receive the delete event + if _, err := os.Lstat(event.Name); os.IsNotExist(err) { + // mark is as delete event + event.Op |= Remove + } + } + + if event.Op&Rename == Rename || event.Op&Remove == Remove { + w.Remove(event.Name) + w.mu.Lock() + delete(w.fileExists, event.Name) + w.mu.Unlock() + } + + if path.isDir && event.Op&Write == Write && !(event.Op&Remove == Remove) { + w.sendDirectoryChangeEvents(event.Name) + } else { + // Send the event on the Events channel. + select { + case w.Events <- event: + case <-w.done: + break loop + } + } + + if event.Op&Remove == Remove { + // Look for a file that may have overwritten this. + // For example, mv f1 f2 will delete f2, then create f2. + if path.isDir { + fileDir := filepath.Clean(event.Name) + w.mu.Lock() + _, found := w.watches[fileDir] + w.mu.Unlock() + if found { + // make sure the directory exists before we watch for changes. When we + // do a recursive watch and perform rm -fr, the parent directory might + // have gone missing, ignore the missing directory and let the + // upcoming delete event remove the watch from the parent directory. + if _, err := os.Lstat(fileDir); err == nil { + w.sendDirectoryChangeEvents(fileDir) + } + } + } else { + filePath := filepath.Clean(event.Name) + if fileInfo, err := os.Lstat(filePath); err == nil { + w.sendFileCreatedEventIfNew(filePath, fileInfo) + } + } + } + + // Move to next event + kevents = kevents[1:] + } + } + + // cleanup + err := unix.Close(w.kq) + if err != nil { + // only way the previous loop breaks is if w.done was closed so we need to async send to w.Errors. + select { + case w.Errors <- err: + default: + } + } + close(w.Events) + close(w.Errors) +} + +// newEvent returns an platform-independent Event based on kqueue Fflags. +func newEvent(name string, mask uint32) Event { + e := Event{Name: name} + if mask&unix.NOTE_DELETE == unix.NOTE_DELETE { + e.Op |= Remove + } + if mask&unix.NOTE_WRITE == unix.NOTE_WRITE { + e.Op |= Write + } + if mask&unix.NOTE_RENAME == unix.NOTE_RENAME { + e.Op |= Rename + } + if mask&unix.NOTE_ATTRIB == unix.NOTE_ATTRIB { + e.Op |= Chmod + } + return e +} + +func newCreateEvent(name string) Event { + return Event{Name: name, Op: Create} +} + +// watchDirectoryFiles to mimic inotify when adding a watch on a directory +func (w *Watcher) watchDirectoryFiles(dirPath string) error { + // Get all files + files, err := ioutil.ReadDir(dirPath) + if err != nil { + return err + } + + for _, fileInfo := range files { + filePath := filepath.Join(dirPath, fileInfo.Name()) + filePath, err = w.internalWatch(filePath, fileInfo) + if err != nil { + return err + } + + w.mu.Lock() + w.fileExists[filePath] = true + w.mu.Unlock() + } + + return nil +} + +// sendDirectoryEvents searches the directory for newly created files +// and sends them over the event channel. This functionality is to have +// the BSD version of fsnotify match Linux inotify which provides a +// create event for files created in a watched directory. +func (w *Watcher) sendDirectoryChangeEvents(dirPath string) { + // Get all files + files, err := ioutil.ReadDir(dirPath) + if err != nil { + select { + case w.Errors <- err: + case <-w.done: + return + } + } + + // Search for new files + for _, fileInfo := range files { + filePath := filepath.Join(dirPath, fileInfo.Name()) + err := w.sendFileCreatedEventIfNew(filePath, fileInfo) + + if err != nil { + return + } + } +} + +// sendFileCreatedEvent sends a create event if the file isn't already being tracked. +func (w *Watcher) sendFileCreatedEventIfNew(filePath string, fileInfo os.FileInfo) (err error) { + w.mu.Lock() + _, doesExist := w.fileExists[filePath] + w.mu.Unlock() + if !doesExist { + // Send create event + select { + case w.Events <- newCreateEvent(filePath): + case <-w.done: + return + } + } + + // like watchDirectoryFiles (but without doing another ReadDir) + filePath, err = w.internalWatch(filePath, fileInfo) + if err != nil { + return err + } + + w.mu.Lock() + w.fileExists[filePath] = true + w.mu.Unlock() + + return nil +} + +func (w *Watcher) internalWatch(name string, fileInfo os.FileInfo) (string, error) { + if fileInfo.IsDir() { + // mimic Linux providing delete events for subdirectories + // but preserve the flags used if currently watching subdirectory + w.mu.Lock() + flags := w.dirFlags[name] + w.mu.Unlock() + + flags |= unix.NOTE_DELETE | unix.NOTE_RENAME + return w.addWatch(name, flags) + } + + // watch file to mimic Linux inotify + return w.addWatch(name, noteAllEvents) +} + +// kqueue creates a new kernel event queue and returns a descriptor. +func kqueue() (kq int, err error) { + kq, err = unix.Kqueue() + if kq == -1 { + return kq, err + } + return kq, nil +} + +// register events with the queue +func register(kq int, fds []int, flags int, fflags uint32) error { + changes := make([]unix.Kevent_t, len(fds)) + + for i, fd := range fds { + // SetKevent converts int to the platform-specific types: + unix.SetKevent(&changes[i], fd, unix.EVFILT_VNODE, flags) + changes[i].Fflags = fflags + } + + // register the events + success, err := unix.Kevent(kq, changes, nil, nil) + if success == -1 { + return err + } + return nil +} + +// read retrieves pending events, or waits until an event occurs. +// A timeout of nil blocks indefinitely, while 0 polls the queue. +func read(kq int, events []unix.Kevent_t, timeout *unix.Timespec) ([]unix.Kevent_t, error) { + n, err := unix.Kevent(kq, nil, events, timeout) + if err != nil { + return nil, err + } + return events[0:n], nil +} + +// durationToTimespec prepares a timeout value +func durationToTimespec(d time.Duration) unix.Timespec { + return unix.NsecToTimespec(d.Nanoseconds()) +} diff --git a/vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go b/vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go new file mode 100644 index 00000000000..7d8de14513e --- /dev/null +++ b/vendor/github.com/fsnotify/fsnotify/open_mode_bsd.go @@ -0,0 +1,11 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build freebsd openbsd netbsd dragonfly + +package fsnotify + +import "golang.org/x/sys/unix" + +const openMode = unix.O_NONBLOCK | unix.O_RDONLY diff --git a/vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go b/vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go new file mode 100644 index 00000000000..9139e17161b --- /dev/null +++ b/vendor/github.com/fsnotify/fsnotify/open_mode_darwin.go @@ -0,0 +1,12 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin + +package fsnotify + +import "golang.org/x/sys/unix" + +// note: this constant is not defined on BSD +const openMode = unix.O_EVTONLY diff --git a/vendor/github.com/fsnotify/fsnotify/windows.go b/vendor/github.com/fsnotify/fsnotify/windows.go new file mode 100644 index 00000000000..09436f31d82 --- /dev/null +++ b/vendor/github.com/fsnotify/fsnotify/windows.go @@ -0,0 +1,561 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build windows + +package fsnotify + +import ( + "errors" + "fmt" + "os" + "path/filepath" + "runtime" + "sync" + "syscall" + "unsafe" +) + +// Watcher watches a set of files, delivering events to a channel. +type Watcher struct { + Events chan Event + Errors chan error + isClosed bool // Set to true when Close() is first called + mu sync.Mutex // Map access + port syscall.Handle // Handle to completion port + watches watchMap // Map of watches (key: i-number) + input chan *input // Inputs to the reader are sent on this channel + quit chan chan<- error +} + +// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. +func NewWatcher() (*Watcher, error) { + port, e := syscall.CreateIoCompletionPort(syscall.InvalidHandle, 0, 0, 0) + if e != nil { + return nil, os.NewSyscallError("CreateIoCompletionPort", e) + } + w := &Watcher{ + port: port, + watches: make(watchMap), + input: make(chan *input, 1), + Events: make(chan Event, 50), + Errors: make(chan error), + quit: make(chan chan<- error, 1), + } + go w.readEvents() + return w, nil +} + +// Close removes all watches and closes the events channel. +func (w *Watcher) Close() error { + if w.isClosed { + return nil + } + w.isClosed = true + + // Send "quit" message to the reader goroutine + ch := make(chan error) + w.quit <- ch + if err := w.wakeupReader(); err != nil { + return err + } + return <-ch +} + +// Add starts watching the named file or directory (non-recursively). +func (w *Watcher) Add(name string) error { + if w.isClosed { + return errors.New("watcher already closed") + } + in := &input{ + op: opAddWatch, + path: filepath.Clean(name), + flags: sysFSALLEVENTS, + reply: make(chan error), + } + w.input <- in + if err := w.wakeupReader(); err != nil { + return err + } + return <-in.reply +} + +// Remove stops watching the the named file or directory (non-recursively). +func (w *Watcher) Remove(name string) error { + in := &input{ + op: opRemoveWatch, + path: filepath.Clean(name), + reply: make(chan error), + } + w.input <- in + if err := w.wakeupReader(); err != nil { + return err + } + return <-in.reply +} + +const ( + // Options for AddWatch + sysFSONESHOT = 0x80000000 + sysFSONLYDIR = 0x1000000 + + // Events + sysFSACCESS = 0x1 + sysFSALLEVENTS = 0xfff + sysFSATTRIB = 0x4 + sysFSCLOSE = 0x18 + sysFSCREATE = 0x100 + sysFSDELETE = 0x200 + sysFSDELETESELF = 0x400 + sysFSMODIFY = 0x2 + sysFSMOVE = 0xc0 + sysFSMOVEDFROM = 0x40 + sysFSMOVEDTO = 0x80 + sysFSMOVESELF = 0x800 + + // Special events + sysFSIGNORED = 0x8000 + sysFSQOVERFLOW = 0x4000 +) + +func newEvent(name string, mask uint32) Event { + e := Event{Name: name} + if mask&sysFSCREATE == sysFSCREATE || mask&sysFSMOVEDTO == sysFSMOVEDTO { + e.Op |= Create + } + if mask&sysFSDELETE == sysFSDELETE || mask&sysFSDELETESELF == sysFSDELETESELF { + e.Op |= Remove + } + if mask&sysFSMODIFY == sysFSMODIFY { + e.Op |= Write + } + if mask&sysFSMOVE == sysFSMOVE || mask&sysFSMOVESELF == sysFSMOVESELF || mask&sysFSMOVEDFROM == sysFSMOVEDFROM { + e.Op |= Rename + } + if mask&sysFSATTRIB == sysFSATTRIB { + e.Op |= Chmod + } + return e +} + +const ( + opAddWatch = iota + opRemoveWatch +) + +const ( + provisional uint64 = 1 << (32 + iota) +) + +type input struct { + op int + path string + flags uint32 + reply chan error +} + +type inode struct { + handle syscall.Handle + volume uint32 + index uint64 +} + +type watch struct { + ov syscall.Overlapped + ino *inode // i-number + path string // Directory path + mask uint64 // Directory itself is being watched with these notify flags + names map[string]uint64 // Map of names being watched and their notify flags + rename string // Remembers the old name while renaming a file + buf [4096]byte +} + +type indexMap map[uint64]*watch +type watchMap map[uint32]indexMap + +func (w *Watcher) wakeupReader() error { + e := syscall.PostQueuedCompletionStatus(w.port, 0, 0, nil) + if e != nil { + return os.NewSyscallError("PostQueuedCompletionStatus", e) + } + return nil +} + +func getDir(pathname string) (dir string, err error) { + attr, e := syscall.GetFileAttributes(syscall.StringToUTF16Ptr(pathname)) + if e != nil { + return "", os.NewSyscallError("GetFileAttributes", e) + } + if attr&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 { + dir = pathname + } else { + dir, _ = filepath.Split(pathname) + dir = filepath.Clean(dir) + } + return +} + +func getIno(path string) (ino *inode, err error) { + h, e := syscall.CreateFile(syscall.StringToUTF16Ptr(path), + syscall.FILE_LIST_DIRECTORY, + syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE, + nil, syscall.OPEN_EXISTING, + syscall.FILE_FLAG_BACKUP_SEMANTICS|syscall.FILE_FLAG_OVERLAPPED, 0) + if e != nil { + return nil, os.NewSyscallError("CreateFile", e) + } + var fi syscall.ByHandleFileInformation + if e = syscall.GetFileInformationByHandle(h, &fi); e != nil { + syscall.CloseHandle(h) + return nil, os.NewSyscallError("GetFileInformationByHandle", e) + } + ino = &inode{ + handle: h, + volume: fi.VolumeSerialNumber, + index: uint64(fi.FileIndexHigh)<<32 | uint64(fi.FileIndexLow), + } + return ino, nil +} + +// Must run within the I/O thread. +func (m watchMap) get(ino *inode) *watch { + if i := m[ino.volume]; i != nil { + return i[ino.index] + } + return nil +} + +// Must run within the I/O thread. +func (m watchMap) set(ino *inode, watch *watch) { + i := m[ino.volume] + if i == nil { + i = make(indexMap) + m[ino.volume] = i + } + i[ino.index] = watch +} + +// Must run within the I/O thread. +func (w *Watcher) addWatch(pathname string, flags uint64) error { + dir, err := getDir(pathname) + if err != nil { + return err + } + if flags&sysFSONLYDIR != 0 && pathname != dir { + return nil + } + ino, err := getIno(dir) + if err != nil { + return err + } + w.mu.Lock() + watchEntry := w.watches.get(ino) + w.mu.Unlock() + if watchEntry == nil { + if _, e := syscall.CreateIoCompletionPort(ino.handle, w.port, 0, 0); e != nil { + syscall.CloseHandle(ino.handle) + return os.NewSyscallError("CreateIoCompletionPort", e) + } + watchEntry = &watch{ + ino: ino, + path: dir, + names: make(map[string]uint64), + } + w.mu.Lock() + w.watches.set(ino, watchEntry) + w.mu.Unlock() + flags |= provisional + } else { + syscall.CloseHandle(ino.handle) + } + if pathname == dir { + watchEntry.mask |= flags + } else { + watchEntry.names[filepath.Base(pathname)] |= flags + } + if err = w.startRead(watchEntry); err != nil { + return err + } + if pathname == dir { + watchEntry.mask &= ^provisional + } else { + watchEntry.names[filepath.Base(pathname)] &= ^provisional + } + return nil +} + +// Must run within the I/O thread. +func (w *Watcher) remWatch(pathname string) error { + dir, err := getDir(pathname) + if err != nil { + return err + } + ino, err := getIno(dir) + if err != nil { + return err + } + w.mu.Lock() + watch := w.watches.get(ino) + w.mu.Unlock() + if watch == nil { + return fmt.Errorf("can't remove non-existent watch for: %s", pathname) + } + if pathname == dir { + w.sendEvent(watch.path, watch.mask&sysFSIGNORED) + watch.mask = 0 + } else { + name := filepath.Base(pathname) + w.sendEvent(filepath.Join(watch.path, name), watch.names[name]&sysFSIGNORED) + delete(watch.names, name) + } + return w.startRead(watch) +} + +// Must run within the I/O thread. +func (w *Watcher) deleteWatch(watch *watch) { + for name, mask := range watch.names { + if mask&provisional == 0 { + w.sendEvent(filepath.Join(watch.path, name), mask&sysFSIGNORED) + } + delete(watch.names, name) + } + if watch.mask != 0 { + if watch.mask&provisional == 0 { + w.sendEvent(watch.path, watch.mask&sysFSIGNORED) + } + watch.mask = 0 + } +} + +// Must run within the I/O thread. +func (w *Watcher) startRead(watch *watch) error { + if e := syscall.CancelIo(watch.ino.handle); e != nil { + w.Errors <- os.NewSyscallError("CancelIo", e) + w.deleteWatch(watch) + } + mask := toWindowsFlags(watch.mask) + for _, m := range watch.names { + mask |= toWindowsFlags(m) + } + if mask == 0 { + if e := syscall.CloseHandle(watch.ino.handle); e != nil { + w.Errors <- os.NewSyscallError("CloseHandle", e) + } + w.mu.Lock() + delete(w.watches[watch.ino.volume], watch.ino.index) + w.mu.Unlock() + return nil + } + e := syscall.ReadDirectoryChanges(watch.ino.handle, &watch.buf[0], + uint32(unsafe.Sizeof(watch.buf)), false, mask, nil, &watch.ov, 0) + if e != nil { + err := os.NewSyscallError("ReadDirectoryChanges", e) + if e == syscall.ERROR_ACCESS_DENIED && watch.mask&provisional == 0 { + // Watched directory was probably removed + if w.sendEvent(watch.path, watch.mask&sysFSDELETESELF) { + if watch.mask&sysFSONESHOT != 0 { + watch.mask = 0 + } + } + err = nil + } + w.deleteWatch(watch) + w.startRead(watch) + return err + } + return nil +} + +// readEvents reads from the I/O completion port, converts the +// received events into Event objects and sends them via the Events channel. +// Entry point to the I/O thread. +func (w *Watcher) readEvents() { + var ( + n, key uint32 + ov *syscall.Overlapped + ) + runtime.LockOSThread() + + for { + e := syscall.GetQueuedCompletionStatus(w.port, &n, &key, &ov, syscall.INFINITE) + watch := (*watch)(unsafe.Pointer(ov)) + + if watch == nil { + select { + case ch := <-w.quit: + w.mu.Lock() + var indexes []indexMap + for _, index := range w.watches { + indexes = append(indexes, index) + } + w.mu.Unlock() + for _, index := range indexes { + for _, watch := range index { + w.deleteWatch(watch) + w.startRead(watch) + } + } + var err error + if e := syscall.CloseHandle(w.port); e != nil { + err = os.NewSyscallError("CloseHandle", e) + } + close(w.Events) + close(w.Errors) + ch <- err + return + case in := <-w.input: + switch in.op { + case opAddWatch: + in.reply <- w.addWatch(in.path, uint64(in.flags)) + case opRemoveWatch: + in.reply <- w.remWatch(in.path) + } + default: + } + continue + } + + switch e { + case syscall.ERROR_MORE_DATA: + if watch == nil { + w.Errors <- errors.New("ERROR_MORE_DATA has unexpectedly null lpOverlapped buffer") + } else { + // The i/o succeeded but the buffer is full. + // In theory we should be building up a full packet. + // In practice we can get away with just carrying on. + n = uint32(unsafe.Sizeof(watch.buf)) + } + case syscall.ERROR_ACCESS_DENIED: + // Watched directory was probably removed + w.sendEvent(watch.path, watch.mask&sysFSDELETESELF) + w.deleteWatch(watch) + w.startRead(watch) + continue + case syscall.ERROR_OPERATION_ABORTED: + // CancelIo was called on this handle + continue + default: + w.Errors <- os.NewSyscallError("GetQueuedCompletionPort", e) + continue + case nil: + } + + var offset uint32 + for { + if n == 0 { + w.Events <- newEvent("", sysFSQOVERFLOW) + w.Errors <- errors.New("short read in readEvents()") + break + } + + // Point "raw" to the event in the buffer + raw := (*syscall.FileNotifyInformation)(unsafe.Pointer(&watch.buf[offset])) + buf := (*[syscall.MAX_PATH]uint16)(unsafe.Pointer(&raw.FileName)) + name := syscall.UTF16ToString(buf[:raw.FileNameLength/2]) + fullname := filepath.Join(watch.path, name) + + var mask uint64 + switch raw.Action { + case syscall.FILE_ACTION_REMOVED: + mask = sysFSDELETESELF + case syscall.FILE_ACTION_MODIFIED: + mask = sysFSMODIFY + case syscall.FILE_ACTION_RENAMED_OLD_NAME: + watch.rename = name + case syscall.FILE_ACTION_RENAMED_NEW_NAME: + if watch.names[watch.rename] != 0 { + watch.names[name] |= watch.names[watch.rename] + delete(watch.names, watch.rename) + mask = sysFSMOVESELF + } + } + + sendNameEvent := func() { + if w.sendEvent(fullname, watch.names[name]&mask) { + if watch.names[name]&sysFSONESHOT != 0 { + delete(watch.names, name) + } + } + } + if raw.Action != syscall.FILE_ACTION_RENAMED_NEW_NAME { + sendNameEvent() + } + if raw.Action == syscall.FILE_ACTION_REMOVED { + w.sendEvent(fullname, watch.names[name]&sysFSIGNORED) + delete(watch.names, name) + } + if w.sendEvent(fullname, watch.mask&toFSnotifyFlags(raw.Action)) { + if watch.mask&sysFSONESHOT != 0 { + watch.mask = 0 + } + } + if raw.Action == syscall.FILE_ACTION_RENAMED_NEW_NAME { + fullname = filepath.Join(watch.path, watch.rename) + sendNameEvent() + } + + // Move to the next event in the buffer + if raw.NextEntryOffset == 0 { + break + } + offset += raw.NextEntryOffset + + // Error! + if offset >= n { + w.Errors <- errors.New("Windows system assumed buffer larger than it is, events have likely been missed.") + break + } + } + + if err := w.startRead(watch); err != nil { + w.Errors <- err + } + } +} + +func (w *Watcher) sendEvent(name string, mask uint64) bool { + if mask == 0 { + return false + } + event := newEvent(name, uint32(mask)) + select { + case ch := <-w.quit: + w.quit <- ch + case w.Events <- event: + } + return true +} + +func toWindowsFlags(mask uint64) uint32 { + var m uint32 + if mask&sysFSACCESS != 0 { + m |= syscall.FILE_NOTIFY_CHANGE_LAST_ACCESS + } + if mask&sysFSMODIFY != 0 { + m |= syscall.FILE_NOTIFY_CHANGE_LAST_WRITE + } + if mask&sysFSATTRIB != 0 { + m |= syscall.FILE_NOTIFY_CHANGE_ATTRIBUTES + } + if mask&(sysFSMOVE|sysFSCREATE|sysFSDELETE) != 0 { + m |= syscall.FILE_NOTIFY_CHANGE_FILE_NAME | syscall.FILE_NOTIFY_CHANGE_DIR_NAME + } + return m +} + +func toFSnotifyFlags(action uint32) uint64 { + switch action { + case syscall.FILE_ACTION_ADDED: + return sysFSCREATE + case syscall.FILE_ACTION_REMOVED: + return sysFSDELETE + case syscall.FILE_ACTION_MODIFIED: + return sysFSMODIFY + case syscall.FILE_ACTION_RENAMED_OLD_NAME: + return sysFSMOVEDFROM + case syscall.FILE_ACTION_RENAMED_NEW_NAME: + return sysFSMOVEDTO + } + return 0 +} From b4ec4a0df9d9873b10aa8362772a36c0489ab8ac Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Fri, 28 Sep 2018 12:18:05 -0700 Subject: [PATCH 11/23] swappable.Handler is now the 'top' http.Handler. ConfigMaps can be updated by either watching a directory or by a Controller style K8s watch. --- cmd/fanoutsidecar/main.go | 66 +++- .../filesystem/config_map_handler.go | 134 +++++++ .../filesystem/config_map_handler_test.go | 341 ++++++++++++++++++ pkg/sidecar/configmap/parse/parse.go | 55 +++ pkg/sidecar/configmap/parse/parse_test.go | 164 +++++++++ pkg/sidecar/configmap/watcher/watcher.go | 121 +++++++ pkg/sidecar/configmap/watcher/watcher_test.go | 161 +++++++++ pkg/sidecar/swappable/swappable.go | 43 ++- pkg/sidecar/swappable/swappable_test.go | 91 ++++- 9 files changed, 1159 insertions(+), 17 deletions(-) create mode 100644 pkg/sidecar/configmap/filesystem/config_map_handler.go create mode 100644 pkg/sidecar/configmap/filesystem/config_map_handler_test.go create mode 100644 pkg/sidecar/configmap/parse/parse.go create mode 100644 pkg/sidecar/configmap/parse/parse_test.go create mode 100644 pkg/sidecar/configmap/watcher/watcher.go create mode 100644 pkg/sidecar/configmap/watcher/watcher_test.go diff --git a/cmd/fanoutsidecar/main.go b/cmd/fanoutsidecar/main.go index 97efbd2178b..be13da2210b 100644 --- a/cmd/fanoutsidecar/main.go +++ b/cmd/fanoutsidecar/main.go @@ -22,14 +22,22 @@ package main import ( "flag" "fmt" - "github.com/knative/eventing/pkg/sidecar/configmaphandler" + "github.com/knative/eventing/pkg/sidecar/configmap/filesystem" + "github.com/knative/eventing/pkg/sidecar/configmap/watcher" + "github.com/knative/eventing/pkg/sidecar/swappable" + "github.com/knative/eventing/pkg/system" "go.uber.org/zap" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/types" "net/http" + "sigs.k8s.io/controller-runtime/pkg/client/config" + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/runtime/signals" "time" ) const ( - port = 11235 + configMapName = "in-memory-bus-config" ) var ( @@ -38,6 +46,9 @@ var ( ) func main() { + portFlag := flag.Int("sidecar_port", -1, "The port to run the sidecar on.") + configMapFlag := flag.String("config_map_noticer", "", "The system to notice changes to the ConfigMap. Valid values are: 'volume', 'watcher'.") + flag.Parse() logger, err := zap.NewProduction() @@ -45,13 +56,31 @@ func main() { panic(err) } - cmh, err := configmaphandler.NewHandler(logger, configmaphandler.ConfigDir) + if *portFlag < 0 { + logger.Fatal("--sidecar_port flag must be set") + } + + sh, err := swappable.NewEmptyHandler(logger) if err != nil { - logger.Fatal("Unable to create configmaphandler.Handler", zap.Error(err)) + logger.Fatal("Unable to create swappable.Handler", zap.Error(err)) + } + + // Setup something to notice that the ConfigMap has updated. + switch *configMapFlag { + case "volume": + _, err = filesystem.NewConfigMapWatcher(logger, filesystem.ConfigDir, sh.UpdateConfig) + if err != nil { + logger.Fatal("Unable to create filesystem.configMapWatcher", zap.Error(err)) + } + case "watcher": + setupWatcher(logger, sh.UpdateConfig) + default: + logger.Fatal("Need to provide the --config_map_noticer flag") } + s := &http.Server{ - Addr: fmt.Sprintf(":%v", port), - Handler: cmh, + Addr: fmt.Sprintf(":%d", *portFlag), + Handler: sh, ErrorLog: zap.NewStdLog(logger), ReadTimeout: readTimeout, WriteTimeout: writeTimeout, @@ -59,3 +88,28 @@ func main() { logger.Info("Fanout sidecar Listening...") s.ListenAndServe() } + +func setupWatcher(logger *zap.Logger, configUpdated swappable.UpdateConfig) { + mgr, err := manager.New(config.GetConfigOrDie(), manager.Options{}) + if err != nil { + logger.Fatal("Error starting manager.", zap.Error(err)) + } + + // Add custom types to this array to get them into the manager's scheme. + corev1.AddToScheme(mgr.GetScheme()) + + + cmName := types.NamespacedName{ + Namespace: system.Namespace, + Name: configMapName, + } + _, err = watcher.NewWatcher(logger, mgr, cmName, configUpdated) + if err != nil { + logger.Fatal("Unable to create watcher.configMapWatcher", zap.Error(err)) + } + + // set up signals so we handle the first shutdown signal gracefully + stopCh := signals.SetupSignalHandler() + // Start blocks forever. + go mgr.Start(stopCh) +} diff --git a/pkg/sidecar/configmap/filesystem/config_map_handler.go b/pkg/sidecar/configmap/filesystem/config_map_handler.go new file mode 100644 index 00000000000..4be275aad13 --- /dev/null +++ b/pkg/sidecar/configmap/filesystem/config_map_handler.go @@ -0,0 +1,134 @@ +/* +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 filesystem + +import ( + "github.com/fsnotify/fsnotify" + "github.com/knative/eventing/pkg/sidecar/configmap/parse" + "github.com/knative/eventing/pkg/sidecar/multichannelfanout" + "github.com/knative/eventing/pkg/sidecar/swappable" + "github.com/knative/pkg/configmap" + "go.uber.org/zap" +) + +const ( + // The mount path of the configMap volume. + ConfigDir = "/etc/config/fanout_sidecar" +) + +// Monitors an attached ConfigMap volume for updated configuration and calls `configUpdated` when +// the value changes. +type configMapWatcher struct { + logger *zap.Logger + // The directory to read the configMap from. + dir string + // Stop the watcher by closing this channel. + watcherStopCh chan<- bool + + // The function to call when the configuration is updated. + configUpdated swappable.UpdateConfig +} + +func NewConfigMapWatcher(logger *zap.Logger, dir string, updateConfig swappable.UpdateConfig) (chan<- bool, error) { + conf, err := readConfigMap(logger, dir) + if err != nil { + logger.Error("Unable to read configMap", zap.Error(err)) + return nil, err + } + + logger.Info("Read initial configMap", zap.Any("conf", conf)) + + err = updateConfig(conf) + if err != nil { + logger.Error("Unable to use the initial configMap: %v", zap.Error(err)) + return nil, err + } + + cmw := &configMapWatcher{ + logger: logger, + dir: dir, + configUpdated: updateConfig, + } + watcherStopCh, err := cmw.startWatcher(dir) + if err != nil { + logger.Error("Unable to start the configMap file watcher", zap.Error(err)) + return nil, err + } + return watcherStopCh, nil +} + +// readConfigMap attempts to read the configMap from the attached volume. +func readConfigMap(logger *zap.Logger, dir string) (*multichannelfanout.Config, error) { + cm, err := configmap.Load(dir) + if err != nil { + logger.Error("Unable to read configMap", zap.Error(err)) + return nil, err + } + return parse.ConfigMapData(logger, cm) +} + +// readConfigMapAndUpdateSubs reads the configMap data and calls `configUpdate` with the updated +// value. +func (cmw *configMapWatcher) readConfigMapAndUpdateConfig() { + conf, err := readConfigMap(cmw.logger, cmw.dir) + if err != nil { + cmw.logger.Error("Unable to read the configMap", zap.Error(err)) + return + } + err = cmw.configUpdated(conf) + if err != nil { + cmw.logger.Error("Unable to update config", zap.Error(err)) + return + } +} + +// startWatcher starts a background go routine that gets events when the filesystem in configDir is +// changed. +func (cmw *configMapWatcher) startWatcher(dir string) (chan<- bool, error) { + watcher, err := fsnotify.NewWatcher() + if err != nil { + return nil, err + } + stopCh := make(chan bool) + go func() { + for { + select { + case _, ok := <-watcher.Events: + if !ok { + // Channel closed. + cmw.logger.Error("watcher.Events channel closed") // TODO: Should this panic? + return + } + cmw.readConfigMapAndUpdateConfig() + case err, ok := <-watcher.Errors: + if !ok { + // Channel closed. + cmw.logger.Error("watcher.Errors channel closed") // TODO: Should this panic? + return + } + cmw.logger.Error("watcher.Errors", zap.Error(err)) + case _, ok := <-stopCh: + if !ok { + // stopCh has been closed + return + } + } + } + }() + + return stopCh, watcher.Add(dir) +} diff --git a/pkg/sidecar/configmap/filesystem/config_map_handler_test.go b/pkg/sidecar/configmap/filesystem/config_map_handler_test.go new file mode 100644 index 00000000000..31a3396382a --- /dev/null +++ b/pkg/sidecar/configmap/filesystem/config_map_handler_test.go @@ -0,0 +1,341 @@ +/* +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 filesystem + +import ( + "fmt" + "github.com/google/go-cmp/cmp" + "github.com/knative/eventing/pkg/sidecar/configmap/parse" + "github.com/knative/eventing/pkg/sidecar/fanout" + "github.com/knative/eventing/pkg/sidecar/multichannelfanout" + "github.com/knative/eventing/pkg/sidecar/swappable" + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "go.uber.org/atomic" + "go.uber.org/zap" + "io" + "io/ioutil" + "net/http" + "net/http/httptest" + "os" + "strings" + "testing" + "time" +) + +const ( + replaceDomain = "replaceDomain" +) + +func TestReadConfigMap(t *testing.T) { + testCases := []struct { + name string + createDir bool + config string + expected *multichannelfanout.Config + expectedErr bool + }{ + { + name: "dir does not exist", + createDir: false, + }, + { + name: "no data", + createDir: true, + expectedErr: true, + }, + { + name: "invalid YAML", + createDir: true, + config: ` + key: + - value + - different indent level + `, + expectedErr: true, + }, + { + name: "valid YAML -- invalid JSON", + config: "{ nil: Key }", + createDir: true, + expectedErr: true, + }, + { + name: "unknown field", + config: "{ channelConfigs: [ { not: a-defined-field } ] }", + createDir: true, + expectedErr: true, + }, + { + name: "valid", + createDir: true, + config: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - callableDomain: event-changer.default.svc.cluster.local + sinkableDomain: message-dumper-bar.default.svc.cluster.local + - callableDomain: message-dumper-foo.default.svc.cluster.local + - sinkableDomain: message-dumper-bar.default.svc.cluster.local + - namespace: default + name: c2 + fanoutConfig: + subscriptions: + - sinkableDomain: message-dumper-foo.default.svc.cluster.local + - namespace: other + name: c3 + fanoutConfig: + subscriptions: + - sinkableDomain: message-dumper-foo.default.svc.cluster.local + `, + expected: &multichannelfanout.Config{ + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: "default", + Name: "c1", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: "event-changer.default.svc.cluster.local", + SinkableDomain: "message-dumper-bar.default.svc.cluster.local", + }, + { + CallableDomain: "message-dumper-foo.default.svc.cluster.local", + }, + { + SinkableDomain: "message-dumper-bar.default.svc.cluster.local", + }, + }, + }, + }, + { + Namespace: "default", + Name: "c2", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + SinkableDomain: "message-dumper-foo.default.svc.cluster.local", + }, + }, + }, + }, + { + Namespace: "other", + Name: "c3", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + SinkableDomain: "message-dumper-foo.default.svc.cluster.local", + }, + }, + }, + }, + }, + }, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + var dir string + if tc.createDir { + dir = createTempDir(t) + defer os.RemoveAll(dir) + } else { + dir = "/tmp/doesNotExist" + } + writeConfig(t, dir, tc.config) + c, e := readConfigMap(zap.NewNop(), dir) + if tc.expectedErr { + if e == nil { + t.Errorf("Expected an error, actual nil") + } + return + } + if !cmp.Equal(c, tc.expected) { + t.Errorf("Unexpected config. Expected '%v'. Actual '%v'.", tc.expected, c) + } + }) + } +} + +func TestServeHTTP(t *testing.T) { + testCases := []struct { + name string + initialConfig string + updatedConfig string + initialRequests int32 + initialRequestsAfterUpdate int32 + updateRequests int32 + }{ + { + name: "send to config", + initialConfig: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - sinkableDomain: replaceDomain + `, + initialRequests: 1, + }, + { + name: "change config", + initialConfig: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - sinkableDomain: replaceDomain + `, + initialRequests: 1, + updatedConfig: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - sinkableDomain: replaceDomain + `, + updateRequests: 1, + }, + { + name: "bad config update -- keeps serving old config", + initialConfig: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - sinkableDomain: replaceDomain + `, + initialRequests: 1, + updatedConfig: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - sinkableDomain: replaceDomain + # Duplicate namespace/name + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - sinkableDomain: replaceDomain + `, + initialRequestsAfterUpdate: 2, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + initialHandler := &fakeHandler{} + initialServer := httptest.NewServer(initialHandler) + defer initialServer.Close() + updateHandler := &fakeHandler{} + updateServer := httptest.NewServer(updateHandler) + defer updateServer.Close() + + dir := createTempDir(t) + defer os.RemoveAll(dir) + writeConfig(t, dir, replaceDomains(tc.initialConfig, initialServer.URL[7:])) + + sh, err := swappable.NewEmptyHandler(zap.NewNop()) + if err != nil { + t.Errorf("Unexpected error making swappable.Handler: %+v", err) + } + _, err = NewConfigMapWatcher(zap.NewNop(), dir, sh.UpdateConfig) + if err != nil { + t.Errorf("Unexpected error making filesystem.configMapWatcher") + } + + w := httptest.NewRecorder() + sh.ServeHTTP(w, makeRequest("default", "c1")) + if w.Result().StatusCode != http.StatusOK { + t.Errorf("Unexpected initial status code: %v", w.Result().StatusCode) + } + if tc.initialRequests != initialHandler.requests.Load() { + t.Errorf("Incorrect initial request count. Expected %v. Actual %v.", + tc.initialRequests, initialHandler.requests.Load()) + } + + if tc.updatedConfig != "" { + writeConfig(t, dir, replaceDomains(tc.updatedConfig, updateServer.URL[7:])) + // The watcher is running in another routine, give it some time to notice the + // change. + time.Sleep(100 * time.Millisecond) + w = httptest.NewRecorder() + sh.ServeHTTP(w, makeRequest("default", "c1")) + if w.Result().StatusCode != http.StatusOK { + t.Errorf("Unexpected updated status code: %v", w.Result().StatusCode) + } + if tc.updateRequests != updateHandler.requests.Load() { + t.Errorf("Incorrect update request count. Expected %v. Actual %v.", tc.updateRequests, updateHandler.requests.Load()) + } + if tc.initialRequestsAfterUpdate != 0 && tc.initialRequestsAfterUpdate != initialHandler.requests.Load() { + t.Errorf("Incorrect requests to initialHandler after config update. Expected %v, actual %v", + tc.initialRequestsAfterUpdate, initialHandler.requests.Load()) + } + } + }) + } +} + +func createTempDir(t *testing.T) string { + dir, err := ioutil.TempDir("", "configMapHandlerTest") + if err != nil { + t.Errorf("Unable to make temp directory: %v", err) + } + return dir +} + +func writeConfig(t *testing.T, dir, config string) { + if config != "" { + // Golang editors tend to replace leading spaces with tabs. YAML is left whitespace + // sensitive, so let's replace the tabs with spaces. + leftSpaceConfig := strings.Replace(config, "\t", " ", -1) + err := ioutil.WriteFile(fmt.Sprintf("%s/%s", dir, parse.MultiChannelFanoutConfigKey), []byte(leftSpaceConfig), 0700) + if err != nil { + t.Errorf("Problem writing the config file: %v", err) + } + } +} + +func body(body string) io.ReadCloser { + return ioutil.NopCloser(strings.NewReader(body)) +} + +func makeRequest(namespace, name string) *http.Request { + r := httptest.NewRequest("POST", fmt.Sprintf("http://%s.%s/", name, namespace), body("")) + return r +} + +type fakeHandler struct { + requests atomic.Int32 +} + +func (h *fakeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + defer r.Body.Close() + w.WriteHeader(http.StatusOK) + h.requests.Inc() +} + +func replaceDomains(config, replacement string) string { + return strings.Replace(config, replaceDomain, replacement, -1) +} diff --git a/pkg/sidecar/configmap/parse/parse.go b/pkg/sidecar/configmap/parse/parse.go new file mode 100644 index 00000000000..185779b8d4e --- /dev/null +++ b/pkg/sidecar/configmap/parse/parse.go @@ -0,0 +1,55 @@ +/* +Copyright 2018 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package parse + +import ( + "bytes" + "encoding/json" + "fmt" + "github.com/knative/eventing/pkg/sidecar/multichannelfanout" + "go.uber.org/zap" + "k8s.io/apimachinery/pkg/util/yaml" +) + +const ( + // The config key that contains all the configuration data. + MultiChannelFanoutConfigKey = "multiChannelFanoutConfig" +) + +// ConfigMapData attempts to parse the config map's data into a multichannelfanout.Config. +func ConfigMapData(logger *zap.Logger, data map[string]string) (*multichannelfanout.Config, error) { + if _, present := data[MultiChannelFanoutConfigKey]; !present { + logger.Error("Expected key not found", zap.String("key", MultiChannelFanoutConfigKey)) + return nil, fmt.Errorf("expected key not found: %v", MultiChannelFanoutConfigKey) + } + jb, err := yaml.ToJSON([]byte(data[MultiChannelFanoutConfigKey])) + if err != nil { + logger.Error("Unable to convert multiChannelFanoutConfig to JSON", zap.Error(err)) + return nil, err + } + var conf multichannelfanout.Config + err = unmarshallJsonDisallowUnknownFields(jb, &conf) + return &conf, err +} + +// unmarshallJsonDisallowUnknownFields unmarshalls JSON, but unlike json.Unmarshall, will fail if +// given an unknown field (rather than json.Unmarshall's ignoring the unknown field). +func unmarshallJsonDisallowUnknownFields(jb []byte, v interface{}) error { + d := json.NewDecoder(bytes.NewReader(jb)) + d.DisallowUnknownFields() + return d.Decode(v) +} diff --git a/pkg/sidecar/configmap/parse/parse_test.go b/pkg/sidecar/configmap/parse/parse_test.go new file mode 100644 index 00000000000..2920f0d6937 --- /dev/null +++ b/pkg/sidecar/configmap/parse/parse_test.go @@ -0,0 +1,164 @@ +/* +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 parse + +import ( + "github.com/google/go-cmp/cmp" + "github.com/knative/eventing/pkg/sidecar/fanout" + "github.com/knative/eventing/pkg/sidecar/multichannelfanout" + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "go.uber.org/zap" + "strings" + "testing" +) + +func TestConfigMapData(t *testing.T) { + testCases := []struct { + name string + createDir bool + config string + expected *multichannelfanout.Config + expectedErr bool + }{ + { + name: "dir does not exist", + createDir: false, + }, + { + name: "no data", + createDir: true, + expectedErr: true, + }, + { + name: "invalid YAML", + createDir: true, + config: ` + key: + - value + - different indent level + `, + expectedErr: true, + }, + { + name: "valid YAML -- invalid JSON", + config: "{ nil: Key }", + createDir: true, + expectedErr: true, + }, + { + name: "unknown field", + config: "{ channelConfigs: [ { not: a-defined-field } ] }", + createDir: true, + expectedErr: true, + }, + { + name: "valid", + createDir: true, + config: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - callableDomain: event-changer.default.svc.cluster.local + sinkableDomain: message-dumper-bar.default.svc.cluster.local + - callableDomain: message-dumper-foo.default.svc.cluster.local + - sinkableDomain: message-dumper-bar.default.svc.cluster.local + - namespace: default + name: c2 + fanoutConfig: + subscriptions: + - sinkableDomain: message-dumper-foo.default.svc.cluster.local + - namespace: other + name: c3 + fanoutConfig: + subscriptions: + - sinkableDomain: message-dumper-foo.default.svc.cluster.local + `, + expected: &multichannelfanout.Config{ + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: "default", + Name: "c1", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: "event-changer.default.svc.cluster.local", + SinkableDomain: "message-dumper-bar.default.svc.cluster.local", + }, + { + CallableDomain: "message-dumper-foo.default.svc.cluster.local", + }, + { + SinkableDomain: "message-dumper-bar.default.svc.cluster.local", + }, + }, + }, + }, + { + Namespace: "default", + Name: "c2", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + SinkableDomain: "message-dumper-foo.default.svc.cluster.local", + }, + }, + }, + }, + { + Namespace: "other", + Name: "c3", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + SinkableDomain: "message-dumper-foo.default.svc.cluster.local", + }, + }, + }, + }, + }, + }, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + data := formatData(tc.config) + c, e := ConfigMapData(zap.NewNop(), data) + if tc.expectedErr { + if e == nil { + t.Errorf("Expected an error, actual nil") + } + return + } + if !cmp.Equal(c, tc.expected) { + t.Errorf("Unexpected config. Expected '%v'. Actual '%v'.", tc.expected, c) + } + }) + } +} + +func formatData(config string) map[string]string { + data := make(map[string]string) + if config != "" { + // Golang editors tend to replace leading spaces with tabs. YAML is left whitespace + // sensitive, so let's replace the tabs with four spaces. + leftSpaceConfig := strings.Replace(config, "\t", " ", -1) + data[MultiChannelFanoutConfigKey] = leftSpaceConfig + } + return data +} diff --git a/pkg/sidecar/configmap/watcher/watcher.go b/pkg/sidecar/configmap/watcher/watcher.go new file mode 100644 index 00000000000..95f49d1bc38 --- /dev/null +++ b/pkg/sidecar/configmap/watcher/watcher.go @@ -0,0 +1,121 @@ +/* +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 watcher + +import ( + "context" + "github.com/knative/eventing/pkg/sidecar/configmap/parse" + "github.com/knative/eventing/pkg/sidecar/swappable" + "go.uber.org/zap" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller" + "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + "sigs.k8s.io/controller-runtime/pkg/source" +) + +const ( + watcherName = "config-map-k8s-watcher" +) + +func NewWatcher(logger *zap.Logger, mgr manager.Manager, cmName types.NamespacedName, configUpdated swappable.UpdateConfig) (controller.Controller, error) { + // We use the controller-runtime pattern of setting up a controller exclusively to watch changes + // to the ConfigMap. We do not write to the API server for any object. + r := &reconciler{ + logger: logger, + configUpdated: configUpdated, + cmName: cmName, + } + c, err := controller.New(watcherName, mgr, controller.Options{ + Reconciler: r, + }) + if err != nil { + logger.Error("Unable to create controller.", zap.Error(err)) + return nil, err + } + + // Watch ConfigMaps. + err = c.Watch(&source.Kind{ + Type: &corev1.ConfigMap{}, + }, &handler.EnqueueRequestForObject{}) + if err != nil { + logger.Error("Unable to watch ConfigMaps.", zap.Error(err)) + return nil, err + } + return c, nil +} + +var _ reconcile.Reconciler = &reconciler{} + +type reconciler struct { + logger *zap.Logger + client client.Client + configUpdated swappable.UpdateConfig + cmName types.NamespacedName +} + +func (r *reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) { + //TODO use this to store the logger and set a deadline + ctx := context.TODO() + + if req.Namespace != r.cmName.Namespace || req.Name != r.cmName.Name { + // Not the ConfigMap we are interested in. + return reconcile.Result{}, nil + } + + cm := &corev1.ConfigMap{} + err := r.client.Get(ctx, req.NamespacedName, cm) + + // The ConfigMap may have been deleted since it was added to the workqueue. If so + // there's nothing to be done. + if errors.IsNotFound(err) { + r.logger.Error("ConfigMap not found", zap.Any("request", req)) + return reconcile.Result{}, nil + } + + // If the ConfigMap exists but could not be retrieved, then we should retry. + if err != nil { + r.logger.Error("Could not get ConfigMap", + zap.Any("request", req), + zap.Error(err)) + return reconcile.Result{}, err + } + + config, err := parse.ConfigMapData(r.logger, cm.Data) + if err != nil { + r.logger.Error("Could not parse ConfigMap", zap.Error(err), + zap.Any("configMap.Data", cm.Data)) + return reconcile.Result{}, err + } + + err = r.configUpdated(config) + if err != nil { + r.logger.Error("Unable to update config", zap.Error(err)) + return reconcile.Result{}, err + } + + return reconcile.Result{}, nil +} + +func (r *reconciler) InjectClient(c client.Client) error { + r.client = c + return nil +} diff --git a/pkg/sidecar/configmap/watcher/watcher_test.go b/pkg/sidecar/configmap/watcher/watcher_test.go new file mode 100644 index 00000000000..2511819d237 --- /dev/null +++ b/pkg/sidecar/configmap/watcher/watcher_test.go @@ -0,0 +1,161 @@ +/* +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 watcher + +import ( + "context" + "errors" + "github.com/google/go-cmp/cmp" + controllertesting "github.com/knative/eventing/pkg/controller/testing" + "github.com/knative/eventing/pkg/sidecar/configmap/parse" + "github.com/knative/eventing/pkg/sidecar/fanout" + "github.com/knative/eventing/pkg/sidecar/multichannelfanout" + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "go.uber.org/zap" + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/client/fake" + "sigs.k8s.io/controller-runtime/pkg/reconcile" + "testing" +) + +const ( + namespace = "test-namespace" + name = "test-name" +) + +func TestReconcile(t *testing.T) { + testCases := map[string]struct { + config map[string]string + getErr error + updateConfigErr error + expectedErr bool + expectedConfig *multichannelfanout.Config + }{ + "cm not found": { + expectedErr: false, + }, + "get cm error": { + expectedErr: true, + getErr: errors.New("test-error"), + }, + "cannot parse cm": { + config: map[string]string{ + parse.MultiChannelFanoutConfigKey: "invalid config", + }, + expectedErr: true, + }, + "configUpdated fails": { + expectedErr: true, + config: map[string]string{ + parse.MultiChannelFanoutConfigKey: "", + }, + updateConfigErr: errors.New("test-error"), + expectedConfig: &multichannelfanout.Config{}, + }, + "success": { + config: map[string]string{ + parse.MultiChannelFanoutConfigKey: ` + channelConfigs: + - name: foo + namespace: bar + fanoutConfig: + subscriptions: + - callableDomain: callable + sinkableDomain: sinkable`, + }, + expectedConfig: &multichannelfanout.Config{ + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Name: "foo", + Namespace: "bar", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: "callable", + SinkableDomain: "sinkable", + }, + }, + }, + }, + }, + }, + }, + } + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + mocks := controllertesting.Mocks{ + MockGets: []controllertesting.MockGet{ + func(innerClient client.Client, ctx context.Context, key client.ObjectKey, obj runtime.Object) (controllertesting.MockHandled, error) { + if tc.getErr != nil { + return controllertesting.Handled, tc.getErr + } + if tc.config != nil { + obj.(*corev1.ConfigMap).Data = tc.config + return controllertesting.Handled, nil + } + return controllertesting.Unhandled, nil + }, + }, + } + c := controllertesting.NewMockClient(fake.NewFakeClient(), mocks) + + cuc := &configUpdatedChecker{ + updateConfigErr: tc.updateConfigErr, + } + + r := reconciler{ + logger: zap.NewNop(), + client: c, + configUpdated: cuc.updateConfig, + cmName: types.NamespacedName{ + Namespace: namespace, + Name: name, + }, + } + + result, err := r.Reconcile(reconcile.Request{ + NamespacedName: types.NamespacedName{ + Namespace: namespace, + Name: name, + }, + }) + if tc.expectedErr != (err != nil) { + t.Errorf("Unexpected error. Expected %v. Actual %v.", tc.expectedErr, err) + } + if diff := cmp.Diff(reconcile.Result{}, result); diff != "" { + t.Errorf("Unexpected result (-want +got): %v", diff) + } + + if diff := cmp.Diff(tc.expectedConfig, cuc.config); diff != "" { + t.Errorf("Unexpected config (-want +got): %v", diff) + } + }) + } +} + +type configUpdatedChecker struct { + config *multichannelfanout.Config + updateConfigErr error +} + +func (cuc *configUpdatedChecker) updateConfig(config *multichannelfanout.Config) error { + cuc.config = config + return cuc.updateConfigErr +} diff --git a/pkg/sidecar/swappable/swappable.go b/pkg/sidecar/swappable/swappable.go index 6c8f75d0d9e..ef60758f697 100644 --- a/pkg/sidecar/swappable/swappable.go +++ b/pkg/sidecar/swappable/swappable.go @@ -17,9 +17,11 @@ limitations under the License. package swappable import ( + "errors" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" "go.uber.org/zap" "net/http" + "sync" "sync/atomic" ) @@ -27,16 +29,21 @@ import ( type Handler struct { // The current multichannelfanout.Handler to delegate HTTP requests to. Never use this directly, // instead use {get,set}MultiChannelFanoutHandler, which enforces the type we expect. - fanout atomic.Value - logger *zap.Logger + fanout atomic.Value + updateLock sync.Mutex + logger *zap.Logger } +type UpdateConfig func(config *multichannelfanout.Config) error + +var _ UpdateConfig = (&Handler{}).UpdateConfig + // NewHandler creates a new swappable.Handler. func NewHandler(handler *multichannelfanout.Handler, logger *zap.Logger) *Handler { h := &Handler{ logger: logger.With(zap.String("httpHandler", "swappable")), } - h.SetMultiChannelFanoutHandler(handler) + h.setMultiChannelFanoutHandler(handler) return h } @@ -50,19 +57,43 @@ func NewEmptyHandler(logger *zap.Logger) (*Handler, error) { // getMultiChannelFanoutHandler gets the current multichannelfanout.Handler to delegate all HTTP // requests to. -func (h *Handler) GetMultiChannelFanoutHandler() *multichannelfanout.Handler { +func (h *Handler) getMultiChannelFanoutHandler() *multichannelfanout.Handler { return h.fanout.Load().(*multichannelfanout.Handler) } // setMultiChannelFanoutHandler sets a new multichannelfanout.Handler to delegate all subsequent // HTTP requests to. -func (h *Handler) SetMultiChannelFanoutHandler(new *multichannelfanout.Handler) { +func (h *Handler) setMultiChannelFanoutHandler(new *multichannelfanout.Handler) { h.fanout.Store(new) } +// UpdateConfig copies the current inner multichannelfanout.Handler with the new configuration. If +// the new configuration is valid, then the new inner handler is swapped in and will start serving +// HTTP traffic. +func (h *Handler) UpdateConfig(config *multichannelfanout.Config) error { + if config == nil { + return errors.New("nil config") + } + + h.updateLock.Lock() + defer h.updateLock.Unlock() + + ih := h.getMultiChannelFanoutHandler() + if diff := ih.ConfigDiff(*config); diff != "" { + h.logger.Info("Updating config (-old +new)", zap.String("diff", diff)) + newIh, err := ih.CopyWithNewConfig(*config) + if err != nil { + h.logger.Info("Unable to update config", zap.Error(err), zap.Any("config", config)) + return err + } + h.setMultiChannelFanoutHandler(newIh) + } + return nil +} + // ServeHTTP delegates all HTTP requests to the current multichannelfanout.Handler. func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Hand work off to the current multi channel fanout handler. h.logger.Debug("ServeHTTP request received") - h.GetMultiChannelFanoutHandler().ServeHTTP(w, r) + h.getMultiChannelFanoutHandler().ServeHTTP(w, r) } diff --git a/pkg/sidecar/swappable/swappable_test.go b/pkg/sidecar/swappable/swappable_test.go index 55de79207bd..396b0797207 100644 --- a/pkg/sidecar/swappable/swappable_test.go +++ b/pkg/sidecar/swappable/swappable_test.go @@ -86,20 +86,101 @@ func TestHandler(t *testing.T) { } } +func TestHandler_InvalidConfigChange(t *testing.T) { + testCases := map[string]struct { + initialConfig multichannelfanout.Config + badUpdateConfig multichannelfanout.Config + }{ + "invalid config change": { + initialConfig: multichannelfanout.Config{ + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: namespace, + Name: name, + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: replaceDomain, + }, + }, + }, + }, + }, + }, + badUpdateConfig: multichannelfanout.Config{ + // Duplicate (namespace, name). + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: namespace, + Name: name, + }, + { + Namespace: namespace, + Name: name, + }, + }, + }, + }, + } + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + h, err := NewEmptyHandler(zap.NewNop()) + if err != nil { + t.Errorf("Unexpected error creating handler: %v", err) + } + + server := httptest.NewServer(&successHandler{}) + defer server.Close() + + rc := replaceDomains(tc.initialConfig, server.URL[7:]) + err = h.UpdateConfig(&rc) + if err != nil { + t.Errorf("Unexpected error updating to initial config: %v", tc.initialConfig) + } + assertRequestOK(t, h) + + // Try to update to the new config, it will fail. But we should still be able to hit the + // original server. + ruc := replaceDomains(tc.badUpdateConfig, server.URL[7:]) + err = h.UpdateConfig(&ruc) + if err == nil { + t.Errorf("Expected an error when updating to a bad config.") + } + assertRequestOK(t, h) + }) + } +} + +func TestHandler_NilConfigChange(t *testing.T) { + h, err := NewEmptyHandler(zap.NewNop()) + if err != nil { + t.Errorf("Unexpected error creating handler: %v", err) + } + + err = h.UpdateConfig(nil) + if err == nil { + t.Errorf("Expected an error when updating to a nil config.") + } +} + func updateConfigAndTest(t *testing.T, h *Handler, config multichannelfanout.Config) { server := httptest.NewServer(&successHandler{}) defer server.Close() - nh, err := multichannelfanout.NewHandler(zap.NewNop(), replaceDomains(config, server.URL[7:])) + rc := replaceDomains(config, server.URL[7:]) + orig := h.fanout.Load() + err := h.UpdateConfig(&rc) if err != nil { - t.Errorf("Unexpected error creating multiChannelFanoutHandler: %v", err) + t.Errorf("Unexpected error updating config: %+v", err) } - orig := h.GetMultiChannelFanoutHandler() - h.SetMultiChannelFanoutHandler(nh) - if orig == h.GetMultiChannelFanoutHandler() { + if orig == h.fanout.Load() { t.Errorf("Expected the inner multiChannelFanoutHandler to change, it didn't: %v", orig) } + assertRequestOK(t, h) +} + +func assertRequestOK(t *testing.T, h *Handler) { w := httptest.NewRecorder() h.ServeHTTP(w, makeRequest(namespace, name)) if w.Code != http.StatusOK { From 8338cebab1bc4e4697f2c74d80a01f6f00b95c6b Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Fri, 28 Sep 2018 16:00:12 -0700 Subject: [PATCH 12/23] Delete the old config_map_handler. --- .../configmaphandler/config_map_handler.go | 190 --------- .../config_map_handler_test.go | 390 ------------------ 2 files changed, 580 deletions(-) delete mode 100644 pkg/sidecar/configmaphandler/config_map_handler.go delete mode 100644 pkg/sidecar/configmaphandler/config_map_handler_test.go diff --git a/pkg/sidecar/configmaphandler/config_map_handler.go b/pkg/sidecar/configmaphandler/config_map_handler.go deleted file mode 100644 index 7a362dd38b2..00000000000 --- a/pkg/sidecar/configmaphandler/config_map_handler.go +++ /dev/null @@ -1,190 +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 configmaphandler - -import ( - "bytes" - "encoding/json" - "fmt" - "github.com/fsnotify/fsnotify" - "github.com/knative/eventing/pkg/sidecar/multichannelfanout" - "github.com/knative/pkg/configmap" - "go.uber.org/zap" - "k8s.io/apimachinery/pkg/util/yaml" - "net/http" - "sync/atomic" -) - -const ( - // The mount path of the configMap volume. - ConfigDir = "/etc/config/fanout_sidecar" - // The config key that contains all the configuration data. - multiChannelFanoutConfigKey = "multiChannelFanoutConfig" -) - -// http.Handler that monitors an attached ConfigMap volume for updated configuration and updates its -// behavior based on the configuration. -type configMapHandler struct { - logger *zap.Logger - // The directory to read the configMap from. - dir string - // Stop the watcher by closing this channel. Expected to only be used by tests. - watcherStopCh chan<- bool - // The current multichannelfanout.Handler to delegate HTTP requests to. Never use this directly, - // instead use {get,set}MultiChannelFanoutHandler, which enforces the type we expect. - fanout atomic.Value -} - -// NewHandler creates a new configmaphandler.Handler. -func NewHandler(logger *zap.Logger, dir string) (http.Handler, error) { - conf, err := readConfigMap(logger, dir) - if err != nil { - logger.Error("Unable to read configMap", zap.Error(err)) - return nil, err - } - - logger.Info("Read initial configMap", zap.Any("conf", conf)) - - mcfh, err := multichannelfanout.NewHandler(logger, conf) - if err != nil { - logger.Error("Unable to create multichannelfanout.Handler: %v", zap.Error(err)) - return nil, err - } - - cmh := &configMapHandler{ - logger: logger, - dir: dir, - } - cmh.setMultiChannelFanoutHandler(mcfh) - watcherStopCh, err := cmh.startWatcher(dir) - if err != nil { - logger.Error("Unable to start the configMap file watcher", zap.Error(err)) - return nil, err - } - cmh.watcherStopCh = watcherStopCh - return cmh, nil -} - -// getMultiChannelFanoutHandler gets the current multichannelfanout.Handler to delegate all HTTP -// requests to. -func (cmh *configMapHandler) getMultiChannelFanoutHandler() *multichannelfanout.Handler { - return cmh.fanout.Load().(*multichannelfanout.Handler) -} - -// setMultiChannelFanoutHandler sets a new multichannelfanout.Handler to delegate all subsequent -// HTTP requests to. -func (cmh *configMapHandler) setMultiChannelFanoutHandler(new *multichannelfanout.Handler) { - cmh.fanout.Store(new) -} - -// readConfigMap attempts to read the configMap from the attached volume. -func readConfigMap(logger *zap.Logger, dir string) (multichannelfanout.Config, error) { - cm, err := configmap.Load(dir) - if err != nil { - logger.Error("Unable to read configMap", zap.Error(err)) - return multichannelfanout.Config{}, err - } - - if _, present := cm[multiChannelFanoutConfigKey]; !present { - logger.Error("Expected key not found", zap.String("key", multiChannelFanoutConfigKey)) - return multichannelfanout.Config{}, fmt.Errorf("expected key not found: %v", multiChannelFanoutConfigKey) - } - jb, err := yaml.ToJSON([]byte(cm[multiChannelFanoutConfigKey])) - if err != nil { - logger.Error("Unable to convert multiChannelFanoutConfig to JSON", zap.Error(err)) - return multichannelfanout.Config{}, err - } - var conf multichannelfanout.Config - err = unmarshallJsonDisallowUnknownFields(jb, &conf) - return conf, err -} - -// readConfigMapAndUpdateSubs reads the configMap data and updates configuration of cmh.fanout, if -// it has changed. -// -// Note that this is often called multiple times when the configMap is updated, so it should do its -// best to discard redundant calls. -func (cmh *configMapHandler) readConfigMapAndUpdateConfig() { - conf, err := readConfigMap(cmh.logger, cmh.dir) - if err != nil { - cmh.logger.Error("Unable to read the configMap", zap.Error(err)) - return - } - current := cmh.getMultiChannelFanoutHandler() - if diff := current.ConfigDiff(conf); diff != "" { - cmh.logger.Info("Updating multiChannelFanout config", zap.String("diff (-old, +new)", diff)) - updated, err := current.CopyWithNewConfig(conf) - if err != nil { - cmh.logger.Error("Unable to create updated multichannelfanout.Handler", zap.Error(err)) - return - } - cmh.setMultiChannelFanoutHandler(updated) - } else { - cmh.logger.Info("fanout config unchanged") - } -} - -// startWatcher starts a background go routine that gets events when the filesystem in configDir is -// changed. -func (cmh *configMapHandler) startWatcher(dir string) (chan<- bool, error) { - watcher, err := fsnotify.NewWatcher() - if err != nil { - return nil, err - } - stopCh := make(chan bool) - go func() { - for { - select { - case _, ok := <-watcher.Events: - if !ok { - // Channel closed. - cmh.logger.Error("watcher.Events channel closed") // TODO: Should this be fatal? - return - } - cmh.readConfigMapAndUpdateConfig() - case err, ok := <-watcher.Errors: - if !ok { - // Channel closed. - cmh.logger.Error("watcher.Errors channel closed") // TODO: Should this be fatal? - return - } - cmh.logger.Error("watcher.Errors", zap.Error(err)) - case _, ok := <-stopCh: - if !ok { - // stopCh has been closed - return - } - } - } - }() - - return stopCh, watcher.Add(dir) -} - -// ServeHTTP delegates all HTTP requests to the current multichannelfanout.Handler. -func (cmh *configMapHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - // Hand work off to the current multi channel fanout handler. - cmh.getMultiChannelFanoutHandler().ServeHTTP(w, r) -} - -// unmarshallJsonDisallowUnknownFields unmarshalls JSON, but unlike json.Unmarshall, will fail if -// given an unknown field (rather than json.Unmarshall's ignoring the unknown field). -func unmarshallJsonDisallowUnknownFields(jb []byte, v interface{}) error { - d := json.NewDecoder(bytes.NewReader(jb)) - d.DisallowUnknownFields() - return d.Decode(v) -} diff --git a/pkg/sidecar/configmaphandler/config_map_handler_test.go b/pkg/sidecar/configmaphandler/config_map_handler_test.go deleted file mode 100644 index 0b847d467e7..00000000000 --- a/pkg/sidecar/configmaphandler/config_map_handler_test.go +++ /dev/null @@ -1,390 +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 configmaphandler - -import ( - "fmt" - "github.com/google/go-cmp/cmp" - "github.com/knative/eventing/pkg/sidecar/fanout" - "github.com/knative/eventing/pkg/sidecar/multichannelfanout" - duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "go.uber.org/atomic" - "go.uber.org/zap" - "io" - "io/ioutil" - "net/http" - "net/http/httptest" - "os" - "strings" - "testing" - "time" -) - -const ( - replaceDomain = "replaceDomain" -) - -func TestReadConfigMap(t *testing.T) { - testCases := []struct { - name string - createDir bool - config string - expected multichannelfanout.Config - expectedErr bool - }{ - { - name: "dir does not exist", - createDir: false, - }, - { - name: "no data", - createDir: true, - expectedErr: true, - }, - { - name: "invalid YAML", - createDir: true, - config: ` - key: - - value - - different indent level - `, - expectedErr: true, - }, - { - name: "valid YAML -- invalid JSON", - config: "{ nil: Key }", - createDir: true, - expectedErr: true, - }, - { - name: "unknown field", - config: "{ channelConfigs: [ { not: a-defined-field } ] }", - createDir: true, - expectedErr: true, - }, - { - name: "valid", - createDir: true, - config: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - callableDomain: event-changer.default.svc.cluster.local - sinkableDomain: message-dumper-bar.default.svc.cluster.local - - callableDomain: message-dumper-foo.default.svc.cluster.local - - sinkableDomain: message-dumper-bar.default.svc.cluster.local - - namespace: default - name: c2 - fanoutConfig: - subscriptions: - - sinkableDomain: message-dumper-foo.default.svc.cluster.local - - namespace: other - name: c3 - fanoutConfig: - subscriptions: - - sinkableDomain: message-dumper-foo.default.svc.cluster.local - `, - expected: multichannelfanout.Config{ - ChannelConfigs: []multichannelfanout.ChannelConfig{ - { - Namespace: "default", - Name: "c1", - FanoutConfig: fanout.Config{ - Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ - { - CallableDomain: "event-changer.default.svc.cluster.local", - SinkableDomain: "message-dumper-bar.default.svc.cluster.local", - }, - { - CallableDomain: "message-dumper-foo.default.svc.cluster.local", - }, - { - SinkableDomain: "message-dumper-bar.default.svc.cluster.local", - }, - }, - }, - }, - { - Namespace: "default", - Name: "c2", - FanoutConfig: fanout.Config{ - Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ - { - SinkableDomain: "message-dumper-foo.default.svc.cluster.local", - }, - }, - }, - }, - { - Namespace: "other", - Name: "c3", - FanoutConfig: fanout.Config{ - Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ - { - SinkableDomain: "message-dumper-foo.default.svc.cluster.local", - }, - }, - }, - }, - }, - }, - }, - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - var dir string - if tc.createDir { - dir = createTempDir(t) - defer os.RemoveAll(dir) - } else { - dir = "/tmp/doesNotExist" - } - writeConfig(t, dir, tc.config) - c, e := readConfigMap(zap.NewNop(), dir) - if tc.expectedErr { - if e == nil { - t.Errorf("Expected an error, actual nil") - } - return - } - if !cmp.Equal(c, tc.expected) { - t.Errorf("Unexpected config. Expected '%v'. Actual '%v'.", tc.expected, c) - } - }) - } -} - -func TestNewHandler(t *testing.T) { - testCases := []struct { - name string - createDir bool - config string - expectErr bool - }{ - { - name: "dir does not exist", - createDir: false, - expectErr: true, - }, - { - name: "duplicate channel key", - createDir: true, - config: ` - channelConfigs: - - namespace: default - name: duplicate - - namespace: default - name: duplicate - `, - expectErr: true, - }, - { - name: "success", - createDir: true, - config: ` - channelConfigs: [] - `, - }, - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - var dir string - if tc.createDir { - dir = createTempDir(t) - defer os.RemoveAll(dir) - } else { - dir = "/tmp/doesNotExist" - } - writeConfig(t, dir, tc.config) - cmh, err := NewHandler(zap.NewNop(), dir) - if err == nil { - // This is not yet about the logic of the test, just ensuring we don't accidentally - // leave the channel open, which will leave the watcher running. - defer close(cmh.(*configMapHandler).watcherStopCh) - } - if tc.expectErr { - if err == nil { - t.Errorf("Expected an error, actually nil") - } - return - } - }) - } -} - -func TestServeHTTP(t *testing.T) { - testCases := []struct { - name string - initialConfig string - updatedConfig string - initialRequests int32 - initialRequestsAfterUpdate int32 - updateRequests int32 - }{ - { - name: "send to config", - initialConfig: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - `, - initialRequests: 1, - }, - { - name: "change config", - initialConfig: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - `, - initialRequests: 1, - updatedConfig: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - `, - updateRequests: 1, - }, - { - name: "bad config update -- keeps serving old config", - initialConfig: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - `, - initialRequests: 1, - updatedConfig: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - # Duplicate namespace/name - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - `, - initialRequestsAfterUpdate: 2, - }, - } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - initialHandler := &fakeHandler{} - initialServer := httptest.NewServer(initialHandler) - defer initialServer.Close() - updateHandler := &fakeHandler{} - updateServer := httptest.NewServer(updateHandler) - defer updateServer.Close() - - dir := createTempDir(t) - defer os.RemoveAll(dir) - writeConfig(t, dir, replaceDomains(tc.initialConfig, initialServer.URL[7:])) - - cmh, _ := NewHandler(zap.NewNop(), dir) - - w := httptest.NewRecorder() - cmh.ServeHTTP(w, makeRequest("default", "c1")) - if w.Result().StatusCode != http.StatusOK { - t.Errorf("Unexpected initial status code: %v", w.Result().StatusCode) - } - if tc.initialRequests != initialHandler.requests.Load() { - t.Errorf("Incorrect initial request count. Expected %v. Actual %v.", - tc.initialRequests, initialHandler.requests.Load()) - } - - if tc.updatedConfig != "" { - writeConfig(t, dir, replaceDomains(tc.updatedConfig, updateServer.URL[7:])) - // The watcher is running in another routine, give it some time to notice the - // change. - time.Sleep(100 * time.Millisecond) - w = httptest.NewRecorder() - cmh.ServeHTTP(w, makeRequest("default", "c1")) - if w.Result().StatusCode != http.StatusOK { - t.Errorf("Unexpected updated status code: %v", w.Result().StatusCode) - } - if tc.updateRequests != updateHandler.requests.Load() { - t.Errorf("Incorrect update request count. Expected %v. Actual %v.", tc.updateRequests, updateHandler.requests.Load()) - } - if tc.initialRequestsAfterUpdate != 0 && tc.initialRequestsAfterUpdate != initialHandler.requests.Load() { - t.Errorf("Incorrect requests to initialHandler after config update. Expected %v, actual %v", - tc.initialRequestsAfterUpdate, initialHandler.requests.Load()) - } - } - }) - } -} - -func createTempDir(t *testing.T) string { - dir, err := ioutil.TempDir("", "configMapHandlerTest") - if err != nil { - t.Errorf("Unable to make temp directory: %v", err) - } - return dir -} - -func writeConfig(t *testing.T, dir, config string) { - if config != "" { - // Golang editors tend to replace leading spaces with tabs. YAML is left whitespace - // sensitive, so let's replace the tabs with spaces. - leftSpaceConfig := strings.Replace(config, "\t", " ", -1) - err := ioutil.WriteFile(fmt.Sprintf("%s/%s", dir, multiChannelFanoutConfigKey), []byte(leftSpaceConfig), 0700) - if err != nil { - t.Errorf("Problem writing the config file: %v", err) - } - } -} - -func body(body string) io.ReadCloser { - return ioutil.NopCloser(strings.NewReader(body)) -} - -func makeRequest(namespace, name string) *http.Request { - r := httptest.NewRequest("POST", fmt.Sprintf("http://%s.%s/", name, namespace), body("")) - return r -} - -type fakeHandler struct { - requests atomic.Int32 -} - -func (h *fakeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - defer r.Body.Close() - w.WriteHeader(http.StatusOK) - h.requests.Inc() -} - -func replaceDomains(config, replacement string) string { - return strings.Replace(config, replaceDomain, replacement, -1) -} From ced872b1aaf76e01ee277b766b72e44869a0fec7 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Mon, 1 Oct 2018 09:22:10 -0700 Subject: [PATCH 13/23] Respond to PR comments. --- pkg/sidecar/fanout/fanout_handler.go | 12 +++++++----- pkg/sidecar/swappable/swappable.go | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/sidecar/fanout/fanout_handler.go b/pkg/sidecar/fanout/fanout_handler.go index 798005a6a4d..e8219d0c92f 100644 --- a/pkg/sidecar/fanout/fanout_handler.go +++ b/pkg/sidecar/fanout/fanout_handler.go @@ -18,10 +18,10 @@ package fanout import ( "fmt" + "github.com/google/uuid" "github.com/knative/eventing/pkg/buses" duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" "go.uber.org/zap" - "math/rand" "net/http" "sync" "time" @@ -81,8 +81,9 @@ func createReceiverFunction(f *fanoutHandler) func(buses.ChannelReference, *buse } } -// ServeHTTP takes the request, fans it out to each subscription in f.config. If all the fanned out -// requests return successfully, then return successfully. Else, return failure. +// ServeHTTP takes the request and fans it out to each subscription in f.config. If all the fanned +// out requests have successful response codes, then this response will have a successful response +// code. Else, this response will have a failure response code. func (f *fanoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { key := addTrackingHeader(r) receiverResponse := &response{} @@ -144,10 +145,12 @@ type response struct { var _ http.ResponseWriter = &response{} +// Header doesn't do anything. Just here so that response is an http.ResponseWriter. func (*response) Header() http.Header { return http.Header{} } +// Write doesn't do anything. Just here so that response is an http.ResponseWriter. func (*response) Write(b []byte) (int, error) { return len(b), nil } @@ -183,8 +186,7 @@ func (ms *messageStorage) pull(key string) (*buses.Message, error) { } func addTrackingHeader(r *http.Request) string { - // Use two random 63 bit ints, as a poor approximation of a UUID. - key := fmt.Sprintf("%X-%X", rand.Int63(), rand.Int63()) + key := uuid.New().String() r.Header.Set(uniqueFanoutHeader, key) return key } diff --git a/pkg/sidecar/swappable/swappable.go b/pkg/sidecar/swappable/swappable.go index ef60758f697..bd9944014ff 100644 --- a/pkg/sidecar/swappable/swappable.go +++ b/pkg/sidecar/swappable/swappable.go @@ -25,7 +25,7 @@ import ( "sync/atomic" ) -// http.Handler that atomically swapping between underlying handlers. +// http.Handler that atomically swaps between underlying handlers. type Handler struct { // The current multichannelfanout.Handler to delegate HTTP requests to. Never use this directly, // instead use {get,set}MultiChannelFanoutHandler, which enforces the type we expect. From 0d1b9ed8cb2edee480e89b259267586d863a9460 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Mon, 1 Oct 2018 14:26:40 -0700 Subject: [PATCH 14/23] Remove the no longer used httpDoer interface. --- pkg/buses/message_dispatcher.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/buses/message_dispatcher.go b/pkg/buses/message_dispatcher.go index 9ba03fa8484..c04b99508dc 100644 --- a/pkg/buses/message_dispatcher.go +++ b/pkg/buses/message_dispatcher.go @@ -30,14 +30,9 @@ import ( const correlationIDHeaderName = "Knative-Correlation-Id" -// httpDoer is an interface for making HTTP requests. -type httpDoer interface { - Do(*http.Request) (*http.Response, error) -} - // MessageDispatcher dispatches messages to a destination over HTTP. type MessageDispatcher struct { - httpClient httpDoer + httpClient *http.Client forwardHeaders map[string]bool forwardPrefixes []string supportedSchemes map[string]bool From 46a9b13aba1991899e85ff01d1d86212ca7ee474 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Fri, 5 Oct 2018 10:01:12 -0700 Subject: [PATCH 15/23] hack/update-deps.sh --- Gopkg.lock | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Gopkg.lock b/Gopkg.lock index 3f91aa7dfda..5093df2ffe6 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -71,6 +71,14 @@ revision = "44cc805cf13205b55f69e14bcb69867d1ae92f98" version = "v1.1.0" +[[projects]] + digest = "1:1b91ae0dc69a41d4c2ed23ea5cffb721ea63f5037ca4b81e6d6771fbb8f45129" + name = "github.com/fsnotify/fsnotify" + packages = ["."] + pruneopts = "NUT" + revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9" + version = "v1.4.7" + [[projects]] digest = "1:81466b4218bf6adddac2572a30ac733a9255919bc2f470b4827a317bd4ee1756" name = "github.com/ghodss/yaml" @@ -268,7 +276,7 @@ revision = "5c1d8c8469d1ed34b2aecf4c2305b3a57fff2ee3" [[projects]] - digest = "1:3032bf41e1ec7fe0093c6db659b3cf202ef528c421c26376a7fe209467a9fd74" + digest = "1:a3f465e8fba2ec1a371c52063ce81f17fbf7356a8cadbc160b2f94796ff5e785" name = "github.com/knative/pkg" packages = [ "apis", @@ -1052,6 +1060,7 @@ "github.com/Shopify/sarama", "github.com/bsm/sarama-cluster", "github.com/davecgh/go-spew/spew", + "github.com/fsnotify/fsnotify", "github.com/golang/glog", "github.com/google/go-cmp/cmp", "github.com/google/go-cmp/cmp/cmpopts", @@ -1077,6 +1086,7 @@ "github.com/knative/test-infra", "github.com/prometheus/client_golang/prometheus/promhttp", "go.opencensus.io/trace", + "go.uber.org/atomic", "go.uber.org/zap", "go.uber.org/zap/zapcore", "golang.org/x/net/context", @@ -1106,6 +1116,7 @@ "k8s.io/apimachinery/pkg/util/sets/types", "k8s.io/apimachinery/pkg/util/validation", "k8s.io/apimachinery/pkg/util/wait", + "k8s.io/apimachinery/pkg/util/yaml", "k8s.io/apimachinery/pkg/watch", "k8s.io/client-go/discovery", "k8s.io/client-go/discovery/fake", From d046c88693e92f4088776c522f577b8a9235cbab Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Tue, 9 Oct 2018 09:20:14 -0700 Subject: [PATCH 16/23] Use channels to send information between the fanout's receiver and dispatcher. --- .../filesystem/config_map_handler_test.go | 4 +- pkg/sidecar/fanout/fanout_handler.go | 206 ++++++++---------- pkg/sidecar/fanout/fanout_handler_test.go | 32 ++- .../multi_channel_fanout_handler.go | 10 +- .../multi_channel_fanout_handler_test.go | 10 +- pkg/sidecar/swappable/swappable.go | 1 + pkg/sidecar/swappable/swappable_test.go | 12 +- 7 files changed, 127 insertions(+), 148 deletions(-) diff --git a/pkg/sidecar/configmap/filesystem/config_map_handler_test.go b/pkg/sidecar/configmap/filesystem/config_map_handler_test.go index 31a3396382a..666e284f110 100644 --- a/pkg/sidecar/configmap/filesystem/config_map_handler_test.go +++ b/pkg/sidecar/configmap/filesystem/config_map_handler_test.go @@ -267,7 +267,7 @@ func TestServeHTTP(t *testing.T) { w := httptest.NewRecorder() sh.ServeHTTP(w, makeRequest("default", "c1")) - if w.Result().StatusCode != http.StatusOK { + if w.Result().StatusCode != http.StatusAccepted { t.Errorf("Unexpected initial status code: %v", w.Result().StatusCode) } if tc.initialRequests != initialHandler.requests.Load() { @@ -282,7 +282,7 @@ func TestServeHTTP(t *testing.T) { time.Sleep(100 * time.Millisecond) w = httptest.NewRecorder() sh.ServeHTTP(w, makeRequest("default", "c1")) - if w.Result().StatusCode != http.StatusOK { + if w.Result().StatusCode != http.StatusAccepted { t.Errorf("Unexpected updated status code: %v", w.Result().StatusCode) } if tc.updateRequests != updateHandler.requests.Load() { diff --git a/pkg/sidecar/fanout/fanout_handler.go b/pkg/sidecar/fanout/fanout_handler.go index e8219d0c92f..e5f546c6bb6 100644 --- a/pkg/sidecar/fanout/fanout_handler.go +++ b/pkg/sidecar/fanout/fanout_handler.go @@ -17,24 +17,18 @@ limitations under the License. package fanout import ( - "fmt" - "github.com/google/uuid" + "errors" "github.com/knative/eventing/pkg/buses" duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" "go.uber.org/zap" "net/http" - "sync" "time" ) const ( - // The header attached to requests sent through the MessageReceiver. It is used to correlate the - // request going into the MessageReceiver and the request coming out of the MessageReceiver. It - // is removed before being sent downstream. - // Note that it MUST be in the headers forwarded by the MessageReceiver. - uniqueFanoutHeader = "Knative-Fanout-Message-Tracker" - defaultTimeout = 1 * time.Minute + + messageBufferSize = 500 ) // Configuration for a fanout.Handler. @@ -43,154 +37,128 @@ type Config struct { } // http.Handler that takes a single request in and fans it out to N other servers. -type fanoutHandler struct { +type Handler struct { config Config - receivedMessages *messageStorage + receivedMessages chan *message receiver *buses.MessageReceiver dispatcher *buses.MessageDispatcher + stopCh chan<- struct{} timeout time.Duration logger *zap.Logger } -var _ http.Handler = &fanoutHandler{} +var _ http.Handler = &Handler{} + +// message is passed between the Receiver and the Dispatcher. +type message struct { + msg *buses.Message + done chan<- error +} -func NewHandler(logger *zap.Logger, config Config) http.Handler { - handler := &fanoutHandler{ +// NewHandler creates a new fanout.Handler and starts a background goroutine to make it work. The +// caller is responsible for calling handler.Stop(), when the handler is to be stopped. +func NewHandler(logger *zap.Logger, config Config) *Handler { + stopCh := make(chan struct{}, 1) + handler := &Handler{ logger: logger, config: config, dispatcher: buses.NewMessageDispatcher(logger.Sugar()), - receivedMessages: &messageStorage{ - messages: make(map[string]*buses.Message), - }, + receivedMessages: make(chan *message, messageBufferSize), + stopCh: stopCh, timeout: defaultTimeout, } // The receiver function needs to point back at the handler itself, so setup it after // initialization. handler.receiver = buses.NewMessageReceiver(createReceiverFunction(handler), logger.Sugar()) + + go handler.foreverDispatch(stopCh) return handler } -func createReceiverFunction(f *fanoutHandler) func(buses.ChannelReference, *buses.Message) error { +func createReceiverFunction(f *Handler) func(buses.ChannelReference, *buses.Message) error { return func(_ buses.ChannelReference, m *buses.Message) error { - f.logger.Debug("Putting message", zap.String("key", m.Headers[uniqueFanoutHeader])) - f.receivedMessages.Put(m) - return nil - } -} - -// ServeHTTP takes the request and fans it out to each subscription in f.config. If all the fanned -// out requests have successful response codes, then this response will have a successful response -// code. Else, this response will have a failure response code. -func (f *fanoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - key := addTrackingHeader(r) - receiverResponse := &response{} - f.receiver.HandleRequest(receiverResponse, r) - - if receiverResponse.statusCode != http.StatusAccepted { - f.logger.Info("MessageReceiver rejected the request", zap.Int("statusCode", receiverResponse.statusCode)) - w.WriteHeader(receiverResponse.statusCode) - // We don't care about the message, we just don't want it to stay in the map forever. - f.receivedMessages.pull(key) - return - } - - f.logger.Debug("Pulling message", zap.String("key", key)) - m, err := f.receivedMessages.pull(key) - if err != nil { - f.logger.Info("Could not find tracked message", zap.Error(err), zap.Any("key", r.Header[uniqueFanoutHeader])) - w.WriteHeader(http.StatusInternalServerError) - return - } - removeTrackingHeader(m) + done := make(chan error) + msg := &message{ + msg: m, + done: done, + } - errorCh := make(chan error, len(f.config.Subscriptions)) - for _, sub := range f.config.Subscriptions { - go func(s duckv1alpha1.ChannelSubscriberSpec) { - errorCh <- f.makeFanoutRequest(r, *m, s) - }(sub) - } + select { + case f.receivedMessages <- msg: + // Continue to next select. + default: + f.logger.Debug("Unable to add message to channel, dropping it.", zap.Any("msg", msg)) + return errors.New("unable to add message to channel, dropping it") + } - sc := http.StatusOK -Loop: - for range f.config.Subscriptions { select { - case err := <-errorCh: - if err != nil { - f.logger.Error("Fanout had an error", zap.Error(err)) - sc = http.StatusInternalServerError - } + case possibleErr := <-done: + f.logger.Debug("Responding", zap.Any("possibleErr", possibleErr)) + return possibleErr case <-time.After(f.timeout): - f.logger.Error("Fanout timed out") - sc = http.StatusInternalServerError - break Loop + f.logger.Debug("Timeout waiting for dispatch") + return errors.New("timeout waiting for dispatch") } } - - w.WriteHeader(sc) } -// makeFanoutRequest sends the request to exactly one subscription. It handles both the `call` and -// the `to` portions of the subscription. -func (f *fanoutHandler) makeFanoutRequest(r *http.Request, m buses.Message, sub duckv1alpha1.ChannelSubscriberSpec) error { - return f.dispatcher.DispatchMessage(&m, sub.CallableDomain, sub.SinkableDomain, buses.DispatchDefaults{}) +func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + f.receiver.HandleRequest(w, r) } -// response is used to capture the statusCode returned by the messageReceiver. -type response struct { - statusCode int +// Stop stops the background goroutine. Once this is called, this Handler will no longer properly +// Serve HTTP traffic. +func (f *Handler) Stop() { + f.stopCh <- struct{}{} } -var _ http.ResponseWriter = &response{} - -// Header doesn't do anything. Just here so that response is an http.ResponseWriter. -func (*response) Header() http.Header { - return http.Header{} -} - -// Write doesn't do anything. Just here so that response is an http.ResponseWriter. -func (*response) Write(b []byte) (int, error) { - return len(b), nil -} - -func (r *response) WriteHeader(statusCode int) { - r.statusCode = statusCode -} - -type messageStorage struct { - messagesLock sync.Mutex - messages map[string]*buses.Message -} - -func (ms *messageStorage) Put(m *buses.Message) { - key := m.Headers[uniqueFanoutHeader] - - ms.messagesLock.Lock() - defer ms.messagesLock.Unlock() - - ms.messages[key] = m -} - -func (ms *messageStorage) pull(key string) (*buses.Message, error) { - ms.messagesLock.Lock() - defer ms.messagesLock.Unlock() - - if m, ok := ms.messages[key]; ok { - delete(ms.messages, key) - return m, nil - } else { - return nil, fmt.Errorf("could not find message: %v", key) +// foreverDispatch dispatches received messages in an infinite loop. It exits only when +// Handler.stopCh receives a message. It is meant to be run as a goroutine. +func (f *Handler) foreverDispatch(stopCh <-chan struct{}) { + for { + select { + case msg := <- f.receivedMessages: + f.dispatch(msg) + case <-stopCh: + f.logger.Info("Fanout dispatch thread stopping.") + return + } } } -func addTrackingHeader(r *http.Request) string { - key := uuid.New().String() - r.Header.Set(uniqueFanoutHeader, key) - return key +// ServeHTTP takes the request, fans it out to each subscription in f.config. If all the fanned out +// requests return successfully, then return successfully. Else, return failure. +func (f *Handler) dispatch(msg *message) { + msg.done <- func() error { + errorCh := make(chan error, len(f.config.Subscriptions)) + for _, sub := range f.config.Subscriptions { + go func(s duckv1alpha1.ChannelSubscriberSpec) { + errorCh <- f.makeFanoutRequest(*msg.msg, s) + }(sub) + } + + for range f.config.Subscriptions { + select { + case err := <-errorCh: + if err != nil { + f.logger.Error("Fanout had an error", zap.Error(err)) + return err + } + case <-time.After(f.timeout): + f.logger.Error("Fanout timed out") + return errors.New("fanout timed out") + } + } + // All Subscriptions returned err=nil. + return nil + }() } -func removeTrackingHeader(m *buses.Message) { - delete(m.Headers, uniqueFanoutHeader) +// makeFanoutRequest sends the request to exactly one subscription. It handles both the `call` and +// the `to` portions of the subscription. +func (f *Handler) makeFanoutRequest(m buses.Message, sub duckv1alpha1.ChannelSubscriberSpec) error { + return f.dispatcher.DispatchMessage(&m, sub.CallableDomain, sub.SinkableDomain, buses.DispatchDefaults{}) } diff --git a/pkg/sidecar/fanout/fanout_handler_test.go b/pkg/sidecar/fanout/fanout_handler_test.go index 831b9184026..eab389529db 100644 --- a/pkg/sidecar/fanout/fanout_handler_test.go +++ b/pkg/sidecar/fanout/fanout_handler_test.go @@ -18,7 +18,6 @@ package fanout import ( "errors" - "fmt" "github.com/knative/eventing/pkg/buses" duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" "go.uber.org/atomic" @@ -67,14 +66,7 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { }{ "rejected by receiver": { receiverFunc: func(buses.ChannelReference, *buses.Message) error { - return errors.New("Rejected by test-receiver") - }, - expectedStatus: http.StatusInternalServerError, - }, - "could not find tracked message": { - receiverFunc: func(buses.ChannelReference, *buses.Message) error { - // Not being written to messageStorage. - return nil + return errors.New("rejected by test-receiver") }, expectedStatus: http.StatusInternalServerError, }, @@ -87,19 +79,19 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { }, callable: func(writer http.ResponseWriter, _ *http.Request) { time.Sleep(10 * time.Millisecond) - writer.WriteHeader(http.StatusOK) + writer.WriteHeader(http.StatusAccepted) }, expectedStatus: http.StatusInternalServerError, }, "zero subs succeed": { subs: []duckv1alpha1.ChannelSubscriberSpec{}, - expectedStatus: http.StatusOK, + expectedStatus: http.StatusAccepted, }, "empty sub succeeds": { subs: []duckv1alpha1.ChannelSubscriberSpec{ {}, }, - expectedStatus: http.StatusOK, + expectedStatus: http.StatusAccepted, }, "sinkable fails": { subs: []duckv1alpha1.ChannelSubscriberSpec{ @@ -147,7 +139,7 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { sinkable: func(writer http.ResponseWriter, _ *http.Request) { writer.WriteHeader(http.StatusAccepted) }, - expectedStatus: http.StatusOK, + expectedStatus: http.StatusAccepted, }, "one sub succeeds, one sub fails": { subs: []duckv1alpha1.ChannelSubscriberSpec{ @@ -183,10 +175,13 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { sinkable: func(writer http.ResponseWriter, _ *http.Request) { writer.WriteHeader(http.StatusAccepted) }, - expectedStatus: http.StatusOK, + expectedStatus: http.StatusAccepted, }, } for n, tc := range testCases { + if n != "fanout times out" { + //continue + } t.Run(n, func(t *testing.T) { callableServer := httptest.NewServer(&fakeHandler{ handler: tc.callable, @@ -209,16 +204,19 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { subs = append(subs, sub) } - h := NewHandler(zap.NewNop(), Config{Subscriptions: subs}).(*fanoutHandler) + h := NewHandler(zap.NewNop(), Config{Subscriptions: subs}) + defer h.Stop() if tc.receiverFunc != nil { h.receiver = buses.NewMessageReceiver(tc.receiverFunc, zap.NewNop().Sugar()) } if tc.timeout != 0 { h.timeout = tc.timeout + } else { + // Reasonable timeout for the tests. + h.timeout = 100 * time.Millisecond } w := httptest.NewRecorder() - fmt.Sprintf("hello %v", n) h.ServeHTTP(w, cloudEventReq) if w.Code != tc.expectedStatus { t.Errorf("Unexpected status code. Expected %v, Actual %v", tc.expectedStatus, w.Code) @@ -242,7 +240,7 @@ type succeedOnce struct { func (s *succeedOnce) handler(w http.ResponseWriter, _ *http.Request) { if s.called.CAS(false, true) { - w.WriteHeader(http.StatusOK) + w.WriteHeader(http.StatusAccepted) } else { w.WriteHeader(http.StatusForbidden) } diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go index 5228b55e6e3..919ae2f5ad2 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go @@ -61,12 +61,12 @@ func getChannelKey(r *http.Request) string { // delegate the request to. type Handler struct { logger *zap.Logger - handlers map[string]http.Handler + handlers map[string]*fanout.Handler config Config } func NewHandler(logger *zap.Logger, conf Config) (*Handler, error) { - handlers := make(map[string]http.Handler, len(conf.ChannelConfigs)) + handlers := make(map[string]*fanout.Handler, len(conf.ChannelConfigs)) for _, cc := range conf.ChannelConfigs { key := makeChannelKeyFromConfig(cc) @@ -85,6 +85,12 @@ func NewHandler(logger *zap.Logger, conf Config) (*Handler, error) { }, nil } +func (h *Handler) Stop() { + for _, fh := range h.handlers { + fh.Stop() + } +} + // ConfigDiffs diffs the new config with the existing config. If there are no differences, then the // empty string is returned. If there are differences, then a non-empty string is returned // describing the differences. diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go index 57be69cd0e4..9ee337527a4 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go @@ -86,7 +86,10 @@ func TestNewHandler(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - _, err := NewHandler(zap.NewNop(), tc.config) + h, err := NewHandler(zap.NewNop(), tc.config) + if err == nil { + defer h.Stop() + } if tc.createErr != "" { if err == nil { t.Errorf("Expected NewHandler error: '%v'. Actual nil", tc.createErr) @@ -139,6 +142,7 @@ func TestCopyWithNewConfig(t *testing.T) { if err != nil { t.Errorf("Unable to create handler, %v", err) } + defer h.Stop() if !cmp.Equal(h.config, orig) { t.Errorf("Incorrect config. Expected '%v'. Actual '%v'", orig, h.config) } @@ -209,6 +213,7 @@ func TestConfigDiff(t *testing.T) { if err != nil { t.Errorf("Unable to create handler: %v", err) } + defer h.Stop() diff := h.ConfigDiff(tc.updated) if hasDiff := diff != ""; hasDiff != tc.expectedDiff { @@ -280,7 +285,7 @@ func TestServeHTTP(t *testing.T) { }, respStatusCode: http.StatusOK, key: "second-channel.default", - expectedStatusCode: http.StatusOK, + expectedStatusCode: http.StatusAccepted, }, } requestWithChannelKey := func(key string) *http.Request { @@ -299,6 +304,7 @@ func TestServeHTTP(t *testing.T) { if err != nil { t.Errorf("Unexpected NewHandler error: '%v'", err) } + defer h.Stop() r := requestWithChannelKey(tc.key) w := httptest.NewRecorder() diff --git a/pkg/sidecar/swappable/swappable.go b/pkg/sidecar/swappable/swappable.go index bd9944014ff..7d5da5a84d7 100644 --- a/pkg/sidecar/swappable/swappable.go +++ b/pkg/sidecar/swappable/swappable.go @@ -87,6 +87,7 @@ func (h *Handler) UpdateConfig(config *multichannelfanout.Config) error { return err } h.setMultiChannelFanoutHandler(newIh) + defer ih.Stop() } return nil } diff --git a/pkg/sidecar/swappable/swappable_test.go b/pkg/sidecar/swappable/swappable_test.go index 396b0797207..2c663bf800b 100644 --- a/pkg/sidecar/swappable/swappable_test.go +++ b/pkg/sidecar/swappable/swappable_test.go @@ -137,7 +137,7 @@ func TestHandler_InvalidConfigChange(t *testing.T) { if err != nil { t.Errorf("Unexpected error updating to initial config: %v", tc.initialConfig) } - assertRequestOK(t, h) + assertRequestAccepted(t, h) // Try to update to the new config, it will fail. But we should still be able to hit the // original server. @@ -146,7 +146,7 @@ func TestHandler_InvalidConfigChange(t *testing.T) { if err == nil { t.Errorf("Expected an error when updating to a bad config.") } - assertRequestOK(t, h) + assertRequestAccepted(t, h) }) } } @@ -177,14 +177,14 @@ func updateConfigAndTest(t *testing.T, h *Handler, config multichannelfanout.Con t.Errorf("Expected the inner multiChannelFanoutHandler to change, it didn't: %v", orig) } - assertRequestOK(t, h) + assertRequestAccepted(t, h) } -func assertRequestOK(t *testing.T, h *Handler) { +func assertRequestAccepted(t *testing.T, h *Handler) { w := httptest.NewRecorder() h.ServeHTTP(w, makeRequest(namespace, name)) - if w.Code != http.StatusOK { - t.Errorf("Unexpected response code. Expected 200. Actual %v", w.Code) + if w.Code != http.StatusAccepted { + t.Errorf("Unexpected response code. Expected 202. Actual %v", w.Code) } } From 6ecefb3accc963bff7f460c1f2cc0af57ec84a51 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Tue, 9 Oct 2018 09:23:29 -0700 Subject: [PATCH 17/23] Symlink VENDOR-LICENSE and LICENSE --- cmd/fanoutsidecar/kodata/LICENSE | 202 +- cmd/fanoutsidecar/kodata/VENDOR-LICENSE | 5806 +---------------------- 2 files changed, 2 insertions(+), 6006 deletions(-) mode change 100644 => 120000 cmd/fanoutsidecar/kodata/LICENSE mode change 100644 => 120000 cmd/fanoutsidecar/kodata/VENDOR-LICENSE diff --git a/cmd/fanoutsidecar/kodata/LICENSE b/cmd/fanoutsidecar/kodata/LICENSE deleted file mode 100644 index 261eeb9e9f8..00000000000 --- a/cmd/fanoutsidecar/kodata/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/cmd/fanoutsidecar/kodata/LICENSE b/cmd/fanoutsidecar/kodata/LICENSE new file mode 120000 index 00000000000..5853aaea53b --- /dev/null +++ b/cmd/fanoutsidecar/kodata/LICENSE @@ -0,0 +1 @@ +../../../LICENSE \ No newline at end of file diff --git a/cmd/fanoutsidecar/kodata/VENDOR-LICENSE b/cmd/fanoutsidecar/kodata/VENDOR-LICENSE deleted file mode 100644 index 332850b0579..00000000000 --- a/cmd/fanoutsidecar/kodata/VENDOR-LICENSE +++ /dev/null @@ -1,5805 +0,0 @@ - -=========================================================== -Import: github.com/knative/eventing/vendor/cloud.google.com/go - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/beorn7/perks - -Copyright (C) 2013 Blake Mizerany - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/davecgh/go-spew - -ISC License - -Copyright (c) 2012-2016 Dave Collins - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/ghodss/yaml - -The MIT License (MIT) - -Copyright (c) 2014 Sam Ghods - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/go-logr/logr - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/go-logr/zapr - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/gogo/protobuf - -Protocol Buffers for Go with Gadgets - -Copyright (c) 2013, The GoGo Authors. All rights reserved. -http://github.com/gogo/protobuf - -Go support for Protocol Buffers - Google's data interchange format - -Copyright 2010 The Go Authors. All rights reserved. -https://github.com/golang/protobuf - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/golang/glog - -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable (except as stated in this section) patent license to make, have -made, use, offer to sell, sell, import, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "[]" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/golang/groupcache - -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable (except as stated in this section) patent license to make, have -made, use, offer to sell, sell, import, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "[]" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/golang/protobuf - -Go support for Protocol Buffers - Google's data interchange format - -Copyright 2010 The Go Authors. All rights reserved. -https://github.com/golang/protobuf - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/google/btree - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/google/go-cmp - -Copyright (c) 2017 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/google/gofuzz - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/google/uuid - -Copyright (c) 2009,2014 Google Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/googleapis/gnostic - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/gregjones/httpcache - -Copyright © 2012 Greg Jones (greg.jones@gmail.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/hashicorp/golang-lru - -Mozilla Public License, version 2.0 - -1. Definitions - -1.1. "Contributor" - - means each individual or legal entity that creates, contributes to the - creation of, or owns Covered Software. - -1.2. "Contributor Version" - - means the combination of the Contributions of others (if any) used by a - Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - - means Source Code Form to which the initial Contributor has attached the - notice in Exhibit A, the Executable Form of such Source Code Form, and - Modifications of such Source Code Form, in each case including portions - thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - a. that the initial Contributor has attached the notice described in - Exhibit B to the Covered Software; or - - b. that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the terms of - a Secondary License. - -1.6. "Executable Form" - - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - - means a work that combines Covered Software with other material, in a - separate file or files, that is not Covered Software. - -1.8. "License" - - means this document. - -1.9. "Licensable" - - means having the right to grant, to the maximum extent possible, whether - at the time of the initial grant or subsequently, any and all of the - rights conveyed by this License. - -1.10. "Modifications" - - means any of the following: - - a. any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered Software; or - - b. any new file in Source Code Form that contains any Covered Software. - -1.11. "Patent Claims" of a Contributor - - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the License, - by the making, using, selling, offering for sale, having made, import, - or transfer of either its Contributions or its Contributor Version. - -1.12. "Secondary License" - - means either the GNU General Public License, Version 2.0, the GNU Lesser - General Public License, Version 2.1, the GNU Affero General Public - License, Version 3.0, or any later versions of those licenses. - -1.13. "Source Code Form" - - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that controls, is - controlled by, or is under common control with You. For purposes of this - definition, "control" means (a) the power, direct or indirect, to cause - the direction or management of such entity, whether by contract or - otherwise, or (b) ownership of more than fifty percent (50%) of the - outstanding shares or beneficial ownership of such entity. - - -2. License Grants and Conditions - -2.1. Grants - - Each Contributor hereby grants You a world-wide, royalty-free, - non-exclusive license: - - a. under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - - b. under Patent Claims of such Contributor to make, use, sell, offer for - sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - - The licenses granted in Section 2.1 with respect to any Contribution - become effective for each Contribution on the date the Contributor first - distributes such Contribution. - -2.3. Limitations on Grant Scope - - The licenses granted in this Section 2 are the only rights granted under - this License. No additional rights or licenses will be implied from the - distribution or licensing of Covered Software under this License. - Notwithstanding Section 2.1(b) above, no patent license is granted by a - Contributor: - - a. for any code that a Contributor has removed from Covered Software; or - - b. for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - - c. under Patent Claims infringed by Covered Software in the absence of - its Contributions. - - This License does not grant any rights in the trademarks, service marks, - or logos of any Contributor (except as may be necessary to comply with - the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - - No Contributor makes additional grants as a result of Your choice to - distribute the Covered Software under a subsequent version of this - License (see Section 10.2) or under the terms of a Secondary License (if - permitted under the terms of Section 3.3). - -2.5. Representation - - Each Contributor represents that the Contributor believes its - Contributions are its original creation(s) or it has sufficient rights to - grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - - This License is not intended to limit any rights You have under - applicable copyright doctrines of fair use, fair dealing, or other - equivalents. - -2.7. Conditions - - Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in - Section 2.1. - - -3. Responsibilities - -3.1. Distribution of Source Form - - All distribution of Covered Software in Source Code Form, including any - Modifications that You create or to which You contribute, must be under - the terms of this License. You must inform recipients that the Source - Code Form of the Covered Software is governed by the terms of this - License, and how they can obtain a copy of this License. You may not - attempt to alter or restrict the recipients' rights in the Source Code - Form. - -3.2. Distribution of Executable Form - - If You distribute Covered Software in Executable Form then: - - a. such Covered Software must also be made available in Source Code Form, - as described in Section 3.1, and You must inform recipients of the - Executable Form how they can obtain a copy of such Source Code Form by - reasonable means in a timely manner, at a charge no more than the cost - of distribution to the recipient; and - - b. You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter the - recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - - You may create and distribute a Larger Work under terms of Your choice, - provided that You also comply with the requirements of this License for - the Covered Software. If the Larger Work is a combination of Covered - Software with a work governed by one or more Secondary Licenses, and the - Covered Software is not Incompatible With Secondary Licenses, this - License permits You to additionally distribute such Covered Software - under the terms of such Secondary License(s), so that the recipient of - the Larger Work may, at their option, further distribute the Covered - Software under the terms of either this License or such Secondary - License(s). - -3.4. Notices - - You may not remove or alter the substance of any license notices - (including copyright notices, patent notices, disclaimers of warranty, or - limitations of liability) contained within the Source Code Form of the - Covered Software, except that You may alter any license notices to the - extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - - You may choose to offer, and to charge a fee for, warranty, support, - indemnity or liability obligations to one or more recipients of Covered - Software. However, You may do so only on Your own behalf, and not on - behalf of any Contributor. You must make it absolutely clear that any - such warranty, support, indemnity, or liability obligation is offered by - You alone, and You hereby agree to indemnify every Contributor for any - liability incurred by such Contributor as a result of warranty, support, - indemnity or liability terms You offer. You may include additional - disclaimers of warranty and limitations of liability specific to any - jurisdiction. - -4. Inability to Comply Due to Statute or Regulation - - If it is impossible for You to comply with any of the terms of this License - with respect to some or all of the Covered Software due to statute, - judicial order, or regulation then You must: (a) comply with the terms of - this License to the maximum extent possible; and (b) describe the - limitations and the code they affect. Such description must be placed in a - text file included with all distributions of the Covered Software under - this License. Except to the extent prohibited by statute or regulation, - such description must be sufficiently detailed for a recipient of ordinary - skill to be able to understand it. - -5. Termination - -5.1. The rights granted under this License will terminate automatically if You - fail to comply with any of its terms. However, if You become compliant, - then the rights granted under this License from a particular Contributor - are reinstated (a) provisionally, unless and until such Contributor - explicitly and finally terminates Your grants, and (b) on an ongoing - basis, if such Contributor fails to notify You of the non-compliance by - some reasonable means prior to 60 days after You have come back into - compliance. Moreover, Your grants from a particular Contributor are - reinstated on an ongoing basis if such Contributor notifies You of the - non-compliance by some reasonable means, this is the first time You have - received notice of non-compliance with this License from such - Contributor, and You become compliant prior to 30 days after Your receipt - of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent - infringement claim (excluding declaratory judgment actions, - counter-claims, and cross-claims) alleging that a Contributor Version - directly or indirectly infringes any patent, then the rights granted to - You by any and all Contributors for the Covered Software under Section - 2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user - license agreements (excluding distributors and resellers) which have been - validly granted by You or Your distributors under this License prior to - termination shall survive termination. - -6. Disclaimer of Warranty - - Covered Software is provided under this License on an "as is" basis, - without warranty of any kind, either expressed, implied, or statutory, - including, without limitation, warranties that the Covered Software is free - of defects, merchantable, fit for a particular purpose or non-infringing. - The entire risk as to the quality and performance of the Covered Software - is with You. Should any Covered Software prove defective in any respect, - You (not any Contributor) assume the cost of any necessary servicing, - repair, or correction. This disclaimer of warranty constitutes an essential - part of this License. No use of any Covered Software is authorized under - this License except under this disclaimer. - -7. Limitation of Liability - - Under no circumstances and under no legal theory, whether tort (including - negligence), contract, or otherwise, shall any Contributor, or anyone who - distributes Covered Software as permitted above, be liable to You for any - direct, indirect, special, incidental, or consequential damages of any - character including, without limitation, damages for lost profits, loss of - goodwill, work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses, even if such party shall have been - informed of the possibility of such damages. This limitation of liability - shall not apply to liability for death or personal injury resulting from - such party's negligence to the extent applicable law prohibits such - limitation. Some jurisdictions do not allow the exclusion or limitation of - incidental or consequential damages, so this exclusion and limitation may - not apply to You. - -8. Litigation - - Any litigation relating to this License may be brought only in the courts - of a jurisdiction where the defendant maintains its principal place of - business and such litigation shall be governed by laws of that - jurisdiction, without reference to its conflict-of-law provisions. Nothing - in this Section shall prevent a party's ability to bring cross-claims or - counter-claims. - -9. Miscellaneous - - This License represents the complete agreement concerning the subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. Any law or regulation which provides that - the language of a contract shall be construed against the drafter shall not - be used to construe this License against a Contributor. - - -10. Versions of the License - -10.1. New Versions - - Mozilla Foundation is the license steward. Except as provided in Section - 10.3, no one other than the license steward has the right to modify or - publish new versions of this License. Each version will be given a - distinguishing version number. - -10.2. Effect of New Versions - - You may distribute the Covered Software under the terms of the version - of the License under which You originally received the Covered Software, - or under the terms of any subsequent version published by the license - steward. - -10.3. Modified Versions - - If you create software not governed by this License, and you want to - create a new license for such software, you may create and use a - modified version of this License if you rename the license and remove - any references to the name of the license steward (except to note that - such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary - Licenses If You choose to distribute Source Code Form that is - Incompatible With Secondary Licenses under the terms of this version of - the License, the notice described in Exhibit B of this License must be - attached. - -Exhibit A - Source Code Form License Notice - - This Source Code Form is subject to the - terms of the Mozilla Public License, v. - 2.0. If a copy of the MPL was not - distributed with this file, You can - obtain one at - http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular file, -then You may include the notice in a location (such as a LICENSE file in a -relevant directory) where a recipient would be likely to look for such a -notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice - - This Source Code Form is "Incompatible - With Secondary Licenses", as defined by - the Mozilla Public License, v. 2.0. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/imdario/mergo - -Copyright (c) 2013 Dario Castañé. All rights reserved. -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/json-iterator/go - -MIT License - -Copyright (c) 2016 json-iterator - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/knative/pkg - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/mattbaird/jsonpatch - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/matttproud/golang_protobuf_extensions - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/modern-go/concurrent - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/modern-go/reflect2 - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/peterbourgon/diskv - -Copyright (c) 2011-2012 Peter Bourgon - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/prometheus/client_golang - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/prometheus/client_model - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/prometheus/common - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/prometheus/procfs - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/github.com/spf13/pflag - -Copyright (c) 2012 Alex Ogier. All rights reserved. -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/go.uber.org/atomic - -Copyright (c) 2016 Uber Technologies, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/go.uber.org/multierr - -Copyright (c) 2017 Uber Technologies, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/go.uber.org/zap - -Copyright (c) 2016-2017 Uber Technologies, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/golang.org/x/crypto - -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/golang.org/x/net - -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/golang.org/x/oauth2 - -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/golang.org/x/sys - -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/golang.org/x/text - -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/golang.org/x/time - -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/gopkg.in/inf.v0 - -Copyright (c) 2012 Péter Surányi. Portions Copyright (c) 2009 The Go -Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/gopkg.in/yaml.v2 - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/k8s.io/api - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/k8s.io/apimachinery - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/k8s.io/client-go - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/k8s.io/kube-openapi - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - -=========================================================== -Import: github.com/knative/eventing/vendor/sigs.k8s.io/controller-runtime - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/cmd/fanoutsidecar/kodata/VENDOR-LICENSE b/cmd/fanoutsidecar/kodata/VENDOR-LICENSE new file mode 120000 index 00000000000..91c1d5bb8f3 --- /dev/null +++ b/cmd/fanoutsidecar/kodata/VENDOR-LICENSE @@ -0,0 +1 @@ +../../../VENDOR-LICENSE \ No newline at end of file From e82c2bb4857f6e992cd29deb6843acc073f927d6 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Tue, 9 Oct 2018 13:27:16 -0700 Subject: [PATCH 18/23] Respond to PR comments. --- cmd/fanoutsidecar/main.go | 115 ++++++++++---- .../filesystem/config_map_handler.go | 79 +++++----- .../filesystem/config_map_handler_test.go | 15 +- pkg/sidecar/configmap/{parse => }/parse.go | 30 +--- .../configmap/{parse => }/parse_test.go | 18 +-- pkg/sidecar/configmap/watcher/watcher.go | 4 +- pkg/sidecar/configmap/watcher/watcher_test.go | 10 +- pkg/sidecar/fanout/fanout_handler.go | 41 ++--- .../multi_channel_fanout_handler.go | 22 ++- pkg/sidecar/multichannelfanout/parse.go | 44 ++++++ pkg/sidecar/multichannelfanout/parse_test.go | 148 ++++++++++++++++++ pkg/sidecar/swappable/swappable.go | 6 + 12 files changed, 383 insertions(+), 149 deletions(-) rename pkg/sidecar/configmap/{parse => }/parse.go (51%) rename pkg/sidecar/configmap/{parse => }/parse_test.go (91%) create mode 100644 pkg/sidecar/multichannelfanout/parse.go create mode 100644 pkg/sidecar/multichannelfanout/parse_test.go diff --git a/cmd/fanoutsidecar/main.go b/cmd/fanoutsidecar/main.go index be13da2210b..4c9e47c7153 100644 --- a/cmd/fanoutsidecar/main.go +++ b/cmd/fanoutsidecar/main.go @@ -20,6 +20,7 @@ limitations under the License. package main import ( + "errors" "flag" "fmt" "github.com/knative/eventing/pkg/sidecar/configmap/filesystem" @@ -27,36 +28,56 @@ import ( "github.com/knative/eventing/pkg/sidecar/swappable" "github.com/knative/eventing/pkg/system" "go.uber.org/zap" + "golang.org/x/sync/errgroup" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" + "log" "net/http" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/runtime/signals" + "strings" "time" ) const ( - configMapName = "in-memory-bus-config" + defaultConfigMapName = "in-memory-bus-config" + + // The following are the only valid values of the config_map_noticer flag. + cmnfVolume = "volume" + cmnfWatcher = "watcher" ) var ( - readTimeout = time.Minute - writeTimeout = time.Minute + readTimeout = 1 * time.Minute + writeTimeout = 1 * time.Minute + + port int + configMapNoticer string + configMapNamespace string + configMapName string ) -func main() { - portFlag := flag.Int("sidecar_port", -1, "The port to run the sidecar on.") - configMapFlag := flag.String("config_map_noticer", "", "The system to notice changes to the ConfigMap. Valid values are: 'volume', 'watcher'.") +func init() { + flag.IntVar(&port, "sidecar_port", -1, "The port to run the sidecar on.") + flag.StringVar(&configMapNoticer, "config_map_noticer", "", fmt.Sprintf("The system to notice changes to the ConfigMap. Valid values are: %s", configMapNoticerFlags())) + flag.StringVar(&configMapNamespace, "config_map_namespace", system.Namespace, "The namespace of the ConfigMap that is watched for configuration.") + flag.StringVar(&configMapName, "config_map_name", defaultConfigMapName, "The name of the ConfigMap that is watched for configuration.") +} + +func configMapNoticerFlags() string { + return strings.Join([]string{cmnfVolume, cmnfWatcher}, ", ") +} +func main() { flag.Parse() logger, err := zap.NewProduction() if err != nil { - panic(err) + log.Fatalf("Unable to create logger: %v", err) } - if *portFlag < 0 { + if port < 0 { logger.Fatal("--sidecar_port flag must be set") } @@ -65,51 +86,77 @@ func main() { logger.Fatal("Unable to create swappable.Handler", zap.Error(err)) } - // Setup something to notice that the ConfigMap has updated. - switch *configMapFlag { - case "volume": - _, err = filesystem.NewConfigMapWatcher(logger, filesystem.ConfigDir, sh.UpdateConfig) - if err != nil { - logger.Fatal("Unable to create filesystem.configMapWatcher", zap.Error(err)) - } - case "watcher": - setupWatcher(logger, sh.UpdateConfig) - default: - logger.Fatal("Need to provide the --config_map_noticer flag") + mgr, err := setupConfigMapNoticer(logger, sh.UpdateConfig) + if err != nil { + logger.Fatal("Unable to create configMap noticer.", zap.Error(err)) } s := &http.Server{ - Addr: fmt.Sprintf(":%d", *portFlag), + Addr: fmt.Sprintf(":%d", port), Handler: sh, ErrorLog: zap.NewStdLog(logger), ReadTimeout: readTimeout, WriteTimeout: writeTimeout, } - logger.Info("Fanout sidecar Listening...") - s.ListenAndServe() + + // Start both the manager (which notices ConfigMap changes) and the HTTP server. + var g errgroup.Group + g.Go(func() error { + // set up signals so we handle the first shutdown signal gracefully + stopCh := signals.SetupSignalHandler() + // Start blocks forever, so run it in a goroutine. + return mgr.Start(stopCh) + }) + logger.Info("Fanout sidecar Listening...", zap.String("Address", s.Addr)) + g.Go(s.ListenAndServe) + if err = g.Wait(); err != nil { + logger.Fatal("Either the HTTP server or the ConfigMap noticer failed.", zap.Error(err)) + } } -func setupWatcher(logger *zap.Logger, configUpdated swappable.UpdateConfig) { +func setupConfigMapNoticer(logger *zap.Logger, configUpdated swappable.UpdateConfig) (manager.Manager, error) { mgr, err := manager.New(config.GetConfigOrDie(), manager.Options{}) if err != nil { - logger.Fatal("Error starting manager.", zap.Error(err)) + return nil, err + logger.Error("Error starting manager.", zap.Error(err)) + } + + switch configMapNoticer { + case cmnfVolume: + err = setupConfigMapVolume(logger, mgr, configUpdated) + case cmnfWatcher: + err = setupConfigMapWatcher(logger, mgr, configUpdated) + default: + err = errors.New("need to provide the --config_map_noticer flag") + } + if err != nil { + return nil, err + } + + return mgr, nil +} + +func setupConfigMapVolume(logger *zap.Logger, mgr manager.Manager, configUpdated swappable.UpdateConfig) error { + cmn, err := filesystem.NewConfigMapWatcher(logger, filesystem.ConfigDir, configUpdated) + if err != nil { + logger.Error("Unable to create filesystem.ConifgMapWatcher", zap.Error(err)) + return err } + mgr.Add(cmn) + return nil +} +func setupConfigMapWatcher(logger *zap.Logger, mgr manager.Manager, configUpdated swappable.UpdateConfig) error { // Add custom types to this array to get them into the manager's scheme. corev1.AddToScheme(mgr.GetScheme()) - cmName := types.NamespacedName{ - Namespace: system.Namespace, - Name: configMapName, + Namespace: configMapNamespace, + Name: configMapName, } - _, err = watcher.NewWatcher(logger, mgr, cmName, configUpdated) - if err != nil { - logger.Fatal("Unable to create watcher.configMapWatcher", zap.Error(err)) + if _, err := watcher.NewWatcher(logger, mgr, cmName, configUpdated); err != nil { + return err } - // set up signals so we handle the first shutdown signal gracefully - stopCh := signals.SetupSignalHandler() - // Start blocks forever. - go mgr.Start(stopCh) + return nil } diff --git a/pkg/sidecar/configmap/filesystem/config_map_handler.go b/pkg/sidecar/configmap/filesystem/config_map_handler.go index 4be275aad13..c364d66ce84 100644 --- a/pkg/sidecar/configmap/filesystem/config_map_handler.go +++ b/pkg/sidecar/configmap/filesystem/config_map_handler.go @@ -17,8 +17,9 @@ limitations under the License. package filesystem import ( + "errors" "github.com/fsnotify/fsnotify" - "github.com/knative/eventing/pkg/sidecar/configmap/parse" + sidecarconfigmap "github.com/knative/eventing/pkg/sidecar/configmap" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" "github.com/knative/eventing/pkg/sidecar/swappable" "github.com/knative/pkg/configmap" @@ -43,7 +44,9 @@ type configMapWatcher struct { configUpdated swappable.UpdateConfig } -func NewConfigMapWatcher(logger *zap.Logger, dir string, updateConfig swappable.UpdateConfig) (chan<- bool, error) { +// NewConfigMapWatcher creates a new filesystem.configMapWatcher. The caller is responsible for +// calling Start(<-chan), likely via a controller-runtime Manager. +func NewConfigMapWatcher(logger *zap.Logger, dir string, updateConfig swappable.UpdateConfig) (*configMapWatcher, error) { conf, err := readConfigMap(logger, dir) if err != nil { logger.Error("Unable to read configMap", zap.Error(err)) @@ -63,27 +66,20 @@ func NewConfigMapWatcher(logger *zap.Logger, dir string, updateConfig swappable. dir: dir, configUpdated: updateConfig, } - watcherStopCh, err := cmw.startWatcher(dir) - if err != nil { - logger.Error("Unable to start the configMap file watcher", zap.Error(err)) - return nil, err - } - return watcherStopCh, nil + return cmw, nil } // readConfigMap attempts to read the configMap from the attached volume. func readConfigMap(logger *zap.Logger, dir string) (*multichannelfanout.Config, error) { cm, err := configmap.Load(dir) if err != nil { - logger.Error("Unable to read configMap", zap.Error(err)) return nil, err } - return parse.ConfigMapData(logger, cm) + return sidecarconfigmap.NewFanoutConfig(logger, cm) } -// readConfigMapAndUpdateSubs reads the configMap data and calls `configUpdate` with the updated -// value. -func (cmw *configMapWatcher) readConfigMapAndUpdateConfig() { +// updateConfig reads the configMap data and calls `configUpdated` with the updated value. +func (cmw *configMapWatcher) updateConfig() { conf, err := readConfigMap(cmw.logger, cmw.dir) if err != nil { cmw.logger.Error("Unable to read the configMap", zap.Error(err)) @@ -96,39 +92,36 @@ func (cmw *configMapWatcher) readConfigMapAndUpdateConfig() { } } -// startWatcher starts a background go routine that gets events when the filesystem in configDir is -// changed. -func (cmw *configMapWatcher) startWatcher(dir string) (chan<- bool, error) { +func (cmw *configMapWatcher) Start(stopCh <-chan struct{}) error { watcher, err := fsnotify.NewWatcher() if err != nil { - return nil, err + return err } - stopCh := make(chan bool) - go func() { - for { - select { - case _, ok := <-watcher.Events: - if !ok { - // Channel closed. - cmw.logger.Error("watcher.Events channel closed") // TODO: Should this panic? - return - } - cmw.readConfigMapAndUpdateConfig() - case err, ok := <-watcher.Errors: - if !ok { - // Channel closed. - cmw.logger.Error("watcher.Errors channel closed") // TODO: Should this panic? - return - } - cmw.logger.Error("watcher.Errors", zap.Error(err)) - case _, ok := <-stopCh: - if !ok { - // stopCh has been closed - return - } + + err = watcher.Add(cmw.dir) + if err != nil { + return err + } + + for { + select { + case _, ok := <-watcher.Events: + if !ok { + // Channel closed. + return errors.New("watcher.Events channel closed") + } + cmw.updateConfig() + case err, ok := <-watcher.Errors: + if !ok { + // Channel closed. + return errors.New("watcher.Errors channel closed") + } + cmw.logger.Error("watcher.Errors", zap.Error(err)) + case _, ok := <-stopCh: + if !ok { + // stopCh has been closed + return nil } } - }() - - return stopCh, watcher.Add(dir) + } } diff --git a/pkg/sidecar/configmap/filesystem/config_map_handler_test.go b/pkg/sidecar/configmap/filesystem/config_map_handler_test.go index 666e284f110..0920310a985 100644 --- a/pkg/sidecar/configmap/filesystem/config_map_handler_test.go +++ b/pkg/sidecar/configmap/filesystem/config_map_handler_test.go @@ -19,7 +19,7 @@ package filesystem import ( "fmt" "github.com/google/go-cmp/cmp" - "github.com/knative/eventing/pkg/sidecar/configmap/parse" + "github.com/knative/eventing/pkg/sidecar/configmap" "github.com/knative/eventing/pkg/sidecar/fanout" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" "github.com/knative/eventing/pkg/sidecar/swappable" @@ -245,6 +245,9 @@ func TestServeHTTP(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { + if tc.name != "change config" { + return + } initialHandler := &fakeHandler{} initialServer := httptest.NewServer(initialHandler) defer initialServer.Close() @@ -260,11 +263,17 @@ func TestServeHTTP(t *testing.T) { if err != nil { t.Errorf("Unexpected error making swappable.Handler: %+v", err) } - _, err = NewConfigMapWatcher(zap.NewNop(), dir, sh.UpdateConfig) + cmw, err := NewConfigMapWatcher(zap.NewNop(), dir, sh.UpdateConfig) if err != nil { t.Errorf("Unexpected error making filesystem.configMapWatcher") } + stopCh := make(chan struct{}) + go cmw.Start(stopCh) + defer func() { + stopCh <- struct{}{} + }() + w := httptest.NewRecorder() sh.ServeHTTP(w, makeRequest("default", "c1")) if w.Result().StatusCode != http.StatusAccepted { @@ -310,7 +319,7 @@ func writeConfig(t *testing.T, dir, config string) { // Golang editors tend to replace leading spaces with tabs. YAML is left whitespace // sensitive, so let's replace the tabs with spaces. leftSpaceConfig := strings.Replace(config, "\t", " ", -1) - err := ioutil.WriteFile(fmt.Sprintf("%s/%s", dir, parse.MultiChannelFanoutConfigKey), []byte(leftSpaceConfig), 0700) + err := ioutil.WriteFile(fmt.Sprintf("%s/%s", dir, configmap.MultiChannelFanoutConfigKey), []byte(leftSpaceConfig), 0700) if err != nil { t.Errorf("Problem writing the config file: %v", err) } diff --git a/pkg/sidecar/configmap/parse/parse.go b/pkg/sidecar/configmap/parse.go similarity index 51% rename from pkg/sidecar/configmap/parse/parse.go rename to pkg/sidecar/configmap/parse.go index 185779b8d4e..8661dd2bf8e 100644 --- a/pkg/sidecar/configmap/parse/parse.go +++ b/pkg/sidecar/configmap/parse.go @@ -14,42 +14,26 @@ See the License for the specific language governing permissions and limitations under the License. */ -package parse +package configmap import ( - "bytes" - "encoding/json" "fmt" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" "go.uber.org/zap" - "k8s.io/apimachinery/pkg/util/yaml" ) const ( - // The config key that contains all the configuration data. + // MultiChannelFanoutConfigKey is the key in the ConfigMap that contains all the configuration + // data. MultiChannelFanoutConfigKey = "multiChannelFanoutConfig" ) // ConfigMapData attempts to parse the config map's data into a multichannelfanout.Config. -func ConfigMapData(logger *zap.Logger, data map[string]string) (*multichannelfanout.Config, error) { - if _, present := data[MultiChannelFanoutConfigKey]; !present { +func NewFanoutConfig(logger *zap.Logger, data map[string]string) (*multichannelfanout.Config, error) { + str, present := data[MultiChannelFanoutConfigKey] + if !present { logger.Error("Expected key not found", zap.String("key", MultiChannelFanoutConfigKey)) return nil, fmt.Errorf("expected key not found: %v", MultiChannelFanoutConfigKey) } - jb, err := yaml.ToJSON([]byte(data[MultiChannelFanoutConfigKey])) - if err != nil { - logger.Error("Unable to convert multiChannelFanoutConfig to JSON", zap.Error(err)) - return nil, err - } - var conf multichannelfanout.Config - err = unmarshallJsonDisallowUnknownFields(jb, &conf) - return &conf, err -} - -// unmarshallJsonDisallowUnknownFields unmarshalls JSON, but unlike json.Unmarshall, will fail if -// given an unknown field (rather than json.Unmarshall's ignoring the unknown field). -func unmarshallJsonDisallowUnknownFields(jb []byte, v interface{}) error { - d := json.NewDecoder(bytes.NewReader(jb)) - d.DisallowUnknownFields() - return d.Decode(v) + return multichannelfanout.Parse(logger, str) } diff --git a/pkg/sidecar/configmap/parse/parse_test.go b/pkg/sidecar/configmap/parse_test.go similarity index 91% rename from pkg/sidecar/configmap/parse/parse_test.go rename to pkg/sidecar/configmap/parse_test.go index 2920f0d6937..a621ad510a8 100644 --- a/pkg/sidecar/configmap/parse/parse_test.go +++ b/pkg/sidecar/configmap/parse_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package parse +package configmap import ( "github.com/google/go-cmp/cmp" @@ -26,26 +26,19 @@ import ( "testing" ) -func TestConfigMapData(t *testing.T) { +func TestNewFanoutConfig(t *testing.T) { testCases := []struct { name string - createDir bool config string expected *multichannelfanout.Config expectedErr bool }{ - { - name: "dir does not exist", - createDir: false, - }, { name: "no data", - createDir: true, expectedErr: true, }, { name: "invalid YAML", - createDir: true, config: ` key: - value @@ -56,18 +49,15 @@ func TestConfigMapData(t *testing.T) { { name: "valid YAML -- invalid JSON", config: "{ nil: Key }", - createDir: true, expectedErr: true, }, { name: "unknown field", config: "{ channelConfigs: [ { not: a-defined-field } ] }", - createDir: true, expectedErr: true, }, { name: "valid", - createDir: true, config: ` channelConfigs: - namespace: default @@ -138,7 +128,7 @@ func TestConfigMapData(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { data := formatData(tc.config) - c, e := ConfigMapData(zap.NewNop(), data) + c, e := NewFanoutConfig(zap.NewNop(), data) if tc.expectedErr { if e == nil { t.Errorf("Expected an error, actual nil") @@ -156,7 +146,7 @@ func formatData(config string) map[string]string { data := make(map[string]string) if config != "" { // Golang editors tend to replace leading spaces with tabs. YAML is left whitespace - // sensitive, so let's replace the tabs with four spaces. + // sensitive and disallows tabs, so let's replace the tabs with four spaces. leftSpaceConfig := strings.Replace(config, "\t", " ", -1) data[MultiChannelFanoutConfigKey] = leftSpaceConfig } diff --git a/pkg/sidecar/configmap/watcher/watcher.go b/pkg/sidecar/configmap/watcher/watcher.go index 95f49d1bc38..990f1235adc 100644 --- a/pkg/sidecar/configmap/watcher/watcher.go +++ b/pkg/sidecar/configmap/watcher/watcher.go @@ -18,7 +18,7 @@ package watcher import ( "context" - "github.com/knative/eventing/pkg/sidecar/configmap/parse" + "github.com/knative/eventing/pkg/sidecar/configmap" "github.com/knative/eventing/pkg/sidecar/swappable" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" @@ -99,7 +99,7 @@ func (r *reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) return reconcile.Result{}, err } - config, err := parse.ConfigMapData(r.logger, cm.Data) + config, err := configmap.NewFanoutConfig(r.logger, cm.Data) if err != nil { r.logger.Error("Could not parse ConfigMap", zap.Error(err), zap.Any("configMap.Data", cm.Data)) diff --git a/pkg/sidecar/configmap/watcher/watcher_test.go b/pkg/sidecar/configmap/watcher/watcher_test.go index 2511819d237..900dea52b4f 100644 --- a/pkg/sidecar/configmap/watcher/watcher_test.go +++ b/pkg/sidecar/configmap/watcher/watcher_test.go @@ -21,7 +21,7 @@ import ( "errors" "github.com/google/go-cmp/cmp" controllertesting "github.com/knative/eventing/pkg/controller/testing" - "github.com/knative/eventing/pkg/sidecar/configmap/parse" + "github.com/knative/eventing/pkg/sidecar/configmap" "github.com/knative/eventing/pkg/sidecar/fanout" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" @@ -57,21 +57,21 @@ func TestReconcile(t *testing.T) { }, "cannot parse cm": { config: map[string]string{ - parse.MultiChannelFanoutConfigKey: "invalid config", + configmap.MultiChannelFanoutConfigKey: "invalid config", }, expectedErr: true, }, "configUpdated fails": { expectedErr: true, config: map[string]string{ - parse.MultiChannelFanoutConfigKey: "", + configmap.MultiChannelFanoutConfigKey: "", }, updateConfigErr: errors.New("test-error"), expectedConfig: &multichannelfanout.Config{}, }, "success": { config: map[string]string{ - parse.MultiChannelFanoutConfigKey: ` + configmap.MultiChannelFanoutConfigKey: ` channelConfigs: - name: foo namespace: bar @@ -126,7 +126,7 @@ func TestReconcile(t *testing.T) { configUpdated: cuc.updateConfig, cmName: types.NamespacedName{ Namespace: namespace, - Name: name, + Name: name, }, } diff --git a/pkg/sidecar/fanout/fanout_handler.go b/pkg/sidecar/fanout/fanout_handler.go index e5f546c6bb6..f9b41f4a19f 100644 --- a/pkg/sidecar/fanout/fanout_handler.go +++ b/pkg/sidecar/fanout/fanout_handler.go @@ -14,6 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package fanout provides an http.Handler that takes in one request and fans it out to N other +// requests, based on a list of Subscriptions. Logically, it represents all the Subscriptions to a +// single Knative Channel. +// It will normally be used in conjunction with multichannelfanout.Handler, which contains multiple +// fanout.Handlers, each corresponding to a single Knative Channel. package fanout import ( @@ -40,10 +45,10 @@ type Config struct { type Handler struct { config Config - receivedMessages chan *message + receivedMessages chan *forwardMessage receiver *buses.MessageReceiver dispatcher *buses.MessageDispatcher - stopCh chan<- struct{} + stopCh chan<- struct{} timeout time.Duration @@ -52,9 +57,9 @@ type Handler struct { var _ http.Handler = &Handler{} -// message is passed between the Receiver and the Dispatcher. -type message struct { - msg *buses.Message +// forwardMessage is passed between the Receiver and the Dispatcher. +type forwardMessage struct { + msg *buses.Message done chan<- error } @@ -63,14 +68,14 @@ type message struct { func NewHandler(logger *zap.Logger, config Config) *Handler { stopCh := make(chan struct{}, 1) handler := &Handler{ - logger: logger, - config: config, - dispatcher: buses.NewMessageDispatcher(logger.Sugar()), - receivedMessages: make(chan *message, messageBufferSize), - stopCh: stopCh, - timeout: defaultTimeout, + logger: logger, + config: config, + dispatcher: buses.NewMessageDispatcher(logger.Sugar()), + receivedMessages: make(chan *forwardMessage, messageBufferSize), + stopCh: stopCh, + timeout: defaultTimeout, } - // The receiver function needs to point back at the handler itself, so setup it after + // The receiver function needs to point back at the handler itself, so set it up after // initialization. handler.receiver = buses.NewMessageReceiver(createReceiverFunction(handler), logger.Sugar()) @@ -81,8 +86,8 @@ func NewHandler(logger *zap.Logger, config Config) *Handler { func createReceiverFunction(f *Handler) func(buses.ChannelReference, *buses.Message) error { return func(_ buses.ChannelReference, m *buses.Message) error { done := make(chan error) - msg := &message{ - msg: m, + msg := &forwardMessage{ + msg: m, done: done, } @@ -120,7 +125,7 @@ func (f *Handler) Stop() { func (f *Handler) foreverDispatch(stopCh <-chan struct{}) { for { select { - case msg := <- f.receivedMessages: + case msg := <-f.receivedMessages: f.dispatch(msg) case <-stopCh: f.logger.Info("Fanout dispatch thread stopping.") @@ -131,7 +136,7 @@ func (f *Handler) foreverDispatch(stopCh <-chan struct{}) { // ServeHTTP takes the request, fans it out to each subscription in f.config. If all the fanned out // requests return successfully, then return successfully. Else, return failure. -func (f *Handler) dispatch(msg *message) { +func (f *Handler) dispatch(msg *forwardMessage) { msg.done <- func() error { errorCh := make(chan error, len(f.config.Subscriptions)) for _, sub := range f.config.Subscriptions { @@ -152,13 +157,13 @@ func (f *Handler) dispatch(msg *message) { return errors.New("fanout timed out") } } - // All Subscriptions returned err=nil. + // All Subscriptions returned err = nil. return nil }() } // makeFanoutRequest sends the request to exactly one subscription. It handles both the `call` and -// the `to` portions of the subscription. +// the `sink` portions of the subscription. func (f *Handler) makeFanoutRequest(m buses.Message, sub duckv1alpha1.ChannelSubscriberSpec) error { return f.dispatcher.DispatchMessage(&m, sub.CallableDomain, sub.SinkableDomain, buses.DispatchDefaults{}) } diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go index 919ae2f5ad2..3afef51dcc4 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go @@ -14,6 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package multichannelfanout provides an http.Handler that takes in one request to a Knative +// Channel and fans it out to N other requests. Logically, it represents multiple Knative Channels. +// It is made up of a map, map[channel]fanout.Handler and each incoming request is inspected to +// determine which Channel it is on. This Handler delegates the HTTP handling to the fanout.Handler +// corresponding to the incoming request's Channel. +// It is often used in conjunction with a swappable.Handler. The swappable.Handler delegates all its +// requests to the multichannelfanout.Handler. When a new configuration is available, a new +// multichannelfanout.Handler is created and swapped in for all subsequent requests. The old +// multichannelfanout.Handler is discarded. package multichannelfanout import ( @@ -37,9 +46,7 @@ type ChannelConfig struct { FanoutConfig fanout.Config `json:"fanoutConfig"` } -// MakeChannelKey creates the value to be sent in the HTTP header -// multichannelfanout.ChannelKeyHeader. This represents the `Channel` the request is being sent -// upon. +// MakeChannelKey creates the key used for this Channel in the Handler's handlers map. func makeChannelKey(namespace, name string) string { return fmt.Sprintf("%s/%s", namespace, name) } @@ -53,18 +60,19 @@ func makeChannelKeyFromConfig(config ChannelConfig) string { // getChannelKey extracts the channel key from the given HTTP request. func getChannelKey(r *http.Request) string { cr := buses.ParseChannel(r.Host) - return fmt.Sprintf("%s/%s", cr.Namespace, cr.Name) + return makeChannelKey(cr.Namespace, cr.Name) } -// Handler is an http.Handler that looks in the HTTP headers of a request for the -// multichannelfanout.ChannelKeyHeader and uses its value to determine which fanout.Handler to -// delegate the request to. +// Handler is an http.Handler that introspects the incoming request to determine what Channel it is +// on, and then delegates handling of that request to the single fanout.Handler corresponding to +// that Channel. type Handler struct { logger *zap.Logger handlers map[string]*fanout.Handler config Config } +// NewHandler creates a new Handler. The caller is responsible for calling handler.Stop(). func NewHandler(logger *zap.Logger, conf Config) (*Handler, error) { handlers := make(map[string]*fanout.Handler, len(conf.ChannelConfigs)) diff --git a/pkg/sidecar/multichannelfanout/parse.go b/pkg/sidecar/multichannelfanout/parse.go new file mode 100644 index 00000000000..f719153c7d2 --- /dev/null +++ b/pkg/sidecar/multichannelfanout/parse.go @@ -0,0 +1,44 @@ +/* +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 multichannelfanout + +import ( + "bytes" + "encoding/json" + "go.uber.org/zap" + "k8s.io/apimachinery/pkg/util/yaml" +) + +// ConfigMapData attempts to parse the YAML string into a multichannelfanout.Config. +func Parse(logger *zap.Logger, str string) (*Config, error) { + jb, err := yaml.ToJSON([]byte(str)) + if err != nil { + logger.Error("Unable to convert str to JSON", zap.Error(err), zap.String("str", str)) + return nil, err + } + var conf Config + err = unmarshalJsonDisallowUnknownFields(jb, &conf) + return &conf, err +} + +// unmarshalJsonDisallowUnknownFields unmarshalls JSON, but unlike json.Unmarshal, will fail if +// given an unknown field (rather than json.Unmarshall's ignoring the unknown field). +func unmarshalJsonDisallowUnknownFields(jb []byte, v interface{}) error { + d := json.NewDecoder(bytes.NewReader(jb)) + d.DisallowUnknownFields() + return d.Decode(v) +} diff --git a/pkg/sidecar/multichannelfanout/parse_test.go b/pkg/sidecar/multichannelfanout/parse_test.go new file mode 100644 index 00000000000..568ac7d3391 --- /dev/null +++ b/pkg/sidecar/multichannelfanout/parse_test.go @@ -0,0 +1,148 @@ +/* +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 multichannelfanout + +import ( + "github.com/google/go-cmp/cmp" + "github.com/knative/eventing/pkg/sidecar/fanout" + duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "go.uber.org/zap" + "strings" + "testing" +) + +func TestConfigMapData(t *testing.T) { + testCases := []struct { + name string + config string + expected *Config + expectedErr bool + }{ + { + name: "no data", + expected: &Config {}, + }, + { + name: "invalid YAML", + config: ` + key: + - value + - different indent level + `, + expectedErr: true, + }, + { + name: "valid YAML -- invalid JSON", + config: "{ nil: Key }", + expectedErr: true, + }, + { + name: "unknown field", + config: "{ channelConfigs: [ { not: a-defined-field } ] }", + expectedErr: true, + }, + { + name: "valid", + config: ` + channelConfigs: + - namespace: default + name: c1 + fanoutConfig: + subscriptions: + - callableDomain: event-changer.default.svc.cluster.local + sinkableDomain: message-dumper-bar.default.svc.cluster.local + - callableDomain: message-dumper-foo.default.svc.cluster.local + - sinkableDomain: message-dumper-bar.default.svc.cluster.local + - namespace: default + name: c2 + fanoutConfig: + subscriptions: + - sinkableDomain: message-dumper-foo.default.svc.cluster.local + - namespace: other + name: c3 + fanoutConfig: + subscriptions: + - sinkableDomain: message-dumper-foo.default.svc.cluster.local + `, + expected: &Config{ + ChannelConfigs: []ChannelConfig{ + { + Namespace: "default", + Name: "c1", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: "event-changer.default.svc.cluster.local", + SinkableDomain: "message-dumper-bar.default.svc.cluster.local", + }, + { + CallableDomain: "message-dumper-foo.default.svc.cluster.local", + }, + { + SinkableDomain: "message-dumper-bar.default.svc.cluster.local", + }, + }, + }, + }, + { + Namespace: "default", + Name: "c2", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + SinkableDomain: "message-dumper-foo.default.svc.cluster.local", + }, + }, + }, + }, + { + Namespace: "other", + Name: "c3", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + SinkableDomain: "message-dumper-foo.default.svc.cluster.local", + }, + }, + }, + }, + }, + }, + }, + } + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + if tc.name != "valid" { return } + c, e := Parse(zap.NewNop(), formatData(tc.config)) + if tc.expectedErr { + if e == nil { + t.Errorf("Expected an error, actual nil") + } + return + } + if !cmp.Equal(c, tc.expected) { + t.Errorf("Unexpected config. Expected '%v'. Actual '%v'.", tc.expected, c) + } + }) + } +} + +func formatData(config string) string { + // Golang editors tend to replace leading spaces with tabs. YAML is left whitespace + // sensitive and disallows tabs, so let's replace the tabs with four spaces. + return strings.Replace(config, "\t", " ", -1) +} diff --git a/pkg/sidecar/swappable/swappable.go b/pkg/sidecar/swappable/swappable.go index 7d5da5a84d7..9072903d24e 100644 --- a/pkg/sidecar/swappable/swappable.go +++ b/pkg/sidecar/swappable/swappable.go @@ -14,6 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package swappable provides an http.Handler that delegates all HTTP requests to an underlying +// multichannelfanout.Handler. When a new configuration is available, a new +// multichannelfanout.Handler is created and swapped in. All subsequent requests go to the new +// handler. +// It is often used in conjunction with something that notices changes to ConfigMaps, such as +// configmap.watcher or configmap.filesystem. package swappable import ( From bd9facc97f63b3ea429224ab269244afa61ccea6 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Tue, 9 Oct 2018 15:20:24 -0700 Subject: [PATCH 19/23] Use InformerWatcher rather the homegrown ConfigMap watcher. --- cmd/fanoutsidecar/main.go | 17 ++- pkg/sidecar/configmap/watcher/watcher.go | 114 ++++-------------- pkg/sidecar/configmap/watcher/watcher_test.go | 71 +++-------- 3 files changed, 46 insertions(+), 156 deletions(-) diff --git a/cmd/fanoutsidecar/main.go b/cmd/fanoutsidecar/main.go index 4c9e47c7153..c3e8ecbc206 100644 --- a/cmd/fanoutsidecar/main.go +++ b/cmd/fanoutsidecar/main.go @@ -29,8 +29,7 @@ import ( "github.com/knative/eventing/pkg/system" "go.uber.org/zap" "golang.org/x/sync/errgroup" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/kubernetes" "log" "net/http" "sigs.k8s.io/controller-runtime/pkg/client/config" @@ -147,16 +146,16 @@ func setupConfigMapVolume(logger *zap.Logger, mgr manager.Manager, configUpdated } func setupConfigMapWatcher(logger *zap.Logger, mgr manager.Manager, configUpdated swappable.UpdateConfig) error { - // Add custom types to this array to get them into the manager's scheme. - corev1.AddToScheme(mgr.GetScheme()) - - cmName := types.NamespacedName{ - Namespace: configMapNamespace, - Name: configMapName, + kc, err := kubernetes.NewForConfig(mgr.GetConfig()) + if err != nil { + return err } - if _, err := watcher.NewWatcher(logger, mgr, cmName, configUpdated); err != nil { + + cmw, err := watcher.NewWatcher(logger, kc, configMapNamespace, configMapName, configUpdated) + if err != nil { return err } + mgr.Add(cmw) return nil } diff --git a/pkg/sidecar/configmap/watcher/watcher.go b/pkg/sidecar/configmap/watcher/watcher.go index 990f1235adc..01dc5d7af9a 100644 --- a/pkg/sidecar/configmap/watcher/watcher.go +++ b/pkg/sidecar/configmap/watcher/watcher.go @@ -17,105 +17,33 @@ limitations under the License. package watcher import ( - "context" - "github.com/knative/eventing/pkg/sidecar/configmap" + sidecarconfigmap "github.com/knative/eventing/pkg/sidecar/configmap" "github.com/knative/eventing/pkg/sidecar/swappable" + "github.com/knative/pkg/configmap" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/controller" - "sigs.k8s.io/controller-runtime/pkg/handler" + "k8s.io/client-go/kubernetes" "sigs.k8s.io/controller-runtime/pkg/manager" - "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/source" ) -const ( - watcherName = "config-map-k8s-watcher" -) - -func NewWatcher(logger *zap.Logger, mgr manager.Manager, cmName types.NamespacedName, configUpdated swappable.UpdateConfig) (controller.Controller, error) { - // We use the controller-runtime pattern of setting up a controller exclusively to watch changes - // to the ConfigMap. We do not write to the API server for any object. - r := &reconciler{ - logger: logger, - configUpdated: configUpdated, - cmName: cmName, - } - c, err := controller.New(watcherName, mgr, controller.Options{ - Reconciler: r, +// NewWatcher creates a new InformedWatcher that watches the specified ConfigMap and on any change +// that results in a valid multichannelfanout.Config calls configUpdated. +func NewWatcher(logger *zap.Logger, kc kubernetes.Interface, cmNamespace, cmName string, configUpdated swappable.UpdateConfig) (manager.Runnable, error) { + iw := configmap.NewInformedWatcher(kc, cmNamespace) + iw.Watch(cmName, func(cm *corev1.ConfigMap) { + config, err := sidecarconfigmap.NewFanoutConfig(logger, cm.Data) + if err != nil { + logger.Error("Could not parse ConfigMap", zap.Error(err), + zap.Any("configMap.Data", cm.Data)) + return + } + + err = configUpdated(config) + if err != nil { + logger.Error("Unable to update config", zap.Error(err)) + return + } }) - if err != nil { - logger.Error("Unable to create controller.", zap.Error(err)) - return nil, err - } - - // Watch ConfigMaps. - err = c.Watch(&source.Kind{ - Type: &corev1.ConfigMap{}, - }, &handler.EnqueueRequestForObject{}) - if err != nil { - logger.Error("Unable to watch ConfigMaps.", zap.Error(err)) - return nil, err - } - return c, nil -} - -var _ reconcile.Reconciler = &reconciler{} - -type reconciler struct { - logger *zap.Logger - client client.Client - configUpdated swappable.UpdateConfig - cmName types.NamespacedName -} - -func (r *reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error) { - //TODO use this to store the logger and set a deadline - ctx := context.TODO() - - if req.Namespace != r.cmName.Namespace || req.Name != r.cmName.Name { - // Not the ConfigMap we are interested in. - return reconcile.Result{}, nil - } - - cm := &corev1.ConfigMap{} - err := r.client.Get(ctx, req.NamespacedName, cm) - - // The ConfigMap may have been deleted since it was added to the workqueue. If so - // there's nothing to be done. - if errors.IsNotFound(err) { - r.logger.Error("ConfigMap not found", zap.Any("request", req)) - return reconcile.Result{}, nil - } - - // If the ConfigMap exists but could not be retrieved, then we should retry. - if err != nil { - r.logger.Error("Could not get ConfigMap", - zap.Any("request", req), - zap.Error(err)) - return reconcile.Result{}, err - } - - config, err := configmap.NewFanoutConfig(r.logger, cm.Data) - if err != nil { - r.logger.Error("Could not parse ConfigMap", zap.Error(err), - zap.Any("configMap.Data", cm.Data)) - return reconcile.Result{}, err - } - - err = r.configUpdated(config) - if err != nil { - r.logger.Error("Unable to update config", zap.Error(err)) - return reconcile.Result{}, err - } - - return reconcile.Result{}, nil -} -func (r *reconciler) InjectClient(c client.Client) error { - r.client = c - return nil + return iw, nil } diff --git a/pkg/sidecar/configmap/watcher/watcher_test.go b/pkg/sidecar/configmap/watcher/watcher_test.go index 900dea52b4f..e6296e5f201 100644 --- a/pkg/sidecar/configmap/watcher/watcher_test.go +++ b/pkg/sidecar/configmap/watcher/watcher_test.go @@ -17,21 +17,16 @@ limitations under the License. package watcher import ( - "context" "errors" "github.com/google/go-cmp/cmp" - controllertesting "github.com/knative/eventing/pkg/controller/testing" - "github.com/knative/eventing/pkg/sidecar/configmap" + sidecarconfigmap "github.com/knative/eventing/pkg/sidecar/configmap" "github.com/knative/eventing/pkg/sidecar/fanout" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" + "github.com/knative/pkg/configmap" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/fake" - "sigs.k8s.io/controller-runtime/pkg/reconcile" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "testing" ) @@ -43,35 +38,29 @@ const ( func TestReconcile(t *testing.T) { testCases := map[string]struct { config map[string]string - getErr error updateConfigErr error - expectedErr bool expectedConfig *multichannelfanout.Config }{ - "cm not found": { - expectedErr: false, - }, - "get cm error": { - expectedErr: true, - getErr: errors.New("test-error"), + "missing key": { + config: map[string]string{}, + expectedConfig: nil, }, "cannot parse cm": { config: map[string]string{ - configmap.MultiChannelFanoutConfigKey: "invalid config", + sidecarconfigmap.MultiChannelFanoutConfigKey: "invalid config", }, - expectedErr: true, + expectedConfig: nil, }, "configUpdated fails": { - expectedErr: true, config: map[string]string{ - configmap.MultiChannelFanoutConfigKey: "", + sidecarconfigmap.MultiChannelFanoutConfigKey: "", }, updateConfigErr: errors.New("test-error"), expectedConfig: &multichannelfanout.Config{}, }, "success": { config: map[string]string{ - configmap.MultiChannelFanoutConfigKey: ` + sidecarconfigmap.MultiChannelFanoutConfigKey: ` channelConfigs: - name: foo namespace: bar @@ -100,48 +89,22 @@ func TestReconcile(t *testing.T) { } for n, tc := range testCases { t.Run(n, func(t *testing.T) { - mocks := controllertesting.Mocks{ - MockGets: []controllertesting.MockGet{ - func(innerClient client.Client, ctx context.Context, key client.ObjectKey, obj runtime.Object) (controllertesting.MockHandled, error) { - if tc.getErr != nil { - return controllertesting.Handled, tc.getErr - } - if tc.config != nil { - obj.(*corev1.ConfigMap).Data = tc.config - return controllertesting.Handled, nil - } - return controllertesting.Unhandled, nil - }, - }, - } - c := controllertesting.NewMockClient(fake.NewFakeClient(), mocks) - cuc := &configUpdatedChecker{ updateConfigErr: tc.updateConfigErr, } - r := reconciler{ - logger: zap.NewNop(), - client: c, - configUpdated: cuc.updateConfig, - cmName: types.NamespacedName{ - Namespace: namespace, - Name: name, - }, + r, err := NewWatcher(zap.NewNop(), nil, namespace, name, cuc.updateConfig) + if err != nil { + t.Errorf("Error creating watcher: %v", err) } - - result, err := r.Reconcile(reconcile.Request{ - NamespacedName: types.NamespacedName{ + iw := r.(*configmap.InformedWatcher) + iw.OnChange(&corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ Namespace: namespace, Name: name, }, + Data: tc.config, }) - if tc.expectedErr != (err != nil) { - t.Errorf("Unexpected error. Expected %v. Actual %v.", tc.expectedErr, err) - } - if diff := cmp.Diff(reconcile.Result{}, result); diff != "" { - t.Errorf("Unexpected result (-want +got): %v", diff) - } if diff := cmp.Diff(tc.expectedConfig, cuc.config); diff != "" { t.Errorf("Unexpected config (-want +got): %v", diff) From 1bb5b443e4049e0a3f2609ac26768835c5633b9d Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Wed, 10 Oct 2018 11:41:58 -0700 Subject: [PATCH 20/23] Change filesystem watcher unit tests away from using the HTTP server (and hopefully remove the flakiness). --- ...g_map_handler.go => filesystem_watcher.go} | 2 +- ...ler_test.go => filesystem_watcher_test.go} | 292 +++++++++--------- pkg/sidecar/fanout/fanout_handler.go | 9 +- 3 files changed, 158 insertions(+), 145 deletions(-) rename pkg/sidecar/configmap/filesystem/{config_map_handler.go => filesystem_watcher.go} (99%) rename pkg/sidecar/configmap/filesystem/{config_map_handler_test.go => filesystem_watcher_test.go} (53%) diff --git a/pkg/sidecar/configmap/filesystem/config_map_handler.go b/pkg/sidecar/configmap/filesystem/filesystem_watcher.go similarity index 99% rename from pkg/sidecar/configmap/filesystem/config_map_handler.go rename to pkg/sidecar/configmap/filesystem/filesystem_watcher.go index c364d66ce84..4cf6877df1b 100644 --- a/pkg/sidecar/configmap/filesystem/config_map_handler.go +++ b/pkg/sidecar/configmap/filesystem/filesystem_watcher.go @@ -120,7 +120,7 @@ func (cmw *configMapWatcher) Start(stopCh <-chan struct{}) error { case _, ok := <-stopCh: if !ok { // stopCh has been closed - return nil + return watcher.Close() } } } diff --git a/pkg/sidecar/configmap/filesystem/config_map_handler_test.go b/pkg/sidecar/configmap/filesystem/filesystem_watcher_test.go similarity index 53% rename from pkg/sidecar/configmap/filesystem/config_map_handler_test.go rename to pkg/sidecar/configmap/filesystem/filesystem_watcher_test.go index 0920310a985..5b3894b1bc6 100644 --- a/pkg/sidecar/configmap/filesystem/config_map_handler_test.go +++ b/pkg/sidecar/configmap/filesystem/filesystem_watcher_test.go @@ -17,29 +17,23 @@ limitations under the License. package filesystem import ( + "errors" "fmt" "github.com/google/go-cmp/cmp" "github.com/knative/eventing/pkg/sidecar/configmap" "github.com/knative/eventing/pkg/sidecar/fanout" "github.com/knative/eventing/pkg/sidecar/multichannelfanout" - "github.com/knative/eventing/pkg/sidecar/swappable" duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1" - "go.uber.org/atomic" "go.uber.org/zap" - "io" + "gopkg.in/yaml.v2" "io/ioutil" - "net/http" - "net/http/httptest" "os" "strings" + "sync" "testing" "time" ) -const ( - replaceDomain = "replaceDomain" -) - func TestReadConfigMap(t *testing.T) { testCases := []struct { name string @@ -158,7 +152,7 @@ func TestReadConfigMap(t *testing.T) { } else { dir = "/tmp/doesNotExist" } - writeConfig(t, dir, tc.config) + writeConfigString(t, dir, tc.config) c, e := readConfigMap(zap.NewNop(), dir) if tc.expectedErr { if e == nil { @@ -173,139 +167,166 @@ func TestReadConfigMap(t *testing.T) { } } -func TestServeHTTP(t *testing.T) { - testCases := []struct { - name string - initialConfig string - updatedConfig string - initialRequests int32 - initialRequestsAfterUpdate int32 - updateRequests int32 +func TestWatch(t *testing.T) { + testCases := map[string]struct { + initialConfigErr error + initialConfig *multichannelfanout.Config + updateConfigErr error + updateConfig *multichannelfanout.Config }{ - { - name: "send to config", - initialConfig: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - `, - initialRequests: 1, + "error applying initial config": { + initialConfig: &multichannelfanout.Config{}, + initialConfigErr: errors.New("test-induced error"), }, - { - name: "change config", - initialConfig: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - `, - initialRequests: 1, - updatedConfig: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - `, - updateRequests: 1, + "read initial config": { + initialConfig: &multichannelfanout.Config{ + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: "default", + Name: "c1", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + SinkableDomain: "foo.bar", + }, + }, + }, + }, + }, + }, }, - { - name: "bad config update -- keeps serving old config", - initialConfig: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - `, - initialRequests: 1, - updatedConfig: ` - channelConfigs: - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - # Duplicate namespace/name - - namespace: default - name: c1 - fanoutConfig: - subscriptions: - - sinkableDomain: replaceDomain - `, - initialRequestsAfterUpdate: 2, + "error apply updated config": { + initialConfig: &multichannelfanout.Config{ + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: "default", + Name: "c1", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + SinkableDomain: "foo.bar", + }, + }, + }, + }, + }, + }, + updateConfigErr: errors.New("test-induced error"), + }, + "update config": { + initialConfig: &multichannelfanout.Config{ + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: "default", + Name: "c1", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + SinkableDomain: "foo.bar", + }, + }, + }, + }, + }, + }, + updateConfig: &multichannelfanout.Config{ + ChannelConfigs: []multichannelfanout.ChannelConfig{ + { + Namespace: "default", + Name: "new-channel", + FanoutConfig: fanout.Config{ + Subscriptions: []duckv1alpha1.ChannelSubscriberSpec{ + { + CallableDomain: "baz.qux", + }, + }, + }, + }, + }, + }, }, } - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - if tc.name != "change config" { - return - } - initialHandler := &fakeHandler{} - initialServer := httptest.NewServer(initialHandler) - defer initialServer.Close() - updateHandler := &fakeHandler{} - updateServer := httptest.NewServer(updateHandler) - defer updateServer.Close() - + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { dir := createTempDir(t) defer os.RemoveAll(dir) - writeConfig(t, dir, replaceDomains(tc.initialConfig, initialServer.URL[7:])) + writeConfig(t, dir, tc.initialConfig) - sh, err := swappable.NewEmptyHandler(zap.NewNop()) - if err != nil { - t.Errorf("Unexpected error making swappable.Handler: %+v", err) + cuc := &configUpdatedChecker{ + updateConfigErr: tc.initialConfigErr, } - cmw, err := NewConfigMapWatcher(zap.NewNop(), dir, sh.UpdateConfig) + cmw, err := NewConfigMapWatcher(zap.NewNop(), dir, cuc.updateConfig) if err != nil { - t.Errorf("Unexpected error making filesystem.configMapWatcher") + if tc.initialConfigErr != err { + t.Errorf("Unexpected error making ConfigMapWatcher. Expected: '%v'. Actual '%v'", tc.initialConfigErr, err) + } + return + } + ac := cuc.getConfig() + if !cmp.Equal(tc.initialConfig, ac) { + t.Errorf("Unexpected initial config. Expected '%v'. Actual '%v'", tc.initialConfig, ac) } stopCh := make(chan struct{}) go cmw.Start(stopCh) defer func() { - stopCh <- struct{}{} + close(stopCh) }() + // Sadly, the test is flaky unless we sleep here, waiting for the file system + // watcher to truly start. + time.Sleep(100 * time.Millisecond) - w := httptest.NewRecorder() - sh.ServeHTTP(w, makeRequest("default", "c1")) - if w.Result().StatusCode != http.StatusAccepted { - t.Errorf("Unexpected initial status code: %v", w.Result().StatusCode) + if tc.updateConfigErr != nil { + cuc.updateConfigErr = tc.updateConfigErr } - if tc.initialRequests != initialHandler.requests.Load() { - t.Errorf("Incorrect initial request count. Expected %v. Actual %v.", - tc.initialRequests, initialHandler.requests.Load()) + + expected := tc.initialConfig + if tc.updateConfig != nil { + expected = tc.updateConfig } - if tc.updatedConfig != "" { - writeConfig(t, dir, replaceDomains(tc.updatedConfig, updateServer.URL[7:])) - // The watcher is running in another routine, give it some time to notice the - // change. - time.Sleep(100 * time.Millisecond) - w = httptest.NewRecorder() - sh.ServeHTTP(w, makeRequest("default", "c1")) - if w.Result().StatusCode != http.StatusAccepted { - t.Errorf("Unexpected updated status code: %v", w.Result().StatusCode) - } - if tc.updateRequests != updateHandler.requests.Load() { - t.Errorf("Incorrect update request count. Expected %v. Actual %v.", tc.updateRequests, updateHandler.requests.Load()) - } - if tc.initialRequestsAfterUpdate != 0 && tc.initialRequestsAfterUpdate != initialHandler.requests.Load() { - t.Errorf("Incorrect requests to initialHandler after config update. Expected %v, actual %v", - tc.initialRequestsAfterUpdate, initialHandler.requests.Load()) - } + cuc.updateCalled = make(chan struct{}, 1) + writeConfig(t, dir, expected) + // The watcher is running in another goroutine, give it some time to notice the + // change. + select { + case <-cuc.updateCalled: + break + case <-time.After(5 * time.Second): + t.Errorf("Time out waiting for watcher to notice change.") + } + + ac = cuc.getConfig() + if !cmp.Equal(ac, expected) { + t.Errorf("Unexpected update config. Expected '%v'. Actual '%v'", expected, ac) } }) } } +type configUpdatedChecker struct { + configLock sync.Mutex + config *multichannelfanout.Config + updateCalled chan struct{} + updateConfigErr error +} + +func (cuc *configUpdatedChecker) updateConfig(config *multichannelfanout.Config) error { + cuc.configLock.Lock() + defer cuc.configLock.Unlock() + cuc.config = config + if cuc.updateCalled != nil { + cuc.updateCalled <- struct{}{} + } + return cuc.updateConfigErr +} + +func (cuc *configUpdatedChecker) getConfig() *multichannelfanout.Config { + cuc.configLock.Lock() + defer cuc.configLock.Unlock() + return cuc.config +} + func createTempDir(t *testing.T) string { dir, err := ioutil.TempDir("", "configMapHandlerTest") if err != nil { @@ -314,7 +335,17 @@ func createTempDir(t *testing.T) string { return dir } -func writeConfig(t *testing.T, dir, config string) { +func writeConfig(t *testing.T, dir string, config *multichannelfanout.Config) { + if config != nil { + yb, err := yaml.Marshal(config) + if err != nil { + t.Errorf("Unable to marshal the config") + } + writeConfigString(t, dir, string(yb)) + } +} + +func writeConfigString(t *testing.T, dir, config string) { if config != "" { // Golang editors tend to replace leading spaces with tabs. YAML is left whitespace // sensitive, so let's replace the tabs with spaces. @@ -325,26 +356,3 @@ func writeConfig(t *testing.T, dir, config string) { } } } - -func body(body string) io.ReadCloser { - return ioutil.NopCloser(strings.NewReader(body)) -} - -func makeRequest(namespace, name string) *http.Request { - r := httptest.NewRequest("POST", fmt.Sprintf("http://%s.%s/", name, namespace), body("")) - return r -} - -type fakeHandler struct { - requests atomic.Int32 -} - -func (h *fakeHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - defer r.Body.Close() - w.WriteHeader(http.StatusOK) - h.requests.Inc() -} - -func replaceDomains(config, replacement string) string { - return strings.Replace(config, replaceDomain, replacement, -1) -} diff --git a/pkg/sidecar/fanout/fanout_handler.go b/pkg/sidecar/fanout/fanout_handler.go index f9b41f4a19f..970008bdc25 100644 --- a/pkg/sidecar/fanout/fanout_handler.go +++ b/pkg/sidecar/fanout/fanout_handler.go @@ -126,12 +126,17 @@ func (f *Handler) foreverDispatch(stopCh <-chan struct{}) { for { select { case msg := <-f.receivedMessages: - f.dispatch(msg) + go f.dispatch(msg) case <-stopCh: f.logger.Info("Fanout dispatch thread stopping.") - return + break } } + // Finish any work already enqueued. Nothing new should be enqueued. + for len(f.receivedMessages) > 0 { + msg := <-f.receivedMessages + f.dispatch(msg) + } } // ServeHTTP takes the request, fans it out to each subscription in f.config. If all the fanned out From 895dcd35dd664a69ab70bd740582edf798d8ff15 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Wed, 10 Oct 2018 12:13:51 -0700 Subject: [PATCH 21/23] fanout.Handler synchronously calls dispatch(), rather than asynchronously and then waiting on the response. --- pkg/sidecar/fanout/fanout_handler.go | 99 +++++-------------- pkg/sidecar/fanout/fanout_handler_test.go | 1 - .../multi_channel_fanout_handler.go | 8 +- .../multi_channel_fanout_handler_test.go | 8 +- pkg/sidecar/swappable/swappable.go | 1 - 5 files changed, 26 insertions(+), 91 deletions(-) diff --git a/pkg/sidecar/fanout/fanout_handler.go b/pkg/sidecar/fanout/fanout_handler.go index 970008bdc25..87e636c8d8e 100644 --- a/pkg/sidecar/fanout/fanout_handler.go +++ b/pkg/sidecar/fanout/fanout_handler.go @@ -48,8 +48,9 @@ type Handler struct { receivedMessages chan *forwardMessage receiver *buses.MessageReceiver dispatcher *buses.MessageDispatcher - stopCh chan<- struct{} + // TODO: Plumb context through the receiver and dispatcher and use that to store the timeout, + // rather than a member variable. timeout time.Duration logger *zap.Logger @@ -63,50 +64,25 @@ type forwardMessage struct { done chan<- error } -// NewHandler creates a new fanout.Handler and starts a background goroutine to make it work. The -// caller is responsible for calling handler.Stop(), when the handler is to be stopped. +// NewHandler creates a new fanout.Handler. func NewHandler(logger *zap.Logger, config Config) *Handler { - stopCh := make(chan struct{}, 1) handler := &Handler{ logger: logger, config: config, dispatcher: buses.NewMessageDispatcher(logger.Sugar()), receivedMessages: make(chan *forwardMessage, messageBufferSize), - stopCh: stopCh, timeout: defaultTimeout, } // The receiver function needs to point back at the handler itself, so set it up after // initialization. handler.receiver = buses.NewMessageReceiver(createReceiverFunction(handler), logger.Sugar()) - go handler.foreverDispatch(stopCh) return handler } func createReceiverFunction(f *Handler) func(buses.ChannelReference, *buses.Message) error { return func(_ buses.ChannelReference, m *buses.Message) error { - done := make(chan error) - msg := &forwardMessage{ - msg: m, - done: done, - } - - select { - case f.receivedMessages <- msg: - // Continue to next select. - default: - f.logger.Debug("Unable to add message to channel, dropping it.", zap.Any("msg", msg)) - return errors.New("unable to add message to channel, dropping it") - } - - select { - case possibleErr := <-done: - f.logger.Debug("Responding", zap.Any("possibleErr", possibleErr)) - return possibleErr - case <-time.After(f.timeout): - f.logger.Debug("Timeout waiting for dispatch") - return errors.New("timeout waiting for dispatch") - } + return f.dispatch(m) } } @@ -114,57 +90,30 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { f.receiver.HandleRequest(w, r) } -// Stop stops the background goroutine. Once this is called, this Handler will no longer properly -// Serve HTTP traffic. -func (f *Handler) Stop() { - f.stopCh <- struct{}{} -} - -// foreverDispatch dispatches received messages in an infinite loop. It exits only when -// Handler.stopCh receives a message. It is meant to be run as a goroutine. -func (f *Handler) foreverDispatch(stopCh <-chan struct{}) { - for { - select { - case msg := <-f.receivedMessages: - go f.dispatch(msg) - case <-stopCh: - f.logger.Info("Fanout dispatch thread stopping.") - break - } - } - // Finish any work already enqueued. Nothing new should be enqueued. - for len(f.receivedMessages) > 0 { - msg := <-f.receivedMessages - f.dispatch(msg) +// dispatch takes the request, fans it out to each subscription in f.config. If all the fanned out +// requests return successfully, then return nil. Else, return an error. +func (f *Handler) dispatch(msg *buses.Message) error { + errorCh := make(chan error, len(f.config.Subscriptions)) + for _, sub := range f.config.Subscriptions { + go func(s duckv1alpha1.ChannelSubscriberSpec) { + errorCh <- f.makeFanoutRequest(*msg, s) + }(sub) } -} -// ServeHTTP takes the request, fans it out to each subscription in f.config. If all the fanned out -// requests return successfully, then return successfully. Else, return failure. -func (f *Handler) dispatch(msg *forwardMessage) { - msg.done <- func() error { - errorCh := make(chan error, len(f.config.Subscriptions)) - for _, sub := range f.config.Subscriptions { - go func(s duckv1alpha1.ChannelSubscriberSpec) { - errorCh <- f.makeFanoutRequest(*msg.msg, s) - }(sub) - } - - for range f.config.Subscriptions { - select { - case err := <-errorCh: - if err != nil { - f.logger.Error("Fanout had an error", zap.Error(err)) - return err - } - case <-time.After(f.timeout): - f.logger.Error("Fanout timed out") - return errors.New("fanout timed out") + for range f.config.Subscriptions { + select { + case err := <-errorCh: + if err != nil { + f.logger.Error("Fanout had an error", zap.Error(err)) + return err } + case <-time.After(f.timeout): + f.logger.Error("Fanout timed out") + return errors.New("fanout timed out") } - // All Subscriptions returned err = nil. - return nil - }() + } + // All Subscriptions returned err = nil. + return nil } // makeFanoutRequest sends the request to exactly one subscription. It handles both the `call` and diff --git a/pkg/sidecar/fanout/fanout_handler_test.go b/pkg/sidecar/fanout/fanout_handler_test.go index eab389529db..9bdf020e544 100644 --- a/pkg/sidecar/fanout/fanout_handler_test.go +++ b/pkg/sidecar/fanout/fanout_handler_test.go @@ -205,7 +205,6 @@ func TestFanoutHandler_ServeHTTP(t *testing.T) { } h := NewHandler(zap.NewNop(), Config{Subscriptions: subs}) - defer h.Stop() if tc.receiverFunc != nil { h.receiver = buses.NewMessageReceiver(tc.receiverFunc, zap.NewNop().Sugar()) } diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go index 3afef51dcc4..3882bb6a2ae 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler.go @@ -72,7 +72,7 @@ type Handler struct { config Config } -// NewHandler creates a new Handler. The caller is responsible for calling handler.Stop(). +// NewHandler creates a new Handler. func NewHandler(logger *zap.Logger, conf Config) (*Handler, error) { handlers := make(map[string]*fanout.Handler, len(conf.ChannelConfigs)) @@ -93,12 +93,6 @@ func NewHandler(logger *zap.Logger, conf Config) (*Handler, error) { }, nil } -func (h *Handler) Stop() { - for _, fh := range h.handlers { - fh.Stop() - } -} - // ConfigDiffs diffs the new config with the existing config. If there are no differences, then the // empty string is returned. If there are differences, then a non-empty string is returned // describing the differences. diff --git a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go index 9ee337527a4..3bc5e6f0faf 100644 --- a/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go +++ b/pkg/sidecar/multichannelfanout/multi_channel_fanout_handler_test.go @@ -86,10 +86,7 @@ func TestNewHandler(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - h, err := NewHandler(zap.NewNop(), tc.config) - if err == nil { - defer h.Stop() - } + _, err := NewHandler(zap.NewNop(), tc.config) if tc.createErr != "" { if err == nil { t.Errorf("Expected NewHandler error: '%v'. Actual nil", tc.createErr) @@ -142,7 +139,6 @@ func TestCopyWithNewConfig(t *testing.T) { if err != nil { t.Errorf("Unable to create handler, %v", err) } - defer h.Stop() if !cmp.Equal(h.config, orig) { t.Errorf("Incorrect config. Expected '%v'. Actual '%v'", orig, h.config) } @@ -213,7 +209,6 @@ func TestConfigDiff(t *testing.T) { if err != nil { t.Errorf("Unable to create handler: %v", err) } - defer h.Stop() diff := h.ConfigDiff(tc.updated) if hasDiff := diff != ""; hasDiff != tc.expectedDiff { @@ -304,7 +299,6 @@ func TestServeHTTP(t *testing.T) { if err != nil { t.Errorf("Unexpected NewHandler error: '%v'", err) } - defer h.Stop() r := requestWithChannelKey(tc.key) w := httptest.NewRecorder() diff --git a/pkg/sidecar/swappable/swappable.go b/pkg/sidecar/swappable/swappable.go index 9072903d24e..bfb2bc3f953 100644 --- a/pkg/sidecar/swappable/swappable.go +++ b/pkg/sidecar/swappable/swappable.go @@ -93,7 +93,6 @@ func (h *Handler) UpdateConfig(config *multichannelfanout.Config) error { return err } h.setMultiChannelFanoutHandler(newIh) - defer ih.Stop() } return nil } From b7c2bf1232ee5bde52854c16956e0612161e7f8c Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Wed, 10 Oct 2018 14:12:15 -0700 Subject: [PATCH 22/23] Respond to PR comments. --- cmd/fanoutsidecar/main.go | 7 +++++-- pkg/sidecar/configmap/filesystem/filesystem_watcher.go | 7 ++----- pkg/sidecar/multichannelfanout/parse.go | 2 +- pkg/sidecar/swappable/swappable.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/fanoutsidecar/main.go b/cmd/fanoutsidecar/main.go index c3e8ecbc206..0da88913951 100644 --- a/cmd/fanoutsidecar/main.go +++ b/cmd/fanoutsidecar/main.go @@ -20,6 +20,7 @@ limitations under the License. package main import ( + "context" "errors" "flag" "fmt" @@ -108,9 +109,11 @@ func main() { }) logger.Info("Fanout sidecar Listening...", zap.String("Address", s.Addr)) g.Go(s.ListenAndServe) - if err = g.Wait(); err != nil { - logger.Fatal("Either the HTTP server or the ConfigMap noticer failed.", zap.Error(err)) + err = g.Wait() + if err != nil { + logger.Error("Either the HTTP server or the ConfigMap noticer failed.", zap.Error(err)) } + s.Shutdown(context.TODO()) } func setupConfigMapNoticer(logger *zap.Logger, configUpdated swappable.UpdateConfig) (manager.Manager, error) { diff --git a/pkg/sidecar/configmap/filesystem/filesystem_watcher.go b/pkg/sidecar/configmap/filesystem/filesystem_watcher.go index 4cf6877df1b..228cbd691b9 100644 --- a/pkg/sidecar/configmap/filesystem/filesystem_watcher.go +++ b/pkg/sidecar/configmap/filesystem/filesystem_watcher.go @@ -117,11 +117,8 @@ func (cmw *configMapWatcher) Start(stopCh <-chan struct{}) error { return errors.New("watcher.Errors channel closed") } cmw.logger.Error("watcher.Errors", zap.Error(err)) - case _, ok := <-stopCh: - if !ok { - // stopCh has been closed - return watcher.Close() - } + case <-stopCh: + return watcher.Close() } } } diff --git a/pkg/sidecar/multichannelfanout/parse.go b/pkg/sidecar/multichannelfanout/parse.go index f719153c7d2..35687b442d8 100644 --- a/pkg/sidecar/multichannelfanout/parse.go +++ b/pkg/sidecar/multichannelfanout/parse.go @@ -23,7 +23,7 @@ import ( "k8s.io/apimachinery/pkg/util/yaml" ) -// ConfigMapData attempts to parse the YAML string into a multichannelfanout.Config. +// Parse attempts to parse the YAML string into a multichannelfanout.Config. func Parse(logger *zap.Logger, str string) (*Config, error) { jb, err := yaml.ToJSON([]byte(str)) if err != nil { diff --git a/pkg/sidecar/swappable/swappable.go b/pkg/sidecar/swappable/swappable.go index bfb2bc3f953..97ba588680c 100644 --- a/pkg/sidecar/swappable/swappable.go +++ b/pkg/sidecar/swappable/swappable.go @@ -69,8 +69,8 @@ func (h *Handler) getMultiChannelFanoutHandler() *multichannelfanout.Handler { // setMultiChannelFanoutHandler sets a new multichannelfanout.Handler to delegate all subsequent // HTTP requests to. -func (h *Handler) setMultiChannelFanoutHandler(new *multichannelfanout.Handler) { - h.fanout.Store(new) +func (h *Handler) setMultiChannelFanoutHandler(nh *multichannelfanout.Handler) { + h.fanout.Store(nh) } // UpdateConfig copies the current inner multichannelfanout.Handler with the new configuration. If From 60247cf9ae442a5532e54fc60bb7bba1336661e9 Mon Sep 17 00:00:00 2001 From: Adam Harwayne Date: Wed, 10 Oct 2018 15:29:46 -0700 Subject: [PATCH 23/23] Shutdown with a timeout. --- cmd/fanoutsidecar/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/fanoutsidecar/main.go b/cmd/fanoutsidecar/main.go index 0da88913951..1ece5804172 100644 --- a/cmd/fanoutsidecar/main.go +++ b/cmd/fanoutsidecar/main.go @@ -113,7 +113,10 @@ func main() { if err != nil { logger.Error("Either the HTTP server or the ConfigMap noticer failed.", zap.Error(err)) } - s.Shutdown(context.TODO()) + + ctx, cancel := context.WithTimeout(context.Background(), writeTimeout) + defer cancel() + s.Shutdown(ctx) } func setupConfigMapNoticer(logger *zap.Logger, configUpdated swappable.UpdateConfig) (manager.Manager, error) {