mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-24 22:26:54 +02:00
add all the plugins
This commit is contained in:
67
plugins/registry/kubernetes/client/mock/utils.go
Normal file
67
plugins/registry/kubernetes/client/mock/utils.go
Normal file
@ -0,0 +1,67 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/plugins/registry/kubernetes/v2/client"
|
||||
"github.com/micro/go-micro/plugins/registry/kubernetes/v2/client/watch"
|
||||
)
|
||||
|
||||
type mockWatcher struct {
|
||||
results chan watch.Event
|
||||
stop chan bool
|
||||
}
|
||||
|
||||
// Changes returns the results channel
|
||||
func (w *mockWatcher) ResultChan() <-chan watch.Event {
|
||||
return w.results
|
||||
}
|
||||
|
||||
// Stop closes any channels
|
||||
func (w *mockWatcher) Stop() {
|
||||
select {
|
||||
case <-w.stop:
|
||||
return
|
||||
default:
|
||||
close(w.stop)
|
||||
close(w.results)
|
||||
}
|
||||
}
|
||||
|
||||
func updateMetadata(a, b *client.Meta) {
|
||||
if a == nil || b == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if b.Labels != nil {
|
||||
for lk, lv := range b.Labels {
|
||||
labels := a.Labels
|
||||
if lv == nil {
|
||||
delete(labels, lk)
|
||||
continue
|
||||
}
|
||||
labels[lk] = lv
|
||||
}
|
||||
}
|
||||
|
||||
if b.Annotations != nil {
|
||||
for ak, av := range b.Annotations {
|
||||
ann := a.Annotations
|
||||
if av == nil {
|
||||
delete(ann, ak)
|
||||
continue
|
||||
}
|
||||
ann[ak] = av
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func labelFilterMatch(a map[string]*string, b map[string]string) bool {
|
||||
match := true
|
||||
for lk, lv := range b {
|
||||
ml, ok := a[lk]
|
||||
if !ok || *ml != lv {
|
||||
match = false
|
||||
break
|
||||
}
|
||||
}
|
||||
return match
|
||||
}
|
Reference in New Issue
Block a user