Skip to content

Commit

Permalink
feat: add a method to list all KongPlugin resources with global label
Browse files Browse the repository at this point in the history
  • Loading branch information
hbagdi committed Sep 10, 2018
1 parent 32ca70f commit eb888b4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions internal/ingress/controller/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import (
"sync"
"time"

"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"

"github.com/eapache/channels"
"github.com/golang/glog"

Expand Down Expand Up @@ -92,6 +95,8 @@ type Storer interface {
ListKongConsumers() []*consumerv1.KongConsumer

ListKongCredentials() []*credentialv1.KongCredential

ListGlobalKongPlugins() ([]*pluginv1.KongPlugin, error)
}

// EventType type of event associated with an informer
Expand Down Expand Up @@ -657,3 +662,24 @@ func (s k8sStore) ListKongCredentials() []*credentialv1.KongCredential {

return credentials
}

func (s k8sStore) ListGlobalKongPlugins() ([]*pluginv1.KongPlugin, error) {

var plugins []*pluginv1.KongPlugin
// var globalPlugins []*pluginv1.KongPlugin
req, err := labels.NewRequirement("global", selection.Equals, []string{"true"})
if err != nil {
return nil, err
}
err = cache.ListAll(s.listers.Kong.Plugin,
labels.NewSelector().Add(*req),
func(ob interface{}) {
if p, ok := ob.(*pluginv1.KongPlugin); ok {
plugins = append(plugins, p)
}
})
if err != nil {
return nil, err
}
return plugins, nil
}

0 comments on commit eb888b4

Please sign in to comment.