From 43dac0bc4302fed79eaeb661723ca584a9c0496a Mon Sep 17 00:00:00 2001 From: HuabingZhao Date: Mon, 4 Sep 2017 15:00:54 +0800 Subject: restructure the source directory Issue-ID: OOM-61 Change-Id: Ib6f633d517ad197bfdbca59b374cdad2f1ed897e Signed-off-by: HuabingZhao --- .../src/vendor/k8s.io/kubernetes/pkg/watch/doc.go | 19 -- .../vendor/k8s.io/kubernetes/pkg/watch/filter.go | 109 ------- .../src/vendor/k8s.io/kubernetes/pkg/watch/mux.go | 257 ---------------- .../k8s.io/kubernetes/pkg/watch/streamwatcher.go | 119 ------- .../vendor/k8s.io/kubernetes/pkg/watch/until.go | 82 ----- .../kubernetes/pkg/watch/versioned/decoder.go | 71 ----- .../kubernetes/pkg/watch/versioned/encoder.go | 51 --- .../kubernetes/pkg/watch/versioned/generated.pb.go | 342 --------------------- .../kubernetes/pkg/watch/versioned/generated.proto | 43 --- .../kubernetes/pkg/watch/versioned/register.go | 84 ----- .../k8s.io/kubernetes/pkg/watch/versioned/types.go | 37 --- .../vendor/k8s.io/kubernetes/pkg/watch/watch.go | 137 --------- 12 files changed, 1351 deletions(-) delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/doc.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/filter.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/mux.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/streamwatcher.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/until.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/decoder.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/encoder.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/generated.pb.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/generated.proto delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/register.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/types.go delete mode 100644 kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/watch.go (limited to 'kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch') diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/doc.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/doc.go deleted file mode 100644 index 5fde5e7..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package watch contains a generic watchable interface, and a fake for -// testing code that uses the watch interface. -package watch diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/filter.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/filter.go deleted file mode 100644 index 3ca27f2..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/filter.go +++ /dev/null @@ -1,109 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package watch - -import ( - "sync" -) - -// FilterFunc should take an event, possibly modify it in some way, and return -// the modified event. If the event should be ignored, then return keep=false. -type FilterFunc func(in Event) (out Event, keep bool) - -// Filter passes all events through f before allowing them to pass on. -// Putting a filter on a watch, as an unavoidable side-effect due to the way -// go channels work, effectively causes the watch's event channel to have its -// queue length increased by one. -// -// WARNING: filter has a fatal flaw, in that it can't properly update the -// Type field (Add/Modified/Deleted) to reflect items beginning to pass the -// filter when they previously didn't. -// -func Filter(w Interface, f FilterFunc) Interface { - fw := &filteredWatch{ - incoming: w, - result: make(chan Event), - f: f, - } - go fw.loop() - return fw -} - -type filteredWatch struct { - incoming Interface - result chan Event - f FilterFunc -} - -// ResultChan returns a channel which will receive filtered events. -func (fw *filteredWatch) ResultChan() <-chan Event { - return fw.result -} - -// Stop stops the upstream watch, which will eventually stop this watch. -func (fw *filteredWatch) Stop() { - fw.incoming.Stop() -} - -// loop waits for new values, filters them, and resends them. -func (fw *filteredWatch) loop() { - defer close(fw.result) - for { - event, ok := <-fw.incoming.ResultChan() - if !ok { - break - } - filtered, keep := fw.f(event) - if keep { - fw.result <- filtered - } - } -} - -// Recorder records all events that are sent from the watch until it is closed. -type Recorder struct { - Interface - - lock sync.Mutex - events []Event -} - -var _ Interface = &Recorder{} - -// NewRecorder wraps an Interface and records any changes sent across it. -func NewRecorder(w Interface) *Recorder { - r := &Recorder{} - r.Interface = Filter(w, r.record) - return r -} - -// record is a FilterFunc and tracks each received event. -func (r *Recorder) record(in Event) (Event, bool) { - r.lock.Lock() - defer r.lock.Unlock() - r.events = append(r.events, in) - return in, true -} - -// Events returns a copy of the events sent across this recorder. -func (r *Recorder) Events() []Event { - r.lock.Lock() - defer r.lock.Unlock() - copied := make([]Event, len(r.events)) - copy(copied, r.events) - return copied -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/mux.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/mux.go deleted file mode 100644 index ec6de05..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/mux.go +++ /dev/null @@ -1,257 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package watch - -import ( - "sync" - - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/runtime" -) - -// FullChannelBehavior controls how the Broadcaster reacts if a watcher's watch -// channel is full. -type FullChannelBehavior int - -const ( - WaitIfChannelFull FullChannelBehavior = iota - DropIfChannelFull -) - -// Buffer the incoming queue a little bit even though it should rarely ever accumulate -// anything, just in case a few events are received in such a short window that -// Broadcaster can't move them onto the watchers' queues fast enough. -const incomingQueueLength = 25 - -// Broadcaster distributes event notifications among any number of watchers. Every event -// is delivered to every watcher. -type Broadcaster struct { - // TODO: see if this lock is needed now that new watchers go through - // the incoming channel. - lock sync.Mutex - - watchers map[int64]*broadcasterWatcher - nextWatcher int64 - distributing sync.WaitGroup - - incoming chan Event - - // How large to make watcher's channel. - watchQueueLength int - // If one of the watch channels is full, don't wait for it to become empty. - // Instead just deliver it to the watchers that do have space in their - // channels and move on to the next event. - // It's more fair to do this on a per-watcher basis than to do it on the - // "incoming" channel, which would allow one slow watcher to prevent all - // other watchers from getting new events. - fullChannelBehavior FullChannelBehavior -} - -// NewBroadcaster creates a new Broadcaster. queueLength is the maximum number of events to queue per watcher. -// It is guaranteed that events will be distributed in the order in which they occur, -// but the order in which a single event is distributed among all of the watchers is unspecified. -func NewBroadcaster(queueLength int, fullChannelBehavior FullChannelBehavior) *Broadcaster { - m := &Broadcaster{ - watchers: map[int64]*broadcasterWatcher{}, - incoming: make(chan Event, incomingQueueLength), - watchQueueLength: queueLength, - fullChannelBehavior: fullChannelBehavior, - } - m.distributing.Add(1) - go m.loop() - return m -} - -const internalRunFunctionMarker = "internal-do-function" - -// a function type we can shoehorn into the queue. -type functionFakeRuntimeObject func() - -func (obj functionFakeRuntimeObject) GetObjectKind() unversioned.ObjectKind { - return unversioned.EmptyObjectKind -} - -// Execute f, blocking the incoming queue (and waiting for it to drain first). -// The purpose of this terrible hack is so that watchers added after an event -// won't ever see that event, and will always see any event after they are -// added. -func (b *Broadcaster) blockQueue(f func()) { - var wg sync.WaitGroup - wg.Add(1) - b.incoming <- Event{ - Type: internalRunFunctionMarker, - Object: functionFakeRuntimeObject(func() { - defer wg.Done() - f() - }), - } - wg.Wait() -} - -// Watch adds a new watcher to the list and returns an Interface for it. -// Note: new watchers will only receive new events. They won't get an entire history -// of previous events. -func (m *Broadcaster) Watch() Interface { - var w *broadcasterWatcher - m.blockQueue(func() { - m.lock.Lock() - defer m.lock.Unlock() - id := m.nextWatcher - m.nextWatcher++ - w = &broadcasterWatcher{ - result: make(chan Event, m.watchQueueLength), - stopped: make(chan struct{}), - id: id, - m: m, - } - m.watchers[id] = w - }) - return w -} - -// WatchWithPrefix adds a new watcher to the list and returns an Interface for it. It sends -// queuedEvents down the new watch before beginning to send ordinary events from Broadcaster. -// The returned watch will have a queue length that is at least large enough to accommodate -// all of the items in queuedEvents. -func (m *Broadcaster) WatchWithPrefix(queuedEvents []Event) Interface { - var w *broadcasterWatcher - m.blockQueue(func() { - m.lock.Lock() - defer m.lock.Unlock() - id := m.nextWatcher - m.nextWatcher++ - length := m.watchQueueLength - if n := len(queuedEvents) + 1; n > length { - length = n - } - w = &broadcasterWatcher{ - result: make(chan Event, length), - stopped: make(chan struct{}), - id: id, - m: m, - } - m.watchers[id] = w - for _, e := range queuedEvents { - w.result <- e - } - }) - return w -} - -// stopWatching stops the given watcher and removes it from the list. -func (m *Broadcaster) stopWatching(id int64) { - m.lock.Lock() - defer m.lock.Unlock() - w, ok := m.watchers[id] - if !ok { - // No need to do anything, it's already been removed from the list. - return - } - delete(m.watchers, id) - close(w.result) -} - -// closeAll disconnects all watchers (presumably in response to a Shutdown call). -func (m *Broadcaster) closeAll() { - m.lock.Lock() - defer m.lock.Unlock() - for _, w := range m.watchers { - close(w.result) - } - // Delete everything from the map, since presence/absence in the map is used - // by stopWatching to avoid double-closing the channel. - m.watchers = map[int64]*broadcasterWatcher{} -} - -// Action distributes the given event among all watchers. -func (m *Broadcaster) Action(action EventType, obj runtime.Object) { - m.incoming <- Event{action, obj} -} - -// Shutdown disconnects all watchers (but any queued events will still be distributed). -// You must not call Action or Watch* after calling Shutdown. This call blocks -// until all events have been distributed through the outbound channels. Note -// that since they can be buffered, this means that the watchers might not -// have received the data yet as it can remain sitting in the buffered -// channel. -func (m *Broadcaster) Shutdown() { - close(m.incoming) - m.distributing.Wait() -} - -// loop receives from m.incoming and distributes to all watchers. -func (m *Broadcaster) loop() { - // Deliberately not catching crashes here. Yes, bring down the process if there's a - // bug in watch.Broadcaster. - for { - event, ok := <-m.incoming - if !ok { - break - } - if event.Type == internalRunFunctionMarker { - event.Object.(functionFakeRuntimeObject)() - continue - } - m.distribute(event) - } - m.closeAll() - m.distributing.Done() -} - -// distribute sends event to all watchers. Blocking. -func (m *Broadcaster) distribute(event Event) { - m.lock.Lock() - defer m.lock.Unlock() - if m.fullChannelBehavior == DropIfChannelFull { - for _, w := range m.watchers { - select { - case w.result <- event: - case <-w.stopped: - default: // Don't block if the event can't be queued. - } - } - } else { - for _, w := range m.watchers { - select { - case w.result <- event: - case <-w.stopped: - } - } - } -} - -// broadcasterWatcher handles a single watcher of a broadcaster -type broadcasterWatcher struct { - result chan Event - stopped chan struct{} - stop sync.Once - id int64 - m *Broadcaster -} - -// ResultChan returns a channel to use for waiting on events. -func (mw *broadcasterWatcher) ResultChan() <-chan Event { - return mw.result -} - -// Stop stops watching and removes mw from its list. -func (mw *broadcasterWatcher) Stop() { - mw.stop.Do(func() { - close(mw.stopped) - mw.m.stopWatching(mw.id) - }) -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/streamwatcher.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/streamwatcher.go deleted file mode 100644 index 26cf61d..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/streamwatcher.go +++ /dev/null @@ -1,119 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package watch - -import ( - "io" - "sync" - - "github.com/golang/glog" - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/util/net" - utilruntime "k8s.io/kubernetes/pkg/util/runtime" -) - -// Decoder allows StreamWatcher to watch any stream for which a Decoder can be written. -type Decoder interface { - // Decode should return the type of event, the decoded object, or an error. - // An error will cause StreamWatcher to call Close(). Decode should block until - // it has data or an error occurs. - Decode() (action EventType, object runtime.Object, err error) - - // Close should close the underlying io.Reader, signalling to the source of - // the stream that it is no longer being watched. Close() must cause any - // outstanding call to Decode() to return with an error of some sort. - Close() -} - -// StreamWatcher turns any stream for which you can write a Decoder interface -// into a watch.Interface. -type StreamWatcher struct { - sync.Mutex - source Decoder - result chan Event - stopped bool -} - -// NewStreamWatcher creates a StreamWatcher from the given decoder. -func NewStreamWatcher(d Decoder) *StreamWatcher { - sw := &StreamWatcher{ - source: d, - // It's easy for a consumer to add buffering via an extra - // goroutine/channel, but impossible for them to remove it, - // so nonbuffered is better. - result: make(chan Event), - } - go sw.receive() - return sw -} - -// ResultChan implements Interface. -func (sw *StreamWatcher) ResultChan() <-chan Event { - return sw.result -} - -// Stop implements Interface. -func (sw *StreamWatcher) Stop() { - // Call Close() exactly once by locking and setting a flag. - sw.Lock() - defer sw.Unlock() - if !sw.stopped { - sw.stopped = true - sw.source.Close() - } -} - -// stopping returns true if Stop() was called previously. -func (sw *StreamWatcher) stopping() bool { - sw.Lock() - defer sw.Unlock() - return sw.stopped -} - -// receive reads result from the decoder in a loop and sends down the result channel. -func (sw *StreamWatcher) receive() { - defer close(sw.result) - defer sw.Stop() - defer utilruntime.HandleCrash() - for { - action, obj, err := sw.source.Decode() - if err != nil { - // Ignore expected error. - if sw.stopping() { - return - } - switch err { - case io.EOF: - // watch closed normally - case io.ErrUnexpectedEOF: - glog.V(1).Infof("Unexpected EOF during watch stream event decoding: %v", err) - default: - msg := "Unable to decode an event from the watch stream: %v" - if net.IsProbableEOF(err) { - glog.V(5).Infof(msg, err) - } else { - glog.Errorf(msg, err) - } - } - return - } - sw.result <- Event{ - Type: action, - Object: obj, - } - } -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/until.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/until.go deleted file mode 100644 index 4259f51..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/until.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package watch - -import ( - "time" - - "k8s.io/kubernetes/pkg/util/wait" -) - -// ConditionFunc returns true if the condition has been reached, false if it has not been reached yet, -// or an error if the condition cannot be checked and should terminate. In general, it is better to define -// level driven conditions over edge driven conditions (pod has ready=true, vs pod modified and ready changed -// from false to true). -type ConditionFunc func(event Event) (bool, error) - -// Until reads items from the watch until each provided condition succeeds, and then returns the last watch -// encountered. The first condition that returns an error terminates the watch (and the event is also returned). -// If no event has been received, the returned event will be nil. -// Conditions are satisfied sequentially so as to provide a useful primitive for higher level composition. -func Until(timeout time.Duration, watcher Interface, conditions ...ConditionFunc) (*Event, error) { - ch := watcher.ResultChan() - defer watcher.Stop() - var after <-chan time.Time - if timeout > 0 { - after = time.After(timeout) - } else { - ch := make(chan time.Time) - close(ch) - after = ch - } - var lastEvent *Event - for _, condition := range conditions { - // check the next condition against the previous event and short circuit waiting for the next watch - if lastEvent != nil { - done, err := condition(*lastEvent) - if err != nil { - return lastEvent, err - } - if done { - break - } - } - ConditionSucceeded: - for { - select { - case event, ok := <-ch: - if !ok { - return lastEvent, wait.ErrWaitTimeout - } - lastEvent = &event - - // TODO: check for watch expired error and retry watch from latest point? - done, err := condition(event) - if err != nil { - return lastEvent, err - } - if done { - break ConditionSucceeded - } - - case <-after: - return lastEvent, wait.ErrWaitTimeout - } - } - } - return lastEvent, nil -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/decoder.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/decoder.go deleted file mode 100644 index e586527..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/decoder.go +++ /dev/null @@ -1,71 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package versioned - -import ( - "fmt" - - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/runtime/serializer/streaming" - "k8s.io/kubernetes/pkg/watch" -) - -// Decoder implements the watch.Decoder interface for io.ReadClosers that -// have contents which consist of a series of watchEvent objects encoded -// with the given streaming decoder. The internal objects will be then -// decoded by the embedded decoder. -type Decoder struct { - decoder streaming.Decoder - embeddedDecoder runtime.Decoder -} - -// NewDecoder creates an Decoder for the given writer and codec. -func NewDecoder(decoder streaming.Decoder, embeddedDecoder runtime.Decoder) *Decoder { - return &Decoder{ - decoder: decoder, - embeddedDecoder: embeddedDecoder, - } -} - -// Decode blocks until it can return the next object in the reader. Returns an error -// if the reader is closed or an object can't be decoded. -func (d *Decoder) Decode() (watch.EventType, runtime.Object, error) { - var got Event - res, _, err := d.decoder.Decode(nil, &got) - if err != nil { - return "", nil, err - } - if res != &got { - return "", nil, fmt.Errorf("unable to decode to versioned.Event") - } - switch got.Type { - case string(watch.Added), string(watch.Modified), string(watch.Deleted), string(watch.Error): - default: - return "", nil, fmt.Errorf("got invalid watch event type: %v", got.Type) - } - - obj, err := runtime.Decode(d.embeddedDecoder, got.Object.Raw) - if err != nil { - return "", nil, fmt.Errorf("unable to decode watch event: %v", err) - } - return watch.EventType(got.Type), obj, nil -} - -// Close closes the underlying r. -func (d *Decoder) Close() { - d.decoder.Close() -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/encoder.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/encoder.go deleted file mode 100644 index df23e0b..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/encoder.go +++ /dev/null @@ -1,51 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package versioned - -import ( - "encoding/json" - - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/runtime/serializer/streaming" - "k8s.io/kubernetes/pkg/watch" -) - -// Encoder serializes watch.Events into io.Writer. The internal objects -// are encoded using embedded encoder, and the outer Event is serialized -// using encoder. -type Encoder struct { - encoder streaming.Encoder - embeddedEncoder runtime.Encoder -} - -func NewEncoder(encoder streaming.Encoder, embeddedEncoder runtime.Encoder) *Encoder { - return &Encoder{ - encoder: encoder, - embeddedEncoder: embeddedEncoder, - } -} - -// Encode writes an event to the writer. Returns an error -// if the writer is closed or an object can't be encoded. -func (e *Encoder) Encode(event *watch.Event) error { - data, err := runtime.Encode(e.embeddedEncoder, event.Object) - if err != nil { - return err - } - // FIXME: get rid of json.RawMessage. - return e.encoder.Encode(&Event{string(event.Type), runtime.RawExtension{Raw: json.RawMessage(data)}}) -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/generated.pb.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/generated.pb.go deleted file mode 100644 index d2576eb..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/generated.pb.go +++ /dev/null @@ -1,342 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by protoc-gen-gogo. -// source: k8s.io/kubernetes/pkg/watch/versioned/generated.proto -// DO NOT EDIT! - -/* - Package versioned is a generated protocol buffer package. - - It is generated from these files: - k8s.io/kubernetes/pkg/watch/versioned/generated.proto - - It has these top-level messages: - Event -*/ -package versioned - -import proto "github.com/gogo/protobuf/proto" -import fmt "fmt" -import math "math" - -import io "io" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -func (m *Event) Reset() { *m = Event{} } -func (m *Event) String() string { return proto.CompactTextString(m) } -func (*Event) ProtoMessage() {} - -func init() { - proto.RegisterType((*Event)(nil), "k8s.io.kubernetes.pkg.watch.versioned.Event") -} -func (m *Event) Marshal() (data []byte, err error) { - size := m.Size() - data = make([]byte, size) - n, err := m.MarshalTo(data) - if err != nil { - return nil, err - } - return data[:n], nil -} - -func (m *Event) MarshalTo(data []byte) (int, error) { - var i int - _ = i - var l int - _ = l - data[i] = 0xa - i++ - i = encodeVarintGenerated(data, i, uint64(len(m.Type))) - i += copy(data[i:], m.Type) - data[i] = 0x12 - i++ - i = encodeVarintGenerated(data, i, uint64(m.Object.Size())) - n1, err := m.Object.MarshalTo(data[i:]) - if err != nil { - return 0, err - } - i += n1 - return i, nil -} - -func encodeFixed64Generated(data []byte, offset int, v uint64) int { - data[offset] = uint8(v) - data[offset+1] = uint8(v >> 8) - data[offset+2] = uint8(v >> 16) - data[offset+3] = uint8(v >> 24) - data[offset+4] = uint8(v >> 32) - data[offset+5] = uint8(v >> 40) - data[offset+6] = uint8(v >> 48) - data[offset+7] = uint8(v >> 56) - return offset + 8 -} -func encodeFixed32Generated(data []byte, offset int, v uint32) int { - data[offset] = uint8(v) - data[offset+1] = uint8(v >> 8) - data[offset+2] = uint8(v >> 16) - data[offset+3] = uint8(v >> 24) - return offset + 4 -} -func encodeVarintGenerated(data []byte, offset int, v uint64) int { - for v >= 1<<7 { - data[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - data[offset] = uint8(v) - return offset + 1 -} -func (m *Event) Size() (n int) { - var l int - _ = l - l = len(m.Type) - n += 1 + l + sovGenerated(uint64(l)) - l = m.Object.Size() - n += 1 + l + sovGenerated(uint64(l)) - return n -} - -func sovGenerated(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n -} -func sozGenerated(x uint64) (n int) { - return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Event) Unmarshal(data []byte) error { - l := len(data) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Event: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Event: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Type = string(data[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Object", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenerated - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenerated - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Object.Unmarshal(data[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenerated(data[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthGenerated - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenerated(data []byte) (n int, err error) { - l := len(data) - iNdEx := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if data[iNdEx-1] < 0x80 { - break - } - } - return iNdEx, nil - case 1: - iNdEx += 8 - return iNdEx, nil - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - iNdEx += length - if length < 0 { - return 0, ErrInvalidLengthGenerated - } - return iNdEx, nil - case 3: - for { - var innerWire uint64 - var start int = iNdEx - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenerated - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := data[iNdEx] - iNdEx++ - innerWire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - innerWireType := int(innerWire & 0x7) - if innerWireType == 4 { - break - } - next, err := skipGenerated(data[start:]) - if err != nil { - return 0, err - } - iNdEx = start + next - } - return iNdEx, nil - case 4: - return iNdEx, nil - case 5: - iNdEx += 4 - return iNdEx, nil - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - } - panic("unreachable") -} - -var ( - ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") -) diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/generated.proto b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/generated.proto deleted file mode 100644 index 8d55065..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/generated.proto +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - - -// This file was autogenerated by go-to-protobuf. Do not edit it manually! - -syntax = 'proto2'; - -package k8s.io.kubernetes.pkg.watch.versioned; - -import "k8s.io/kubernetes/pkg/runtime/generated.proto"; -import "k8s.io/kubernetes/pkg/util/intstr/generated.proto"; - -// Package-wide variables from generator "generated". -option go_package = "versioned"; - -// Event represents a single event to a watched resource. -// -// +protobuf=true -message Event { - optional string type = 1; - - // Object is: - // * If Type is Added or Modified: the new state of the object. - // * If Type is Deleted: the state of the object immediately before deletion. - // * If Type is Error: *api.Status is recommended; other types may make sense - // depending on context. - optional k8s.io.kubernetes.pkg.runtime.RawExtension object = 2; -} - diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/register.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/register.go deleted file mode 100644 index e90a021..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/register.go +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package versioned - -import ( - "k8s.io/kubernetes/pkg/api/unversioned" - "k8s.io/kubernetes/pkg/conversion" - "k8s.io/kubernetes/pkg/runtime" - "k8s.io/kubernetes/pkg/watch" -) - -// WatchEventKind is name reserved for serializing watch events. -const WatchEventKind = "WatchEvent" - -// AddToGroupVersion registers the watch external and internal kinds with the scheme, and ensures the proper -// conversions are in place. -func AddToGroupVersion(scheme *runtime.Scheme, groupVersion unversioned.GroupVersion) { - scheme.AddKnownTypeWithName(groupVersion.WithKind(WatchEventKind), &Event{}) - scheme.AddKnownTypeWithName( - unversioned.GroupVersion{Group: groupVersion.Group, Version: runtime.APIVersionInternal}.WithKind(WatchEventKind), - &InternalEvent{}, - ) - scheme.AddConversionFuncs( - Convert_versioned_Event_to_watch_Event, - Convert_versioned_InternalEvent_to_versioned_Event, - Convert_watch_Event_to_versioned_Event, - Convert_versioned_Event_to_versioned_InternalEvent, - ) -} - -func Convert_watch_Event_to_versioned_Event(in *watch.Event, out *Event, s conversion.Scope) error { - out.Type = string(in.Type) - switch t := in.Object.(type) { - case *runtime.Unknown: - // TODO: handle other fields on Unknown and detect type - out.Object.Raw = t.Raw - case nil: - default: - out.Object.Object = in.Object - } - return nil -} - -func Convert_versioned_InternalEvent_to_versioned_Event(in *InternalEvent, out *Event, s conversion.Scope) error { - return Convert_watch_Event_to_versioned_Event((*watch.Event)(in), out, s) -} - -func Convert_versioned_Event_to_watch_Event(in *Event, out *watch.Event, s conversion.Scope) error { - out.Type = watch.EventType(in.Type) - if in.Object.Object != nil { - out.Object = in.Object.Object - } else if in.Object.Raw != nil { - // TODO: handle other fields on Unknown and detect type - out.Object = &runtime.Unknown{ - Raw: in.Object.Raw, - ContentType: runtime.ContentTypeJSON, - } - } - return nil -} - -func Convert_versioned_Event_to_versioned_InternalEvent(in *Event, out *InternalEvent, s conversion.Scope) error { - return Convert_versioned_Event_to_watch_Event(in, (*watch.Event)(out), s) -} - -// InternalEvent makes watch.Event versioned -type InternalEvent watch.Event - -func (e *InternalEvent) GetObjectKind() unversioned.ObjectKind { return unversioned.EmptyObjectKind } -func (e *Event) GetObjectKind() unversioned.ObjectKind { return unversioned.EmptyObjectKind } diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/types.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/types.go deleted file mode 100644 index f8e968c..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/versioned/types.go +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package versioned contains the versioned types for watch. This is the first -// serialization version unless otherwise noted. -package versioned - -import ( - "k8s.io/kubernetes/pkg/runtime" -) - -// Event represents a single event to a watched resource. -// -// +protobuf=true -type Event struct { - Type string `json:"type" protobuf:"bytes,1,opt,name=type"` - - // Object is: - // * If Type is Added or Modified: the new state of the object. - // * If Type is Deleted: the state of the object immediately before deletion. - // * If Type is Error: *api.Status is recommended; other types may make sense - // depending on context. - Object runtime.RawExtension `json:"object" protobuf:"bytes,2,opt,name=object"` -} diff --git a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/watch.go b/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/watch.go deleted file mode 100644 index 96b2fe3..0000000 --- a/kube2msb/src/vendor/k8s.io/kubernetes/pkg/watch/watch.go +++ /dev/null @@ -1,137 +0,0 @@ -/* -Copyright 2014 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package watch - -import ( - "sync" - - "k8s.io/kubernetes/pkg/runtime" -) - -// Interface can be implemented by anything that knows how to watch and report changes. -type Interface interface { - // Stops watching. Will close the channel returned by ResultChan(). Releases - // any resources used by the watch. - Stop() - - // Returns a chan which will receive all the events. If an error occurs - // or Stop() is called, this channel will be closed, in which case the - // watch should be completely cleaned up. - ResultChan() <-chan Event -} - -// EventType defines the possible types of events. -type EventType string - -const ( - Added EventType = "ADDED" - Modified EventType = "MODIFIED" - Deleted EventType = "DELETED" - Error EventType = "ERROR" -) - -// Event represents a single event to a watched resource. -type Event struct { - Type EventType - - // Object is: - // * If Type is Added or Modified: the new state of the object. - // * If Type is Deleted: the state of the object immediately before deletion. - // * If Type is Error: *api.Status is recommended; other types may make sense - // depending on context. - Object runtime.Object -} - -type emptyWatch chan Event - -// NewEmptyWatch returns a watch interface that returns no results and is closed. -// May be used in certain error conditions where no information is available but -// an error is not warranted. -func NewEmptyWatch() Interface { - ch := make(chan Event) - close(ch) - return emptyWatch(ch) -} - -// Stop implements Interface -func (w emptyWatch) Stop() { -} - -// ResultChan implements Interface -func (w emptyWatch) ResultChan() <-chan Event { - return chan Event(w) -} - -// FakeWatcher lets you test anything that consumes a watch.Interface; threadsafe. -type FakeWatcher struct { - result chan Event - Stopped bool - sync.Mutex -} - -func NewFake() *FakeWatcher { - return &FakeWatcher{ - result: make(chan Event), - } -} - -// Stop implements Interface.Stop(). -func (f *FakeWatcher) Stop() { - f.Lock() - defer f.Unlock() - if !f.Stopped { - close(f.result) - f.Stopped = true - } -} - -// Reset prepares the watcher to be reused. -func (f *FakeWatcher) Reset() { - f.Lock() - defer f.Unlock() - f.Stopped = false - f.result = make(chan Event) -} - -func (f *FakeWatcher) ResultChan() <-chan Event { - return f.result -} - -// Add sends an add event. -func (f *FakeWatcher) Add(obj runtime.Object) { - f.result <- Event{Added, obj} -} - -// Modify sends a modify event. -func (f *FakeWatcher) Modify(obj runtime.Object) { - f.result <- Event{Modified, obj} -} - -// Delete sends a delete event. -func (f *FakeWatcher) Delete(lastValue runtime.Object) { - f.result <- Event{Deleted, lastValue} -} - -// Error sends an Error event. -func (f *FakeWatcher) Error(errValue runtime.Object) { - f.result <- Event{Error, errValue} -} - -// Action sends an event of the requested type, for table-based testing. -func (f *FakeWatcher) Action(action EventType, obj runtime.Object) { - f.result <- Event{action, obj} -} -- cgit 1.2.3-korg