Skip to content

Commit

Permalink
Drop unused KubeClientSet from the CEL interceptor.
Browse files Browse the repository at this point in the history
This is unused in the CEL interceptor.
  • Loading branch information
bigkevmcd authored and tekton-robot committed Jan 10, 2020
1 parent d182697 commit f7305fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
15 changes: 5 additions & 10 deletions pkg/interceptors/cel/cel.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/tektoncd/triggers/pkg/interceptors"
"go.uber.org/zap"
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
"k8s.io/client-go/kubernetes"

triggersv1 "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1"
)
Expand All @@ -40,19 +39,15 @@ import (
// against the incoming body and headers to match, if the expression returns
// a true value, then the interception is "successful".
type Interceptor struct {
KubeClientSet kubernetes.Interface
Logger *zap.SugaredLogger
CEL *triggersv1.CELInterceptor
EventListenerNamespace string
Logger *zap.SugaredLogger
CEL *triggersv1.CELInterceptor
}

// NewInterceptor creates a prepopulated Interceptor.
func NewInterceptor(cel *triggersv1.CELInterceptor, k kubernetes.Interface, ns string, l *zap.SugaredLogger) interceptors.Interceptor {
func NewInterceptor(cel *triggersv1.CELInterceptor, l *zap.SugaredLogger) interceptors.Interceptor {
return &Interceptor{
Logger: l,
CEL: cel,
KubeClientSet: k,
EventListenerNamespace: ns,
Logger: l,
CEL: cel,
}
}

Expand Down
11 changes: 2 additions & 9 deletions pkg/interceptors/cel/cel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ import (
"github.com/google/cel-go/common/types/ref"
"github.com/tektoncd/pipeline/pkg/logging"
triggersv1 "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1"
fakekubeclient "knative.dev/pkg/client/injection/kube/client/fake"
rtesting "knative.dev/pkg/reconciler/testing"
)

// Allow configuration via a config map

func TestInterceptor_ExecuteTrigger(t *testing.T) {
type args struct {
payload []byte
Expand Down Expand Up @@ -126,13 +122,10 @@ func TestInterceptor_ExecuteTrigger(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx, _ := rtesting.SetupFakeContext(t)
logger, _ := logging.NewLogger("", "")
kubeClient := fakekubeclient.Get(ctx)
w := &Interceptor{
KubeClientSet: kubeClient,
CEL: tt.CEL,
Logger: logger,
CEL: tt.CEL,
Logger: logger,
}
request := &http.Request{
Body: ioutil.NopCloser(bytes.NewReader(tt.args.payload)),
Expand Down
1 change: 0 additions & 1 deletion pkg/interceptors/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func NewInterceptor(gl *triggersv1.GitLabInterceptor, k kubernetes.Interface, ns
}
}

//func (w *Interceptor) ExecuteTrigger(payload []byte, request *http.Request, _ *triggersv1.EventListenerTrigger, _ string) ([]byte, error) {
func (w *Interceptor) ExecuteTrigger(request *http.Request) (*http.Response, error) {
// Validate the secret first, if set.
if w.GitLab.SecretRef != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sink/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (r Sink) executeInterceptors(t *triggersv1.EventListenerTrigger, request *h
case i.GitLab != nil:
interceptor = gitlab.NewInterceptor(i.GitLab, r.KubeClientSet, r.EventListenerNamespace, log)
case i.CEL != nil:
interceptor = cel.NewInterceptor(i.CEL, r.KubeClientSet, r.EventListenerNamespace, log)
interceptor = cel.NewInterceptor(i.CEL, log)
default:
return nil, nil, fmt.Errorf("unknown interceptor type: %v", i)
}
Expand Down

0 comments on commit f7305fc

Please sign in to comment.